usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject usergrid git commit: Jersey 2 fix for IndexResourceIT
Date Fri, 04 Sep 2015 13:24:13 GMT
Repository: usergrid
Updated Branches:
  refs/heads/usergrid-103-upgrade-jersey e070ad55f -> dfa65d610


Jersey 2 fix for IndexResourceIT


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

Branch: refs/heads/usergrid-103-upgrade-jersey
Commit: dfa65d61000ad1443c7e6125706dc0642e5b7463
Parents: e070ad5
Author: Dave Johnson <snoopdave@apache.org>
Authored: Fri Sep 4 09:24:09 2015 -0400
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Fri Sep 4 09:24:09 2015 -0400

----------------------------------------------------------------------
 .../apache/usergrid/rest/IndexResourceIT.java   |  5 ++--
 .../resource/endpoints/CollectionEndpoint.java  | 29 ++++++++++++--------
 .../test/resource/endpoints/NamedResource.java  | 21 +++++++-------
 3 files changed, 32 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/dfa65d61/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
index 2bf9855..af91ad7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
@@ -62,12 +62,13 @@ public class IndexResourceIT extends AbstractRestIT {
         assertNotNull( collectionResponse );
 
         //try reindex endpoint with ALl mixed case characters
-        Token superUserToken = clientSetup.getRestClient().management().token().get(clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword());
+        Token superUserToken = clientSetup.getRestClient().management().token()
+            .get(clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword());
 
         QueryParameters queryParameters = new QueryParameters();
         queryParameters.addParam( "access_token",superUserToken.getAccessToken());
         ApiResponse result = clientSetup.getRestClient()
-            .pathResource( "system/index/rebuild/"+clientSetup.getAppUuid()+"/StOrElaTloNs"
)
+            .pathResource( "system/index/rebuild/" + clientSetup.getAppUuid() + "/StOrElaTloNs"
)
             .post( false, ApiResponse.class, null, queryParameters, true );
 
         assertNotNull(result);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dfa65d61/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
index 6873955..958079c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
@@ -203,11 +203,13 @@ public class CollectionEndpoint extends NamedResource {
      * DELETE /users
      * </pre>
      */
-    public org.apache.usergrid.rest.test.resource.model.ApiResponse delete( final org.apache.usergrid.rest.test.resource.model.QueryParameters
parameters ){
+    public org.apache.usergrid.rest.test.resource.model.ApiResponse delete(
+        final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters ){
         return delete(parameters, true);
     }
 
-    public org.apache.usergrid.rest.test.resource.model.ApiResponse delete(final org.apache.usergrid.rest.test.resource.model.QueryParameters
parameters, final boolean useToken) {
+    public org.apache.usergrid.rest.test.resource.model.ApiResponse delete(
+        final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters, final
boolean useToken) {
 
         String acceptHeader = MediaType.APPLICATION_JSON;
 
@@ -230,7 +232,8 @@ public class CollectionEndpoint extends NamedResource {
      * POST /users {"color","red"}
      * </pre>
      */
-    public org.apache.usergrid.rest.test.resource.model.Entity post(org.apache.usergrid.rest.test.resource.model.Entity
payload){
+    public org.apache.usergrid.rest.test.resource.model.Entity post(
+        org.apache.usergrid.rest.test.resource.model.Entity payload){
 
         String acceptHeader = MediaType.APPLICATION_JSON;
         if (this.acceptHeaders.size() > 0) {
@@ -248,7 +251,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue( new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue( new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -275,7 +279,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue( new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue( new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -283,7 +288,8 @@ public class CollectionEndpoint extends NamedResource {
         return new org.apache.usergrid.rest.test.resource.model.Entity(response);
     }
 
-    public org.apache.usergrid.rest.test.resource.model.ApiResponse post(List<org.apache.usergrid.rest.test.resource.model.Entity>
entityList) {
+    public org.apache.usergrid.rest.test.resource.model.ApiResponse post(
+        List<org.apache.usergrid.rest.test.resource.model.Entity> entityList) {
 
         String acceptHeader = MediaType.APPLICATION_JSON;
 
@@ -302,8 +308,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue(
-                new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue( new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -351,8 +357,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue(
-                new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue( new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -360,7 +366,8 @@ public class CollectionEndpoint extends NamedResource {
         return response;
     }
 
-    public CollectionEndpoint matrix(org.apache.usergrid.rest.test.resource.model.QueryParameters
parameters) {
+    public CollectionEndpoint matrix(
+        org.apache.usergrid.rest.test.resource.model.QueryParameters parameters) {
         this.matrix = getMatrixValue(parameters);
         return this;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dfa65d61/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
index 34e3a84..dc6de4b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
@@ -24,6 +24,8 @@ import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME;
 import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD;
+
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 import org.glassfish.jersey.media.multipart.FormDataMultiPart;
 import org.glassfish.jersey.media.multipart.MultiPart;
 
@@ -243,21 +245,20 @@ public class NamedResource implements UrlResource {
 
         WebTarget resource = getTarget( useToken );
         resource = addParametersToResource(resource, queryParameters);
-        Invocation.Builder builder = resource.request()
-            .accept( MediaType.APPLICATION_JSON );
 
+        GenericType<T> gt = new GenericType<>((Class) type);
 
         if ( useBasicAuthentication ) {
-            String uname = (String)entity.get("username");
-            String pword = (String)entity.get("password");
-            builder = builder.property( HTTP_AUTHENTICATION_BASIC_USERNAME, uname )
-                             .property( HTTP_AUTHENTICATION_BASIC_PASSWORD, pword );
+            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+                .credentials( "superuser", "superpassword" ).build();
+            return resource.register( feature ).request()
+                .accept( MediaType.APPLICATION_JSON )
+                .post( javax.ws.rs.client.Entity.json( entity ), gt );
         }
 
-        // it's OK for the entity to be null
-        GenericType<T> gt = new GenericType<>((Class) type);
-        return builder.post( javax.ws.rs.client.Entity.json( entity ), gt );
-
+        return resource.request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( javax.ws.rs.client.Entity.json( entity ), gt );
     }
 
     //For edge cases like Organizations and Tokens without any payload


Mime
View raw message