You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/02/26 18:27:18 UTC

[16/16] incubator-usergrid git commit: merge two-o

merge two-o


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: 382610d0a602a5ee58b7a21232b235dfa63fd6b9
Parents: 489b2d7 b4727f1
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Feb 26 10:26:02 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Feb 26 10:26:02 2015 -0700

----------------------------------------------------------------------
 .../apache/usergrid/rest/PartialUpdateTest.java |   2 +-
 .../collection/BrowserCompatibilityTest.java    |  66 +++--
 .../collection/CollectionsResourceIT.java       | 255 +++++++++--------
 .../collection/DuplicateNameIT.java             |  37 ++-
 .../collection/groups/GroupResourceIT.java      |   2 +-
 .../users/ConnectionResourceTest.java           | 272 ++++++++-----------
 .../rest/management/ImportResourceIT.java       |   5 +-
 .../organizations/AdminEmailEncodingIT.java     | 154 ++++++-----
 .../endpoints/CollectionEndpoint.java           |  58 +++-
 .../endpoints/EntityEndpoint.java               |   2 -
 .../endpoints/mgmt/ManagementResource.java      |   7 +-
 .../rest/test/resource2point0/model/Entity.java |   7 +-
 12 files changed, 469 insertions(+), 398 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/382610d0/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
index dfdbdd8,841d98b..ed0489b
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
@@@ -17,21 -17,15 +17,19 @@@
  package org.apache.usergrid.rest.applications.collection;
  
  
- import java.util.Map;
- import java.util.UUID;
- 
- import com.fasterxml.jackson.databind.JsonNode;
  import java.io.IOException;
- import org.junit.Rule;
++
++import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
  import org.junit.Test;
 -import org.apache.usergrid.cassandra.Concurrent;
 -import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 +
- import org.apache.usergrid.rest.AbstractRestIT;
 +import org.apache.usergrid.rest.TestContextSetup;
 +import org.apache.usergrid.rest.test.resource.CustomCollection;
 +
+ import org.apache.usergrid.rest.test.resource2point0.model.Collection;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
  import static junit.framework.Assert.assertNotNull;
  import static org.junit.Assert.assertEquals;
- import static org.apache.usergrid.utils.MapUtils.hashMap;
  
  
  /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/382610d0/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 115c9af,b9e1191..51956df
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@@ -17,35 -17,32 +17,31 @@@
  package org.apache.usergrid.rest.applications.collection;
  
  
- import java.util.HashMap;
- import java.util.Map;
- import java.util.UUID;
- 
- import javax.ws.rs.core.MediaType;
- 
+ import java.io.IOException;
+ import java.util.NoSuchElementException;
  import com.fasterxml.jackson.databind.JsonNode;
- import org.junit.Assert;
+ import com.sun.jersey.api.client.UniformInterfaceException;
+ import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+ 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.Entity;
+ import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
+ import org.junit.Ignore;
  import org.junit.Test;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
 -import org.apache.usergrid.cassandra.Concurrent;
  
