You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/03/30 21:58:10 UTC

[06/50] incubator-usergrid git commit: Fixes for most of the ImportResourceIT tests.

Fixes for most of the ImportResourceIT tests.


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

Branch: refs/heads/two-dot-o-dev
Commit: 531e6590a35396ba10df960fa459cb743a0810a0
Parents: c298a45
Author: Dave Johnson <dm...@apigee.com>
Authored: Thu Mar 5 13:03:32 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Thu Mar 5 13:03:32 2015 -0500

----------------------------------------------------------------------
 .../rest/management/ImportResourceIT.java       | 77 ++++++++++++--------
 stack/rest/src/test/resources/log4j.properties  |  5 +-
 .../resources/testImport.testApplication.2.json | 56 ++++++++++++++
 .../src/test/resources/testimport-bad-json.json | 67 +++++++++++++++++
 .../management/importer/ImportCollectionIT.java |  1 -
 5 files changed, 171 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/531e6590/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --git 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
index 52a095a..2edeb65 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
@@ -52,6 +52,7 @@ import org.junit.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -98,7 +99,7 @@ public class ImportResourceIT extends AbstractRestIT {
     @Before
     public void before() {
         configured =
-            !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ))
+                   !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ))
                 && !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ))
                 && !StringUtils.isEmpty(System.getProperty("bucketName"));
 
