usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [01/27] git commit: Added in suite of tests for organization level exports. Will need to get ready for query support.
Date Tue, 01 Apr 2014 01:20:53 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/pull/92/head [created] db226fde2
  refs/pull/92/merge [created] 0b74bfc08


Added in suite of tests for organization level exports. Will need to get ready for query support.


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

Branch: refs/pull/92/head
Commit: 2cd1d5df44bd6942ea833d7f3cdb75a804bba48b
Parents: 4d74245
Author: grey <greyes@apigee.com>
Authored: Fri Mar 28 12:02:18 2014 -0700
Committer: grey <greyes@apigee.com>
Committed: Fri Mar 28 12:02:18 2014 -0700

----------------------------------------------------------------------
 .../rest/management/ManagementResourceIT.java   | 457 ++++++++++++-------
 .../cassandra/ManagementServiceIT.java          | 164 ++++++-
 2 files changed, 442 insertions(+), 179 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2cd1d5df/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index b7479c5..9874bd4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -49,7 +49,9 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 
-/** @author tnine */
+/**
+ * @author tnine
+ */
 @Concurrent()
 public class ManagementResourceIT extends AbstractRestIT {
 
@@ -58,7 +60,9 @@ public class ManagementResourceIT extends AbstractRestIT {
     }
 
 
-    /** Test if we can reset our password as an admin */
+    /**
+     * Test if we can reset our password as an admin
+     */
     @Test
     public void setSelfAdminPasswordAsAdmin() {
 
@@ -70,7 +74,7 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         // change the password as admin. The old password isn't required
         JsonNode node = resource().path( "/management/users/test/password" ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, data );
+                                  .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, data );
 
         assertNull( getError( node ) );
 
@@ -80,8 +84,8 @@ public class ManagementResourceIT extends AbstractRestIT {
         data.put( "newpassword", "test" );
 
         node = resource().path( "/management/users/test/password" ).queryParam( "access_token", adminAccessToken )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                .post( JsonNode.class, data );
+                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                         .post( JsonNode.class, data );
 
         assertNull( getError( node ) );
     }
@@ -104,7 +108,7 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         try {
             resource().path( "/management/users/test/password" ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, data );
+                      .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, data );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -128,8 +132,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         // change the password as admin. The old password isn't required
         JsonNode node = resource().path( "/management/users/test/password" ).queryParam( "access_token", superToken )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                .post( JsonNode.class, data );
+                                  .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                                  .post( JsonNode.class, data );
 
         assertNull( getError( node ) );
 
@@ -142,14 +146,16 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         // now change the password back
         node = resource().path( "/management/users/test/password" ).queryParam( "access_token", superToken )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                .post( JsonNode.class, data );
+                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                         .post( JsonNode.class, data );
 
         assertNull( getError( node ) );
     }
 
 