- import org.apache.usergrid.rest.AbstractRestIT;
- import org.apache.usergrid.utils.UUIDUtils;
- 
- import com.sun.jersey.api.client.UniformInterfaceException;
- import java.io.IOException;
- 
- import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.assertNotNull;
- import static org.junit.Assert.assertNull;
- import static org.apache.usergrid.utils.MapUtils.hashMap;
+ import static org.junit.Assert.*;
  
  
  /**
   * @author zznate
   * @author tnine
+  * @author rockerston
+  *
+  *  misc tests for collections
   */
 -@Concurrent()
 +
  public class CollectionsResourceIT extends AbstractRestIT {
  
      private static Logger log = LoggerFactory.getLogger( CollectionsResourceIT.class );
@@@ -129,42 -178,37 +177,37 @@@
  
      @Test
      public void stringWithSpaces() throws IOException {
-         Map<String, String> payload = hashMap( "summaryOverview", "My Summary" ).map( "caltype", "personal" );
  
-         JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" )
-                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
- 
- 
-         UUID id = getEntityId( node, 0 );
+         // create entity with a property with spaces
+         String collection = "calendarlists";
+         String summaryOverview = "My Summary";
+         String calType = "personal";
+         Entity payload = new Entity();
+         payload.put("summaryOverview", summaryOverview);
+         payload.put("caltype", calType);
+         Entity calendarlistOne = this.app().collection(collection).post(payload);
+         assertEquals(calendarlistOne.get("summaryOverview"), summaryOverview);
+         assertEquals(calendarlistOne.get("caltype"), calType);
 -        String calendarlistOneUUID = calendarlistOne.getString("uuid");
++        String calendarlistOneUUID = calendarlistOne.getAsString("uuid");
+         this.refreshIndex();
  
          //post a second entity
+         payload = new Entity();
+         String summaryOverviewTwo = "Your Summary";
+         String calTypeTwo = "personal";
+         payload.put("summaryOverview", summaryOverviewTwo);
+         payload.put("caltype", calTypeTwo);
+         Entity calendarlistTwo = this.app().collection(collection).post(payload);
+         assertEquals(calendarlistTwo.get("summaryOverview"), summaryOverviewTwo);
+         assertEquals(calendarlistTwo.get("caltype"), calTypeTwo);
  
  
-         payload = hashMap( "summaryOverview", "Your Summary" ).map( "caltype", "personal" );
- 
-         node = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" ).queryParam( "access_token", access_token )
-                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                 .post( String.class, payload ));
- 
- 
-         refreshIndex("test-organization", "test-app");
- 
          //query for the first entity
- 
          String query = "summaryOverview = 'My Summary'";
+         QueryParameters queryParameters = new QueryParameters().setQuery(query);
+         Collection calendarListCollection = this.app().collection(collection).get(queryParameters);
+         assertEquals(calendarListCollection.hasNext(), false);
  
- 
-         JsonNode queryResponse = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" )
-                 .queryParam( "access_token", access_token ).queryParam( "ql", query )
-                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- 
- 
-         UUID returnedId = getEntityId( queryResponse, 0 );
- 
-         assertEquals( id, returnedId );
- 
-         assertEquals( 1, queryResponse.get( "entities" ).size() );
      }
  
  

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/382610d0/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
index 9c1636a,d01c533..dafbff9
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
@@@ -16,15 -16,12 +16,15 @@@
  
  package org.apache.usergrid.rest.applications.collection;
  
 +
- import org.junit.Rule;
- import org.junit.Test;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
 +
- import org.apache.usergrid.rest.AbstractRestIT;
- import org.apache.usergrid.rest.TestContextSetup;
 +
