You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/08/14 18:41:35 UTC

[04/11] git commit: More progress on getting REST tests passing with Core Persistence, plus some config necessary to get better logging out of Jersey.

More progress on getting REST tests passing with Core Persistence, plus some config necessary to get better logging out of Jersey.


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

Branch: refs/heads/two-dot-o
Commit: 30d00089777923778fa3c25e8d566771331662aa
Parents: 6d666f0
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Aug 12 16:37:06 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Aug 12 16:37:06 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      |  1 -
 .../index/impl/EsEntityIndexImpl.java           | 20 ++++----
 .../persistence/index/impl/EsQueryVistor.java   |  8 +++-
 .../usergrid/persistence/index/query/Query.java |  2 +-
 .../persistence/query/tree/GrammarTreeTest.java | 11 +++++
 stack/pom.xml                                   |  4 +-
 stack/rest/pom.xml                              | 10 ++--
 .../usergrid/rest/AbstractContextResource.java  | 32 +++++++------
 .../rest/applications/ApplicationResource.java  | 40 ++++++++--------
 .../applications/ApplicationResourceIT.java     |  5 ++
 .../rest/applications/DevicesResourceIT.java    |  2 +
 .../collection/activities/AndOrQueryTest.java   | 11 +++--
 .../applications/users/GroupResourceIT.java     |  2 +
 .../applications/users/OwnershipResourceIT.java | 48 ++++++++++++--------
 .../rest/applications/users/UserResourceIT.java | 22 +++++----
 .../rest/test/resource/ValueResource.java       |  8 ++--
 .../rest/src/test/resources/logging.properties  | 28 ++++++++++++
 .../resources/usergrid-custom-test.properties   |  2 +-
 .../usergrid/services/AbstractService.java      |  2 -
 19 files changed, 170 insertions(+), 88 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 739db8f..0f75145 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -109,7 +109,6 @@ import static java.util.Arrays.asList;
 
 import static me.prettyprint.hector.api.factory.HFactory.createMutator;
 import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
