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/06 00:29:48 UTC

incubator-usergrid git commit: Added the jersey 2 framework to the rest pom for use. Changed the name of the Client to the RESTClient in order to avoid conflicts with the Client in jersey2 Moved the ManagementResource to its own folder. Added the WebTarg

Repository: incubator-usergrid
Updated Branches:
  refs/heads/UG-rest-test-framework-overhaul 7f532d298 -> 35a26da01


Added the jersey 2 framework to the rest pom for use.
Changed the name of the Client to the RESTClient in order to avoid conflicts with the Client in jersey2
Moved the ManagementResource to its own folder.
Added the WebTarget and Client to the RestClient to start building out jersey2 compatibility.


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

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 35a26da01ef16464d8cd16d0f69a03787307c928
Parents: 7f532d2
Author: grey <gr...@apigee.com>
Authored: Fri Dec 5 15:29:45 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Fri Dec 5 15:29:45 2014 -0800

----------------------------------------------------------------------
 stack/pom.xml                                   |  6 ++
 stack/rest/pom.xml                              | 24 +++++
 .../rest/test/resource2point0/Client.java       | 77 ----------------
 .../rest/test/resource2point0/DumbClient.java   | 11 ++-
 .../rest/test/resource2point0/RestClient.java   | 94 ++++++++++++++++++++
 .../endpoints/ManagementResource.java           | 35 --------
 .../resource2point0/endpoints/RootResource.java |  2 +-
 .../endpoints/mgmt/ManagementResource.java      | 38 ++++++++
 8 files changed, 172 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35a26da0/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 7978048..fc93574 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -726,6 +726,12 @@
         <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>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35a26da0/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 4a99443..ad86590 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -421,6 +421,30 @@
             <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/35a26da0/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/Client.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/Client.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/Client.java
deleted file mode 100644
index 6bccd40..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/Client.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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 org.apache.usergrid.rest.test.resource2point0.endpoints.Collection;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.ManagementResource;
-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.endpoints.UrlResource;
-import org.apache.usergrid.rest.test.resource2point0.model.EntityResponse;
-import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-
-
-/**
- * Extends the JerseyTest framework because this is the client that we are going to be using to interact with tomcat
- */
-public class Client implements UrlResource {
-
-
-    private final String serverUrl;
-    private final ClientContext context;
-//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.
-
-    public Client( final String serverUrl ) {
-        this.serverUrl = serverUrl;
-        this.context = new ClientContext();
-    }
-
-
-    @Override
-    public String getPath() {
-        return serverUrl;
-    }
-
-
-    /**
-     * Get the management resource
-     */
-    public ManagementResource management() {
-        return new ManagementResource( context, this );
-    }
-
-
-    /**
-     * Get hte organization resource
-     */
-    public OrganizationResource org( final String orgName ) {
-        return new OrganizationResource( orgName, context,  this );
-    }
-
-//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);
-
-        //context.setToken( token );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35a26da0/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 a0db03b..3813afa 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,12 @@
 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.apache.usergrid.rest.test.resource2point0.endpoints.Collection;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.RootResource;
 import org.apache.usergrid.rest.test.resource2point0.model.Entity;
@@ -24,11 +30,12 @@ import org.apache.usergrid.rest.test.resource2point0.model.EntityResponse;
 
 
 /**
- * Test Class used to model if the client is working or doing what it is supposed to be doing. 
+ * Test Class used to model if the client is working or doing what it is supposed to be doing.
  */
 public class DumbClient {
 
-    private final Client client = new Client("http://localhost:8080");
+    private final RestClient client = new RestClient("http://localhost:8080");
+
 
     public void stuff(){
         EntityResponse itr  =  client.org( "test" ).getApp( "test" ).users().getEntityResponse();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35a26da0/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
new file mode 100644
index 0000000..e890a1e
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/RestClient.java
@@ -0,0 +1,94 @@
+/*
+ * 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 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 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;
+
+
+/**
+ * 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();
+
+
+    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();
+
+
+//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.
+
+    public RestClient( final String serverUrl ) {
+        this.serverUrl = serverUrl;
+        this.context = new ClientContext();
+        webTarget = client.target( serverUrl );
+        //webTarget = webTarget.path( serverUrl );
+    }
+
+
+    @Override
+    public String getPath() {
+        return serverUrl;
+    }
+
+
+    /**
+     * Get the management resource
+     */
+    public ManagementResource management() {
+        return new ManagementResource( context, this );
+    }
+
+
+    /**
+     * Get hte organization resource
+     */
+    public OrganizationResource org( final String orgName ) {
+        //OrganizationResource
+        return new OrganizationResource( orgName, context,  this );
+    }
+
+//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);
+
+        //context.setToken( token );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35a26da0/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ManagementResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ManagementResource.java
deleted file mode 100644
index 5aa0ce4..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/ManagementResource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.endpoints;
-
-
-import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-
-
-/**
- * Contains the REST methods to interacting with the ManagementEndpoints
- */
-public class ManagementResource extends NamedResource {
-    public ManagementResource( final ClientContext context, final UrlResource parent ) {
-        super( "management", context, parent );
-    }
-
-    public TokenResource token(){
-        return new TokenResource( context, this );
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35a26da0/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java
index 9ddc6ac..300ba0f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/RootResource.java
@@ -17,6 +17,7 @@
 package org.apache.usergrid.rest.test.resource2point0.endpoints;
 
 
+import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
 
@@ -26,7 +27,6 @@ import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
  * Contains the two top level functions that can be called from the "root" ( actual root is the serverUrl )
  * 1.) Is the management resource i.e /management/org/blah/...
  * 2.) Is the organization resource i.e /<orgname>/<appname>...
- *
  * This is where top level elements are contained and managemend
  */
 public class RootResource implements UrlResource {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35a26da0/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
new file mode 100644
index 0000000..147ff44
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
@@ -0,0 +1,38 @@
+/*
+ * 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.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.state.ClientContext;
+
+
+/**
+ * Contains the REST methods to interacting with the ManagementEndpoints
+ */
+public class ManagementResource extends NamedResource {
+    public ManagementResource( final ClientContext context, final UrlResource parent ) {
+        super( "management", context, parent );
+    }
+
+    public TokenResource token(){
+        return new TokenResource( context, this );
+    }
+
+}
\ No newline at end of file