+ import com.sun.jersey.api.client.UniformInterfaceException;
+ import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+ import org.junit.Test;
+ 
+ import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.fail;
  
  
@@@ -38,32 -35,20 +38,47 @@@ public class DuplicateNameIT extends Ab
      @Test
      public void duplicateNamePrevention() {
  
 +        fail("This test is incorrectly written and should not use direct serialization to test duplicate names");
 +
 +//        CustomCollection things = context.application().customCollection( "things" );
 +//
 +//        Map<String, String> entity = MapUtils.hashMap( "name", "enzo" );
 +//
 +//        try {
 +//            things.create( entity );
 +//        } catch (IOException ex) {
 +//            logger.error("Cannot create entity", ex);
 +//        }
 +//
 +//        refreshIndex( context.getAppUuid() );
 +//
 +//        Injector injector = Guice.createInjector( new TestGuiceModule( null ) );
 +//        SerializationFig sfig = injector.getInstance( SerializationFig.class );
 +//
 +//        // wait for any temporary unique value records to timeout
 +//        try { Thread.sleep( sfig.getTimeout() * 1100 ); } catch (InterruptedException ignored) {}
 +//
 +//        try {
 +//            things.create( entity );
 +//            fail("Should not have created duplicate entity");
 +//
 +//        } catch (Exception ex) {
 +//            // good
 +//        }
+         String collectionName = "things";
+         Entity entity = new Entity();
+         entity.put("name", "enzo");
+         //Create an entity named "enzo" in the "things" collection
+         entity = this.app().collection(collectionName).post(entity);
+         refreshIndex();
+         try {
+             // Try to create a second entity in "things" with the name "enzo".
+             this.app().collection(collectionName).post(entity);
+             // fail if the POST did not return an exception
+             fail("Should not have created duplicate entity");
+         } catch (UniformInterfaceException uie) {
+             //Check for an exception
+             assertEquals(400, uie.getResponse().getStatus());
+         }
      }
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/382610d0/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/382610d0/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index a095afa,0000000..e464f72
mode 100644,000000..100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
@@@ -1,769 -1,0 +1,768 @@@
 +/*
 + * 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.management;
 +
 +import com.amazonaws.SDKGlobalConfiguration;
 +import com.google.common.collect.ImmutableSet;
 +import com.google.common.util.concurrent.Service;
 +import com.google.inject.Module;
 +import com.sun.jersey.api.client.ClientResponse;
 +import com.sun.jersey.api.client.UniformInterfaceException;
 +import org.apache.commons.lang.RandomStringUtils;
 +import org.apache.commons.lang3.StringUtils;
 +import org.apache.usergrid.ServiceITSetup;
 +import org.apache.usergrid.ServiceITSetupImpl;
 +import org.apache.usergrid.batch.service.JobSchedulerService;
- import org.apache.usergrid.cassandra.CassandraResource;
 +import org.apache.usergrid.management.importer.S3Upload;
 +import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
 +import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 +import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 +import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 +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.Organization;
 +import org.apache.usergrid.rest.test.resource2point0.model.Token;
 +import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 +
 +import org.jclouds.ContextBuilder;
 +import org.jclouds.blobstore.BlobStore;
 +import org.jclouds.blobstore.BlobStoreContext;
 +import org.jclouds.blobstore.ContainerNotFoundException;
 +import org.jclouds.blobstore.domain.PageSet;
 +import org.jclouds.blobstore.domain.StorageMetadata;
 +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
 +import org.jclouds.logging.log4j.config.Log4JLoggingModule;
 +import org.jclouds.netty.config.NettyPayloadModule;
 +import org.junit.*;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +import java.util.ArrayList;
 +import java.util.HashMap;
 +import java.util.List;
 +import java.util.Properties;
 +
 +import static org.junit.Assert.*;
 +
 +
 +public class ImportResourceIT extends AbstractRestIT {
 +
 +    private static final Logger logger = LoggerFactory.getLogger(ImportResourceIT.class);
 +
 +
 +    private static String bucketPrefix;
 +
 +    private String bucketName;
 +
 +    boolean configured;
 +
 +
 +    public ImportResourceIT() throws Exception {
 +
 +    }
 +
 +
 +    @ClassRule
 +    public static final ServiceITSetup setup =
 +        new ServiceITSetupImpl();
 +
 +    @BeforeClass
 +    public static void setup() throws Exception {
 +
 +        bucketPrefix = System.getProperty("bucketName");
 +
 +        // start the scheduler after we're all set up
 +        JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( JobSchedulerService.class );
 +        if (jobScheduler.state() != Service.State.RUNNING) {
 +            jobScheduler.startAndWait();
 +        }
 +
 +    }
 +
 +    @Before
 +    public void before() {
 +        configured =
 +            !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ))
 +                && !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ))
 +                && !StringUtils.isEmpty(System.getProperty("bucketName"));
 +
 +
 +        if (!configured) {
 +            logger.warn("Skipping test because {}, {} and bucketName not " +
 +                    "specified as system properties, e.g. in your Maven settings.xml file.",
 +                new Object[]{
 +                    "s3_key",
 +                    "s3_access_id"
 +                });
 +        }
 +
 +        if (!StringUtils.isEmpty(bucketPrefix)) {
 +            deleteBucketsWithPrefix();
 +        }
 +
 +        bucketName = bucketPrefix + RandomStringUtils.randomAlphanumeric(10).toLowerCase();
 +    }
 +
 +
 +    /**
 +     * Verify that we can get call the import endpoint and get the job state back.
 +     *
 +     * @throws Exception
 +     */
 +    @Test
 +    public void importGetCollectionJobStatTest() throws Exception {
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        Entity payload = payloadBuilder();
 +
 +        ///management/orgs/orgname/apps/appname/import
 +        Entity entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .post(payload);
 +
 +        assertNotNull(entity);
 +
 +        entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .addToPath(entity.getUuid().toString())
 +            .get();
 +
-         assertNotNull(entity.getString("state"));
++        assertNotNull(entity.getAsString("state"));
 +    }
 +
 +    /**
 +     * Verify that import job can only be read with an authorized token and cannot be read
 +     * with an invalid/notAllowed token.
 +     */
 +    @Test
 +    public void importTokenAuthorizationTest() throws Exception {
 +
 +        // this test should post one import job with one token,
 +        // then try to read back the job with another token
 +
 +        // create an import job
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        Entity payload = payloadBuilder();
 +
 +        // /management/orgs/orgname/apps/appname/import
 +        Entity entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .post(payload);
 +
 +
 +        assertNotNull(entity);
 +
 +        // test that you can access the organization using the currently set token.
 +        this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports").addToPath(entity.getUuid().toString()).get();
 +
 +        //create a new org/app
 +        String newOrgName = "org" + UUIDUtils.newTimeUUID();
 +        String newOrgUsername = "orgusername" + UUIDUtils.newTimeUUID();
 +        String newOrgEmail = UUIDUtils.newTimeUUID() + "@usergrid.com";
 +        String newOrgPassword = "password1";
 +        Organization orgPayload = new Organization(
 +            newOrgName, newOrgUsername, newOrgEmail, newOrgName, newOrgPassword, null);
 +        Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post(orgPayload);
 +        this.refreshIndex();
 +        assertNotNull(orgCreatedResponse);
 +
 +
 +        //log into the new org/app and get a token
 +        Token tokenPayload = new Token("password", newOrgUsername, newOrgPassword);
 +        Token newOrgToken = clientSetup.getRestClient().management().token().post(tokenPayload);
 +
 +        //save the old token and set the newly issued token as current
 +        context().setToken(newOrgToken);
 +
 +
 +        //try to read with the new token, which should fail as unauthorized
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app)
 +                .addToPath("imports").addToPath(entity.getUuid().toString()).get();
 +            fail("Should not be able to read import job with unauthorized token");
 +        } catch (UniformInterfaceException ex) {
 +            errorParse(401, "unauthorized", ex);
 +        }
 +
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerProperties() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = new Entity();
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageInfo() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +        Entity properties = (Entity) payload.get("properties");
 +        //remove storage_info field
 +        properties.remove("storage_info");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageProvider() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +        Entity properties = (Entity) payload.get("properties");
 +        //remove storage_info field
 +        properties.remove("storage_provider");
 +
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageVerification() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +
 +        Entity properties = (Entity) payload.get("properties");
 +        Entity storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("s3_key");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +
 +        payload = payloadBuilder();
 +        properties = (Entity) payload.get("properties");
 +        storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("s3_access_id");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +
 +        payload = payloadBuilder();
 +        properties = (Entity) payload.get("properties");
 +        storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("bucket_location");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +//    @Test
 +//    public void testExportImportCollection() throws Exception {
 +//        Assume.assumeTrue( configured );
 +//        // create a collection of "thing" entities in the first application, export to S3
 +//        try {
 +//
 +//            Map<UUID, org.apache.usergrid.persistence.Entity> thingsMap = new HashMap<>();
 +//            List<org.apache.usergrid.persistence.Entity> things = new ArrayList<>();
 +//            createTestEntities(emApp1, thingsMap, things, "thing");
 +//
 +//            deleteBucket();
 +//            exportCollection( emApp1, "things" );
 +//
 +//            // create new second application, import the data from S3
 +//
 +//            final UUID appId2 = setup.getMgmtSvc().createApplication(
 +//                organization.getUuid(), "second").getId();
 +//
 +//            final EntityManager emApp2 = setup.getEmf().getEntityManager(appId2);
 +//            importCollection( emApp2, "things" );
 +//
 +//
 +//            // make sure that it worked
 +//
 +//            logger.debug("\n\nCheck connections\n");
 +//
 +//            List<org.apache.usergrid.persistence.Entity> importedThings = emApp2.getCollection(
 +//                appId2, "things", null, Query.Level.ALL_PROPERTIES).getEntities();
 +//            assertTrue( !importedThings.isEmpty() );
 +//
 +//            // two things have connections
 +//
 +//            int conCount = 0;
 +//            for ( org.apache.usergrid.persistence.Entity e : importedThings ) {
 +//                Results r = emApp2.getConnectedEntities( e, "related", null, Query.Level.IDS);
 +//                List<ConnectionRef> connections = r.getConnections();
 +//                conCount += connections.size();
 +//            }
 +//            assertEquals( 2, conCount );
 +//
 +//            logger.debug("\n\nCheck dictionaries\n");
 +//
 +//            // first two items have things in dictionary
 +//
 +//            EntityRef entity0 = importedThings.get(0);
 +//            Map connected0 = emApp2.getDictionaryAsMap(entity0, "connected_types");
 +//            Map connecting0 = emApp2.getDictionaryAsMap(entity0, "connected_types");
 +//            Assert.assertEquals( 1, connected0.size() );
 +//            Assert.assertEquals( 1, connecting0.size() );
 +//
 +//            EntityRef entity1 = importedThings.get(1);
 +//            Map connected1 = emApp2.getDictionaryAsMap(entity1, "connected_types");
 +//            Map connecting1 = emApp2.getDictionaryAsMap(entity1, "connected_types");
 +//            Assert.assertEquals( 1, connected1.size() );
 +//            Assert.assertEquals( 1, connecting1.size() );
 +//
 +//            // the rest rest do not have connections
 +//
 +//            EntityRef entity2 = importedThings.get(2);
 +//            Map connected2 = emApp2.getDictionaryAsMap(entity2, "connected_types");
 +//            Map connecting2 = emApp2.getDictionaryAsMap(entity2, "connected_types");
 +//            Assert.assertEquals( 0, connected2.size() );
 +//            Assert.assertEquals( 0, connecting2.size() );
 +//
 +//            // if entities are deleted from app1, they still exist in app2
 +//
 +//            logger.debug("\n\nCheck dictionary\n");
 +//            for ( org.apache.usergrid.persistence.Entity importedThing : importedThings ) {
 +//                emApp1.delete( importedThing );
 +//            }
 +//            emApp1.refreshIndex();
 +//            emApp2.refreshIndex();
 +//
 +//            importedThings = emApp2.getCollection(
 +//                appId2, "things", null, Query.Level.ALL_PROPERTIES).getEntities();
 +//            assertTrue( !importedThings.isEmpty() );
 +//
 +//        } finally {
 +//            deleteBucket();
 +//        }
 +//    }
 +
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportGoodJson() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImportCorrect.testCol.1.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app )
 +            .addToPath( "imports" ).addToPath( importEntity.getUuid().toString() ).get();
 +
 +
 +        refreshIndex();
 +
 +        Entity importGetIncludes = this.management().orgs().organization(org).app().addToPath(app)
 +                                       .addToPath("imports" ).addToPath(importEntity.getUuid().toString() )
 +                                       .addToPath("files" ).get();
 +
 +        ApiResponse importGetIncludesResponse = importGetIncludes.getResponse();
 +
 +        assertNotNull(importGet);
 +        assertNotNull( importGetIncludes );
 +        assertEquals( 1,importGetIncludesResponse.getEntityCount());
 +
 +
 +        final Entity includesEntity = importGetIncludesResponse.getEntities().get( 0 );
 +
