]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA: Update image urls in blob test.
authorRay Lee <ray.lee@lyrasis.org>
Sun, 28 Apr 2019 03:34:00 +0000 (20:34 -0700)
committerRay Lee <ray.lee@lyrasis.org>
Sun, 28 Apr 2019 03:34:00 +0000 (20:34 -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

index 56cefc5aa4c3320ca392c923496ea552256b249a..2742c23c6403189cf298370ec3045ab6e140c030 100644 (file)
@@ -27,7 +27,7 @@ import org.testng.annotations.Test;
 public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
 
     private final Logger logger = LoggerFactory.getLogger(BlobScaleTest.class);
-       
+
        private static final int IMAGE_SIZE = 1000;
        private static final int IMAGE_EDGE = -15;
        private static final int MIN_FONTSIZE = 15;
@@ -39,7 +39,7 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
     private List<String> allGeneratedImages = new ArrayList<String>();
 
        private static Random generator = new Random(System.currentTimeMillis());
-       
+
        @Override
        protected CollectionSpaceClient getClientInstance() throws Exception {
         return new BlobClient();
@@ -62,7 +62,7 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
 
        private int getImagesToCreate() {
                int result = DEFAULT_IMAGES_TO_CREATE;
-               
+
         String imagesToCreate = System.getProperty(IMAGES_TO_CREATE_PROP);
         try {
                result = Integer.parseInt(imagesToCreate);
@@ -75,31 +75,31 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
                                + result
                                + " images.");
         }
-        
+
         return result;
        }
-       
+
        @Test(dataProvider = "testName", dependsOnMethods = {"scaleTest"})
        public void scaleGETTest(String testName) throws Exception {
                this.setupRead();
         BlobClient client = new BlobClient();
-        
+
         // We seem to sometimes need a delay before Nuxeo finishes creating all the derivatives, so
         // we'll put our thread to sleep for 3 seconds before checking
         Thread.sleep(3000); // sleep for 3 seconds
-        
+
         for (int i = 0; i < allGeneratedImages.size(); i++) {
                Response res = client.getDerivativeContent(allGeneratedImages.get(i), "Thumbnail");
                try {
                        assertStatusCode(res, testName);
-                       logger.debug(String.format("Performed GET operation on Thumbnail derivative of image blob ID = '%s'.", 
+                       logger.debug(String.format("Performed GET operation on Thumbnail derivative of image blob ID = '%s'.",
                                        allGeneratedImages.get(i)));
                } finally {
                        res.close();
                }
-        }        
+        }
        }
-       
+
        @Test(dataProvider = "testName")
        public void scaleTest(String testName) throws Exception {
                this.createDirectory(GENERATED_IMAGES);
@@ -107,13 +107,13 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
                int imagesToCreate = getImagesToCreate();
         BlobClient client = new BlobClient();
                Profiler profiler = new Profiler(this, 1);
-        
+
         for (int i = 0; i < imagesToCreate; i++, profiler.reset()) {
-                       File jpegFile = createJpeg(GENERATED_IMAGES);   
+                       File jpegFile = createJpeg(GENERATED_IMAGES);
                        URL url = jpegFile.toURI().toURL();
-                       
+
                profiler.start();
-                       Response res = client.createBlobFromURI("http://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg");//url.toString());
+                       Response res = client.createBlobFromURI("https://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg");//url.toString());
                        try {
                                profiler.stop();
                        assertStatusCode(res, testName);
@@ -125,7 +125,7 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
                                                + " - "
                                                + " : "
                                                + jpegFile.getAbsolutePath());
-                               
+
                        String csid = extractId(res);
                        this.knownResourceId = csid;
                        allResourceIdsCreated.add(csid);
@@ -137,20 +137,20 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
                        }
         }
        }
-       
+
        private void createDirectory(String dirName) {
                boolean success = (
                                new File(dirName)).mkdir();
                if (success) {
-                       logger.debug("Directory: " 
+                       logger.debug("Directory: "
                                        + dirName + " created");
-               } 
+               }
        }
-       
+
        public File createJpeg(String destDir) {
                File result = null;
 
-               BufferedImage image = new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_INT_RGB);   
+               BufferedImage image = new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_INT_RGB);
                Graphics g = image.getGraphics();
                for (int i = 0; i < IMAGE_SIZE; i = i + 10) {
                        int x = random(IMAGE_EDGE, IMAGE_SIZE);
@@ -164,14 +164,14 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
                                        random(MIN_FONTSIZE, MAX_FONTSIZE));
                        g.setFont(newFont);
                }
-               try {    
+               try {
                        ImageIO.write(image, "jpg", result = new File(destDir
                                        + File.separator
                                        + System.currentTimeMillis()
                                        + ".jpg"));
-               } catch (IOException e) {    
-                       e.printStackTrace();   
-               } 
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
 
                return result;
        }
index 368c3643e650df3dfd51651a61704ab56a0c2b1d..52fce8a546e2909651bfc3453eea86286825f408 100644 (file)
@@ -55,19 +55,19 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
 
     private final String CLASS_NAME = BlobServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
-    
+
     private final static String KNOWN_IMAGE_FILENAME = "01-03-09_1546.jpg";
     private final static int WIDTH_DIMENSION_INDEX = 0;
     private final static int HEIGHT_DIMENSION_INDEX = 1;
-    
+
     private final static String KNOWN_IMAGE_SIZE = "56261";
     private final static BigDecimal KNOWN_IMAGE_WIDTH = new BigDecimal(640.0);
     private final static BigDecimal KNOWN_IMAGE_HEIGHT = new BigDecimal(480.0);
