usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [37/39] git commit: Removed extraneous code. Added licenses to new refactored tests. Fixed singleton/concurrency issue in test cases. Removed validity tests as all tests enforce validity in a certain way. Made Mock export filename storage final, so that
Date Wed, 02 Apr 2014 21:21:38 GMT
Removed extraneous code.
Added licenses to new refactored tests.
Fixed singleton/concurrency issue in test cases.
Removed validity tests as all tests enforce validity in a certain way.
Made Mock export filename storage final, so that it can not be overwritten by concurrency
issues.


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

Branch: refs/pull/92/merge
Commit: cb76cca98c60e32e555e6e180ec3d17fb26d1b28
Parents: 6527517
Author: grey <greyes@apigee.com>
Authored: Wed Apr 2 13:45:25 2014 -0700
Committer: grey <greyes@apigee.com>
Committed: Wed Apr 2 13:45:25 2014 -0700

----------------------------------------------------------------------
 .../applications/ApplicationResource.java       |  25 --
 .../rest/management/ExportResourceIT.java       |  17 ++
 .../management/export/ExportService.java        |   1 -
 .../management/export/ExportServiceImpl.java    |  32 +-
 .../usergrid/management/export/S3Export.java    |   2 -
 .../management/export/S3ExportImpl.java         |   2 -
 .../usergrid/ConcurrentServiceITSuite.java      |   3 +-
 .../management/cassandra/ExportServiceIT.java   | 296 +++++--------------
 .../management/cassandra/MockS3ExportImpl.java  |  13 +-
 9 files changed, 113 insertions(+), 278 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index 14268da..a5fffdc 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -342,29 +342,4 @@ public class ApplicationResource extends AbstractContextResource {
 
         return Response.status( SC_ACCEPTED ).entity( uuidRet ).build();
     }