-         assertEquals( "testImportCorrect.testCol.1.json", includesEntity.getString( "fileName" ) );
++        assertEquals( "testImportCorrect.testCol.1.json", includesEntity.getAsString( "fileName" ) );
 +        assertEquals(1, includesEntity.get( "importedConnectionCount" ));
 +        assertEquals(1, includesEntity.get( "importedEntityCount" ));
 +
 +        assertEquals("FINISHED", importGet.get("state"));
 +        assertEquals(1, importGet.get("fileCount"));
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(1, collection.getNumOfEntities());
 +        assertEquals("thing0", collection.getResponse().getEntities().get(0).get("name"));
 +
 +
 +        //TODO: make sure it checks the actual imported entities. And the progress they have made.
 +
 +    }
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportOneGoodOneBad() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImportCorrect.testCol.1.json");
 +        filenames.add("testImport.testApplication.2.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath( "imports" ).addToPath(importEntity.getUuid().toString() ).get();
 +
 +
 +        assertNotNull(importGet);
 +
 +        assertEquals("FAILED", importGet.get("state"));
 +        assertEquals(2, importGet.get("fileCount"));
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(1, collection.getNumOfEntities());
 +        assertEquals("thing0", collection.getResponse().getEntities().get(0).get("name"));
 +
 +
 +    }
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportOneBadFile() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImport.testApplication.2.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports" ).addToPath(importEntity.getUuid().toString() ).get();
 +
 +
 +        assertNotNull(importGet);
 +
 +        assertEquals("FAILED", importGet.get("state"));
 +        assertEquals(1, importGet.get("fileCount"));
 +
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(0, collection.getNumOfEntities());
 +
 +
 +    }
 +//export with two files and import the two files.
 +    //also test the includes endpoint.
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportBadJson() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +        filenames.add("testImportInvalidJson.testApplication.3.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        // we should now have 100 Entities in the default app
 +
 +        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app ).addToPath("imports")
 +            .addToPath( importEntity.getUuid().toString() ).get();
 +
 +        Entity importGetIncludes = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports" ).addToPath(importEntity.getUuid().toString() )
 +            .addToPath("files" ).get();
 +
 +        assertNotNull(importGet);
 +        //TODO: needs better error checking
 +        assertNotNull(importGetIncludes);
 +
 +        // check that error message indicates JSON parsing error
 +    }
 +
 +    /**
 +     * Call importService to import files from the configured S3 bucket.
 +     */
 +    private Entity importCollection() throws Exception {
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +        logger.debug("\n\nImport into new app {}\n", app);
 +
 +        Entity importPayload = new Entity(new HashMap<String, Object>() {{
 +            put("properties", new HashMap<String, Object>() {{
 +                put("storage_provider", "s3");
 +                put("storage_info", new HashMap<String, Object>() {{
 +                    put("s3_key",
 +                        System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ));
 +                    put("s3_access_id",
 +                        System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ));
 +                    put("bucket_location", bucketName);
 +                }});
 +            }});
 +        }});
 +
 +        Entity importEntity = this.management().orgs().organization(org).app().addToPath(app).addToPath("imports")
 +                                  .post(importPayload);
 +
 +        int maxRetries = 120;
 +        int retries = 0;
 +
 +        while (retries++ < maxRetries) {
 +
 +            Entity importGet = this.management()
 +                .orgs()
 +                .organization(org)
 +                .app()
 +                .addToPath(app)
 +                .addToPath("imports")
 +                .addToPath(importEntity.getUuid().toString())
 +                .get();
 +
 +            if (importGet.get("state").equals("FINISHED") || importGet.get( "state" ).equals( "FAILED" )) {
 +                break;
 +            }
 +
 +            logger.debug("Waiting for import...");
 +            Thread.sleep(1000);
 +        }
 +
 +        refreshIndex();
 +
 +        return importEntity;
 +    }
 +
 +    /**
 +     * Create test entities of a specified type.
 +     * First two entities are connected.
 +     */
 +    private void createTestEntities() throws Exception {
 +
 +        logger.debug("\n\nCreating users in application {}\n",
 +            clientSetup.getAppName());
 +
 +        List<org.apache.usergrid.persistence.Entity> created = new ArrayList<>();
 +        for (int i = 0; i < 10; i++) {
 +            String name = "test" + i;
 +            Entity payload = new Entity();
 +            payload.put("name", name);
 +            payload.put("username", name);
 +            payload.put("email", name + "@test.com");
 +            this.app().collection("users").post(payload);
 +
 +
 +        }
 +
 +        this.refreshIndex();
 +
 +//        // first two things are related to each other
 +//        em.createConnection(new SimpleEntityRef(type, created.get(0).getUuid()),
 +//            "related", new SimpleEntityRef(type, created.get(1).getUuid()));
 +//        em.createConnection(new SimpleEntityRef(type, created.get(1).getUuid()),
 +//            "related", new SimpleEntityRef(type, created.get(0).getUuid()));
 +//
 +//        em.refreshIndex();
 +    }
 +
 +    /**
 +     * Delete the configured s3 bucket.
 +     */
 +    public void deleteBucket() {
 +
 +        logger.debug("\n\nDelete bucket\n");
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty("s3" + ".identity", accessId);
 +        overrides.setProperty("s3" + ".credential", secretKey);
 +
 +        final Iterable<? extends Module> MODULES = ImmutableSet.of(new JavaUrlHttpCommandExecutorServiceModule(),
 +            new Log4JLoggingModule(), new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +            ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
 +                .overrides(overrides ).buildView(BlobStoreContext.class);
 +
 +        BlobStore blobStore = context.getBlobStore();
 +        blobStore.deleteContainer(bucketName);
 +    }
 +
 +    // might be handy if you need to clean up buckets
 +    private static void deleteBucketsWithPrefix() {
 +
 +        logger.debug("\n\nDelete buckets with prefix {}\n", bucketPrefix);
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty("s3" + ".identity", accessId);
 +        overrides.setProperty("s3" + ".credential", secretKey);
 +
 +        final Iterable<? extends Module> MODULES = ImmutableSet
 +            .of(new JavaUrlHttpCommandExecutorServiceModule(),
 +                new Log4JLoggingModule(),
 +                new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +            ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
 +                .overrides(overrides ).buildView(BlobStoreContext.class);
 +
 +        BlobStore blobStore = context.getBlobStore();
 +        final PageSet<? extends StorageMetadata> blobStoreList = blobStore.list();
 +
 +        for (Object o : blobStoreList.toArray()) {
 +            StorageMetadata s = (StorageMetadata) o;
 +
 +            if (s.getName().startsWith(bucketPrefix)) {
 +                try {
 +                    blobStore.deleteContainer(s.getName());
 +                } catch (ContainerNotFoundException cnfe) {
 +                    logger.warn("Attempted to delete bucket {} but it is already deleted", cnfe);
 +                }
 +                logger.debug("Deleted bucket {}", s.getName());
 +            }
 +        }
 +    }
 +
 +
 +    /*Creates fake payload for testing purposes.*/
 +    public Entity payloadBuilder() {
 +        Entity payload = new Entity();
 +        Entity properties = new Entity();
 +        Entity storage_info = new Entity();
 +        //TODO: always put dummy values here and ignore this test.
 +        //TODO: add a ret for when s3 values are invalid.
 +        storage_info.put("s3_key", "insert key here");
 +        storage_info.put("s3_access_id", "insert access id here");
 +        storage_info.put("bucket_location", "insert bucket name here");
 +        properties.put("storage_provider", "s3");
 +        properties.put("storage_info", storage_info);
 +        payload.put("properties", properties);
 +        return payload;
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/382610d0/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
index e9ebe60,648abd1..65fd8d9
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
@@@ -17,14 -17,20 +17,20 @@@
  package org.apache.usergrid.rest.management.organizations;
  
  
- import com.fasterxml.jackson.databind.JsonNode;
- import java.io.IOException;
- import org.junit.Rule;
++
+ import com.sun.jersey.api.client.UniformInterfaceException;
 -import org.apache.usergrid.cassandra.Concurrent;
+ import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+ import org.apache.usergrid.rest.test.resource2point0.model.Application;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+ import org.apache.usergrid.rest.test.resource2point0.model.Organization;
+ import org.apache.usergrid.rest.test.resource2point0.model.Token;
+ import org.junit.Ignore;
  import org.junit.Test;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
  
- import org.apache.usergrid.rest.AbstractRestIT;
- import org.apache.usergrid.rest.TestContextSetup;
- import org.apache.usergrid.rest.test.security.TestAdminUser;
+ import java.io.IOException;
+ import java.util.UUID;
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertNotNull;
@@@ -36,84 -42,96 +42,96 @@@
   *
   * @author tnine
   */
 -@Concurrent()
 +
  public class AdminEmailEncodingIT extends AbstractRestIT {
+     private static Logger log = LoggerFactory.getLogger(AdminEmailEncodingIT.class);
  
-     @Rule
-     public TestContextSetup context = new TestContextSetup( this );
- 
- 
+     /**
+      * Ensure that '+' characters in email addresses are handled properly
+      *
+      * @throws Exception
+      */
      @Test
      public void getTokenPlus() throws Exception {
-         String org = "AdminEmailEncodingTestgetTokenPlus";
-         String app = "Plus";
- 
-         doTest( "+", org, app );
+         doTest("+");
      }
  
- 
+     /**
+      * Ensure that '_' characters in email addresses are handled properly
+      *
+      * @throws Exception
+      */
      @Test
      public void getTokenUnderscore() throws Exception {
-         String org = "AdminEmailEncodingTestgetTokenUnderscore";
-         String app = "Underscore";
- 
-         doTest( "_", org, app );
+         doTest("_");
      }
  
- 
+     /**
+      * Ensure that '-' characters in email addresses are handled properly
+      *
+      * @throws Exception
+      */
      @Test
      public void getTokenDash() throws Exception {
-         String org = "AdminEmailEncodingTestgetTokenDash";
-         String app = "Dash";
- 
-         doTest( "-", org, app );
+         doTest("-");
      }
  
+     /**
+      * Ensure that "'" characters in email addresses are handled properly
+      *
+      * @throws Exception
+      */
+     @Test
+     @Ignore //This fails. I'm not sure if it is by design, but a single quote is valid in an email address
+     public void getTokenQuote() throws Exception {
+         doTest("'");
+     }
  
-     private void doTest( String symbol, String org, String app ) throws IOException {
- 
-         org = org.toLowerCase();
-         app = app.toLowerCase();
- 
-         String email = String.format( "admin%sname@adminemailencodingtest.org", symbol );
-         String user = email;
-         String password = "password";
- 
-         TestAdminUser adminUser = new TestAdminUser( user, password, email );
- 
-         context.withApp( app ).withOrg( org ).withUser( adminUser );
- 
-         // create the org and app
-         context.createNewOrgAndUser();
- 
-         // no need for refresh here as Service module does an index refresh when org/app created
- 
-         // now log in via a GET
- 
-         String getToken = context.management().tokenGet( email, password );
- 
-         assertNotNull( getToken );
- 
-         String postToken = context.management().tokenPost( email, password );
- 
-         assertNotNull( postToken );
- 
-         // not log in with our admin
-         context.withUser( adminUser ).loginUser();
- 
-         //now get the "me" and ensure it's correct
- 
-         JsonNode data = context.management().me().get();
- 
-         assertNotNull( data.get( "access_token" ).asText() );
- 
-         data = context.management().users().user( email ).get();
- 
-         JsonNode admin = data.get( "data" ).get( "organizations" ).get( org ).get( "users" ).get( email );
- 
-         assertNotNull( admin );
+     /**
+      * Given an organization name and an arbitrary character or string,
+      * ensure that an organization and admin user can be created when
+      * the given string is a part of the admin email address
+      *
+      * @param symbol
+      * @throws IOException
+      */
+     private void doTest(String symbol) throws UniformInterfaceException {
+ 
+         String unique = UUID.randomUUID().toString();
+         String org = "org_getTokenDash" + unique;
+         String app = "app_getTokenDash" + unique;
+ 
+         //Username and password
+         String username = "testuser" + unique;
+         String password = "password" + unique;
+         //create an email address containing 'symbol'
+         String email = String.format("test%suser%s@usergrid.com", symbol, unique);
+ 
+         //create the organization entity
+         Organization orgPayload = new Organization(org, username, email, username, password, null);
+ 
+         //post the organization entity
+         Organization organization = clientSetup.getRestClient().management().orgs().post(orgPayload);
+         assertNotNull(organization);
+ 
+         //Retrieve an authorization token using the credentials created above
+         Token tokenReturned = clientSetup.getRestClient().management().token().post(new Token("password", username, password));
+         assertNotNull(tokenReturned);
+ 
+         //Instruct the test framework to use the new token
+         this.app().token().setToken(tokenReturned);
+         //Create an application within the organization
+         clientSetup.getRestClient().management().orgs().organization(organization.getName()).app().post(new Application(app));
+ 
+         //retrieve the new management user by username and ensure the username and email address matches the input
+         Entity me = clientSetup.getRestClient().management().users().entity(username).get();
+         assertEquals(email, me.get("email"));
+         assertEquals(username, me.get("username"));
+ 
+         //retrieve the new management user by email and ensure the username and email address matches the input
+         me = clientSetup.getRestClient().management().users().entity(email).get();
+         assertEquals(email, me.get("email"));
+         assertEquals(username, me.get("username"));
  
-         assertEquals( email, admin.get( "email" ).asText() );
-         assertEquals( user, admin.get( "username" ).asText() );
      }
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/382610d0/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------