-    
-    private final static String PUBLIC_URL_BIRD = "http://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg";
-    private final static String PUBLIC_URL_DECK = "http://farm8.staticflickr.com/7231/6962564226_4bdfc17599_k_d.jpg";
-    
-    
+
+    private final static String PUBLIC_URL_BIRD = "https://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg";
+    private final static String PUBLIC_URL_DECK = "https://farm8.staticflickr.com/7231/6962564226_4bdfc17599_k_d.jpg";
+
+
     private boolean blobCleanup = true;
 
     @Override
@@ -79,7 +79,7 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
        protected String getServiceName() {
                return BlobClient.SERVICE_NAME;
        }
-    
+
     @Override
     protected CollectionSpaceClient getClientInstance() throws Exception {
         return new BlobClient();
@@ -109,11 +109,11 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
             this.blobCleanup = false;
        }
     }
-    
+
     private boolean isBlobCleanup() {
        return blobCleanup;
     }
-        
+
     /**
      * Looks in the .../src/test/resources/blobs directory for files from which to create Blob
      * instances.
@@ -126,7 +126,7 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
     protected void createBlob(String testName, boolean fromUri, String uri) throws Exception {
         setupCreate();
         BlobClient client = new BlobClient();
-        
+
         String currentDir = this.getResourceDir();
         String blobsDirPath = currentDir + File.separator + BLOBS_DIR;
         File blobsDir = new File(blobsDirPath);
@@ -171,14 +171,14 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
                logger.debug("Directory: " + blobsDirPath + " is missing or cannot be read.");
         }
     }
-    
+
     /*
      * For a known image file, make sure we're getting back the correct metadata about it.
      */
     @Test(dataProvider = "testName", dependsOnMethods = {"createBlobWithURI"})
     public void testImageDimensions(String testName) throws Exception {
         setupCreate();
-        
+
         String currentDir = this.getResourceDir();
         String blobsDirPath = currentDir
                        + File.separator + BLOBS_DIR + File.separator + KNOWN_IMAGE_FILENAME;
@@ -193,7 +193,7 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
                res = client.createBlobFromURI(uri);
                String blobCsid = null;
                try {
-               assertStatusCode(res, testName);                
+               assertStatusCode(res, testName);
                blobCsid = extractId(res);
                if (isBlobCleanup() == true) {
                        allResourceIdsCreated.add(blobCsid);
@@ -218,40 +218,40 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
                        readResponse.close();
             }
         }
-        
+
         Assert.assertEquals(blobsCommon.getLength(), KNOWN_IMAGE_SIZE, "The known image blob was not the expected size of " + KNOWN_IMAGE_SIZE);
-        
+
         MeasuredPartGroup measuredImagePart = blobsCommon.getMeasuredPartGroupList().getMeasuredPartGroup().get(0);
         Assert.assertEquals(measuredImagePart.getMeasuredPart(), BlobClient.IMAGE_MEASURED_PART_LABEL, "First measured part of the image blob was not the image itself.");
-        
+
         List<DimensionSubGroup> dimensionSubGroupList = measuredImagePart.getDimensionSubGroupList().getDimensionSubGroup();
         DimensionSubGroup widthDimension = dimensionSubGroupList.get(WIDTH_DIMENSION_INDEX);
         Assert.assertEquals(widthDimension.getDimension(), BlobClient.IMAGE_WIDTH_LABEL, "First dimension item of the image blob was not the width.");
         Assert.assertTrue(widthDimension.getValue().compareTo(KNOWN_IMAGE_WIDTH) == 0);
-        
+
         DimensionSubGroup heightDimension = dimensionSubGroupList.get(HEIGHT_DIMENSION_INDEX);
         Assert.assertEquals(heightDimension.getDimension(), BlobClient.IMAGE_HEIGHT_LABEL, "Second dimension item of the image blob was not the height.");
         Assert.assertTrue(heightDimension.getValue().compareTo(KNOWN_IMAGE_HEIGHT) == 0);
     }
-    
+
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
                dependsOnMethods = {"CRUDTests"})
     public void createBlobWithURI(String testName) throws Exception {
        createBlob(testName, true /*with URI*/, null);
     }
-    
+
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
                dependsOnMethods = {"CRUDTests"})
     public void createBlobWithURL1(String testName) throws Exception {
        createBlob(testName, true /*with URI*/, PUBLIC_URL_BIRD);
-    }    
-    
+    }
+
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
                dependsOnMethods = {"CRUDTests"})
     public void createBlobWithURL2(String testName) throws Exception {
        createBlob(testName, true /*with URI*/, PUBLIC_URL_DECK);
-    }    
-    
+    }
+
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
                dependsOnMethods = {"createBlobWithURI"})
     public void createBlobWithPost(String testName) throws Exception {
@@ -261,12 +261,12 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
-    
+
     @Override
     protected PoxPayloadOut createInstance(String identifier) throws Exception {
        return createBlobInstance(identifier);
-    }    
-    
+    }
+
     private PoxPayloadOut createBlobInstance(String exitNumber) throws Exception {
        BlobClient client = new BlobClient();
         String identifier = "blobNumber-" + exitNumber;
@@ -296,7 +296,7 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
     @Override
     @Test(dataProvider = "testName",
                dependsOnMethods = {
-                       "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})    
+                       "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
     public void CRUDTests(String testName) {
        // Do nothing.  Simply here to for a TestNG execution order for our tests
     }
@@ -304,9 +304,9 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
        @Override
        protected BlobsCommon updateInstance(BlobsCommon blobsCommon) {
                BlobsCommon result = new BlobsCommon();
-               
+
         result.setName("updated-" + blobsCommon.getName());
-               
+
                return result;
        }