You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2014/12/10 01:43:58 UTC
[1/2] incubator-usergrid git commit: Got paths working for the
resource just like they used to work with Jersey 2.
Repository: incubator-usergrid
Updated Branches:
refs/heads/UG-rest-test-framework-overhaul fa4b4ccb2 -> 9af4135ae
Got paths working for the resource just like they used to work with Jersey 2.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c1993652
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c1993652
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c1993652
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: c19936524c6fdc8a44ebe28017fec4773d6741df
Parents: fa4b4cc
Author: grey <gr...@apigee.com>
Authored: Tue Dec 9 12:16:55 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Dec 9 12:16:55 2014 -0800
----------------------------------------------------------------------
.../test/resource2point0/AbstractRestIT.java | 57 +++++++++++++++-
.../rest/test/resource2point0/DumbClient.java | 10 ++-
.../rest/test/resource2point0/RestClient.java | 72 +++++++++++++++++---
3 files changed, 124 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1993652/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 7b71b19..acf386e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -18,24 +18,79 @@ package org.apache.usergrid.rest.test.resource2point0;
import java.net.URI;
+import java.net.URLClassLoader;
+import java.util.Arrays;
import org.junit.ClassRule;
+import org.apache.usergrid.java.client.Client;
import org.apache.usergrid.rest.ITSetup;
import org.apache.usergrid.rest.RestITSuite;
import javax.ws.rs.core.Application;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.test.framework.AppDescriptor;
+import com.sun.jersey.test.framework.JerseyTest;
+import com.sun.jersey.test.framework.WebAppDescriptor;
+import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
+
//import com.sun.jersey.api.json.JSONConfiguration;
//import com.sun.jersey.test.framework.WebAppDescriptor;
-public class AbstractRestIT {
+public class AbstractRestIT extends JerseyTest {
+
+ private static ClientConfig clientConfig = new DefaultClientConfig();
+
+ protected static Client client;
@ClassRule
public static ITSetup setup = new ITSetup( RestITSuite.cassandraResource );
+ protected static final AppDescriptor descriptor;
+
+ public AbstractRestIT() {
+ super( descriptor );
+ }
+
+
+ static {
+ clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
+ descriptor = new WebAppDescriptor.Builder( "org.apache.usergrid.rest" )
+ .clientConfig( clientConfig ).build();
+ dumpClasspath( AbstractRestIT.class.getClassLoader() );
+ }
+
+ public static void dumpClasspath( ClassLoader loader ) {
+ System.out.println( "Classloader " + loader + ":" );
+
+ if ( loader instanceof URLClassLoader ) {
+ URLClassLoader ucl = ( URLClassLoader ) loader;
+ System.out.println( "\t" + Arrays.toString( ucl.getURLs() ) );
+ }
+ else {
+ System.out.println( "\t(cannot display components as not a URLClassLoader)" );
+ }
+
+ if ( loader.getParent() != null ) {
+ dumpClasspath( loader.getParent() );
+ }
+ }
+
+ @Override
+ protected URI getBaseURI() {
+ return setup.getBaseURI();
+ }
+
+ @Override
+ protected TestContainerFactory getTestContainerFactory() {
+ return new com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1993652/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
index 781f239..d818a7f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
@@ -17,6 +17,7 @@
package org.apache.usergrid.rest.test.resource2point0;
import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
import org.apache.catalina.startup.Tomcat;
@@ -42,20 +43,23 @@ import static org.junit.Assert.assertNotNull;
public class DumbClient extends AbstractRestIT {
//TODO: maybe this should just take in the raw uri.
- private final RestClient client = new RestClient( "");
+ //TODO:fix this so it can work a lot like the context.
+ @Rule
+ public final RestClient client = new RestClient( getBaseURI().toString() );
@Test
public void stuff(){
+
//EntityResponse itr = client.org( "test" ).getApp( "test" ).users().getEntityResponse();
OrganizationResource organizationResource = client.org( "borg" );
assertNotNull( organizationResource );
- //assertEquals( getBaseUri().toString()+"borg",client.getPath());
+ assertEquals( getBaseURI().toString()+"borg",client.getPath());
ApplicationResource applicationResource = client.org( "morg" ).getApp( "app" );
assertNotNull( applicationResource );
- //assertEquals( getBaseUri().toString()+"borg/morg",client.getPath());
+ assertEquals( getBaseURI().toString()+"borg/morg",client.getPath());
// for(Entity entity: itr){
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1993652/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
index 9955e46..4072c95 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
@@ -16,35 +16,42 @@
*/
package org.apache.usergrid.rest.test.resource2point0;
+import java.io.IOException;
import java.net.URI;
import org.junit.ClassRule;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
import org.apache.usergrid.rest.ITSetup;
import org.apache.usergrid.rest.RestITSuite;
import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+import org.apache.usergrid.rest.test.security.TestAdminUser;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.test.framework.JerseyTest;
/**
* Extends the JerseyTest framework because this is the client that we are going to be using to interact with tomcat
*/
-public class RestClient implements UrlResource {
-
- //ClientConfig clientConfig = new ClientConfig();
+public class RestClient implements UrlResource,TestRule {
// @ClassRule
// public static ITSetup setup = new ITSetup( RestITSuite.cassandraResource );
- //Client client = ClientBuilder.newClient( clientConfig );
-
- // private WebTarget webTarget;// = client.target("http://example.com/rest");
-
private final String serverUrl;
private final ClientContext context;
- //ClientConfig config = new ClientConfig();
-
+ WebResource resource;
+ ClientConfig config = new DefaultClientConfig( );//new ClientConfig();
+ Client client = Client.create( config );
//This should work independantly of test frameowkr. Need to be able to pull the WebResource Url and not have to integrate the webresource into the Endpoints/Client.
//This uses jeresy to create the client. Initialize the client with the webresource, and then the CLIENT calls the root resource.
@@ -55,6 +62,9 @@ public class RestClient implements UrlResource {
public RestClient( final String serverUrl ) {
this.serverUrl = serverUrl;
this.context = new ClientContext();
+ resource = client.resource( serverUrl );
+ resource.path( serverUrl );
+
//maybe the problem here is with the jaxrs version not having the correct dependencies or methods.
// webTarget = client.target( serverUrl );
//webTarget = webTarget.path( serverUrl );
@@ -67,8 +77,8 @@ public class RestClient implements UrlResource {
*/
@Override
public String getPath() {
- //return webTarget.getUri().toString();
- return serverUrl;
+ return resource.getURI().toString(); //webResource.getUri().toString();
+ //return serverUrl;
}
@@ -85,6 +95,7 @@ public class RestClient implements UrlResource {
*/
public OrganizationResource org( final String orgName ) {
OrganizationResource organizationResource = new OrganizationResource( orgName, context, this );
+ resource = resource.path( organizationResource.getPath() );
//webTarget = webTarget.path( organizationResource.getPath()); This worked really well, shame it couldn't be used.
return new OrganizationResource( orgName, context, this );
}
@@ -96,4 +107,43 @@ public class RestClient implements UrlResource {
//context.setToken( token );
}
+
+ //TODO: maybe take out the below methods to be a seperate class? Follow solid principles? Single responsiblitiy. This is currently
+ //taking on the responsibility of both the
+
+ @Override
+ public Statement apply( Statement base, Description description ) {
+ return statement( base, description );
+ }
+
+ private Statement statement( final Statement base, final Description description ) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ before( description );
+ try {
+ base.evaluate();
+ }
+ finally {
+ cleanup();
+ }
+ }
+ };
+ }
+ protected void cleanup() {
+ // might want to do something here later
+ }
+
+ //TODO: look over this logic
+ protected void before( Description description ) throws IOException {
+// String testClass = description.getTestClass().getName();
+// String methodName = description.getMethodName();
+// String name = testClass + "." + methodName;
+//
+// TestAdminUser testAdmin = new TestAdminUser( name+ UUIDUtils.newTimeUUID(),
+// name + "@usergrid.com"+UUIDUtils.newTimeUUID(),
+// name + "@usergrid.com"+UUIDUtils.newTimeUUID() );
+// withOrg( name+ UUIDUtils.newTimeUUID() ).withApp( methodName + UUIDUtils.newTimeUUID() ).withUser(
+// testAdmin ).initAll();
+ }
}
[2/2] incubator-usergrid git commit: Cleaned up some of the old
jersey 2 code. Revamped the separation of concerns for files and added in a
WebResource so that the appropriate calls can be made.
Posted by gr...@apache.org.
Cleaned up some of the old jersey 2 code. Revamped the separation of concerns for files and added in a WebResource so that the appropriate calls can be made.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9af4135a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9af4135a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9af4135a
Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 9af4135ae7799f5da11e74314804bacb29637a15
Parents: c199365
Author: grey <gr...@apigee.com>
Authored: Tue Dec 9 16:43:54 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Dec 9 16:43:54 2014 -0800
----------------------------------------------------------------------
.../test/resource2point0/AbstractRestIT.java | 12 ++-
.../rest/test/resource2point0/DumbClient.java | 31 +++++--
.../rest/test/resource2point0/RestClient.java | 92 ++++----------------
.../resource2point0/endpoints/Collection.java | 2 +-
.../endpoints/NamedResource.java | 8 ++
.../endpoints/OrganizationResource.java | 18 ++++
.../resource2point0/endpoints/UrlResource.java | 8 ++
.../endpoints/mgmt/ManagementResource.java | 8 +-
.../endpoints/mgmt/OrganizationResource.java | 44 ++++++++++
9 files changed, 133 insertions(+), 90 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index acf386e..2113cde 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -22,13 +22,12 @@ import java.net.URLClassLoader;
import java.util.Arrays;
import org.junit.ClassRule;
+import org.junit.Rule;
import org.apache.usergrid.java.client.Client;
import org.apache.usergrid.rest.ITSetup;
import org.apache.usergrid.rest.RestITSuite;
-import javax.ws.rs.core.Application;
-
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
@@ -37,11 +36,6 @@ import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.WebAppDescriptor;
import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
-
-//import com.sun.jersey.api.json.JSONConfiguration;
-//import com.sun.jersey.test.framework.WebAppDescriptor;
-
-
public class AbstractRestIT extends JerseyTest {
private static ClientConfig clientConfig = new DefaultClientConfig();
@@ -50,6 +44,10 @@ public class AbstractRestIT extends JerseyTest {
@ClassRule
public static ITSetup setup = new ITSetup( RestITSuite.cassandraResource );
+//
+// TODO: Allow the client to be setup seperately
+// @Rule
+// public ClientSetup clientSetup = new ClientSetup(my url);
protected static final AppDescriptor descriptor;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
index d818a7f..5f247d0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/DumbClient.java
@@ -16,6 +16,9 @@
*/
package org.apache.usergrid.rest.test.resource2point0;
+import java.util.Map;
+import java.util.UUID;
+
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -23,6 +26,7 @@ import org.junit.Test;
import org.apache.catalina.startup.Tomcat;
import org.apache.usergrid.TomcatMain;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
import org.apache.usergrid.rest.TomcatResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.Collection;
@@ -30,6 +34,7 @@ import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResou
import org.apache.usergrid.rest.test.resource2point0.endpoints.RootResource;
import org.apache.usergrid.rest.test.resource2point0.model.Entity;
import org.apache.usergrid.rest.test.resource2point0.model.EntityResponse;
+import org.apache.usergrid.utils.MapUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -51,21 +56,35 @@ public class DumbClient extends AbstractRestIT {
@Test
public void stuff(){
+ String name = "stuff"+ UUIDUtils.newTimeUUID();
+ c
+
//EntityResponse itr = client.org( "test" ).getApp( "test" ).users().getEntityResponse();
- OrganizationResource organizationResource = client.org( "borg" );
- assertNotNull( organizationResource );
- assertEquals( getBaseURI().toString()+"borg",client.getPath());
+// OrganizationResource organizationResource = client.org( "borg" );
+// assertNotNull( organizationResource );
+// assertEquals( getBaseURI().toString()+"borg",client.getPath());
+//
+//
+// ApplicationResource applicationResource = client.org( "morg" ).getApp( "app" );
+// assertNotNull( applicationResource );
+// assertEquals( getBaseURI().toString()+"borg/morg",client.getPath());
- ApplicationResource applicationResource = client.org( "morg" ).getApp( "app" );
- assertNotNull( applicationResource );
- assertEquals( getBaseURI().toString()+"borg/morg",client.getPath());
+ //can't post an org to an organization endpoint you derp. I think it has to be to management.
+ //client.post(mapOrganization(name,name,name+"@apigee.com",name,name ));
// for(Entity entity: itr){
//
// }
}
+ public Map<String,String> mapOrganization(String orgName, String username, String email, String name, String password){
+
+ return MapUtils.hashMap( "organization", orgName ).map( "username", username )
+ .map( "email", email ).map( "name", name )
+ .map( "password", password);
+ }
+
@Ignore
public void stateful(){
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
index 4072c95..4c41a0a 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
@@ -16,69 +16,54 @@
*/
package org.apache.usergrid.rest.test.resource2point0;
-import java.io.IOException;
-import java.net.URI;
-import org.junit.ClassRule;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.ITSetup;
-import org.apache.usergrid.rest.RestITSuite;
import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-import org.apache.usergrid.rest.test.security.TestAdminUser;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.test.framework.JerseyTest;
/**
- * Extends the JerseyTest framework because this is the client that we are going to be using to interact with tomcat
+ * This REST client was made to be able to send calls to any backend system that accepts calls. To do this It needs to
+ * work independently of the existing REST test framework.
*/
-public class RestClient implements UrlResource,TestRule {
-
-// @ClassRule
-// public static ITSetup setup = new ITSetup( RestITSuite.cassandraResource );
+public class RestClient implements UrlResource {
private final String serverUrl;
private final ClientContext context;
- WebResource resource;
- ClientConfig config = new DefaultClientConfig( );//new ClientConfig();
+
+ public WebResource resource;
+ ClientConfig config = new DefaultClientConfig();
Client client = Client.create( config );
-//This should work independantly of test frameowkr. Need to be able to pull the WebResource Url and not have to integrate the webresource into the Endpoints/Client.
- //This uses jeresy to create the client. Initialize the client with the webresource, and then the CLIENT calls the root resource.
- //
- //after initialization of the client htne use it to build our path using our resources.
- //Just keep checking in early and checkin often.
+ /**
+ *
+ * @param serverUrl
+ */
public RestClient( final String serverUrl ) {
this.serverUrl = serverUrl;
this.context = new ClientContext();
resource = client.resource( serverUrl );
resource.path( serverUrl );
-
- //maybe the problem here is with the jaxrs version not having the correct dependencies or methods.
- // webTarget = client.target( serverUrl );
- //webTarget = webTarget.path( serverUrl );
}
/**
* TODO: should this method return the base path or the total path we have built?
- * @return
*/
@Override
public String getPath() {
- return resource.getURI().toString(); //webResource.getUri().toString();
- //return serverUrl;
+ return resource.getURI().toString();
+ }
+
+ @Override
+ public WebResource getResource() {
+ return client.resource( serverUrl );
}
@@ -94,13 +79,11 @@ public class RestClient implements UrlResource,TestRule {
* Get hte organization resource
*/
public OrganizationResource org( final String orgName ) {
- OrganizationResource organizationResource = new OrganizationResource( orgName, context, this );
- resource = resource.path( organizationResource.getPath() );
- //webTarget = webTarget.path( organizationResource.getPath()); This worked really well, shame it couldn't be used.
- return new OrganizationResource( orgName, context, this );
+ return new OrganizationResource( orgName, context, this );
}
-//todo:fix this method for the client.
+
+ //todo:fix this method for the client.
public void loginAdminUser( final String username, final String password ) {
//Post isn't implemented yet, but using the method below we should be able to get a superuser password as well.
//final String token = management().token().post(username, password);
@@ -108,42 +91,5 @@ public class RestClient implements UrlResource,TestRule {
//context.setToken( token );
}
- //TODO: maybe take out the below methods to be a seperate class? Follow solid principles? Single responsiblitiy. This is currently
- //taking on the responsibility of both the
-
- @Override
- public Statement apply( Statement base, Description description ) {
- return statement( base, description );
- }
-
- private Statement statement( final Statement base, final Description description ) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- before( description );
- try {
- base.evaluate();
- }
- finally {
- cleanup();
- }
- }
- };
- }
- protected void cleanup() {
- // might want to do something here later
- }
- //TODO: look over this logic
- protected void before( Description description ) throws IOException {
-// String testClass = description.getTestClass().getName();
-// String methodName = description.getMethodName();
-// String name = testClass + "." + methodName;
-//
-// TestAdminUser testAdmin = new TestAdminUser( name+ UUIDUtils.newTimeUUID(),
-// name + "@usergrid.com"+UUIDUtils.newTimeUUID(),
-// name + "@usergrid.com"+UUIDUtils.newTimeUUID() );
-// withOrg( name+ UUIDUtils.newTimeUUID() ).withApp( methodName + UUIDUtils.newTimeUUID() ).withUser(
-// testAdmin ).initAll();
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java
index 6b31cb6..a51a07c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/Collection.java
@@ -44,7 +44,7 @@ public class Collection extends NamedResource {
* @return
*/
public ApiResponse get(final Optional<String> cursor){
- return null;
+ return getResource().get( ApiResponse.class );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
index 32232e0..5f58ba6 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
@@ -19,6 +19,8 @@ package org.apache.usergrid.rest.test.resource2point0.endpoints;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+import com.sun.jersey.api.client.WebResource;
+
/**
* Base class that is extended by named endpoints.
@@ -45,4 +47,10 @@ public class NamedResource implements UrlResource {
public String getPath() {
return name;
}
+
+
+ @Override
+ public WebResource getResource() {
+ return parent.getResource().path( getPath() );
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
index 210fd4f..703a534 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/OrganizationResource.java
@@ -17,7 +17,17 @@
package org.apache.usergrid.rest.test.resource2point0.endpoints;
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+import org.apache.usergrid.utils.MapUtils;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
/**
@@ -34,4 +44,12 @@ public class OrganizationResource extends NamedResource {
public ApplicationResource getApp(final String app){
return new ApplicationResource( app, context ,this );
}
+
+ public void post(Map<String,String> organization){
+
+ getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
+ .post( ApiResponse.class, organization );
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java
index 6c48c30..70d48c1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/UrlResource.java
@@ -19,6 +19,8 @@ package org.apache.usergrid.rest.test.resource2point0.endpoints;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+import com.sun.jersey.api.client.WebResource;
+
/**
* Interface that returns the path that is currently being pointed to.
@@ -31,5 +33,11 @@ public interface UrlResource {
*/
public String getPath();
+ /**
+ * Get the resource
+ * @return
+ */
+ public WebResource getResource();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
index 147ff44..846d761 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
@@ -17,9 +17,7 @@
package org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.TokenResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.*;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
@@ -35,4 +33,8 @@ public class ManagementResource extends NamedResource {
return new TokenResource( context, this );
}
+ public OrganizationResource orgs(String name) {
+ return new OrganizationResource( name ,context,this );
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9af4135a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
new file mode 100644
index 0000000..92cc60e
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
@@ -0,0 +1,44 @@
+package org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt;
+
+
+/**
+ * Created by ApigeeCorporation on 12/9/14.
+ */
+
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+
+
+/**
+ * This is for the Management endpoint.
+ * Holds the information required for building and chaining organization objects to applications.
+ * Should also contain the GET,PUT,POST,DELETE methods of functioning in here.
+ */
+public class OrganizationResource extends NamedResource {
+
+//TODO: need to find a way to integrate having the orgs/<org_name> into the same endpoint.
+ //maybe I could append the orgs to the end of the parent
+ public OrganizationResource( final String name, final ClientContext context, final UrlResource parent ) {
+ super( name, context, parent. );
+ }
+
+ //TODO: change this so that it reflects the management endpoint
+// public ApplicationResource getApp(final String app){
+// return new ApplicationResource( app, context ,this );
+// }
+
+ public void post(Map<String,String> organization){
+
+ getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
+ .post( ApiResponse.class, organization );
+ }
+
+
+}