@@ -416,11 +417,12 @@ public class ImportResourceIT extends AbstractRestIT {
         String org = clientSetup.getOrganizationName();
         String app = clientSetup.getAppName();
 
+        String basePath = System.getProperty("target.directory")
+            + File.separator + "test-classes" + File.separator;
 
-        //list out all the files in the resource directory you want uploaded
-        List<String> filenames = new ArrayList<>(1);
+        List<String> filenames = new ArrayList<>( 1 );
+        filenames.add( basePath  + "testImportCorrect.testCol.1.json" );
 
-        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(
@@ -432,15 +434,20 @@ public class ImportResourceIT extends AbstractRestIT {
 
         Entity importEntity = importCollection();
 
-        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app )
-            .addToPath( "imports" ).addToPath( importEntity.getUuid().toString() ).get();
-
+        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();
+        Entity importGetIncludes = this.management().orgs().organization(org).app()
+            .addToPath(app)
+            .addToPath("imports")
+            .addToPath(importEntity.getUuid().toString())
+            .addToPath("files")
+            .get();
 
         ApiResponse importGetIncludesResponse = importGetIncludes.getResponse();
 
@@ -451,7 +458,8 @@ public class ImportResourceIT extends AbstractRestIT {
 
         final Entity includesEntity = importGetIncludesResponse.getEntities().get( 0 );
 
-        assertEquals( "testImportCorrect.testCol.1.json", includesEntity.getAsString( "fileName" ) );
+        assertTrue( includesEntity.getAsString("fileName").endsWith("testImportCorrect.testCol.1.json"));
+
         assertEquals(1, includesEntity.get( "importedConnectionCount" ));
         assertEquals(1, includesEntity.get( "importedEntityCount" ));
 
@@ -474,18 +482,20 @@ public class ImportResourceIT extends AbstractRestIT {
      */
     @Test
     public void testImportOneGoodOneBad() throws Exception {
+
         // import from a bad JSON file
         Assume.assumeTrue(configured);
 
         String org = clientSetup.getOrganizationName();
         String app = clientSetup.getAppName();
 
+        String basePath = System.getProperty("target.directory")
+            + File.separator + "test-classes" + File.separator;
 
-        //list out all the files in the resource directory you want uploaded
-        List<String> filenames = new ArrayList<>(1);
+        List<String> filenames = new ArrayList<>( 2 );
+        filenames.add( basePath + "testImportCorrect.testCol.1.json");
+        filenames.add( basePath + "testImport.testApplication.2.json");
 
-        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(
@@ -497,9 +507,10 @@ public class ImportResourceIT extends AbstractRestIT {
 
         Entity importEntity = importCollection();
 
-        Entity importGet = this.management().orgs().organization(org).app().addToPath(app)
-            .addToPath( "imports" ).addToPath(importEntity.getUuid().toString() ).get();
-
+        Entity importGet = this.management().orgs().organization(org).app()
+            .addToPath(app)
+            .addToPath("imports")
+            .addToPath(importEntity.getUuid().toString()).get();
 
         assertNotNull(importGet);
 
@@ -526,11 +537,12 @@ public class ImportResourceIT extends AbstractRestIT {
         String org = clientSetup.getOrganizationName();
         String app = clientSetup.getAppName();
 
+        String basePath = System.getProperty("target.directory")
+            + File.separator + "test-classes" + File.separator;
 
-        //list out all the files in the resource directory you want uploaded
-        List<String> filenames = new ArrayList<>(1);
+        List<String> filenames = new ArrayList<>( 1 );
+        filenames.add( basePath + "testimport-bad-json.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(
@@ -573,12 +585,16 @@ public class ImportResourceIT extends AbstractRestIT {
         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");
+        String basePath = System.getProperty("target.directory")
+            + File.separator + "test-classes" + File.separator;
+
+        List<String> filenames = new ArrayList<>( 1 );
+        filenames.add( basePath + "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 ),
+        s3Upload.copyToS3(
+            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
             System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
             bucketName, filenames);
 
@@ -633,13 +649,10 @@ public class ImportResourceIT extends AbstractRestIT {
 
         while (retries++ < maxRetries) {
 
-            Entity importGet = this.management()
-                .orgs()
-                .organization(org)
-                .app()
-                .addToPath(app)
-                .addToPath("imports")
-                .addToPath(importEntity.getUuid().toString())
+            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" )) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/531e6590/stack/rest/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/log4j.properties b/stack/rest/src/test/resources/log4j.properties
index 26d4306..4c9c709 100644
--- a/stack/rest/src/test/resources/log4j.properties
+++ b/stack/rest/src/test/resources/log4j.properties
@@ -71,13 +71,14 @@ log4j.logger.org.apache.usergrid.rest.filters.MeteringFilter=ERROR
 #log4j.logger.org.apache.usergrid.cassandra.CassandraResource=DEBUG
 #log4j.logger.org.apache.usergrid.rest.TomcatResource=INFO
 #log4j.logger.org.apache.usergrid.rest=INFO
+log4j.logger.org.apache.usergrid.rest.management=DEBUG
 #log4j.logger.org.apache.usergrid.rest.management.users=DEBUG
 #log4j.logger.org.apache.usergrid.rest.organizations.users=DEBUG
 #log4j.logger.org.apache.usergrid.rest.applications.users.UsersResource=DEBUG
 #log4j.logger.org.apache.usergrid.rest.applications.ServiceResource=DEBUG
 
-log4j.logger.org.apache.usergrid.rest.security=DEBUG
-log4j.logger.org.apache.usergrid.security=DEBUG
+#log4j.logger.org.apache.usergrid.rest.security=DEBUG
+#log4j.logger.org.apache.usergrid.security=DEBUG
 
 #log4j.logger.org.elasticsearch=DEBUG
 #log4j.logger.com.netflix.hystrix=DEBUG

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/531e6590/stack/rest/src/test/resources/testImport.testApplication.2.json
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/testImport.testApplication.2.json b/stack/rest/src/test/resources/testImport.testApplication.2.json
new file mode 100644
index 0000000..f45d129
--- /dev/null
+++ b/stack/rest/src/test/resources/testImport.testApplication.2.json
@@ -0,0 +1,56 @@
+[ {
+    "Metadata" : {
+        "uuid" : "589d95fa-ad7c-11e4-98bc-0f85bf181834",
+        "type" : "qtsmagic",
+        "created" : 1423171030223,
+        "modified" : 1423171030223,
+        "email" : "test0@anuff.com",
+        "username" : "billybob0"
+    },
+    "connections" : { },
+    "dictionaries" : { }
+}, {
+    "Metadata" : {
+        "uuid" : "589f91ca-ad7c-11e4-a250-63b6975ea888",
+        "type" : "qtsmagic",
+        "created" : 1423171030236,
+        "modified" : 1423171030236,
+        "email" : "test1@anuff.com",
+        "username" : "billybob1"
+    },
+    "connections" : { },
+    "dictionaries" : { }
+}, {
+    "Metadata" : {
+        "uuid" : "58a1186a-ad7c-11e4-bfc2-89e1e7bff3a8",
+        "type" : "qtsmagic",
+        "created" : 1423171030246,
+        "modified" : 1423171030246,
+        "email" : "test2@anuff.com",
+        "username" : "billybob2"
+    },
+    "connections" : { },
+    "dictionaries" : { }
+}, {
+    "Metadata" : {
+        "uuid" : "58a2c61a-ad7c-11e4-b2be-ab36d8b017f3",
+        "type" : "qtsmagic",
+        "created" : 1423171030257,
+        "modified" : 1423171030257,
+        "email" : "test3@anuff.com",
+        "username" : "billybob3"
+    },
+    "connections" : { },
+    "dictionaries" : { }
+}, {
+    "Metadata" : {
+        "uuid" : "58a44cba-ad7c-11e4-9fe5-fb8577a1f4a5",
+        "type" : "qtsmagic",
+        "created" : 1423171030267,
+        "modified" : 1423171030267,
+        "email" : "test4@anuff.com",
+        "username" : "billybob4"
+    },
+    "connections" : { },
+    "dictionaries" : { }
+} ]

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/531e6590/stack/rest/src/test/resources/testimport-bad-json.json
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/testimport-bad-json.json b/stack/rest/src/test/resources/testimport-bad-json.json
new file mode 100644
index 0000000..b744893
--- /dev/null
+++ b/stack/rest/src/test/resources/testimport-bad-json.json
@@ -0,0 +1,67 @@
+{
+    "collections": {
+        "badjsons": [
+            {
+                "Metadata": {
+                    "uuid": "589d95fa-ad7c-11e4-98bc-0f85bf181834",
+                    "type": "qtsmagic",
+                    "created": 1423171030223,
+                    "modified": 1423171030223,
+                    "email": "test0@anuff.com",
+                    "username": "billybob0"
+                },
+                "connections": {},
+                "dictionaries": {}
+            },
+            {
+                "Metadata": {
+                    "uuid": "589f91ca-ad7c-11e4-a250-63b6975ea888",
+                    "type": "qtsmagic",
+                    "created": 1423171030236,
+                    "modified": 1423171030236,
+                    "email": "test1@anuff.com",
+                    "username": "billybob1"
+                },
+                "connections": {},
+                "dictionaries": {}
+            },
+            {
+                "Metadata": {
+                    "uuid": "58a1186a-ad7c-11e4-bfc2-89e1e7bff3a8",
+                    "type": "qtsmagic",
+                    "created": 1423171030246,
+                    "modified": 1423171030246,
+                    "email": "test2@anuff.com",
+                    "username": "billybob2"
+                },
+                "connections": {},
+                "dictionaries": {}
+            },
+            {
+                "Metadata": {
+                    "uuid": "58a2c61a-ad7c-11e4-b2be-ab36d8b017f3",
+                    "type": "qtsmagic",
+                    "created": 1423171030257,
+                    "modified": 1423171030257,
+                    "email": "test3@anuff.com",
+                    "username": "billybob3"
+                },
+                "connections": {},
+                "dictionaries": {}
+            },
+            <INTENTIONALLY BAD JSON>
+            {
+                "Metadata": {
+                    "uuid": "58a44cba-ad7c-11e4-9fe5-fb8577a1f4a5",
+                    "type": "qtsmagic",
+                    "created": 1423171030267,
+                    "modified": 1423171030267,
+                    "email": "test4@anuff.com",
+                    "username": "billybob4"
+                },
+                "connections": {},
+                "dictionaries": {}
+            }
+        ]
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/531e6590/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index d8e104d..c9aeb9a 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@ -375,7 +375,6 @@ public class ImportCollectionIT {
 
         // export and upload a bad JSON file to the S3 bucket
 
-        File cwd = new File(".");
         String basePath = System.getProperty("target.directory")
             + File.separator + "test-classes" + File.separator;