]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6375: Cleaning up some of the blob service tests.
authorremillet <remillet@yahoo.com>
Wed, 1 Apr 2015 18:00:58 +0000 (11:00 -0700)
committerremillet <remillet@yahoo.com>
Wed, 1 Apr 2015 18:00:58 +0000 (11:00 -0700)
services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java
services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java
services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java

index 6a9c95d3eae57263b6c0879adce2225541447397..ce1fe34771b10ff2d13a24b2d68a2d1f8d33f20c 100644 (file)
@@ -8,6 +8,8 @@ import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Random;
 
 import javax.imageio.ImageIO;
@@ -31,9 +33,10 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
        private static final int MIN_FONTSIZE = 15;
        private static final int MAX_FONTSIZE = 60;
        private static final String IMAGES_TO_CREATE_PROP = "imagesToCreate";
-       private static final int DEFAULT_IMAGES_TO_CREATE = 1;
-       private static final int DEFAULT_IMAGES_TO_GET = 12; //1024;
+       private static final int DEFAULT_IMAGES_TO_CREATE = 3; // Override this value by setting a system property named 'imagesToCreate' -i.e., mvn test -DimagesToCreate=30
+       private static final int DEFAULT_IMAGES_TO_GET = DEFAULT_IMAGES_TO_CREATE;
     private static final String GENERATED_IMAGES = "target/generated_images";
+    private List<String> allGeneratedImages = new ArrayList<String>();
 
        private static Random generator = new Random(System.currentTimeMillis());
        
@@ -74,16 +77,14 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
        @Test(dataProvider = "testName", dependsOnMethods = {"scaleTest"})
        public void scaleGETTest(String testName) throws MalformedURLException {
                this.setupRead();
-               String blobToGetID = getKnowResourceId();
         BlobClient client = new BlobClient();
         
-        for (int i = 0; i < DEFAULT_IMAGES_TO_GET; i++) {
-               ClientResponse<Response> res = client.getDerivativeContent(blobToGetID, "Thumbnail");
+        for (int i = 0; i < allGeneratedImages.size(); i++) {
+               ClientResponse<Response> res = client.getDerivativeContent(allGeneratedImages.get(i), "Thumbnail");
                assertStatusCode(res, testName);
-        }
-        
-        logger.debug(String.format("Performed %d GET operations on blob = %s.", 
-                       DEFAULT_IMAGES_TO_GET, blobToGetID));
+               logger.debug(String.format("Performed GET operation on Thumbnail derivative of image blob ID = '%s'.", 
+                               allGeneratedImages.get(i)));
+        }        
        }
        
        @Test(dataProvider = "testName")
@@ -115,6 +116,7 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
                        String csid = extractId(res);
                        this.knownResourceId = csid;
                        allResourceIdsCreated.add(csid);
+                       allGeneratedImages.add(csid);
                        } finally {
                                if (res != null) {
                     res.releaseConnection();
index 48b4da88e121b35e6939540296a81c209582ec7a..984a4be49977089cff4034f9b3682bbaed4b3503 100644 (file)
@@ -100,7 +100,7 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
        protected void setupCreate() {
         super.setupCreate();
         String noBlobCleanup = System.getProperty(NO_BLOB_CLEANUP);
-       if(Boolean.TRUE.toString().equalsIgnoreCase(noBlobCleanup)) {
+       if (Boolean.TRUE.toString().equalsIgnoreCase(noBlobCleanup)) {
                //
                // Don't delete the blobs that we created during the test cycle
                //
@@ -140,7 +140,7 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
                                        if (fromUri == true) {
                                                if (uri != null) {
                                                        res = client.createBlobFromURI(uri);
-                                                       break;
+                                                       //break;
                                                } else {
                                                        URL childUrl = child.toURI().toURL();
                                                        res = client.createBlobFromURI(childUrl.toString());
index 818847faebb960d9ccacd20b87d9be7edec137c4..2a537c2578289c70ae2351059622a3371aae7691 100644 (file)
@@ -149,15 +149,16 @@ public class NuxeoBlobUtils {
                        + "_";
 
        public static final String DERIVATIVE_ORIGINAL_JPEG = "OriginalJpeg";
-       public static final String DERIVATIVE_ORIGINAL_JPEG_TAG = DERIVATIVE_ORIGINAL_JPEG
-                       + "_";
+       public static final String DERIVATIVE_ORIGINAL_JPEG_TAG = DERIVATIVE_ORIGINAL_JPEG + "_";
 
        public static final String DERIVATIVE_MEDIUM = "Medium";
        public static final String DERIVATIVE_MEDIUM_TAG = DERIVATIVE_MEDIUM + "_";
 
+       public static final String DERIVATIVE_SMALL = "Small";
+       public static final String DERIVATIVE_SMALL_TAG = DERIVATIVE_SMALL + "_";
+
        public static final String DERIVATIVE_THUMBNAIL = "Thumbnail";
-       public static final String DERIVATIVE_THUMBNAIL_TAG = DERIVATIVE_THUMBNAIL
-                       + "_";
+       public static final String DERIVATIVE_THUMBNAIL_TAG = DERIVATIVE_THUMBNAIL + "_";
 
        public static final String DERIVATIVE_UNKNOWN = "_UNKNOWN_DERIVATIVE_NAME_";
 
@@ -209,6 +210,8 @@ public class NuxeoBlobUtils {
                        result = DERIVATIVE_ORIGINAL_JPEG;
                } else if (derivativeName.startsWith(DERIVATIVE_MEDIUM_TAG) == true) {
                        result = DERIVATIVE_MEDIUM;
+               } else if (derivativeName.startsWith(DERIVATIVE_SMALL_TAG) == true) {
+                       result = DERIVATIVE_SMALL;
                } else if (derivativeName.startsWith(DERIVATIVE_THUMBNAIL_TAG) == true) {
                        result = DERIVATIVE_THUMBNAIL;
                }