You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/03/04 23:57:38 UTC
[14/50] [abbrv] incubator-usergrid git commit: Exclude Codehaus
Jackson JAX-RS dependency, plus some better logging & test improvements.
Exclude Codehaus Jackson JAX-RS dependency, plus some better logging & test improvements.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2f6edd71
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2f6edd71
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2f6edd71
Branch: refs/heads/USERGRID-405
Commit: 2f6edd71c1a2a2b4aa09b46de49455668d970cc2
Parents: 80cd97e
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 27 15:42:49 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 27 15:42:49 2015 -0500
----------------------------------------------------------------------
stack/rest/pom.xml | 37 +----
.../org/apache/usergrid/rest/SimplestTest.java | 40 ++++-
.../applications/queries/GeoPagingTest.java | 44 +++---
.../endpoints/CollectionEndpoint.java | 155 ++++++++++++++-----
.../endpoints/mgmt/OrgResource.java | 81 +++++++---
.../rest/test/resource2point0/model/Entity.java | 6 -
stack/services/pom.xml | 6 +
stack/test-utils/pom.xml | 10 +-
8 files changed, 254 insertions(+), 125 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f6edd71/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 34a3858..3ad58b4 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -255,6 +255,11 @@
</dependency>
<dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-spring</artifactId>
</dependency>
@@ -375,38 +380,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-xc</artifactId>
- <version>${jackson-version}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Arquillian deps -->
-
- <!--<dependency>-->
- <!--<groupId>org.jboss.arquillian</groupId>-->
- <!--<artifactId>arquillian-bom</artifactId>-->
- <!--<version>1.1.7.Final</version>-->
- <!--<scope>test</scope>-->
- <!--<type>pom</type>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>org.jboss.arquillian.junit</groupId>-->
- <!--<artifactId>arquillian-junit-container</artifactId>-->
- <!--<version>1.1.7.Final</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>org.jboss.shrinkwrap.resolver</groupId>-->
- <!--<artifactId>shrinkwrap-resolver-depchain</artifactId>-->
- <!--<version>2.1.1</version>-->
- <!--<scope>test</scope>-->
- <!--<type>pom</type>-->
- <!--</dependency>-->
-
<!-- use the external test client. Just depend on the maven jetty plugin to launch jetty -->
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f6edd71/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java
index 6703c1b..27898a9 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java
@@ -16,20 +16,56 @@
*/
package org.apache.usergrid.rest;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.usergrid.persistence.DynamicEntity;
+import org.apache.usergrid.rest.test.resource2point0.model.Collection;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
+import org.apache.usergrid.utils.MapUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+
/**
- * Simplest test verifies if REST test infrastructure is functioning.
+ * Simple test verifies if REST test infrastructure is functioning.
*/
public class SimplestTest extends org.apache.usergrid.rest.test.resource2point0.AbstractRestIT {
- private static final Logger log = LoggerFactory.getLogger(SimplestTest.class);
+ private static final Logger logger = LoggerFactory.getLogger(SimplestTest.class);
@Test
public void getGetToken() {
assertNotNull( getAdminToken() );
}
+
+ @Test
+ public void testEntityPost() {
+
+ Entity cat = new Entity();
+ cat.put("name", "Bertha");
+ cat.put("property1", "value1");
+ Entity savedCat = this.app().collection("cats").post(cat);
+
+ assertEquals( cat.get("property1"), savedCat.get("property1"));
+ }
+
+ @Test
+ public void testEntityPostAndGet() {
+
+ Entity dog = new Entity();
+ dog.put("name", "Pokey");
+ dog.put("property1", "value1");
+ this.app().collection("dogs").post(dog);
+ refreshIndex();
+
+ Collection savedDogs = this.app().collection("dogs").get();
+ Entity savedDog = (Entity)savedDogs.iterator().next();
+ assertEquals( dog.get("property1"), savedDog.get("property1"));
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f6edd71/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
index 6c48af2..f9fe5b3 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
@@ -152,55 +152,47 @@ public class GeoPagingTest extends AbstractRestIT {
}
/**
- * Test that geolocation returns entities with consistent ordering
- * 1. Create several entities
- * 2. Query a subset of the entities
- * 3. Test that the entities were returned in the order expected
- *
- * @throws IOException
+ * Test that geo-query returns co-located entities in expected order.
*/
@Test // USERGRID-1401
public void groupQueriesWithConsistentResults() throws IOException {
int maxRangeLimit = 20;
- Entity[] saved = new Entity[maxRangeLimit];
- //Our base entity that the others will derive from
- Entity actor = new Entity();
- actor.put("displayName", "Erin");
- actor.put("location", new MapUtils.HashMapBuilder<String, Double>()
- .map("latitude", 37.0)
- .map("longitude", -75.0));
- Entity props = new Entity();
+ Entity[] cats = new Entity[maxRangeLimit];
- props.put("actor", actor);
- props.put("verb", "go");
- props.put("content", "bragh");
// 1. Create several entities
for (int i = 0; i < 20; i++) {
- String newPath = String.format("/kero" + i);
- props.put("path", newPath);
- props.put("ordinal", i);
- saved[i] = this.app().collection("groups").post(props);
+ Entity cat = new Entity();
+ cat.put("name", "cat" + i);
+ cat.put("location", new MapUtils.HashMapBuilder<String, Double>()
+ .map("latitude", 37.0)
+ .map("longitude", -75.0));
+ cat.put("ordinal", i);
+ cats[i] = cat;
+ this.app().collection("cats").post(cat);
}
this.refreshIndex();
QueryParameters params = new QueryParameters();
for (int consistent = 0; consistent < 20; consistent++) {
+
// 2. Query a subset of the entities
String query = String.format(
- "select * where location within 100 of 37, -75 and ordinal >= %d and ordinal < %d",
- saved[7].get("ordinal"), saved[10].get("ordinal"));
+ "select * where location within 100 of 37, -75 and ordinal >= %s and ordinal < %s",
+ cats[7].get("ordinal"), cats[10].get("ordinal"));
params.setQuery(query);
- Collection collection = this.app().collection("groups").get(params);
+ Collection collection = this.app().collection("cats").get(params);
assertEquals(3, collection.getResponse().getEntityCount());
List entities = collection.getResponse().getEntities();
+
// 3. Test that the entities were returned in the order expected
for (int i = 0; i < 3; i++) {
+
// shouldn't start at 10 since you're excluding it above in the query, it should return 9,8,7
Entity entity = (Entity)entities.get(i);
- Entity savedEntity = saved[7 + i];
- assertEquals(savedEntity.get("uuid"), entity.get("uuid"));
+ Entity savedEntity = cats[7 + i];
+ assertEquals(savedEntity.get("ordinal"), entity.get("ordinal"));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f6edd71/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
index 6f62a20..5d48524 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/CollectionEndpoint.java
@@ -16,14 +16,19 @@
*/
package org.apache.usergrid.rest.test.resource2point0.endpoints;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.jersey.api.client.WebResource;
import org.apache.usergrid.rest.test.resource2point0.model.*;
import org.apache.usergrid.rest.test.resource2point0.model.Collection;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
import org.apache.usergrid.services.ServiceParameter;
import org.apache.usergrid.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.io.StringReader;
import java.util.*;
@@ -31,6 +36,7 @@ import java.util.*;
* //myorg/myapp/mycollection
*/
public class CollectionEndpoint extends NamedResource {
+ private static final Logger logger = LoggerFactory.getLogger(CollectionEndpoint.class);
protected List<String> acceptHeaders = new ArrayList<String> ();
@@ -62,12 +68,13 @@ public class CollectionEndpoint extends NamedResource {
}
/**
- *
+ * <pre>
* app.collection("users").uniqueID("fred").connection("following").collection("users").uniqueID("barney").post();
* POST /users/fred/following/users/barney?token=<token>
*
* app.collection("users").uniqueID("fred").connection().collection("users").uniqueID("barney").post();
* POST /users/fred/groups/theitcrowd?token=<token>
+ * </pre>
*/
public CollectionEndpoint collection(final String identifier){
return new CollectionEndpoint(identifier, context, this);
@@ -76,10 +83,9 @@ public class CollectionEndpoint extends NamedResource {
/**
- * Get a list of entities
- * @return
+ * Get a list of entities.
*
- * @usage
+ * <pre>
* //with token
* app.collection("users").get(); //return entity
* GET /users?token=<token>
@@ -97,6 +103,7 @@ public class CollectionEndpoint extends NamedResource {
* GET /users
*
* collection = app.collection("users").get(collection);
+ * <pre>
*/
public Collection get(){
return get(null, true);
@@ -115,26 +122,37 @@ public class CollectionEndpoint extends NamedResource {
WebResource resource = getResource(useToken);
resource = addParametersToResource(resource, parameters);
- ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(acceptHeader)
- .get(ApiResponse.class);
+
+ // use string type so we can log actual response from server
+ String responseString = resource.type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(acceptHeader)
+ .get(String.class);
+
+ logger.debug("Response from get: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
return new Collection(response);
}
/**
* Gets the next page using only default settings with the passed in collection.
- * @param collection
- * @param useToken
- * @return
*
- * @usage
+ * <pre>
* Collection usersCollection = app.collection("users").get();
* //iterate through the collection
* while(usersCollection.hasNext()){
* Entity bob = usersCollection.next();
* assert("blah",bob.get("words"));
- * } *
+ * }
* usersCollection = app.collections("users").getNextPage(usersCollection.cursor);
+ * </pre>
*/
//TODO: add queryParameters here
public Collection getNextPage(Collection collection, QueryParameters passedParameters ,final boolean useToken) {
@@ -159,10 +177,9 @@ public class CollectionEndpoint extends NamedResource {
}
/**
- * DELETE on a collection endpoint with query (use DELETE on entity for single entity delete)
- *
- * @return ApiResponse
+ * DELETE on a collection endpoint with query (use DELETE on entity for single entity delete).
*
+ * <pre>
* //with token
* app.collection("users").delete(parameters);
* DELETE /users?ql=select * where created > 0&token=<token>
@@ -173,89 +190,155 @@ public class CollectionEndpoint extends NamedResource {
*
* app.collection("users").delete(null, false);
* DELETE /users
+ * </pre>
*/
public ApiResponse delete( final QueryParameters parameters ){
return delete(parameters, true);
}
- public ApiResponse delete(final QueryParameters parameters, final boolean useToken){
+ public ApiResponse delete(final QueryParameters parameters, final boolean useToken) {
+
String acceptHeader = MediaType.APPLICATION_JSON;
+
if (this.acceptHeaders.size() > 0) {
acceptHeader = StringUtils.join(this.acceptHeaders, ',');
}
WebResource resource = getResource(useToken);
resource = addParametersToResource(resource, parameters);
- return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(acceptHeader)
- .delete(ApiResponse.class);
+ return resource.type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(acceptHeader)
+ .delete(ApiResponse.class);
}
/**
- * Post an entity to a collection
- * @param payload
- * @return
+ * Post an entity to a collection.
*
+ * <pre>
* app.collection("users").post(entity);
* POST /users {"color","red"}
- *
+ * </pre>
*/
public Entity post(Entity payload){
+
String acceptHeader = MediaType.APPLICATION_JSON;
if (this.acceptHeaders.size() > 0) {
acceptHeader = StringUtils.join(this.acceptHeaders, ',');
}
- ApiResponse response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(acceptHeader)
- .post(ApiResponse.class, payload);
+
+ // use string type so we can log actual response from server
+ String responseString = getResource(true)
+ .type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(acceptHeader)
+ .post(String.class, payload);
+
+ logger.debug("Response from post: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+
return new Entity(response);
}
- public Entity post(){
+ public Entity post() {
+
String acceptHeader = MediaType.APPLICATION_JSON;
+
if (this.acceptHeaders.size() > 0) {
acceptHeader = StringUtils.join(this.acceptHeaders, ',');
}
- ApiResponse response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(acceptHeader)
- .post(ApiResponse.class);
+
+ // use string type so we can log actual response from server
+ String responseString = getResource(true)
+ .type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(acceptHeader)
+ .post(String.class);
+
+ logger.debug("Response from post: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+
return new Entity(response);
}
- public ApiResponse post(List<Entity> entityList){
+ public ApiResponse post(List<Entity> entityList) {
+
String acceptHeader = MediaType.APPLICATION_JSON;
+
if (this.acceptHeaders.size() > 0) {
acceptHeader = StringUtils.join(this.acceptHeaders, ',');
}
- ApiResponse response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(acceptHeader)
- .post(ApiResponse.class,entityList);
+
+ // use string type so we can log actual response from server
+ String responseString = getResource(true)
+ .type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(acceptHeader)
+ .post(String.class, entityList );
+
+ logger.debug("Response from post: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+
return response;
}
/**
- * PUT a payload to a collection
+ * PUT a payload to a collection.
*
+ * <pre>
* app.collection("users").put(entity, param);
* PUT /users?ql=select * where created > 0&token=<token>
*
* app.collection("users").put(entity, false, param);
* PUT /users?ql=select * where created > 0
- *
+ * </pre>
*/
public ApiResponse put( final QueryParameters parameters, Entity entity ){
return put(parameters, true, entity);
}
- public ApiResponse put(final QueryParameters parameters, final boolean useToken, Entity entity){
+ public ApiResponse put(final QueryParameters parameters, final boolean useToken, Entity entity) {
+
String acceptHeader = MediaType.APPLICATION_JSON;
if (this.acceptHeaders.size() > 0) {
acceptHeader = StringUtils.join(this.acceptHeaders, ',');
}
+
WebResource resource = getResource(useToken);
addParametersToResource(getResource(), parameters);
- return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(acceptHeader)
- .put(ApiResponse.class, entity);
- }
-
+ // use string type so we can log actual response from server
+ String responseString = resource.type(MediaType.APPLICATION_JSON_TYPE)
+ .accept(acceptHeader)
+ .post(String.class, entity);
+ logger.debug("Response from put: " + responseString);
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
+ return response;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f6edd71/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
index 839f2cd..1a940bd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrgResource.java
@@ -19,6 +19,7 @@ package org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt;
import javax.ws.rs.core.MediaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
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;
@@ -30,13 +31,19 @@ import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.representation.Form;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.StringReader;
-//TODO: add error checking to each of the rest calls.
+
+//TODO: add error checking to each of the REST calls.
/**
* Manages the Management/ORG endpoint.
*/
public class OrgResource extends NamedResource {
+ private static final Logger logger = LoggerFactory.getLogger(OrgResource.class);
public OrgResource( final ClientContext context, final UrlResource parent ) {
super( "orgs", context, parent );
@@ -48,15 +55,15 @@ public class OrgResource extends NamedResource {
}
/**
- * This post is for the POST params case, where the entire call is made using queryParameters
- * @return
+ * This post is for the POST params case, where the entire call is made using queryParameters.
*/
public Organization post(Form form){
- //Seems like an apiresponse can't handle what gets returned from the from urlended media type
- ApiResponse response = getResource().type( MediaType.APPLICATION_FORM_URLENCODED )
- .accept( MediaType.APPLICATION_JSON ).post( ApiResponse.class, form );
+ // Seems like an apiresponse can't handle what gets returned from the from urlended media type
+ ApiResponse response = getResource().type( MediaType.APPLICATION_FORM_URLENCODED )
+ .accept(MediaType.APPLICATION_JSON)
+ .post(ApiResponse.class, form);
Organization organization = new Organization(response);
organization.setOwner( response );
@@ -64,25 +71,50 @@ public class OrgResource extends NamedResource {
}
/**
- * This post is for the POST params case, where the entire call is made using queryParameters
- * @return
+ * This post is for the POST params case, where the entire call is made using queryParameters.
*/
public Organization post(QueryParameters parameters){
- //Seems like an apiresponse can't handle what gets returned from the from urlended media type
+
+ // Seems like an ApiResponse can't handle what gets returned from the from URL encoded media type
WebResource resource = addParametersToResource( getResource(), parameters);
- ApiResponse response = resource.type( MediaType.APPLICATION_FORM_URLENCODED )
- .accept( MediaType.APPLICATION_JSON ).post( ApiResponse.class );
+ // use string type so we can log actual response from server
+ String responseString = resource.type(MediaType.APPLICATION_JSON_TYPE)
+ .accept(MediaType.APPLICATION_JSON)
+ .post(String.class);
+ logger.debug("Response from post: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
Organization org = new Organization(response);
org.setOwner( response );
+
return org;
}
public Organization post(Organization organization){
- ApiResponse response = getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
- .post( ApiResponse.class,organization );
+
+ // use string type so we can log actual response from server
+ String responseString = getResource().type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(MediaType.APPLICATION_JSON)
+ .post(String.class, organization);
+
+ logger.debug("Response from post: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
Organization org = new Organization(response);
org.setOwner( response );
@@ -91,8 +123,21 @@ public class OrgResource extends NamedResource {
}
public Organization put(Organization organization){
- ApiResponse response = getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
- .put(ApiResponse.class, organization);
+
+ // use string type so we can log actual response from server
+ String responseString = getResource().type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(MediaType.APPLICATION_JSON)
+ .put(String.class, organization);
+
+ logger.debug("Response from put: " + responseString);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ApiResponse response;
+ try {
+ response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
+ } catch (IOException e) {
+ throw new RuntimeException("Error parsing response", e);
+ }
Organization org = new Organization(response);
org.setOwner( response );
@@ -106,9 +151,9 @@ public class OrgResource extends NamedResource {
}
public void delete(){
- ApiResponse response = getResource().type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
- .delete(ApiResponse.class);
-
+ ApiResponse response = getResource().type( MediaType.APPLICATION_JSON_TYPE )
+ .accept(MediaType.APPLICATION_JSON)
+ .delete(ApiResponse.class);
}
public CredentialsResource credentials(){
return new CredentialsResource( context ,this );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f6edd71/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index b616be8..89bf092 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -1,6 +1,3 @@
-/**
- * Created by ApigeeCorporation on 12/4/14.
- */
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,10 +15,8 @@
* limitations under the License.
*/
-
package org.apache.usergrid.rest.test.resource2point0.model;
-
import java.io.Serializable;
import java.util.*;
@@ -38,7 +33,6 @@ import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
* Contains a model that can be deconstructed from the api response. This is a base level value that contains the bare
* minumum of what other classes use. Such as . users or groups.
*/
-
public class Entity implements Serializable, Map<String,Object> {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f6edd71/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index ad54fb5..46b0878 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -394,6 +394,12 @@
<groupId>com.github.fernandospr</groupId>
<artifactId>java-wns</artifactId>
<version>1.3</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>jackson-jaxrs</artifactId>
+ <groupId>org.codehaus.jackson</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f6edd71/stack/test-utils/pom.xml
----------------------------------------------------------------------
diff --git a/stack/test-utils/pom.xml b/stack/test-utils/pom.xml
index 5c3539b..d9728af 100644
--- a/stack/test-utils/pom.xml
+++ b/stack/test-utils/pom.xml
@@ -242,7 +242,7 @@
<!-- we need this in all scopes, not just test -->
</dependency>
- <!-- "The artifact junit:junit-dep:jar:4.11 has been relocated to junit:junit:jar:4.11"
+ <!-- "The artifact junit:junit-dep:jar:4.11 has been relocated to junit:junit:jar:4.11"
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
@@ -256,10 +256,10 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- </dependency>
+ <!--<dependency>-->
+ <!--<groupId>org.codehaus.jackson</groupId>-->
+ <!--<artifactId>jackson-mapper-asl</artifactId>-->
+ <!--</dependency>-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>