From: Ray Lee Date: Sun, 28 Apr 2019 03:34:00 +0000 (-0700) Subject: NOJIRA: Update image urls in blob test. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=640a28f5b5e05e690a21768982b987041aa2e4d7;p=tmp%2Fjakarta-migration.git NOJIRA: Update image urls in blob test. --- diff --git a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java index 56cefc5aa..2742c23c6 100644 --- a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java +++ b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java @@ -27,7 +27,7 @@ import org.testng.annotations.Test; public class BlobScaleTest extends BaseServiceTest { 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 { private List allGeneratedImages = new ArrayList(); 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 { 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 { + 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 { 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 { + " - " + " : " + jpegFile.getAbsolutePath()); - + String csid = extractId(res); this.knownResourceId = csid; allResourceIdsCreated.add(csid); @@ -137,20 +137,20 @@ public class BlobScaleTest extends BaseServiceTest { } } } - + 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 { 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; } diff --git a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java index 368c3643e..52fce8a54 100644 --- a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java +++ b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java @@ -55,19 +55,19 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl 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