-
-
-//    @GET
-//    @RequireOrganizationAccess
-//    @Path("export/{exportEntity: [A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}}")
-//    public Response exportGetJson( @Context UriInfo ui, @PathParam("exportEntity") UUID
exportEntityUUIDStr,
-//                                   @QueryParam("callback") @DefaultValue("") String callback
) throws Exception {
-//
-//        Export entity;
-//        try {
-//            entity = smf.getServiceManager( applicationId ).getEntityManager().get( exportEntityUUIDStr,
Export.class );
-//        }
-//        catch ( Exception e ) { //this might not be a bad request and needs better error
checking
-//            return Response.status( SC_BAD_REQUEST ).type( JSONPUtils.jsonMediaType( callback
) )
-//                           .entity( ServiceResource.wrapWithCallback( e.getMessage(), callback
) ).build();
-//        }
-//
-//        if ( entity == null ) {
-//            return Response.status( SC_BAD_REQUEST ).build();
-//        }
-//
-//        return Response.status( SC_OK ).entity( entity).build();
-//    }
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
index 0fa3d6c..67d51c3 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
@@ -1,3 +1,20 @@
+/*
+ * 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;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
index 3cba828..5a14012 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportService.java
@@ -46,5 +46,4 @@ public interface ExportService {
 
     String getErrorMessage( UUID appId, UUID state ) throws Exception;
 
-    void setS3Export( S3Export s3Export );
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
index 199bc07..18bd130 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
@@ -32,7 +32,6 @@ import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.util.DefaultPrettyPrinter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import org.apache.usergrid.batch.JobExecution;
 import org.apache.usergrid.batch.service.SchedulerService;
@@ -80,7 +79,7 @@ public class ExportServiceImpl implements ExportService {
 
     private JsonFactory jsonFactory = new JsonFactory();
 
-    private S3Export s3Export;
+    //private S3Export s3Export;
 
     private String defaultAppExportname = "exporters";
 
@@ -88,6 +87,7 @@ public class ExportServiceImpl implements ExportService {
     @Override
     public UUID schedule( final Map<String, Object> config ) throws Exception {
         ApplicationInfo defaultExportApp = null;
+        S3Export exportTransfer = new S3ExportImpl();
 
         if ( config == null ) {
             logger.error( "export information cannot be null" );
@@ -127,6 +127,7 @@ public class ExportServiceImpl implements ExportService {
         JobData jobData = new JobData();
         jobData.setProperty( "exportInfo", config );
         jobData.setProperty( EXPORT_ID, export.getUuid() );
+        jobData.setProperty( "s3Export", exportTransfer);
 
         long soonestPossible = System.currentTimeMillis() + 250; //sch grace period
 
@@ -196,6 +197,7 @@ public class ExportServiceImpl implements ExportService {
     @Override
     public void doExport( final JobExecution jobExecution ) throws Exception {
         Map<String, Object> config = ( Map<String, Object> ) jobExecution.getJobData().getProperty(
"exportInfo" );
+        S3Export s3Export = ( S3Export )jobExecution.getJobData().getProperty( "s3Export"
);
 
 //        UUID scopedAppId = ( UUID ) config.get( "applicationId" );
 
@@ -222,7 +224,7 @@ public class ExportServiceImpl implements ExportService {
         else if ( config.get( "applicationId" ) == null ) {
             //exports All the applications from an organization
             try {
-                exportApplicationsFromOrg( ( UUID ) config.get( "organizationId" ), config,
jobExecution );
+                exportApplicationsFromOrg( ( UUID ) config.get( "organizationId" ), config,
jobExecution,s3Export );
             }
             catch ( Exception e ) {
                 export.setErrorMessage( e.getMessage() );
@@ -235,7 +237,7 @@ public class ExportServiceImpl implements ExportService {
             //exports an Application from a single organization
             try {
                 exportApplicationFromOrg( ( UUID ) config.get( "organizationId" ),
-                        ( UUID ) config.get( "applicationId" ), config, jobExecution );
+                        ( UUID ) config.get( "applicationId" ), config, jobExecution, s3Export
);
             }
             catch ( Exception e ) {
                 export.setErrorMessage( e.getMessage() );
@@ -249,7 +251,7 @@ public class ExportServiceImpl implements ExportService {
                 //exports a single collection from an app org combo
                 try {
                     exportCollectionFromOrgApp( ( UUID ) config.get( "organizationId" ),
-                            ( UUID ) config.get( "applicationId" ), config, jobExecution
);
+                            ( UUID ) config.get( "applicationId" ), config, jobExecution,s3Export
);
                 }
                 catch ( Exception e ) {
                     export.setErrorMessage( e.getMessage() );
@@ -313,7 +315,7 @@ public class ExportServiceImpl implements ExportService {
      * Exports All Applications from an Organization
      */
     private void exportApplicationsFromOrg( UUID organizationUUID, final Map<String, Object>
config,
-                                            final JobExecution jobExecution ) throws Exception
{
+                                            final JobExecution jobExecution, S3Export s3Export
) throws Exception {
 
         //TODO: move extranous code out of these methods and make each one more distinct.
         //retrieves export entity
@@ -333,7 +335,7 @@ public class ExportServiceImpl implements ExportService {
 
             ByteArrayOutputStream baos = collectionExportAndQuery(application.getKey(),config,export,jobExecution);
 
-            fileTransfer( export,appFileName,baos,config );
+            fileTransfer( export,appFileName,baos,config, s3Export );
 
 //            InputStream is = new ByteArrayInputStream( baos.toByteArray() );
 //            try {
@@ -346,7 +348,7 @@ public class ExportServiceImpl implements ExportService {
         }
     }
 
-    public void fileTransfer(Export export,String appFileName,ByteArrayOutputStream baos,Map<String,Object>
config) {
+    public void fileTransfer(Export export,String appFileName,ByteArrayOutputStream baos,Map<String,Object>
config, S3Export s3Export) {
         InputStream is = new ByteArrayInputStream( baos.toByteArray() );
         try {
             s3Export.copyToS3( is, config, appFileName );
@@ -364,7 +366,7 @@ public class ExportServiceImpl implements ExportService {
      * Exports a specific applications from an organization
      */
     private void exportApplicationFromOrg( UUID organizationUUID, UUID applicationId, final
Map<String, Object> config,
-                                           final JobExecution jobExecution ) throws Exception
{
+                                           final JobExecution jobExecution, S3Export s3Export
) throws Exception {
 
         //retrieves export entity
         Export export = getExportEntity(jobExecution);
@@ -374,7 +376,7 @@ public class ExportServiceImpl implements ExportService {
 
         ByteArrayOutputStream baos = collectionExportAndQuery(applicationId,config,export,jobExecution);
 
-        fileTransfer( export,appFileName,baos,config );
+        fileTransfer( export,appFileName,baos,config, s3Export );
         //sets up the Inputstream for copying the method to s3.
 //        InputStream is = new ByteArrayInputStream( baos.toByteArray() );
 //        try {
@@ -392,7 +394,7 @@ public class ExportServiceImpl implements ExportService {
      */
     //might be confusing, but uses the /s/ inclusion or exclusion nomenclature.
     private void exportCollectionFromOrgApp( UUID organizationUUID, UUID applicationUUID,
-                                             final Map<String, Object> config, final
JobExecution jobExecution )
+                                             final Map<String, Object> config, final
JobExecution jobExecution, S3Export s3Export )
             throws Exception {
 
         //retrieves export entity
@@ -408,7 +410,7 @@ public class ExportServiceImpl implements ExportService {
         //sets up the Inputstream for copying the method to s3.
         InputStream is = new ByteArrayInputStream( baos.toByteArray() );
 
-        fileTransfer( export,appFileName,baos,config );
+        fileTransfer( export,appFileName,baos,config, s3Export );
 //        try {
 //            s3Export.copyToS3( is, config, appFileName );
 //        }
@@ -644,7 +646,7 @@ public class ExportServiceImpl implements ExportService {
     }
 
 
-    @Autowired
-    @Override
-    public void setS3Export( S3Export s3Export ) { this.s3Export = s3Export; }
+//    @Autowired
+//    @Override
+//    public void setS3Export( S3Export s3Export ) { this.s3Export = s3Export; }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/services/src/main/java/org/apache/usergrid/management/export/S3Export.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/S3Export.java
b/stack/services/src/main/java/org/apache/usergrid/management/export/S3Export.java
index 5b416d0..63b10d9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/S3Export.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/S3Export.java
@@ -30,6 +30,4 @@ public interface S3Export {
 
     String getFilename ();
 
-    void setFilename (String givenName);
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
index c6cfc37..521f962 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
@@ -108,6 +108,4 @@ public class S3ExportImpl implements S3Export {
     @Override
     public String getFilename () {return fn;}
 
-    @Override
-    public void setFilename(String givenName) {fn = givenName;}
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/services/src/test/java/org/apache/usergrid/ConcurrentServiceITSuite.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ConcurrentServiceITSuite.java
b/stack/services/src/test/java/org/apache/usergrid/ConcurrentServiceITSuite.java
index ef84a3c..2db2c48 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ConcurrentServiceITSuite.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ConcurrentServiceITSuite.java
@@ -27,6 +27,7 @@ import org.apache.usergrid.management.EmailFlowIT;
 import org.apache.usergrid.management.OrganizationIT;
 import org.apache.usergrid.management.RoleIT;
 import org.apache.usergrid.management.cassandra.ApplicationCreatorIT;
+import org.apache.usergrid.management.cassandra.ExportServiceIT;
 import org.apache.usergrid.management.cassandra.ManagementServiceIT;
 import org.apache.usergrid.security.providers.FacebookProviderIT;
 import org.apache.usergrid.security.providers.PingIdentityProviderIT;
@@ -47,7 +48,7 @@ import org.apache.usergrid.services.UsersServiceIT;
 @Suite.SuiteClasses(
         {
                 ActivitiesServiceIT.class, ApplicationCreatorIT.class, ApplicationsServiceIT.class,
-                CollectionServiceIT.class, ConnectionsServiceIT.class, ManagementServiceIT.class,
EmailFlowIT.class,
+                CollectionServiceIT.class, ConnectionsServiceIT.class, ManagementServiceIT.class,
ExportServiceIT.class ,EmailFlowIT.class,
                 FacebookProviderIT.class, GroupServiceIT.class, OrganizationIT.class, PingIdentityProviderIT.class,
                 RolesServiceIT.class, RoleIT.class, ServiceRequestIT.class, ServiceFactoryIT.class,
                 ServiceInvocationIT.class, TokenServiceIT.class, UsersServiceIT.class

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ExportServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ExportServiceIT.java
b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ExportServiceIT.java
index 5764053..f64412d 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ExportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ExportServiceIT.java
@@ -1,3 +1,20 @@
+/*
+ * 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.management.cassandra;
 
 
@@ -42,14 +59,11 @@ import org.apache.usergrid.management.export.S3Export;
 import org.apache.usergrid.management.export.S3ExportImpl;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.entities.Export;
 import org.apache.usergrid.persistence.entities.JobData;
 
 import com.google.common.collect.ImmutableSet;
 import com.google.inject.Module;
 
-import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION_ID;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -83,9 +97,9 @@ public class ExportServiceIT {
     @BeforeClass
     public static void setup() throws Exception {
         LOG.info( "in setup" );
-        adminUser = setup.getMgmtSvc().createAdminUser( "edanuff", "Ed Anuff", "ed@anuff.com",
"test", false, false );
-        organization = setup.getMgmtSvc().createOrganization( "ed-organization", adminUser,
true );
-        applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "ed-application"
).getId();
+        adminUser = setup.getMgmtSvc().createAdminUser( "grey", "George Reyes", "george@reyes.com",
"test", false, false );
+        organization = setup.getMgmtSvc().createOrganization( "george-organization", adminUser,
true );
+        applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "george-application"
).getId();
     }
 
 
@@ -105,8 +119,7 @@ public class ExportServiceIT {
         }
         f.deleteOnExit();
 
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "testFileConnections.json" );
+        S3Export s3Export = new MockS3ExportImpl("testFileConnections.json" );
 
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
@@ -133,13 +146,9 @@ public class ExportServiceIT {
         em.createConnection( em.getRef( entity[1].getUuid() ), "Vibrations", em.getRef( entity[0].getUuid()
) );
 
         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 );
+        JobData jobData = jobDataCreator( payload,exportUUID,s3Export );
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -186,8 +195,7 @@ public class ExportServiceIT {
         }
 
 
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "testConnectionsOnApplicationEndpoint.json" );
+        S3Export s3Export = new MockS3ExportImpl( "testConnectionsOnApplicationEndpoint.json"
);
 
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
@@ -213,13 +221,9 @@ public class ExportServiceIT {
         em.createConnection( em.getRef( entity[1].getUuid() ), "Vibrations", em.getRef( entity[0].getUuid()
) );
 
         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 );
+        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -256,103 +260,6 @@ public class ExportServiceIT {
         f.deleteOnExit();
     }
 
-    //
-    ////need to add tests for the other endpoint as well.
-    @Test
-    public void testValidityOfCollectionExport() throws Exception {
-
-        File f = null;
-
-        try {
-            f = new File( "fileValidity.json" );
-        }
-        catch ( Exception e ) {
-            //consumed because this checks to see if the file exists. If it doesn't then
don't do anything and carry on.
-        }
-
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "fileValidity.json" );
-        ExportService exportService = setup.getExportService();
-        HashMap<String, Object> payload = payloadBuilder();
-
-        payload.put( "organizationId", organization.getUuid() );
-        payload.put( "applicationId", applicationId );
-        payload.put( "collectionName", "users" );
-
-        UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
-
-        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 );
-
-        JSONParser parser = new JSONParser();
-
-        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader(
f ) );
-
-        for ( int i = 0; i < a.size(); i++ ) {
-            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject ) a.get( i );
-            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata"
);
-            assertNotNull( entityData );
-        }
-        f.deleteOnExit();
-    }
-
-
-    //
-    @Test
-    public void testValidityOfApplicationExport() throws Exception {
-
-        File f = null;
-
-        try {
-            f = new File( "testValidityOfApplicationExport.json" );
-        }
-        catch ( Exception e ) {
-            //consumed because this checks to see if the file exists. If it doesn't then
don't do anything and carry on.
-        }
-
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "testValidityOfApplicationExport.json" );
-        ExportService exportService = setup.getExportService();
-        HashMap<String, Object> payload = payloadBuilder();
-
-        payload.put( "organizationId", organization.getUuid() );
-        payload.put( "applicationId", applicationId );
-
-        UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
-
-        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 );
-
-        JSONParser parser = new JSONParser();
-
-        org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader(
f ) );
-
-        for ( int i = 0; i < a.size(); i++ ) {
-            org.json.simple.JSONObject entity = ( org.json.simple.JSONObject ) a.get( i );
-            org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata"
);
-            assertNotNull( entityData );
-        }
-        f.deleteOnExit();
-    }
-
-
-    //
     @Test
     public void testExportOneOrgCollectionEndpoint() throws Exception {
 
@@ -369,8 +276,8 @@ public class ExportServiceIT {
              .createOwnerAndOrganization( "noExport", "junkUserName", "junkRealName", "ugExport@usergrid.com",
                      "123456789" );
 
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "exportOneOrg.json" );
+        S3Export s3Export = new MockS3ExportImpl("exportOneOrg.json");
+      //  s3Export.setFilename( "exportOneOrg.json" );
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
 
@@ -379,12 +286,10 @@ public class ExportServiceIT {
         payload.put( "collectionName", "roles" );
 
         UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
+        //exportService.setS3Export( s3Export );
+
+        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 
-        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 );
@@ -413,7 +318,7 @@ public class ExportServiceIT {
     public void testExportOneAppOnCollectionEndpoint() throws Exception {
 
         File f = null;
-        String orgName = "ed-organization";
+        String orgName = "george-organization";
         String appName = "testAppCollectionTestNotExported";
 
         try {
@@ -437,12 +342,12 @@ public class ExportServiceIT {
         for ( int i = 0; i < 1; i++ ) {
             userProperties = new LinkedHashMap<String, Object>();
             userProperties.put( "username", "junkRealName" );
-            userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com",
i ) );
+            userProperties.put( "email", "test" + i + "@anuff.com" );
             entity[i] = em.create( "user", userProperties );
         }
 
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "exportOneApp.json" );
+        S3Export s3Export = new MockS3ExportImpl("exportOneApp.json");
+        //s3Export.setFilename( "exportOneApp.json" );
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
 
@@ -450,12 +355,8 @@ public class ExportServiceIT {
         payload.put( "applicationId", applicationId );
 
         UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
 
-        JobData jobData = new JobData();
-        jobData.setProperty( "jobName", "exportJob" );
-        jobData.setProperty( "exportInfo", payload );
-        jobData.setProperty( "exportId", exportUUID );
+        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -474,8 +375,8 @@ public class ExportServiceIT {
             assertFalse( "junkRealName".equals( entityName ) );
         }
     }
-
-
+//
+//
     @Test
     public void testExportOneAppOnApplicationEndpointWQuery() throws Exception {
 
@@ -503,8 +404,7 @@ public class ExportServiceIT {
             entity[i] = em.create( "users", userProperties );
         }
 
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "exportOneAppWQuery.json" );
+        S3Export s3Export = new MockS3ExportImpl("exportOneAppWQuery.json" );
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
 
@@ -513,12 +413,8 @@ public class ExportServiceIT {
         payload.put( "applicationId", applicationId );
 
         UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
 
-        JobData jobData = new JobData();
-        jobData.setProperty( "jobName", "exportJob" );
-        jobData.setProperty( "exportInfo", payload );
-        jobData.setProperty( "exportId", exportUUID );
+        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -569,8 +465,7 @@ public class ExportServiceIT {
             entity[i] = em.create( "qts", userProperties );
         }
 
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "exportOneCollection.json" );
+        S3Export s3Export = new MockS3ExportImpl("exportOneCollection.json" );
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
 
@@ -579,12 +474,8 @@ public class ExportServiceIT {
         payload.put( "collectionName", "qts" );
 
         UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
 
-        JobData jobData = new JobData();
-        jobData.setProperty( "jobName", "exportJob" );
-        jobData.setProperty( "exportInfo", payload );
-        jobData.setProperty( "exportId", exportUUID );
+        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -627,8 +518,7 @@ public class ExportServiceIT {
             entity[i] = em.create( "baconators", userProperties );
         }
 
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "exportOneCollectionWQuery.json" );
+        S3Export s3Export = new MockS3ExportImpl("exportOneCollectionWQuery.json");
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
         payload.put( "query", "select * where username contains 'billybob0'" );
@@ -638,12 +528,8 @@ public class ExportServiceIT {
         payload.put( "collectionName", "baconators" );
 
         UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
 
-        JobData jobData = new JobData();
-        jobData.setProperty( "jobName", "exportJob" );
-        jobData.setProperty( "exportInfo", payload );
-        jobData.setProperty( "exportId", exportUUID );
+        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -689,8 +575,8 @@ public class ExportServiceIT {
             entity[i] = em.create( "newOrg", userProperties );
         }
 
-        S3Export s3Export = new MockS3ExportImpl();
-        s3Export.setFilename( "exportOneOrganization.json" );
+        S3Export s3Export = new MockS3ExportImpl("exportOneOrganization.json" );
+
         ExportService exportService = setup.getExportService();
         HashMap<String, Object> payload = payloadBuilder();
 
@@ -719,12 +605,8 @@ public class ExportServiceIT {
         payload.put( "applicationId", appMade.getId() );
 
         UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
 
-        JobData jobData = new JobData();
-        jobData.setProperty( "jobName", "exportJob" );
-        jobData.setProperty( "exportInfo", payload );
-        jobData.setProperty( "exportId", exportUUID );
+        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -769,48 +651,6 @@ public class ExportServiceIT {
         assert ( true );
     }
 
-
-    @Test
-    public void testExportDoExportOnApplicationEndpoint() throws Exception {
-
-        EntityManagerFactory emf = setup.getEmf();
-        EntityManager em = emf.getEntityManager( MANAGEMENT_APPLICATION_ID );
-        HashMap<String, Object> payload = payloadBuilder();
-        ExportService eS = setup.getExportService();
-
-        JobExecution jobExecution = mock( JobExecution.class );
-
-        payload.put( "organizationId", organization.getUuid() );
-        payload.put( "applicationId", applicationId );
-
-        UUID entityExportUUID = eS.schedule( payload );
-
-
-        JobData jobData = new JobData();
-        jobData.setProperty( "jobName", "exportJob" );
-        jobData.setProperty( "exportInfo", payload );
-        jobData.setProperty( "exportId", entityExportUUID );
-
-        when( jobExecution.getJobData() ).thenReturn( jobData );
-
-        //Exportem.get(entityExport);
-        Export exportEntity = ( Export ) em.get( entityExportUUID );
-        assertNotNull( exportEntity );
-        String derp = exportEntity.getState().name();
-        assertEquals( "SCHEDULED", exportEntity.getState().name() );
-        try {
-            eS.doExport( jobExecution );
-        }
-        catch ( Exception e ) {
-            //throw e;
-            assert ( false );
-        }
-        exportEntity = ( Export ) em.get( entityExportUUID );
-        assertNotNull( exportEntity );
-        assertEquals( "FINISHED", exportEntity.getState().name() );
-    }
-
-
     //tests that with empty job data, the export still runs.
     @Test
     public void testExportEmptyJobData() throws Exception {
@@ -823,7 +663,7 @@ public class ExportServiceIT {
 
         ExportJob job = new ExportJob();
         S3Export s3Export = mock( S3Export.class );
-        setup.getExportService().setS3Export( s3Export );
+        //setup.getExportService().setS3Export( s3Export );
         job.setExportService( setup.getExportService() );
         try {
             job.doJob( jobExecution );
@@ -846,7 +686,7 @@ public class ExportServiceIT {
 
         ExportJob job = new ExportJob();
         S3Export s3Export = mock( S3Export.class );
-        setup.getExportService().setS3Export( s3Export );
+       // setup.getExportService().setS3Export( s3Export );
         job.setExportService( setup.getExportService() );
         try {
             job.doJob( jobExecution );
@@ -858,8 +698,8 @@ public class ExportServiceIT {
     }
 
 
-   // @Ignore //For this test please input your s3 credentials into settings.xml or Attach
a -D with relevant fields.
-    @Test
+    @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 {
 
         S3Export s3Export = new S3ExportImpl();
@@ -892,13 +732,9 @@ public class ExportServiceIT {
         }
 
         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 );
+        JobData jobData = jobDataCreator( payload,exportUUID,s3Export );
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -951,8 +787,8 @@ public class ExportServiceIT {
         blobStore.deleteContainer( bucketName );
     }
 
-    //@Ignore
-    @Test
+    @Ignore
+    //@Test
     public void testIntegration100EntitiesForAllApps() throws Exception {
 
         S3Export s3Export = new S3ExportImpl();
@@ -985,13 +821,9 @@ public class ExportServiceIT {
 
         UUID exportUUID = exportService.schedule( payload );
         assertNotNull( exportUUID );
-        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 );
+        JobData jobData = jobDataCreator( payload,exportUUID,s3Export );
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -1042,8 +874,8 @@ public class ExportServiceIT {
     }
 
 
-    //@Ignore
-    @Test
+    @Ignore
+   // @Test
     public void testIntegration100EntitiesOnOneOrg() throws Exception {
 
         S3Export s3Export = new S3ExportImpl();
@@ -1089,13 +921,11 @@ public class ExportServiceIT {
         }
 
         UUID exportUUID = exportService.schedule( payload );
-        exportService.setS3Export( s3Export );
+       // 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 );
+        JobData jobData = jobDataCreator( payload,exportUUID,s3Export );
+
 
         JobExecution jobExecution = mock( JobExecution.class );
         when( jobExecution.getJobData() ).thenReturn( jobData );
@@ -1144,6 +974,16 @@ public class ExportServiceIT {
         blobStore.deleteContainer( bucketName );
     }
 
+    public JobData jobDataCreator(HashMap<String, Object> payload,UUID exportUUID,S3Export
s3Export) {
+        JobData jobData = new JobData();
+
+        jobData.setProperty( "jobName", "exportJob" );
+        jobData.setProperty( "exportInfo", payload );
+        jobData.setProperty( "exportId", exportUUID );
+        jobData.setProperty( "s3Export", s3Export );
+
+        return jobData;
+    }
 
     /*Creates fake payload for testing purposes.*/
     public HashMap<String, Object> payloadBuilder() {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb76cca9/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
index a1814fd..adabf42 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
@@ -35,7 +35,12 @@ import org.apache.usergrid.management.export.S3Export;
  * Streams / reads the information written from the export service to a file named "test.json"
  */
 public class MockS3ExportImpl implements S3Export {
-    public static String filename;
+    private final String filename;
+
+    public MockS3ExportImpl (String filename) {
+        this.filename = filename;
+    }
+
     @Override
     public void copyToS3( final InputStream inputStream, final Map<String,Object> exportInfo,
String filename ) {
         Logger logger = LoggerFactory.getLogger( MockS3ExportImpl.class );
@@ -44,7 +49,7 @@ public class MockS3ExportImpl implements S3Export {
         OutputStream outputStream = null;
 
         try {
-            outputStream = new FileOutputStream( new File( getFilename() ) );
+            outputStream = new FileOutputStream( new File( this.filename ) );
         }
         catch ( FileNotFoundException e ) {
             e.printStackTrace();
@@ -66,6 +71,6 @@ public class MockS3ExportImpl implements S3Export {
         return filename;
     }
 
-    @Override
-    public void setFilename (String givenName) { filename = givenName; }
+//    @Override
+//    public void setFilename (String givenName) { filename = givenName; }
 }


Mime
View raw message