-import static org.apache.usergrid.persistence.Schema.COLLECTION_USERS;
 import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_ENTITIES;
 import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_TYPES;
 import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTING_ENTITIES;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 0738473..9c27c85 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -353,7 +353,7 @@ public class EsEntityIndexImpl implements EntityIndex {
             .setRefresh( refresh )
             .execute().actionGet();
 
-        if ( refresh) {
+        if ( refresh ) {
             refresh();
         }
 
@@ -481,14 +481,14 @@ public class EsEntityIndexImpl implements EntityIndex {
 
             if (f instanceof ListField)  {
                 List list = (List) field.getValue();
-                    entityMap.put(field.getName(),
+                    entityMap.put(field.getName().toLowerCase(),
                             new ArrayList(processCollectionForMap(list)));
 
                 if ( !list.isEmpty() ) {
                     if ( list.get(0) instanceof String ) {
                         Joiner joiner = Joiner.on(" ").skipNulls();
                         String joined = joiner.join(list);
-                        entityMap.put(field.getName() + ANALYZED_SUFFIX,
+                        entityMap.put(field.getName().toLowerCase() + ANALYZED_SUFFIX,
                             new ArrayList(processCollectionForMap(list)));
                         
                     }
@@ -496,23 +496,23 @@ public class EsEntityIndexImpl implements EntityIndex {
 
             } else if (f instanceof ArrayField) {
                 List list = (List) field.getValue();
-                entityMap.put(field.getName(),
+                entityMap.put(field.getName().toLowerCase(),
                         new ArrayList(processCollectionForMap(list)));
 
             } else if (f instanceof SetField) {
                 Set set = (Set) field.getValue();
-                entityMap.put(field.getName(),
+                entityMap.put(field.getName().toLowerCase(),
                         new ArrayList(processCollectionForMap(set)));
 
             } else if (f instanceof EntityObjectField) {
                 EntityObject eo = (EntityObject)field.getValue();
-                entityMap.put(field.getName(), entityToMap(eo)); // recursion
+                entityMap.put(field.getName().toLowerCase(), entityToMap(eo)); // recursion
 
             } else if (f instanceof StringField) {
 
                 // index in lower case because Usergrid queries are case insensitive
-                entityMap.put(field.getName(), ((String) field.getValue()).toLowerCase());
-                entityMap.put(field.getName() + ANALYZED_SUFFIX, field.getValue());
+                entityMap.put(field.getName().toLowerCase(), ((String) field.getValue()).toLowerCase());
+                entityMap.put(field.getName().toLowerCase() + ANALYZED_SUFFIX, ((String) field.getValue()).toLowerCase());
 
             } else if (f instanceof LocationField) {
                 LocationField locField = (LocationField) f;
@@ -521,10 +521,10 @@ public class EsEntityIndexImpl implements EntityIndex {
                 // field names lat and lon trigger ElasticSearch geo location 
                 locMap.put("lat", locField.getValue().getLatitude());
                 locMap.put("lon", locField.getValue().getLongtitude());
-                entityMap.put(field.getName() + GEO_SUFFIX, locMap);
+                entityMap.put(field.getName().toLowerCase() + GEO_SUFFIX, locMap);
 
             } else {
-                entityMap.put(field.getName(), field.getValue());
+                entityMap.put(field.getName().toLowerCase(), field.getValue());
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index ec0845e..21e7b1a 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -35,7 +35,6 @@ import org.apache.usergrid.persistence.index.query.tree.NotOperand;
 import org.apache.usergrid.persistence.index.query.tree.OrOperand;
 import org.apache.usergrid.persistence.index.query.tree.QueryVisitor;
 import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
-import org.elasticsearch.common.geo.builders.ShapeBuilder;
 import org.elasticsearch.common.unit.DistanceUnit;
 import org.elasticsearch.index.query.BoolQueryBuilder;
 import org.elasticsearch.index.query.FilterBuilder;
@@ -138,6 +137,7 @@ public class EsQueryVistor implements QueryVisitor {
     @Override
     public void visit( ContainsOperand op ) throws NoFullTextIndexException {
         String name = op.getProperty().getValue();
+        name = name.toLowerCase();
         Object value = op.getLiteral().getValue();
         if ( value instanceof String ) {
             name = addAnayzedSuffix( name );
@@ -149,6 +149,7 @@ public class EsQueryVistor implements QueryVisitor {
     public void visit( WithinOperand op ) {
 
         String name = op.getProperty().getValue();
+        name = name.toLowerCase();
 
         float lat = op.getLatitude().getFloatValue();
         float lon = op.getLongitude().getFloatValue();
@@ -166,6 +167,7 @@ public class EsQueryVistor implements QueryVisitor {
     @Override
     public void visit( LessThan op ) throws NoIndexException {
         String name = op.getProperty().getValue();
+        name = name.toLowerCase();
         Object value = op.getLiteral().getValue();
         if ( value instanceof String ) {
             name = addAnayzedSuffix( name );
@@ -176,6 +178,7 @@ public class EsQueryVistor implements QueryVisitor {
     @Override
     public void visit( LessThanEqual op ) throws NoIndexException {
         String name = op.getProperty().getValue();
+        name = name.toLowerCase();
         Object value = op.getLiteral().getValue();
         if ( value instanceof String ) {
             name = addAnayzedSuffix( name );
@@ -186,6 +189,7 @@ public class EsQueryVistor implements QueryVisitor {
     @Override
     public void visit( Equal op ) throws NoIndexException {
         String name = op.getProperty().getValue();
+        name = name.toLowerCase();
         Object value = op.getLiteral().getValue();
 
         if ( value instanceof String ) {
@@ -207,6 +211,7 @@ public class EsQueryVistor implements QueryVisitor {
     @Override
     public void visit( GreaterThan op ) throws NoIndexException {
         String name = op.getProperty().getValue();
+        name = name.toLowerCase();
         Object value = op.getLiteral().getValue();
         if ( value instanceof String ) {
             name = addAnayzedSuffix( name );
@@ -217,6 +222,7 @@ public class EsQueryVistor implements QueryVisitor {
     @Override
     public void visit( GreaterThanEqual op ) throws NoIndexException {
         String name = op.getProperty().getValue();
+        name = name.toLowerCase();
         Object value = op.getLiteral().getValue();
         if ( value instanceof String ) {
             name = addAnayzedSuffix( name );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
index 6c0c065..9dda724 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
@@ -196,7 +196,7 @@ public class Query {
             }
         }
 
-        ANTLRStringStream in = new ANTLRStringStream( ql.trim() );
+        ANTLRStringStream in = new ANTLRStringStream( ql.trim().toLowerCase() );
         CpQueryFilterLexer lexer = new CpQueryFilterLexer( in );
         CommonTokenStream tokens = new CommonTokenStream( lexer );
         CpQueryFilterParser parser = new CpQueryFilterParser( tokens );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
index 8361580..d0e2d11 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
@@ -591,6 +591,17 @@ public class GrammarTreeTest {
 
 
     @Test
+    public void orderByGrammar() throws QueryParseException {
+
+        String s = "select * where name = 'bob' order by name asc";
+
+        Query query = Query.fromQL( s );
+
+        assertEquals( 1, query.getSortPredicates().size() );
+    }
+
+
+    @Test
     public void badOrderByGrammar() throws QueryParseException {
         // from isn't allowed
         String s = "select * where name = 'bob' order by";

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 40506b8..e51da28 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -197,11 +197,11 @@
     <module>core</module>
     <module>services</module>
     <module>rest</module>
-    <module>tools</module>
+<!--    <module>tools</module>
     <module>websocket</module>
     <module>launcher</module>
     <module>mongo-emulator</module>
-    <module>query-validator</module>
+    <module>query-validator</module>-->
   </modules>
 
   <dependencyManagement>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index bbe6811..b780709 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -61,7 +61,11 @@
                             <parallel>false</parallel>
                             <perCoreThreadCount>false</perCoreThreadCount>
 
-                            <argLine>-Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar</argLine>
+                            <argLine>-Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar -Djava.util.logging.config.file=src/test/resources/logging.properties</argLine>
+
+                            <additionalClasspathElements>
+                                <additionalClasspathElement>./target/classes/jsp/WEB_002dINF/jsp</additionalClasspathElement>
+                            </additionalClasspathElements>
 
                             <includes>
 <!--                                <include>**/RestTestSuite.java</include>
@@ -382,7 +386,7 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
+<!--        <dependency>
             <groupId>org.apache.tomcat.embed</groupId>
             <artifactId>tomcat-embed-core</artifactId>
             <scope>test</scope>
@@ -410,7 +414,7 @@
             <groupId>org.apache.tomcat</groupId>
             <artifactId>tomcat-jsp-api</artifactId>
             <scope>test</scope>
-        </dependency>
+        </dependency>-->
 
         <!--  use the external test client.  Just depend on the maven jetty plugin to launch jetty -->
         <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
index f881bf2..6595d5e 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
@@ -42,9 +42,7 @@ import com.sun.jersey.spi.CloseableService;
 import net.tanesha.recaptcha.ReCaptcha;
 import net.tanesha.recaptcha.ReCaptchaFactory;
 
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-import static org.apache.commons.lang.StringUtils.removeEnd;
-import org.apache.usergrid.rest.management.ManagementResource;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -132,7 +130,8 @@ public abstract class AbstractContextResource {
 
 
     public boolean useReCaptcha() {
-        return isNotBlank( properties.getRecaptchaPublic() ) && isNotBlank( properties.getRecaptchaPrivate() );
+        return StringUtils.isNotBlank( properties.getRecaptchaPublic() ) 
+                && StringUtils.isNotBlank( properties.getRecaptchaPrivate() );
     }
 
 
@@ -140,32 +139,39 @@ public abstract class AbstractContextResource {
         if ( !useReCaptcha() ) {
             return "";
         }
-        ReCaptcha c = ReCaptchaFactory
-                .newSecureReCaptcha( properties.getRecaptchaPublic(), properties.getRecaptchaPrivate(), false );
+        ReCaptcha c = ReCaptchaFactory.newSecureReCaptcha( 
+                properties.getRecaptchaPublic(), properties.getRecaptchaPrivate(), false );
         return c.createRecaptchaHtml( null, null );
     }
 
 
     public void sendRedirect( String location ) {
-        if ( isNotBlank( location ) ) {
+        if ( StringUtils.isNotBlank( location ) ) {
             throw new RedirectionException( location );
         }
     }
 
 
     public Viewable handleViewable( String template, Object model ) { 
+
+        String className = this.getClass().getName().toLowerCase();
+        String packageName = AbstractContextResource.class.getPackage().getName();
+
         String template_property = "usergrid.view" + 
-                removeEnd( this.getClass().getName().toLowerCase(), "resource" )
-                .substring( AbstractContextResource.class.getPackage().getName().length() ) + "." + template
-                .toLowerCase();
+            StringUtils.removeEnd( className.toLowerCase(), "resource" )
+                .substring( packageName.length() ) + "." + template.toLowerCase();
+
         String redirect_url = properties.getProperty( template_property );
-        if ( isNotBlank( redirect_url ) ) {
+        
+        if ( StringUtils.isNotBlank( redirect_url ) ) {
             logger.debug("Redirecting to URL: ", redirect_url);
             sendRedirect( redirect_url );
         }
-        logger.debug("Dispatching to viewable with template: {} template_property: {}", 
+        logger.debug("Dispatching to viewable with template: {}", 
                 template, template_property );
-        return new Viewable( template, model, this.getClass() );
+
+        Viewable viewable = new Viewable( template, model, this.getClass() );
+        return viewable;
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
index 7c679a7..6144940 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
@@ -273,6 +273,7 @@ public class ApplicationResource extends ServiceResource {
             }
 
             if ( user == null ) {
+                logger.debug("Returning 400 bad request due to: " + errorDescription );
                 OAuthResponse response =
                         OAuthResponse.errorResponse( SC_BAD_REQUEST ).setError( OAuthError.TokenResponse.INVALID_GRANT )
                                      .setErrorDescription( errorDescription ).buildJSONMessage();
@@ -376,9 +377,8 @@ public class ApplicationResource extends ServiceResource {
     @Path("credentials")
     @RequireApplicationAccess
     @Produces(MediaType.APPLICATION_JSON)
-    public JSONWithPadding generateKeys( @Context UriInfo ui,
-                                         @QueryParam("callback") @DefaultValue("callback") String callback )
-            throws Exception {
+    public JSONWithPadding generateKeys( @Context UriInfo ui, 
+        @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
         logger.debug( "AuthResource.keys" );
 
@@ -386,9 +386,9 @@ public class ApplicationResource extends ServiceResource {
             throw new UnauthorizedException();
         }
 
-        ClientCredentialsInfo kp =
-                new ClientCredentialsInfo( management.getClientIdForApplication( services.getApplicationId() ),
-                        management.newClientSecretForApplication( services.getApplicationId() ) );
+        ClientCredentialsInfo kp = new ClientCredentialsInfo( 
+            management.getClientIdForApplication( services.getApplicationId() ),
+            management.newClientSecretForApplication( services.getApplicationId() ) );
 
         return new JSONWithPadding(
                 createApiResponse().withCredentials( kp ).withAction( "generate application keys" ).withSuccess(),
@@ -398,10 +398,13 @@ public class ApplicationResource extends ServiceResource {
 
     @GET
     @Path("authorize")
-    public Viewable showAuthorizeForm( @Context UriInfo ui, @QueryParam("response_type") String response_type,
-                                       @QueryParam("client_id") String client_id,
-                                       @QueryParam("redirect_uri") String redirect_uri,
-                                       @QueryParam("scope") String scope, @QueryParam("state") String state ) {
+    public Viewable showAuthorizeForm( 
+            @Context UriInfo ui, 
+            @QueryParam("response_type") String response_type,
+            @QueryParam("client_id") String client_id,
+            @QueryParam("redirect_uri") String redirect_uri,
+            @QueryParam("scope") String scope, 
+            @QueryParam("state") String state ) {
 
         try {
             UUID uuid = getUUIDFromClientId( client_id );
@@ -433,12 +436,13 @@ public class ApplicationResource extends ServiceResource {
     @POST
     @Path("authorize")
     @Produces(MediaType.TEXT_HTML)
-    public Viewable handleAuthorizeForm( @Context UriInfo ui, @FormParam("response_type") String response_type,
-                                         @FormParam("client_id") String client_id,
-                                         @FormParam("redirect_uri") String redirect_uri,
-                                         @FormParam("scope") String scope, @FormParam("state") String state,
-                                         @FormParam("username") String username,
-                                         @FormParam("password") String password ) {
+    public Response handleAuthorizeForm( @Context UriInfo ui, 
+            @FormParam("response_type") String response_type,
+            @FormParam("client_id") String client_id,
+            @FormParam("redirect_uri") String redirect_uri,
+            @FormParam("scope") String scope, @FormParam("state") String state,
+            @FormParam("username") String username,
+            @FormParam("password") String password ) {
 
         LOG.debug( "ApplicationResource /authorize: {}/{}", username, password );
 
@@ -478,14 +482,14 @@ public class ApplicationResource extends ServiceResource {
             ApplicationInfo app = management.getApplicationInfo( applicationId );
             applicationName = app.getName();
 
-            return handleViewable( "authorize_form", this );
+            return Response.ok( handleViewable( "authorize_form", this ) ).build() ;
         }
         catch ( RedirectionException e ) {
             throw e;
         }
         catch ( Exception e ) {
             LOG.debug("handleAuthorizeForm failed", e);
-            return handleViewable( "error", e );
+            return Response.ok( handleViewable( "error", this ) ).build() ;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index 1bfa288..3c6dbee 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -41,6 +41,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -50,6 +52,7 @@ import static org.apache.usergrid.utils.MapUtils.hashMap;
  */
 @Concurrent()
 public class ApplicationResourceIT extends AbstractRestIT {
+    private static final Logger logger = LoggerFactory.getLogger( ApplicationResourceIT.class );
 
     @Test
     public void applicationWithOrgCredentials() throws Exception {
@@ -370,6 +373,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
                 .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).accept( MediaType.TEXT_HTML )
                 .post( String.class, payload );
 
+    
+        logger.debug("result: " + result);
         assertTrue( result.contains( "Username or password do not match" ) );
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java
index 33667c7..247bc37 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java
@@ -32,12 +32,14 @@ import java.io.IOException;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
+import org.junit.Ignore;
 
 
 @Concurrent()
 public class DevicesResourceIT extends AbstractRestIT {
 
     @Test
+    @Ignore // cannot be supported with Core Persistence which requires time based UUIDs
     public void putWithUUIDShouldCreateAfterDelete() throws IOException {
 
         Map<String, String> payload = new HashMap<String, String>();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
index fd4a12a..bb36628 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
@@ -22,6 +22,7 @@ import java.util.Map;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
+import org.apache.commons.lang.RandomStringUtils;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
@@ -148,20 +149,20 @@ public class AndOrQueryTest extends AbstractRestIT {
     @Test //Check to make sure that asc works
     public void queryCheckAsc() throws Exception {
 
-        CustomCollection madeupStuff = context.collection( "imagination" );
+        CustomCollection madeupStuff = context.collection( "imagination" + RandomStringUtils.randomAlphabetic(5));
         Map character = hashMap( "WhoHelpedYou", "Ruff" );
 
         JsonNode[] correctValues;
-        correctValues = madeupStuff.createEntitiesWithOrdinal( character, 1000 );
+        correctValues = madeupStuff.createEntitiesWithOrdinal( character, 10 );
 
         this.refreshIndex( context.getAppUuid() );
 
-        String inquisitiveQuery =
-                "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff' ORDER BY " + "Ordinal asc";
+        String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 10 "
+                + "or WhoHelpedYou eq 'Ruff' ORDER BY Ordinal asc";
 
         int totalEntitiesContained = madeupStuff.verificationOfQueryResults( correctValues, false, inquisitiveQuery );
 
-        assertEquals( 1000, totalEntitiesContained );
+        assertEquals( 10, totalEntitiesContained );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java
index adb64b0..6278067 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java
@@ -237,6 +237,8 @@ public class GroupResourceIT extends AbstractRestIT {
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
 
+        refreshIndex("test-organization", "test-app");
+
         // check it
         assertNull( node.get( "errors" ) );
         assertEquals( node.get( "entities" ).get( 0 ).get( "name" ).asText(), roleName );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java
index 68cf9b8..d11f473 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java
@@ -50,18 +50,27 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
     @Test
     public void meVerify() throws Exception {
+
         context.clearUser();
-        TestUser user1 =
-                new TestAppUser( "testuser1@usergrid.org", "password", "testuser1@usergrid.org" ).create( context )
-                                                                                                 .login( context )
-                                                                                                 .makeActive( context );
+
+        String email = "testuser1@usergrid.org";
+        TestUser user1 = new TestAppUser( email, "password", email ).create( context );
+        refreshIndex(context.getOrgName(), context.getAppName());
+        user1.login( context ).makeActive( context );
+
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String token = user1.getToken();
         JsonNode userNode = context.application().users().user( "me" ).get();
         assertNotNull( userNode );
+
         String uuid = userNode.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
         assertNotNull( uuid );
+
         setup.getMgmtSvc().revokeAccessTokenForAppUser( token );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         try {
             context.application().users().user( "me" ).get();
             fail();
@@ -180,18 +189,20 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         refreshIndex(context.getOrgName(), context.getAppName());
 
-        TestUser user1 =
-                new TestAppUser( "testuser1@usergrid.org", "password", "testuser1@usergrid.org" ).create( context )
-                                                                                                 .login( context )
-                                                                                                 .makeActive( context );
+        String email = "testuser1@usergrid.org";
+        TestUser user1 = new TestAppUser( email, "password", email ).create( context );
+        refreshIndex(context.getOrgName(), context.getAppName());
+        user1.login( context ).makeActive( context );
 
         // create a 4peaks restaurant
-        JsonNode data =
-                context.application().collection( "restaurants" ).create( MapUtils.hashMap( "name", "4peaks" ) );
+        JsonNode data = context.application()
+                .collection( "restaurants" ).create( MapUtils.hashMap( "name", "4peaks" ) );
+
+        refreshIndex(context.getOrgName(), context.getAppName());
 
         // create our connection
-        data = context.application().users().user( "me" ).connection( "likes" ).collection( "restaurants" )
-                      .entity( "4peaks" ).post();
+        data = context.application().users().user( "me" )
+                .connection( "likes" ).collection( "restaurants" ).entity( "4peaks" ).post();
 
         refreshIndex(context.getOrgName(), context.getAppName());
 
@@ -201,19 +212,19 @@ public class OwnershipResourceIT extends AbstractRestIT {
         context.clearUser();
 
         // create a restaurant and link it to user 2
-        TestUser user2 =
-                new TestAppUser( "testuser2@usergrid.org", "password", "testuser2@usergrid.org" ).create( context )
-                                                                                                 .login( context )
-                                                                                                 .makeActive( context );
+        email = "testuser2@usergrid.org";
+        TestUser user2 = new TestAppUser( email, "password", email ).create( context );
+        refreshIndex(context.getOrgName(), context.getAppName());
 
+        user2.login( context ).makeActive( context );
         refreshIndex(context.getOrgName(), context.getAppName());
 
         data = context.application().collection( "restaurants" )
                       .create( MapUtils.hashMap( "name", "arrogantbutcher" ) );
+        refreshIndex(context.getOrgName(), context.getAppName());
 
         data = context.application().users().user( "me" ).connection( "likes" ).collection( "restaurants" )
                       .entity( "arrogantbutcher" ).post();
-
         refreshIndex(context.getOrgName(), context.getAppName());
 
         String arrogantButcherId = getEntity( data, 0 ).get( "uuid" ).asText();
@@ -223,7 +234,6 @@ public class OwnershipResourceIT extends AbstractRestIT {
         CustomCollection likeRestaurants =
                 context.withUser( user1 ).application().users().user( "me" ).connection( "likes" )
                        .collection( "restaurants" );
-
         refreshIndex(context.getOrgName(), context.getAppName());
 
         // check we can get it via id
@@ -337,6 +347,8 @@ public class OwnershipResourceIT extends AbstractRestIT {
         Connection likeRestaurants =
                 context.application().collection( "cities" ).entity( "tempe" ).connection( "likes" );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // check we can get it via id with no collection name
         data = likeRestaurants.entity( peaksId ).get();
         assertNotNull( data );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java
index a524042..c424268 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java
@@ -956,17 +956,23 @@ public class UserResourceIT extends AbstractRestIT {
     public void test_GET_user_ok() throws InterruptedException, IOException {
 
         // TODO figure out what is being overridden? why 400?
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" ).queryParam( "access_token", access_token )
-                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                          .get( String.class ));
+        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" )
+                .queryParam( "access_token", access_token )
+                .accept( MediaType.APPLICATION_JSON )
+                .type( MediaType.APPLICATION_JSON_TYPE )
+                .get( String.class ));
 
         String uuid = node.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
-
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + uuid ).queryParam( "access_token", access_token )
-                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                         .get( String.class ));
+        String email = node.get( "entities" ).get( 0 ).get( "email" ).textValue();
+
+        node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + uuid )
+                .queryParam( "access_token", access_token )
+                .accept( MediaType.APPLICATION_JSON )
+                .type( MediaType.APPLICATION_JSON_TYPE )
+                .get( String.class ));
+        
         logNode( node );
-        assertEquals( "ed@anuff.com", node.get( "entities" ).get( 0 ).get( "email" ).textValue() );
+        assertEquals( email, node.get( "entities" ).get( 0 ).get( "email" ).textValue() );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ValueResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ValueResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ValueResource.java
index d47aab2..0eb3eaa 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ValueResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ValueResource.java
@@ -26,7 +26,6 @@ import com.fasterxml.jackson.databind.JsonNode;
 
 import com.sun.jersey.api.client.WebResource;
 import java.io.IOException;
-import org.apache.usergrid.rest.applications.collection.PagingResourceIT;
 
 import static org.junit.Assert.assertEquals;
 import org.slf4j.Logger;
@@ -239,7 +238,7 @@ public abstract class ValueResource extends NamedResource {
 
         int totalEntitiesContained = 0;
 
-        JsonNode checkedNodes = this.withQuery( checkedQuery ).withLimit( 1000 ).get();
+        JsonNode checkedNodes = this.withQuery( checkedQuery ).withLimit( correctValues.length ).get();
 
         while ( correctValues.length != totalEntitiesContained )//correctNode.get("entities") != null)
         {
@@ -258,9 +257,8 @@ public abstract class ValueResource extends NamedResource {
             }
 
 
-      /*works because this method checks to make sure both queries return the same thing
-      therefore this if shouldn't be needed, but added just in case
-       */
+            // works because this method checks to make sure both queries return the same thing
+            // therefore this if shouldn't be needed, but added just in case
             if ( checkedNodes.get( "cursor" ) != null ) {
                 checkedNodes = this.query( checkedQuery, "cursor", checkedNodes.get( "cursor" ).toString() );
             }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/resources/logging.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/logging.properties b/stack/rest/src/test/resources/logging.properties
new file mode 100644
index 0000000..a0eca06
--- /dev/null
+++ b/stack/rest/src/test/resources/logging.properties
@@ -0,0 +1,28 @@
+# 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.
+
+# Tweak this file to get more logging out Jersey and other depedencies that use
+# Java Logging instead of our preferred SLF4J via Log4j setup. 
+
+handlers=java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level=FINEST
+java.util.logging.SimpleFormatter.format=%4$-7s [%3$s] %5$s%6$s%n
+
+#All log level details
+.level=INFO
+#org.glassfish.jersey.level=FINE
+#org.glassfish.jersey.tracing.level=FINE
+#com.sun.jersey.level=FINE

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/rest/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-custom-test.properties b/stack/rest/src/test/resources/usergrid-custom-test.properties
index 37d2423..b234fd6 100644
--- a/stack/rest/src/test/resources/usergrid-custom-test.properties
+++ b/stack/rest/src/test/resources/usergrid-custom-test.properties
@@ -7,7 +7,7 @@ usergrid.counter.batch.size=1
 
 swagger.basepath=http://sometestvalue
 
-elasticsearch.force_refresh=true
+elasticsearch.force_refresh=false
 
 tomcat.startup=embedded
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/30d00089/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
index 17bbdc2..e315fb1 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
@@ -352,8 +352,6 @@ public abstract class AbstractService implements Service {
             metadata.putAll( defaultEntityMetadata );
         }
 
-        sm.getEntityManager().refreshIndex();
-
         Set<Object> connections = getConnectedTypesSet( entity );
         if ( connections != null ) {
             Map<String, Object> m = new LinkedHashMap<String, Object>();