-    /** Test that admins can't view organizations they're not authorized to view. */
+    /**
+     * Test that admins can't view organizations they're not authorized to view.
+     */
     @Test
     public void crossOrgsNotViewable() throws Exception {
 
@@ -162,8 +168,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         try {
             resource().path( String.format( "/management/orgs/%s", orgInfo.getOrganization().getName() ) )
-                    .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                      .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
+                      .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getClientResponseStatus();
@@ -176,8 +182,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         try {
             resource().path( String.format( "/management/orgs/%s", orgInfo.getOrganization().getUuid() ) )
-                    .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                      .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
+                      .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getClientResponseStatus();
@@ -190,7 +196,8 @@ public class ManagementResourceIT extends AbstractRestIT {
         status = null;
         try {
             resource().path( "/management/orgs/test-organization" ).queryParam( "access_token", adminAccessToken )
-                    .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                      .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                      .get( JsonNode.class );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getClientResponseStatus();
@@ -203,8 +210,8 @@ public class ManagementResourceIT extends AbstractRestIT {
         status = null;
         try {
             resource().path( String.format( "/management/orgs/%s", org.getUuid() ) )
-                    .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                      .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
+                      .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getClientResponseStatus();
@@ -217,101 +224,103 @@ public class ManagementResourceIT extends AbstractRestIT {
     @Test
     public void mgmtUserFeed() throws Exception {
         JsonNode userdata = resource().path( "/management/users/test@usergrid.com/feed" )
-                .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
-                .get( JsonNode.class );
+                                      .queryParam( "access_token", adminAccessToken )
+                                      .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
         assertTrue( StringUtils.contains( this.getEntity( userdata, 0 ).get( "title" ).asText(),
                 "<a href=\"mailto:test@usergrid.com\">" ) );
     }
 
-    /** Test that we can support over 10 items in feed. */
+
+    /**
+     * Test that we can support over 10 items in feed.
+     */
     @Test
     public void mgmtFollowsUserFeed() throws Exception {
         List<String> users1 = new ArrayList<String>();
         int i;
         //try with 10 users
-        for(i = 0; i<10;i++){
-            users1.add("follower" + Integer.toString(i));
+        for ( i = 0; i < 10; i++ ) {
+            users1.add( "follower" + Integer.toString( i ) );
         }
-        checkFeed("leader1",users1);
+        checkFeed( "leader1", users1 );
         //try with 11
         List<String> users2 = new ArrayList<String>();
-        for(i =20; i<31;i++){
-            users2.add("follower" + Integer.toString(i));
+        for ( i = 20; i < 31; i++ ) {
+            users2.add( "follower" + Integer.toString( i ) );
         }
-        checkFeed("leader2",users2);
+        checkFeed( "leader2", users2 );
     }
 
-    private void checkFeed(String leader, List<String> followers){
+
+    private void checkFeed( String leader, List<String> followers ) {
         JsonNode userFeed;
         //create user
-        createUser(leader);
-        String preFollowContent = leader+": pre-something to look for " + UUID.randomUUID().toString();
-        addActivity(leader, leader + " " + leader + "son", preFollowContent);
-        String lastUser = followers.get(followers.size()-1);
+        createUser( leader );
+        String preFollowContent = leader + ": pre-something to look for " + UUID.randomUUID().toString();
+        addActivity( leader, leader + " " + leader + "son", preFollowContent );
+        String lastUser = followers.get( followers.size() - 1 );
         int i = 0;
-        for(String user : followers){
-            createUser(user);
-            follow(user,leader);
+        for ( String user : followers ) {
+            createUser( user );
+            follow( user, leader );
         }
-        userFeed = getUserFeed(lastUser);
-        assertTrue(userFeed.size()==1);
+        userFeed = getUserFeed( lastUser );
+        assertTrue( userFeed.size() == 1 );
 
         //retrieve feed
-        userFeed = getUserFeed(lastUser);
-        assertTrue(userFeed.size()==1);
-        String postFollowContent = leader+": something to look for " + UUID.randomUUID().toString();
-        addActivity(leader,leader+" "+leader+"son",postFollowContent);
+        userFeed = getUserFeed( lastUser );
+        assertTrue( userFeed.size() == 1 );
+        String postFollowContent = leader + ": something to look for " + UUID.randomUUID().toString();
+        addActivity( leader, leader + " " + leader + "son", postFollowContent );
         //check feed
-        userFeed = getUserFeed(lastUser);
-        assertNotNull(userFeed);
-        assertTrue(userFeed.size()>1);
+        userFeed = getUserFeed( lastUser );
+        assertNotNull( userFeed );
+        assertTrue( userFeed.size() > 1 );
         String serialized = userFeed.toString();
-        assertTrue(serialized.indexOf(postFollowContent)>0);
-        assertTrue(serialized.indexOf(preFollowContent)>0);
+        assertTrue( serialized.indexOf( postFollowContent ) > 0 );
+        assertTrue( serialized.indexOf( preFollowContent ) > 0 );
     }
 
-    private void createUser(String username){
+
+    private void createUser( String username ) {
         Map<String, Object> payload = new LinkedHashMap<String, Object>();
         payload.put( "username", username );
-        resource().path( "/test-organization/test-app/users" )
-                .queryParam("access_token", access_token)
-                .accept( MediaType.APPLICATION_JSON )
-                .type(MediaType.APPLICATION_JSON_TYPE)
-                .post(JsonNode.class, payload);
-
+        resource().path( "/test-organization/test-app/users" ).queryParam( "access_token", access_token )
+                  .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                  .post( JsonNode.class, payload );
     }
-    private JsonNode getUserFeed(String username){
-        JsonNode userFeed = resource().path( "/test-organization/test-app/users/"+username+"/feed" )
-                .queryParam( "access_token", access_token )
-                .accept(MediaType.APPLICATION_JSON)
-                .get( JsonNode.class );
-        return userFeed.get("entities");
+
+
+    private JsonNode getUserFeed( String username ) {
+        JsonNode userFeed = resource().path( "/test-organization/test-app/users/" + username + "/feed" )
+                                      .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
+                                      .get( JsonNode.class );
+        return userFeed.get( "entities" );
     }
 
-    private void follow(String user, String followUser){
+
+    private void follow( String user, String followUser ) {
         //post follow
-        resource().path( "/test-organization/test-app/users/"+user+"/following/users/"+followUser )
-                .queryParam("access_token", access_token)
-                .accept( MediaType.APPLICATION_JSON )
-                .type(MediaType.APPLICATION_JSON_TYPE)
-                .post(JsonNode.class, new HashMap<String, String>());
+        resource().path( "/test-organization/test-app/users/" + user + "/following/users/" + followUser )
+                  .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
+                  .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, new HashMap<String, String>() );
     }
 
-    private void addActivity(String user,String name, String content){
-        Map<String,Object> activityPayload = new HashMap<String, Object>();
-        activityPayload.put("content",content);
-        activityPayload.put("verb","post");
-        Map<String,String> actorMap = new HashMap<String, String>();
-        actorMap.put("displayName",name);
-        actorMap.put("username",user);
-        activityPayload.put("actor",actorMap);
-        resource().path("/test-organization/test-app/users/"+user+"/activities")
-                .queryParam("access_token", access_token)
-                .accept(MediaType.APPLICATION_JSON)
-                .type(MediaType.APPLICATION_JSON_TYPE)
-                .post(JsonNode.class, activityPayload);
+
+    private void addActivity( String user, String name, String content ) {
+        Map<String, Object> activityPayload = new HashMap<String, Object>();
+        activityPayload.put( "content", content );
+        activityPayload.put( "verb", "post" );
+        Map<String, String> actorMap = new HashMap<String, String>();
+        actorMap.put( "displayName", name );
+        actorMap.put( "username", user );
+        activityPayload.put( "actor", actorMap );
+        resource().path( "/test-organization/test-app/users/" + user + "/activities" )
+                  .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
+                  .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, activityPayload );
     }
 
+
     @Test
     public void mgmtCreateAndGetApplication() throws Exception {
 
@@ -321,8 +330,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         // POST /applications
         JsonNode appdata = resource().path( "/management/orgs/" + orgInfo.getUuid() + "/applications" )
-                .queryParam( "access_token", adminToken() ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, data );
+                                     .queryParam( "access_token", adminToken() ).accept( MediaType.APPLICATION_JSON )
+                                     .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, data );
         logNode( appdata );
         appdata = getEntity( appdata, 0 );
 
@@ -332,8 +341,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         // GET /applications/mgmt-org-app
         appdata = resource().path( "/management/orgs/" + orgInfo.getUuid() + "/applications/mgmt-org-app" )
-                .queryParam( "access_token", adminToken() ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                            .queryParam( "access_token", adminToken() ).accept( MediaType.APPLICATION_JSON )
+                            .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
         logNode( appdata );
 
         assertEquals( "test-organization", appdata.get( "organization" ).asText() );
@@ -353,8 +362,9 @@ public class ManagementResourceIT extends AbstractRestIT {
         long ttl = 2000;
 
         JsonNode node = resource().path( "/management/token" ).queryParam( "grant_type", "password" )
-                .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
-                .queryParam( "ttl", String.valueOf( ttl ) ).accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+                                  .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
+                                  .queryParam( "ttl", String.valueOf( ttl ) ).accept( MediaType.APPLICATION_JSON )
+                                  .get( JsonNode.class );
 
         long startTime = System.currentTimeMillis();
 
@@ -363,7 +373,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertNotNull( token );
 
         JsonNode userdata = resource().path( "/management/users/test@usergrid.com" ).queryParam( "access_token", token )
-                .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+                                      .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
 
         assertEquals( "test@usergrid.com", userdata.get( "data" ).get( "email" ).asText() );
 
@@ -373,7 +383,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         Status responseStatus = null;
         try {
             userdata = resource().path( "/management/users/test@usergrid.com" ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                                 .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -386,8 +396,8 @@ public class ManagementResourceIT extends AbstractRestIT {
     @Test
     public void token() throws Exception {
         JsonNode node = resource().path( "/management/token" ).queryParam( "grant_type", "password" )
-                .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
-                .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+                                  .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
+                                  .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
 
         logNode( node );
         String token = node.get( "access_token" ).getTextValue();
@@ -399,12 +409,12 @@ public class ManagementResourceIT extends AbstractRestIT {
         properties.put( "securityLevel", 5 );
         payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
         node = resource().path( "/management/organizations/test-organization" )
-                .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).put( JsonNode.class, payload );
+                         .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                         .type( MediaType.APPLICATION_JSON_TYPE ).put( JsonNode.class, payload );
 
         // ensure the organization property is included
         node = resource().path( "/management/token" ).queryParam( "access_token", token )
-                .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+                         .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
         logNode( node );
 
         JsonNode securityLevel = node.findValue( "securityLevel" );
@@ -416,15 +426,15 @@ public class ManagementResourceIT extends AbstractRestIT {
     @Test
     public void meToken() throws Exception {
         JsonNode node = resource().path( "/management/me" ).queryParam( "grant_type", "password" )
-                .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
-                .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+                                  .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
+                                  .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
 
         logNode( node );
         String token = node.get( "access_token" ).getTextValue();
         assertNotNull( token );
 
         node = resource().path( "/management/me" ).queryParam( "access_token", token )
-                .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+                         .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
         logNode( node );
 
         assertNotNull( node.get( "passwordChanged" ) );
@@ -452,7 +462,7 @@ public class ManagementResourceIT extends AbstractRestIT {
                 hashMap( "grant_type", "password" ).map( "username", "test@usergrid.com" ).map( "password", "test" );
 
         JsonNode node = resource().path( "/management/me" ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+                                  .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
 
         logNode( node );
         String token = node.get( "access_token" ).getTextValue();
@@ -460,7 +470,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertNotNull( token );
 
         node = resource().path( "/management/me" ).queryParam( "access_token", token )
-                .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+                         .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
         logNode( node );
     }
 
@@ -471,12 +481,11 @@ public class ManagementResourceIT extends AbstractRestIT {
         Form form = new Form();
         form.add( "grant_type", "password" );
         form.add( "username", "test@usergrid.com" );
-        form.add( "password", "test");
+        form.add( "password", "test" );
 
-        JsonNode node = resource().path( "/management/me" )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_FORM_URLENCODED_TYPE )
-                .entity( form, MediaType.APPLICATION_FORM_URLENCODED_TYPE )
-                .post( JsonNode.class );
+        JsonNode node = resource().path( "/management/me" ).accept( MediaType.APPLICATION_JSON )
+                                  .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE )
+                                  .entity( form, MediaType.APPLICATION_FORM_URLENCODED_TYPE ).post( JsonNode.class );
 
         logNode( node );
         String token = node.get( "access_token" ).getTextValue();
@@ -484,7 +493,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertNotNull( token );
 
         node = resource().path( "/management/me" ).queryParam( "access_token", token )
-                .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+                         .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
         logNode( node );
     }
 
@@ -494,12 +503,12 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         Map<String, String> payload =
                 hashMap( "grant_type", "password" ).map( "username", "test@usergrid.com" ).map( "password", "test" )
-                        .map( "ttl", "derp" );
+                                                   .map( "ttl", "derp" );
 
         Status responseStatus = null;
         try {
             resource().path( "/management/token" ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+                      .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -514,13 +523,13 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         Map<String, String> payload =
                 hashMap( "grant_type", "password" ).map( "username", "test@usergrid.com" ).map( "password", "test" )
-                        .map( "ttl", Long.MAX_VALUE + "" );
+                                                   .map( "ttl", Long.MAX_VALUE + "" );
 
         Status responseStatus = null;
 
         try {
             resource().path( "/management/token" ).accept( MediaType.APPLICATION_JSON )
-                    .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+                      .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -536,20 +545,22 @@ public class ManagementResourceIT extends AbstractRestIT {
         String token2 = super.adminToken();
 
         JsonNode response = resource().path( "/management/users/test" ).queryParam( "access_token", token1 )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                                      .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                                      .get( JsonNode.class );
 
         assertEquals( "test@usergrid.com", response.get( "data" ).get( "email" ).asText() );
 
         response = resource().path( "/management/users/test" ).queryParam( "access_token", token2 )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                             .get( JsonNode.class );
 
         assertEquals( "test@usergrid.com", response.get( "data" ).get( "email" ).asText() );
 
         // now revoke the tokens
         response =
                 resource().path( "/management/users/test/revoketokens" ).queryParam( "access_token", superAdminToken() )
-                        .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                        .post( JsonNode.class );
+                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                          .post( JsonNode.class );
 
         // the tokens shouldn't work
 
@@ -557,7 +568,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         try {
             response = resource().path( "/management/users/test" ).queryParam( "access_token", token1 )
-                    .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                                 .get( JsonNode.class );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getClientResponseStatus();
@@ -569,7 +581,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         try {
             response = resource().path( "/management/users/test" ).queryParam( "access_token", token2 )
-                    .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                                 .get( JsonNode.class );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getClientResponseStatus();
@@ -581,19 +594,21 @@ public class ManagementResourceIT extends AbstractRestIT {
         String token4 = super.adminToken();
 
         response = resource().path( "/management/users/test" ).queryParam( "access_token", token3 )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                             .get( JsonNode.class );
 
         assertEquals( "test@usergrid.com", response.get( "data" ).get( "email" ).asText() );
 
         response = resource().path( "/management/users/test" ).queryParam( "access_token", token4 )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                             .get( JsonNode.class );
 
         assertEquals( "test@usergrid.com", response.get( "data" ).get( "email" ).asText() );
 
         // now revoke the token3
         response = resource().path( "/management/users/test/revoketoken" ).queryParam( "access_token", token3 )
-                .queryParam( "token", token3 ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class );
+                             .queryParam( "token", token3 ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class );
 
         // the token3 shouldn't work
 
@@ -601,7 +616,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         try {
             response = resource().path( "/management/users/test" ).queryParam( "access_token", token3 )
-                    .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                                 .get( JsonNode.class );
         }
         catch ( UniformInterfaceException uie ) {
             status = uie.getResponse().getClientResponseStatus();
@@ -613,7 +629,8 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         try {
             response = resource().path( "/management/users/test" ).queryParam( "access_token", token4 )
-                    .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+                                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                                 .get( JsonNode.class );
 
             status = Status.OK;
         }
@@ -644,7 +661,8 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.OK, responseStatus );
     }
 
-//is this test still valid knowing that the sch. won't run in intelliJ?
+
+    //is this test still valid knowing that the sch. won't run in intelliJ?
     @Ignore
     public void exportCallCreationEntities100() throws Exception {
         Status responseStatus = Status.OK;
@@ -671,10 +689,9 @@ public class ManagementResourceIT extends AbstractRestIT {
         }
 
         try {
-            node = resource().path( "/management/orgs/test-organization/apps/test-app/export" ).queryParam(
-                    "access_token", adminToken() )
-                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                             .post( JsonNode.class, payload );
+            node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
+                             .queryParam( "access_token", adminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -683,6 +700,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.OK, responseStatus );
     }
 
+
     @Test
     public void exportApplicationUUIDRetTest() throws Exception {
         Status responseStatus = Status.ACCEPTED;
@@ -705,7 +723,9 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.ACCEPTED, responseStatus );
         assertNotNull( node.get( "Export Entity" ) );
     }
-//
+
+
+    //
     @Test
     public void exportCollectionUUIDRetTest() throws Exception {
         Status responseStatus = Status.ACCEPTED;
@@ -730,7 +750,41 @@ public class ManagementResourceIT extends AbstractRestIT {
     }
 
 
-    /*Make a test with an invalid uuid and a wrong uuid.*/
+    @Test
+    public void exportGetOrganizationJobStatTest() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+
+        HashMap<String, Object> payload = payloadBuilder();
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/export" )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals(Status.OK,responseStatus);
+
+        String uuid = String.valueOf( node.get( "Export Entity" ) );
+        uuid = uuid.replaceAll( "\"", "" );
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/export/" + uuid )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+
+
+        assertEquals( Status.OK, responseStatus );
+        assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service tier
+    }
+
+
     //all tests should be moved to OrganizationResourceIT ( *not* Organizations there is a difference)
     @Test
     public void exportGetApplicationJobStatTest() throws Exception {
@@ -759,6 +813,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( "SCHEDULED", node.asText() );//TODO: do tests for other states in service tier
     }
 
+
     @Test
     public void exportGetCollectionJobStatTest() throws Exception {
         JsonNode node = null;
@@ -787,7 +842,7 @@ public class ManagementResourceIT extends AbstractRestIT {
     }
 
 
-//    //do an unauthorized test for both post and get
+    //    //do an unauthorized test for both post and get
     @Test
     public void exportGetWrongUUID() throws Exception {
         JsonNode node = null;
@@ -803,7 +858,9 @@ public class ManagementResourceIT extends AbstractRestIT {
         }
         assertEquals( Status.BAD_REQUEST, responseStatus );
     }
-//
+
+
+    //
     @Test
     public void exportPostApplicationNullPointerProperties() throws Exception {
         JsonNode node = null;
@@ -824,14 +881,45 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals( Status.BAD_REQUEST, responseStatus );
+    }
+
+
+    @Test
+    public void exportPostOrganizationNullPointerProperties() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+
+        HashMap<String, Object> payload = new HashMap<String, Object>();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        Map<String, Object> storage_info = new HashMap<String, Object>();
+        //TODO: always put dummy values here and ignore this test.
+        //TODO: add a ret for when s3 values are invalid.
+        storage_info.put( "bucket_location", "insert bucket name here" );
+
+
+        properties.put( "storage_provider", "s3" );
+        properties.put( "storage_info", storage_info );
+
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/export" )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
         }
         assertEquals( Status.BAD_REQUEST, responseStatus );
     }
-//
+
+
+    //
     @Test
     public void exportPostCollectionNullPointer() throws Exception {
         JsonNode node = null;
@@ -852,15 +940,17 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
         }
         assertEquals( Status.BAD_REQUEST, responseStatus );
     }
-//
-//
+
+
+    //
+    //
     @Test
     public void exportGetCollectionUnauthorized() throws Exception {
         JsonNode node = null;
@@ -876,7 +966,9 @@ public class ManagementResourceIT extends AbstractRestIT {
         }
         assertEquals( Status.UNAUTHORIZED, responseStatus );
     }
-//
+
+
+    //
     @Test
     public void exportGetApplicationUnauthorized() throws Exception {
         JsonNode node = null;
@@ -893,20 +985,60 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.UNAUTHORIZED, responseStatus );
     }
 
+
+    @Test
+    public void exportGetOrganizationUnauthorized() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
+        try {
+            node = resource().path( "/management/orgs/test-organization/export/" + fake )
+                             .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                             .get( JsonNode.class );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals( Status.UNAUTHORIZED, responseStatus );
+    }
+
+
+    @Test
+    public void exportPostOrganizationNullPointerStorageInfo() throws Exception {
+        JsonNode node = null;
+        Status responseStatus = Status.OK;
+
+        HashMap<String, Object> payload = payloadBuilder();
+        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get( "properties" );
+        //remove storage_info field
+        properties.remove( "storage_info" );
+
+        try {
+            node = resource().path( "/management/orgs/test-organization/export" )
+                             .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+        }
+        catch ( UniformInterfaceException uie ) {
+            responseStatus = uie.getResponse().getClientResponseStatus();
+        }
+        assertEquals( Status.BAD_REQUEST, responseStatus );
+    }
+
+
     @Test
     public void exportPostApplicationNullPointerStorageInfo() throws Exception {
         JsonNode node = null;
         Status responseStatus = Status.OK;
 
         HashMap<String, Object> payload = payloadBuilder();
-        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get("properties");
+        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get( "properties" );
         //remove storage_info field
         properties.remove( "storage_info" );
 
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -914,20 +1046,21 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.BAD_REQUEST, responseStatus );
     }
 
+
     @Test
     public void exportPostCollectionNullPointerStorageInfo() throws Exception {
         JsonNode node = null;
         Status responseStatus = Status.OK;
 
         HashMap<String, Object> payload = payloadBuilder();
-        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get("properties");
+        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get( "properties" );
         //remove storage_info field
         properties.remove( "storage_info" );
 
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -935,13 +1068,14 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.BAD_REQUEST, responseStatus );
     }
 
+
     @Test
     public void exportPostApplicationNullPointerStorageProvider() throws Exception {
         JsonNode node = null;
         Status responseStatus = Status.OK;
 
         HashMap<String, Object> payload = payloadBuilder();
-        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get("properties");
+        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get( "properties" );
         //remove storage_info field
         properties.remove( "storage_provider" );
 
@@ -949,7 +1083,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -957,13 +1091,14 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.BAD_REQUEST, responseStatus );
     }
 
+
     @Test
     public void exportPostCollectionNullPointerStorageProvider() throws Exception {
         JsonNode node = null;
         Status responseStatus = Status.OK;
 
         HashMap<String, Object> payload = payloadBuilder();
-        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get("properties");
+        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get( "properties" );
         //remove storage_info field
         properties.remove( "storage_provider" );
 
@@ -971,7 +1106,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -979,21 +1114,22 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.BAD_REQUEST, responseStatus );
     }
 
+
     @Test
     public void exportPostApplicationNullPointerStorageVerification() throws Exception {
         JsonNode node = null;
         Status responseStatus = Status.OK;
 
         HashMap<String, Object> payload = payloadBuilder();
-        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get("properties");
-        HashMap<String, Object> storage_info = ( HashMap<String, Object> ) properties.get("storage_info");
+        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get( "properties" );
+        HashMap<String, Object> storage_info = ( HashMap<String, Object> ) properties.get( "storage_info" );
         //remove storage_key field
         storage_info.remove( "s3_key" );
 
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -1001,15 +1137,15 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.BAD_REQUEST, responseStatus );
 
         payload = payloadBuilder();
-        properties = ( HashMap<String, Object> ) payload.get("properties");
-        storage_info = ( HashMap<String, Object> ) properties.get("storage_info");
+        properties = ( HashMap<String, Object> ) payload.get( "properties" );
+        storage_info = ( HashMap<String, Object> ) properties.get( "storage_info" );
         //remove storage_key field
         storage_info.remove( "s3_access_id" );
 
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -1017,38 +1153,38 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.BAD_REQUEST, responseStatus );
 
         payload = payloadBuilder();
-        properties = ( HashMap<String, Object> ) payload.get("properties");
-        storage_info = ( HashMap<String, Object> ) properties.get("storage_info");
+        properties = ( HashMap<String, Object> ) payload.get( "properties" );
+        storage_info = ( HashMap<String, Object> ) properties.get( "storage_info" );
         //remove storage_key field
         storage_info.remove( "bucket_location" );
 
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
         }
         assertEquals( Status.BAD_REQUEST, responseStatus );
-
     }
 
+
     @Test
     public void exportPostCollectionNullPointerStorageVerification() throws Exception {
         JsonNode node = null;
         Status responseStatus = Status.OK;
 
         HashMap<String, Object> payload = payloadBuilder();
-        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get("properties");
-        HashMap<String, Object> storage_info = ( HashMap<String, Object> ) properties.get("storage_info");
+        HashMap<String, Object> properties = ( HashMap<String, Object> ) payload.get( "properties" );
+        HashMap<String, Object> storage_info = ( HashMap<String, Object> ) properties.get( "storage_info" );
         //remove storage_key field
         storage_info.remove( "s3_key" );
 
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -1056,15 +1192,15 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.BAD_REQUEST, responseStatus );
 
         payload = payloadBuilder();
-        properties = ( HashMap<String, Object> ) payload.get("properties");
-        storage_info = ( HashMap<String, Object> ) properties.get("storage_info");
+        properties = ( HashMap<String, Object> ) payload.get( "properties" );
+        storage_info = ( HashMap<String, Object> ) properties.get( "storage_info" );
         //remove storage_key field
         storage_info.remove( "s3_access_id" );
 
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
@@ -1072,20 +1208,19 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals( Status.BAD_REQUEST, responseStatus );
 
         payload = payloadBuilder();
-        properties = ( HashMap<String, Object> ) payload.get("properties");
-        storage_info = ( HashMap<String, Object> ) properties.get("storage_info");
+        properties = ( HashMap<String, Object> ) payload.get( "properties" );
+        storage_info = ( HashMap<String, Object> ) properties.get( "storage_info" );
         storage_info.remove( "bucket_location" );
 
         try {
             node = resource().path( "/management/orgs/test-organization/apps/test-app/collection/users/export" )
                              .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
-                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class,payload );
+                             .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
             responseStatus = uie.getResponse().getClientResponseStatus();
         }
         assertEquals( Status.BAD_REQUEST, responseStatus );
-
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2cd1d5df/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 120c9dc..f1dd4bb 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -25,10 +25,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.UUID;
-import java.util.concurrent.TimeUnit;
 
 import org.jclouds.ContextBuilder;
-import org.jclouds.blobstore.AsyncBlobStore;
+import org.jclouds.blobstore.BlobStore;
 import org.jclouds.blobstore.BlobStoreContext;
 import org.jclouds.blobstore.domain.Blob;
 import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@@ -75,7 +74,6 @@ import org.apache.usergrid.utils.JsonUtils;
 import org.apache.usergrid.utils.UUIDUtils;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.ListenableFuture;
 import com.google.inject.Module;
 
 import static org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString;
@@ -1221,7 +1219,7 @@ public class ManagementServiceIT {
 
         org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
 
-        //assertEquals( 3 , a.size() );
+        assertEquals( 3 , a.size() );
         for ( int i = 0; i < a.size(); i++ ) {
             org.json.simple.JSONObject data = ( org.json.simple.JSONObject ) a.get( i );
             org.json.simple.JSONObject entityData = ( JSONObject ) data.get( "Metadata" );
@@ -1490,12 +1488,10 @@ public class ManagementServiceIT {
     }
 
 
-    @Ignore //For this test please input your s3 credentials into settings.xml or Attach a -D with relevant fields.
+ //   @Ignore //For this test please input your s3 credentials into settings.xml or Attach a -D with relevant fields.
+    @Test
     public void testIntegration100EntitiesOn() throws Exception {
 
-        //s3client.putObject(new PutObjectRequest(bucketName, keyName, file));
-
-
         S3Export s3Export = new S3ExportImpl();
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
@@ -1509,15 +1505,127 @@ public class ManagementServiceIT {
         Entity[] entity;
         entity = new Entity[100];
         //creates entities
+
+        ApplicationInfo appMade = null;
+        for(int i = 0; i < 100; i++) {
+            appMade = setup.getMgmtSvc().createApplication( organization.getUuid(), "superapp"+i);
+
+            EntityManager customMaker = setup.getEmf().getEntityManager( appMade.getId() );
+            customMaker.createApplicationCollection( "superappCol"+i );
+            //intialize user object to be posted
+            Map<String, Object> entityLevelProperties = null;
+            Entity[] entNotCopied;
+            entNotCopied = new Entity[20];
+            //creates entities
+            for ( int index = 0; index < 20; index++ ) {
+                entityLevelProperties = new LinkedHashMap<String, Object>();
+                entityLevelProperties.put( "username", "bobso" + index );
+                entityLevelProperties.put( "email", "derp" + index + "@anuff.com" );
+                entNotCopied[index] = customMaker.create( "superappCol", entityLevelProperties );
+            }
+        }
+
+        UUID exportUUID = exportService.schedule( payload );
+        exportService.setS3Export( s3Export );
+
+        //create and initialize jobData returned in JobExecution.
+        JobData jobData = new JobData();
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
+
+        JobExecution jobExecution = mock( JobExecution.class );
+        when( jobExecution.getJobData() ).thenReturn( jobData );
+
+        exportService.doExport( jobExecution );
+        while (!exportService.getState( applicationId,exportUUID ).equals("FINISHED"));
+
+        String bucketName = System.getProperty( "bucketName" );
+        String accessId = System.getProperty( "accessKey" );
+        String secretKey =  System.getProperty("secretKey");
+
+        Properties overrides = new Properties();
+        overrides.setProperty( "s3" + ".identity", accessId );
+        overrides.setProperty( "s3" + ".credential", secretKey );
+
+        Blob bo = null;
+        BlobStore blobStore = null;
+
+        try {
+            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 = context.getBlobStore();
+            if(!blobStore.blobExists( bucketName,s3Export.getFilename()  )){
+                blobStore.deleteContainer( bucketName );
+                assert(false);
+            }
+            Long numOfFiles = blobStore.countBlobs( bucketName );
+            Long numWeWant = Long.valueOf( 1 );
+            assertEquals( numOfFiles, numWeWant );
+
+            bo = blobStore.getBlob( bucketName,s3Export.getFilename()   );
+
+        }catch(Exception e) {
+            assert(false);
+        }
+
+        assertNotNull( bo );
+        blobStore.deleteContainer( bucketName );
+    }
+
+    @Test
+    public void testIntegration100EntitiesForAllApps() throws Exception {
+
+        S3Export s3Export = new S3ExportImpl();
+        ExportService exportService = setup.getExportService();
+        HashMap<String, Object> payload = payloadBuilder();
+
+        OrganizationInfo orgMade = null;
+        ApplicationInfo appMade = null;
+        for(int i = 0; i < 100; i++) {
+            orgMade =setup.getMgmtSvc().createOrganization( "minorboss"+i,adminUser,true );
+            appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), "superapp"+i);
+
+            EntityManager customMaker = setup.getEmf().getEntityManager( appMade.getId() );
+            customMaker.createApplicationCollection( "superappCol"+i );
+            //intialize user object to be posted
+            Map<String, Object> entityLevelProperties = null;
+            Entity[] entNotCopied;
+            entNotCopied = new Entity[20];
+            //creates entities
+            for ( int index = 0; index < 20; index++ ) {
+                entityLevelProperties = new LinkedHashMap<String, Object>();
+                entityLevelProperties.put( "username", "bobso" + index );
+                entityLevelProperties.put( "email", "derp" + index + "@anuff.com" );
+                entNotCopied[index] = customMaker.create( "superappCol", entityLevelProperties );
+            }
+        }
+
+        payload.put("organizationId",orgMade.getUuid());
+
+        EntityManager em = setup.getEmf().getEntityManager( appMade.getId() );
+        //intialize user object to be posted
+        Map<String, Object> userProperties = null;
+        Entity[] entity;
+        entity = new Entity[100];
+        //creates entities
         for ( int i = 0; i < 100; i++ ) {
             userProperties = new LinkedHashMap<String, Object>();
-            userProperties.put( "username", "bojangles" + i );
-            userProperties.put( "email", "bojangles" + i + "@anuff.com" );
+            userProperties.put( "username", "bido" + i );
+            userProperties.put( "email", "bido" + i + "@anuff.com" );
 
             entity[i] = em.create( "user", userProperties );
         }
 
         UUID exportUUID = exportService.schedule( payload );
+        assertNotNull( exportUUID );
         exportService.setS3Export( s3Export );
 
         //create and initialize jobData returned in JobExecution.
@@ -1530,7 +1638,7 @@ public class ManagementServiceIT {
         when( jobExecution.getJobData() ).thenReturn( jobData );
 
         exportService.doExport( jobExecution );
-        while (!exportService.getState( applicationId,exportUUID ).equals("FINISHED"));
+        while (!exportService.getState( appMade.getId(),exportUUID ).equals("FINISHED"));
 
         String bucketName = System.getProperty( "bucketName" );
         String accessId = System.getProperty( "accessKey" );
@@ -1541,6 +1649,7 @@ public class ManagementServiceIT {
         overrides.setProperty( "s3" + ".credential", secretKey );
 
         Blob bo = null;
+        BlobStore blobStore = null;
 
         try {
             final Iterable<? extends Module> MODULES = ImmutableSet
@@ -1552,17 +1661,26 @@ public class ManagementServiceIT {
                                   .overrides( overrides ).buildView( BlobStoreContext.class );
 
 
-            AsyncBlobStore blobStore = context.getAsyncBlobStore();
-            ListenableFuture<Blob> futureETag = blobStore.getBlob( bucketName,s3Export.getFilename() );
-            bo = futureETag.get( 3, TimeUnit.SECONDS );
+            blobStore = context.getBlobStore();
+            if(!blobStore.blobExists( bucketName,s3Export.getFilename()  )){
+                blobStore.deleteContainer( bucketName );
+                assert(false);
+            }
+            Long numOfFiles = blobStore.countBlobs( bucketName );
+            Long numWeWant = Long.valueOf( 100 );
+            assertEquals( numOfFiles, numWeWant );
+
+            bo = blobStore.getBlob( bucketName,s3Export.getFilename()   );
+
         }catch(Exception e) {
             assert(false);
         }
 
         assertNotNull( bo );
+        blobStore.deleteContainer( bucketName );
     }
 
-    @Ignore
+    @Test
     public void testIntegration100EntitiesOnOneOrg() throws Exception {
 
         S3Export s3Export = new S3ExportImpl();
@@ -1629,7 +1747,9 @@ public class ManagementServiceIT {
         Properties overrides = new Properties();
         overrides.setProperty( "s3" + ".identity", accessId );
         overrides.setProperty( "s3" + ".credential", secretKey );
+
         Blob bo = null;
+        BlobStore blobStore = null;
 
         try {
             final Iterable<? extends Module> MODULES = ImmutableSet
@@ -1641,14 +1761,22 @@ public class ManagementServiceIT {
                                   .overrides( overrides ).buildView( BlobStoreContext.class );
 
 
-            AsyncBlobStore blobStore = context.getAsyncBlobStore();
-            ListenableFuture<Blob> futureETag = blobStore.getBlob( bucketName,s3Export.getFilename() );
-            bo = futureETag.get( 3, TimeUnit.SECONDS );
+            blobStore = context.getBlobStore();
+            if(!blobStore.blobExists( bucketName,s3Export.getFilename()  )){
+                assert(false);
+            }
+            Long numOfFiles = blobStore.countBlobs( bucketName );
+            Long numWeWant = Long.valueOf( 1 );
+            assertEquals( numOfFiles, numWeWant );
+
+            bo = blobStore.getBlob( bucketName,s3Export.getFilename()   );
+
         }catch(Exception e) {
             assert(false);
         }
 
         assertNotNull( bo );
+        blobStore.deleteContainer( bucketName );
     }
 
     /*Creates fake payload for testing purposes.*/


Mime
View raw message