usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [1/2] incubator-usergrid git commit: Added AbstractRestIT for class compatibility but should probably be merged into the rest client. Made the DumbClient a test class to check that path building with the new jersey stuff works. ( it does! ) Tore out a lo
Date Tue, 09 Dec 2014 00:03:08 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/UG-rest-test-framework-overhaul 35a26da01 -> fa4b4ccb2


Added AbstractRestIT for class compatibility but should probably be merged into the rest client.
Made the DumbClient a test class to check that path building with the new jersey stuff works.
( it does! )
Tore out a lot of old things that were in the AbstractRestIT class.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/37e805b3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/37e805b3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/37e805b3

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 37e805b37162d349d2e097177b2f98757478438a
Parents: 35a26da
Author: grey <greyes@apigee.com>
Authored: Mon Dec 8 13:44:11 2014 -0800
Committer: grey <greyes@apigee.com>
Committed: Mon Dec 8 13:44:11 2014 -0800

----------------------------------------------------------------------
 .../test/resource2point0/AbstractRestIT.java    | 86 ++++++++++++++++++++
 .../rest/test/resource2point0/DumbClient.java   | 34 ++++++--
 .../rest/test/resource2point0/RestClient.java   | 15 +++-
 3 files changed, 128 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/37e805b3/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
new file mode 100644
index 0000000..3242da8
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.test.resource2point0;
+
+
+import java.net.URI;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.DeploymentContext;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.TestProperties;
+import org.glassfish.jersey.test.external.ExternalTestContainerFactory;
+import org.glassfish.jersey.test.spi.TestContainer;
+import org.glassfish.jersey.test.spi.TestContainerFactory;
+import org.junit.ClassRule;
+
+import org.apache.usergrid.rest.ITSetup;
+import org.apache.usergrid.rest.RestITSuite;
+
+import javax.ws.rs.core.Application;
+
+
+//import com.sun.jersey.api.json.JSONConfiguration;
+//import com.sun.jersey.test.framework.WebAppDescriptor;
+
+
+public class AbstractRestIT extends JerseyTest {
+
+    private static ClientConfig clientConfig = new ClientConfig();
+
+
+//    protected static final Application descriptor;
+
+    @ClassRule
+    public static ITSetup setup = new ITSetup( RestITSuite.cassandraResource );
+
+//    public AbstractRestIT() {
+//        super(descriptor);
+//    }
+
+//    static {
+//
+//        //clientConfig.property(  ); //.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING,
Boolean.TRUE );
+//        descriptor = new DeploymentContext.Builder("").
+////       descriptor = new WebAppDescriptor.Builder( "org.apache.usergrid.rest" )
+////                .clientConfig( clientConfig ).build();
+////        dumpClasspath( AbstractRestIT.class.getClassLoader() );
+//    }
+
+    @Override
+    protected TestContainerFactory getTestContainerFactory(){
+        return new ExternalTestContainerFactory();
+    }
+
+    @Override
+    protected URI getBaseUri() {
+        return setup.getBaseURI();
+    }
+
+    @Override
+    protected Application configure(){
+        enable(TestProperties.LOG_TRAFFIC);
+        enable( TestProperties.DUMP_ENTITY);
+
+        ResourceConfig rc = new ResourceConfig(  );
+
+        return rc;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/37e805b3/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 3813afa..7087185 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
@@ -22,29 +22,53 @@ import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.WebTarget;
 
 import org.glassfish.jersey.client.ClientConfig;
+import org.junit.Ignore;
+import org.junit.Test;
 
+import org.apache.catalina.startup.Tomcat;
+
+import org.apache.usergrid.TomcatMain;
+import org.apache.usergrid.rest.TomcatResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.Collection;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 
 /**
  * Test Class used to model if the client is working or doing what it is supposed to be doing.
+ * ask if this is for test purposes and if so if I can mark it with junit
  */
-public class DumbClient {
 
-    private final RestClient client = new RestClient("http://localhost:8080");
+public class DumbClient extends AbstractRestIT {
 
+    //TODO: maybe this should just take in the raw uri.
+    private final RestClient client = new RestClient( getBaseUri().toString());
 
+
+    @Test
     public void stuff(){
-        EntityResponse itr  =  client.org( "test" ).getApp( "test" ).users().getEntityResponse();
+        //EntityResponse itr  =  client.org( "test" ).getApp( "test" ).users().getEntityResponse();
+        OrganizationResource organizationResource = client.org( "borg" );
+        assertNotNull( organizationResource );https://community.spotify.com/t5/forums/replypage/board-id/spotifyiOS/message-id/42230
+        assertEquals( getBaseUri().toString()+"borg",client.getPath());
 
-        for(Entity entity: itr){
 
-        }
+        ApplicationResource applicationResource = client.org( "morg" ).getApp( "app" );
+        assertNotNull( applicationResource );
+        assertEquals( getBaseUri().toString()+"borg/morg",client.getPath());
+
+        //        for(Entity entity: itr){
+//
+//        }
     }
 
+    @Ignore
     public void stateful(){
 
         EntityResponse itr  =  client.org( "test" ).getApp( "test" ).users().getEntityResponse();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/37e805b3/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 e890a1e..b455c46 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
@@ -24,7 +24,10 @@ import javax.ws.rs.core.UriBuilder;
 import org.glassfish.jersey.client.JerseyClientBuilder;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.client.JerseyWebTarget;
+import org.junit.ClassRule;
 
+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;
@@ -38,6 +41,8 @@ public class RestClient implements UrlResource {
 
     ClientConfig clientConfig = new ClientConfig();
 
+//    @ClassRule
+//    public static ITSetup setup = new ITSetup( RestITSuite.cassandraResource );
 
     Client client = ClientBuilder.newClient( clientConfig );
 
@@ -62,9 +67,14 @@ public class RestClient implements UrlResource {
     }
 
 
+    /**
+     * TODO: should this method return the base path or the total path we have built?
+     * @return
+     */
     @Override
     public String getPath() {
-        return serverUrl;
+        return webTarget.getUri().toString();
+        //return serverUrl;
     }
 
 
@@ -80,7 +90,8 @@ public class RestClient implements UrlResource {
      * Get hte organization resource
      */
     public OrganizationResource org( final String orgName ) {
-        //OrganizationResource
+        OrganizationResource organizationResource = new OrganizationResource( orgName, context,
 this );
+        webTarget = webTarget.path( organizationResource.getPath());
         return new OrganizationResource( orgName, context,  this );
     }
 


Mime
View raw message