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/09 01:03:08 UTC

[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

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 <gr...@apigee.com>
Authored: Mon Dec 8 13:44:11 2014 -0800
Committer: grey <gr...@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 );
     }
 


[2/2] incubator-usergrid git commit: Removed all instances of jersey 2 package and code.

Posted by gr...@apache.org.
Removed all instances of jersey 2 package and code.


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

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: fa4b4ccb2e71aee3e13aff37395104c8df9358ad
Parents: 37e805b
Author: grey <gr...@apigee.com>
Authored: Mon Dec 8 16:03:06 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Mon Dec 8 16:03:06 2014 -0800

----------------------------------------------------------------------
 stack/pom.xml                                   | 22 ---------
 stack/rest/pom.xml                              | 24 ----------
 .../test/resource2point0/AbstractRestIT.java    | 47 +-------------------
 .../rest/test/resource2point0/DumbClient.java   | 14 ++----
 .../rest/test/resource2point0/RestClient.java   | 24 ++++------
 5 files changed, 14 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fa4b4ccb/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index fc93574..e02a08e 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -105,7 +105,6 @@
     <jackson-2-version>2.3.3</jackson-2-version>
     <jclouds.version>1.6.2-incubating</jclouds.version>
     <jersey-version>1.18.1</jersey-version>
-    <jersey2-version>2.13</jersey2-version>
     <junit-version>4.11</junit-version>
     <log4j-version>1.2.16</log4j-version>
     <metrics-version>2.1.2</metrics-version>
@@ -712,27 +711,6 @@
         <artifactId>jersey-test-framework-core</artifactId>
         <version>${jersey-version}</version>
       </dependency>
-      <!-- Starting glassfish jersey dependencies -->
-
-      <dependency>
-        <groupId>org.glassfish.jersey.test-framework.providers</groupId>
-        <artifactId>jersey-test-framework-provider-external</artifactId>
-        <version>${jersey2-version}</version>
-      </dependency>
-
-      <dependency>
-        <groupId>org.glassfish.jersey.test-framework</groupId>
-        <artifactId>jersey-test-framework-core</artifactId>
-        <version>${jersey2-version}</version>
-      </dependency>
-
-      <dependency>
-        <groupId>org.glassfish.jersey.core</groupId>
-        <artifactId>jersey-client</artifactId>
-        <version>2.13</version>
-      </dependency>
-
-      <!-- Ending glassfish jersey dependencies -->
 
       <dependency>
         <groupId>com.sun.mail</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fa4b4ccb/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index ad86590..4a99443 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -421,30 +421,6 @@
             <scope>test</scope>
         </dependency>
 
-        <!--  Glassfish version of jeresy -->
-        <!-- Starting glassfish jersey dependencies -->
-
-        <dependency>
-            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
-            <artifactId>jersey-test-framework-provider-external</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.glassfish.jersey.test-framework</groupId>
-            <artifactId>jersey-test-framework-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.glassfish.jersey.core</groupId>
-            <artifactId>jersey-client</artifactId>
-            <scope>test</scope>
-
-        </dependency>
-
-        <!-- Ending glassfish jersey dependencies -->
-
         <dependency>
             <groupId>org.apache.usergrid</groupId>
             <artifactId>usergrid-services</artifactId>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fa4b4ccb/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 3242da8..7b71b19 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
@@ -19,14 +19,6 @@ 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;
@@ -39,48 +31,11 @@ import javax.ws.rs.core.Application;
 //import com.sun.jersey.test.framework.WebAppDescriptor;
 
 
-public class AbstractRestIT extends JerseyTest {
-
-    private static ClientConfig clientConfig = new ClientConfig();
-
-
-//    protected static final Application descriptor;
+public class AbstractRestIT {
 
     @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/fa4b4ccb/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 7087185..781f239 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,12 +16,6 @@
  */
 package org.apache.usergrid.rest.test.resource2point0;
 
-
-import javax.ws.rs.client.Client;
-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;
 
@@ -48,20 +42,20 @@ 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( getBaseUri().toString());
+    private final RestClient client = new RestClient( "");
 
 
     @Test
     public void stuff(){
         //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());
+        assertNotNull( organizationResource );
+        //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/fa4b4ccb/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 b455c46..9955e46 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,14 +16,7 @@
  */
 package org.apache.usergrid.rest.test.resource2point0;
 
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.WebTarget;
-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 java.net.URI;
 import org.junit.ClassRule;
 
 import org.apache.usergrid.rest.ITSetup;
@@ -39,14 +32,14 @@ import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
  */
 public class RestClient implements UrlResource {
 
-    ClientConfig clientConfig = new ClientConfig();
+    //ClientConfig clientConfig = new ClientConfig();
 
 //    @ClassRule
 //    public static ITSetup setup = new ITSetup( RestITSuite.cassandraResource );
 
-    Client client = ClientBuilder.newClient( clientConfig );
+    //Client client = ClientBuilder.newClient( clientConfig );
 
-    private WebTarget webTarget;// = client.target("http://example.com/rest");
+   // private WebTarget webTarget;// = client.target("http://example.com/rest");
 
     private final String serverUrl;
     private final ClientContext context;
@@ -62,7 +55,8 @@ public class RestClient implements UrlResource {
     public RestClient( final String serverUrl ) {
         this.serverUrl = serverUrl;
         this.context = new ClientContext();
-        webTarget = client.target( 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 );
     }
 
@@ -73,8 +67,8 @@ public class RestClient implements UrlResource {
      */
     @Override
     public String getPath() {
-        return webTarget.getUri().toString();
-        //return serverUrl;
+        //return webTarget.getUri().toString();
+        return serverUrl;
     }
 
 
@@ -91,7 +85,7 @@ public class RestClient implements UrlResource {
      */
     public OrganizationResource org( final String orgName ) {
         OrganizationResource organizationResource = new OrganizationResource( orgName, context,  this );
-        webTarget = webTarget.path( organizationResource.getPath());
+        //webTarget = webTarget.path( organizationResource.getPath()); This worked really well, shame it couldn't be used.
         return new OrganizationResource( orgName, context,  this );
     }