]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-1829: Remove flickr urls from tests (#473)
authorMichael Ritter <mikejritter@users.noreply.github.com>
Tue, 22 Jul 2025 17:10:43 +0000 (11:10 -0600)
committerGitHub <noreply@github.com>
Tue, 22 Jul 2025 17:10:43 +0000 (11:10 -0600)
* Add maven-failsafe-plugin
* Add jetty-maven-plugin to serve static files
* Add maven-remote-resources-plugin
* Create StaticImage enum for tests
* Rename *Test classes to *IT
* Remove flickr from Blob/Media tests

14 files changed:
pom.xml
services/blob/blob-test-utils/pom.xml [new file with mode: 0644]
services/blob/blob-test-utils/src/main/java/org/collectionspace/serivces/blob/StaticImage.java [new file with mode: 0644]
services/blob/blob-test-utils/src/main/resources/bird.jpg [new file with mode: 0644]
services/blob/blob-test-utils/src/main/resources/deck.jpg [new file with mode: 0644]
services/blob/client/pom.xml
services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleIT.java [moved from services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java with 78% similarity]
services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceIT.java [moved from services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java with 76% similarity]
services/blob/pom.xml
services/blob/service/src/test/java/org/collectionspace/services/test/BlobServiceTest.java [deleted file]
services/media/client/pom.xml
services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceIT.java [moved from services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java with 96% similarity]
services/restrictedmedia/client/pom.xml
services/restrictedmedia/client/src/test/java/org/collectionspace/services/client/test/RestrictedMediaServiceIT.java [moved from services/restrictedmedia/client/src/test/java/org/collectionspace/services/client/test/RestrictedMediaServiceTest.java with 97% similarity]

diff --git a/pom.xml b/pom.xml
index 8d5b5421aa92f0f0179e8ae9e651258d326310ea..059383ac3d2e056620f8e940fc204d9c7fe68330 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                                                </execution>
                                        </executions>
                                </plugin>
+
+                               <!-- Integration Test plugins: jetty, failsafe, and remote-resources -->
+                               <plugin>
+                                       <groupId>org.eclipse.jetty</groupId>
+                                       <artifactId>jetty-maven-plugin</artifactId>
+                                       <version>9.4.57.v20241219</version>
+                                       <executions>
+                                               <execution>
+                                                       <id>start-jetty</id>
+                                                       <phase>pre-integration-test</phase>
+                                                       <goals>
+                                                               <goal>start</goal>
+                                                       </goals>
+                                                       <configuration>
+                                                               <skip>${skipTests}</skip>
+                                                       </configuration>
+                                               </execution>
+                                               <execution>
+                                                       <id>stop-jetty</id>
+                                                       <phase>post-integration-test</phase>
+                                                       <goals>
+                                                               <goal>stop</goal>
+                                                       </goals>
+                                               </execution>
+                                       </executions>
+                               </plugin>
+
+                               <plugin>
+                                       <groupId>org.apache.maven.plugins</groupId>
+                                       <artifactId>maven-failsafe-plugin</artifactId>
+                                       <version>3.5.3</version>
+                                       <executions>
+                                               <execution>
+                                                       <id>integration-test</id>
+                                                       <goals>
+                                                               <goal>integration-test</goal>
+                                                       </goals>
+                                               </execution>
+                                               <execution>
+                                                       <id>verify</id>
+                                                       <goals>
+                                                               <goal>verify</goal>
+                                                       </goals>
+                                               </execution>
+                                       </executions>
+                                       <configuration>
+                                               <includes>
+                                                       <include>**/*IT.class</include>
+                                               </includes>
+                                       </configuration>
+                               </plugin>
+
+                               <plugin>
+                                       <groupId>org.apache.maven.plugins</groupId>
+                                       <artifactId>maven-remote-resources-plugin</artifactId>
+                                       <version>3.3.0</version>
+                               </plugin>
                        </plugins>
                </pluginManagement>
 
diff --git a/services/blob/blob-test-utils/pom.xml b/services/blob/blob-test-utils/pom.xml
new file mode 100644 (file)
index 0000000..87d3b79
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.blob</artifactId>
+    <version>${revision}</version>
+  </parent>
+
+  <groupId>org.collectionspace.services.blob</groupId>
+  <artifactId>blob-test-utils</artifactId>
+  <name>services.blob.blob-test-utils</name>
+  <packaging>jar</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-remote-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>bundle</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <includes>
+            <include>**/*.jpg</include>
+          </includes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/services/blob/blob-test-utils/src/main/java/org/collectionspace/serivces/blob/StaticImage.java b/services/blob/blob-test-utils/src/main/java/org/collectionspace/serivces/blob/StaticImage.java
new file mode 100644 (file)
index 0000000..a73d9df
--- /dev/null
@@ -0,0 +1,28 @@
+package org.collectionspace.serivces.blob;
+
+/**
+ * Static images which are served by an embedded jetty server. These are the images found under src/main/resources and
+ * it's expected that they're served on /static in jetty, e.g. /static/bird.jpg
+ *
+ * @since 8.3.0
+ */
+public enum StaticImage {
+    BIRD("bird.jpg"),
+    DECK("deck.jpg");
+
+    private final String path;
+
+    StaticImage(final String path) {
+        this.path = path;
+    }
+
+    public String getUrl() {
+        final String port = System.getProperty("jetty.port");
+        if (port == null) {
+            throw new RuntimeException("jetty.port property is not set; check your maven plugin configuration");
+        }
+
+        return "http://localhost:" + port + "/static/" + path;
+    }
+
+}
diff --git a/services/blob/blob-test-utils/src/main/resources/bird.jpg b/services/blob/blob-test-utils/src/main/resources/bird.jpg
new file mode 100644 (file)
index 0000000..6a744c9
Binary files /dev/null and b/services/blob/blob-test-utils/src/main/resources/bird.jpg differ
diff --git a/services/blob/blob-test-utils/src/main/resources/deck.jpg b/services/blob/blob-test-utils/src/main/resources/deck.jpg
new file mode 100644 (file)
index 0000000..23f43dd
Binary files /dev/null and b/services/blob/blob-test-utils/src/main/resources/deck.jpg differ
index aba3397d7fa66be27c11ba6a74752e6d23f61786..9e004c39ca48ca90b6157d69ee79e4dd348ce6dd 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.collectionspace.services</groupId>
-        <artifactId>org.collectionspace.services.blob</artifactId>
-        <version>${revision}</version>
-    </parent>
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.blob</artifactId>
+    <version>${revision}</version>
+  </parent>
 
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.collectionspace.services.blob.client</artifactId>
-    <name>services.blob.client</name>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>org.collectionspace.services.blob.client</artifactId>
+  <name>services.blob.client</name>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.nuxeo.ecm.core</groupId>
-            <artifactId>nuxeo-core-storage-sql-management</artifactId>
-            <version>${nuxeo.general.release}</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
+  <dependencies>
+    <!-- CollectionSpace dependencies -->
+    <dependency>
+      <groupId>org.collectionspace.services</groupId>
+      <artifactId>org.collectionspace.services.jaxb</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.collectionspace.services</groupId>
+      <artifactId>org.collectionspace.services.client</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.collectionspace.services</groupId>
+      <artifactId>org.collectionspace.services.person.client</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.collectionspace.services.blob</groupId>
+      <artifactId>blob-test-utils</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- External dependencies -->
+    <dependency>
+      <groupId>org.jboss.resteasy</groupId>
+      <artifactId>resteasy-multipart-provider</artifactId>
+    </dependency>
 
-<!-- CollectionSpace dependencies -->
-        <dependency>
-            <groupId>org.collectionspace.services</groupId>
-            <artifactId>org.collectionspace.services.authority.jaxb</artifactId>
-            <optional>true</optional>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.collectionspace.services</groupId>
-            <artifactId>org.collectionspace.services.jaxb</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-<!--
-        <dependency>
-            <groupId>org.collectionspace.services</groupId>
-            <artifactId>org.collectionspace.services.common</artifactId>
-            <optional>true</optional>
-            <version>${project.version}</version>
-        </dependency>
- -->
-        <dependency>
-            <groupId>org.collectionspace.services</groupId>
-            <artifactId>org.collectionspace.services.client</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.collectionspace.services</groupId>
-            <artifactId>org.collectionspace.services.person.client</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-<!-- External dependencies -->
-        <dependency>
-            <groupId>org.testng</groupId>
-            <artifactId>testng</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.jboss.resteasy</groupId>
-            <artifactId>resteasy-jaxrs</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.jboss.resteasy</groupId>
-            <artifactId>resteasy-jaxb-provider</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.jboss.resteasy</groupId>
-            <artifactId>resteasy-multipart-provider</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-httpclient</groupId>
-            <artifactId>commons-httpclient</artifactId>
-        </dependency>
-    </dependencies>
+    <dependency>
+      <groupId>org.testng</groupId>
+      <artifactId>testng</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <finalName>collectionspace-services-blob-client</finalName>
-    </build>
+  <build>
+    <finalName>collectionspace-services-blob-client</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-remote-resources-plugin</artifactId>
+        <configuration>
+          <resourceBundles>
+            <resourceBundle>org.collectionspace.services.blob:blob-test-utils:${project.version}</resourceBundle>
+          </resourceBundles>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>process</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>3.6.0</version>
+        <configuration>
+          <portNames>
+            <portName>jetty.port</portName>
+            <portName>jetty.stop.port</portName>
+          </portNames>
+          <fileSet/>
+          <name/>
+          <regex/>
+          <source/>
+          <value/>
+        </configuration>
+        <executions>
+          <execution>
+            <id>reserve-port</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>reserve-network-port</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>3.5.3</version>
+        <configuration>
+          <excludes>
+            <exclude>**/*IT.class</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.eclipse.jetty</groupId>
+        <artifactId>jetty-maven-plugin</artifactId>
+        <configuration>
+          <httpConnector>
+            <port>${jetty.port}</port>
+          </httpConnector>
+          <stopKey>quit</stopKey>
+          <stopPort>${jetty.stop.port}</stopPort>
+          <stopWait>10</stopWait>
+          <contextHandlers>
+            <contextHandler implementation="org.eclipse.jetty.server.handler.ContextHandler">
+              <contextPath>/static</contextPath>
+              <resourceBase>${project.build.directory}/maven-shared-archive-resources</resourceBase>
+              <handler implementation="org.eclipse.jetty.server.handler.ResourceHandler" />
+            </contextHandler>
+          </contextHandlers>
+          <supportedPackagings>jar</supportedPackagings>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <configuration>
+          <systemPropertyVariables>
+            <jetty.port>${jetty.port}</jetty.port>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>
similarity index 78%
rename from services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleTest.java
rename to services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobScaleIT.java
index 2742c23c6403189cf298370ec3045ab6e140c030..a1ddfe696bce3cd6e3ae2ac4b59ec4d3a398ff74 100644 (file)
@@ -6,8 +6,6 @@ import java.awt.Graphics;
 import java.awt.image.BufferedImage;
 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;
@@ -15,6 +13,7 @@ import java.util.Random;
 import javax.imageio.ImageIO;
 import javax.ws.rs.core.Response;
 
+import org.collectionspace.serivces.blob.StaticImage;
 import org.collectionspace.services.client.BlobClient;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.Profiler;
@@ -24,9 +23,9 @@ import org.slf4j.LoggerFactory;
 import org.testng.annotations.Test;
 
 @SuppressWarnings("rawtypes")
-public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
+public class BlobScaleIT extends BaseServiceTest<AbstractCommonList> {
 
-    private final Logger logger = LoggerFactory.getLogger(BlobScaleTest.class);
+    private final Logger logger = LoggerFactory.getLogger(BlobScaleIT.class);
 
        private static final int IMAGE_SIZE = 1000;
        private static final int IMAGE_EDGE = -15;
@@ -34,7 +33,6 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
        private static final int MAX_FONTSIZE = 60;
        private static final String IMAGES_TO_CREATE_PROP = "imagesToCreate";
        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>();
 
@@ -71,9 +69,7 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
                                + IMAGES_TO_CREATE_PROP
                                + "' was defined, so we'll use the default instead.");
         } finally {
-               logger.info("Testing blob scaling by creating "
-                               + result
-                               + " images.");
+            logger.info("Testing blob scaling by creating {} images.", result);
         }
 
         return result;
@@ -89,14 +85,14 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
         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'.",
-                                       allGeneratedImages.get(i)));
-               } finally {
-                       res.close();
-               }
+            Response res = client.getDerivativeContent(allGeneratedImages.get(i), "Thumbnail");
+            try {
+                assertStatusCode(res, testName);
+                logger.debug("Performed GET operation on Thumbnail derivative of image blob ID = '{}'.",
+                             allGeneratedImages.get(i));
+            } finally {
+                res.close();
+            }
         }
        }
 
@@ -110,21 +106,15 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
 
         for (int i = 0; i < imagesToCreate; i++, profiler.reset()) {
                        File jpegFile = createJpeg(GENERATED_IMAGES);
-                       URL url = jpegFile.toURI().toURL();
 
-               profiler.start();
-                       Response res = client.createBlobFromURI("https://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg");//url.toString());
+            profiler.start();
+                       Response res = client.createBlobFromURI(StaticImage.BIRD.getUrl());
                        try {
                                profiler.stop();
                        assertStatusCode(res, testName);
 
-                       logger.debug(
-                                               i + ": Uploaded image to Nuxeo in "
-                                               + profiler.getCumulativeTime()
-                                               + " milleseconds "
-                                               + " - "
-                                               + " : "
-                                               + jpegFile.getAbsolutePath());
+                logger.debug("{}: Uploaded image to Nuxeo in {} milleseconds  -  : {}", i, profiler.getCumulativeTime(),
+                             jpegFile.getAbsolutePath());
 
                        String csid = extractId(res);
                        this.knownResourceId = csid;
@@ -138,14 +128,12 @@ public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
         }
        }
 
-       private void createDirectory(String dirName) {
-               boolean success = (
-                               new File(dirName)).mkdir();
-               if (success) {
-                       logger.debug("Directory: "
-                                       + dirName + " created");
-               }
-       }
+    private void createDirectory(String dirName) {
+        boolean success = (new File(dirName)).mkdir();
+        if (success) {
+            logger.debug("Directory: {} created", dirName);
+        }
+    }
 
        public File createJpeg(String destDir) {
                File result = null;
similarity index 76%
rename from services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java
rename to services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceIT.java
index 52fce8a546e2909651bfc3453eea86286825f408..c47448d20ee7a4c612fd178727ba77860fc8238f 100644 (file)
@@ -30,6 +30,7 @@ import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import org.collectionspace.serivces.blob.StaticImage;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.BlobClient;
 import org.collectionspace.services.client.PayloadOutputPart;
@@ -51,22 +52,17 @@ import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
  * $LastChangedDate:  $
  */
 @SuppressWarnings("rawtypes")
-public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, BlobsCommon> {
+public class BlobServiceIT extends AbstractPoxServiceTestImpl<AbstractCommonList, BlobsCommon> {
 
-    private final String CLASS_NAME = BlobServiceTest.class.getName();
-    private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+    private final Logger logger = LoggerFactory.getLogger(BlobServiceIT.class);
 
     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 = "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 static final String KNOWN_IMAGE_SIZE = "56261";
+    private static final BigDecimal KNOWN_IMAGE_WIDTH = new BigDecimal("640.0");
+    private static final BigDecimal KNOWN_IMAGE_HEIGHT = new BigDecimal("480.0");
 
     private boolean blobCleanup = true;
 
@@ -131,44 +127,44 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
         String blobsDirPath = currentDir + File.separator + BLOBS_DIR;
         File blobsDir = new File(blobsDirPath);
         if (blobsDir != null && blobsDir.exists()) {
-               File[] children = blobsDir.listFiles();
-               if (children != null && children.length > 0) {
-                       for (File child : children) {
-                               if (isBlobbable(child) == true) {
-                                       Response res = null;
-                                       String mimeType = this.getMimeType(child);
-                                       logger.debug("Processing file URI: " + child.getAbsolutePath());
-                                       logger.debug("MIME type is: " + mimeType);
-                                       if (fromUri == true) {
-                                               if (uri != null) {
-                                                       res = client.createBlobFromURI(uri);
-                                                       //break;
-                                               } else {
-                                                       URL childUrl = child.toURI().toURL();
-                                                       res = client.createBlobFromURI(childUrl.toString());
-                                               }
-                                       } else {
-                                           MultipartFormDataOutput form = new MultipartFormDataOutput();
-                                           OutputPart outputPart = form.addFormData("file", child, MediaType.valueOf(mimeType));
-                                           res = client.createBlobFromFormData(form);
-                                       }
-                                       try {
-                                           assertStatusCode(res, testName);
-                                           if (isBlobCleanup() == true) {
-                                               allResourceIdsCreated.add(extractId(res));
-                                           }
-                                       } finally {
-                                               if (res != null) {
-                                       res.close();
-                                   }
-                                       }
-                               }
-                       }
-               } else {
-                       logger.debug("Directory: " + blobsDirPath + " is empty or cannot be read.");
-               }
+            File[] children = blobsDir.listFiles();
+            if (children != null && children.length > 0) {
+                for (File child : children) {
+                    if (isBlobbable(child)) {
+                        Response res = null;
+                        String mimeType = this.getMimeType(child);
+                        logger.debug("Processing file URI: {}", child.getAbsolutePath());
+                        logger.debug("MIME type is: {}", mimeType);
+                        if (fromUri) {
+                            if (uri != null) {
+                                res = client.createBlobFromURI(uri);
+                                // break;
+                            } else {
+                                URL childUrl = child.toURI().toURL();
+                                res = client.createBlobFromURI(childUrl.toString());
+                            }
+                        } else {
+                            MultipartFormDataOutput form = new MultipartFormDataOutput();
+                            OutputPart outputPart = form.addFormData("file", child, MediaType.valueOf(mimeType));
+                            res = client.createBlobFromFormData(form);
+                        }
+                        try {
+                            assertStatusCode(res, testName);
+                            if (isBlobCleanup()) {
+                                allResourceIdsCreated.add(extractId(res));
+                            }
+                        } finally {
+                            if (res != null) {
+                                res.close();
+                            }
+                        }
+                    }
+                }
+            } else {
+                logger.debug("Directory: {} is empty or cannot be read.", blobsDirPath);
+            }
         } else {
-               logger.debug("Directory: " + blobsDirPath + " is missing or cannot be read.");
+            logger.debug("Directory: {} is missing or cannot be read.", blobsDirPath);
         }
     }
 
@@ -189,17 +185,17 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
         // Create the blob
         //
         BlobClient client = new BlobClient();
-               Response res = null;
-               res = client.createBlobFromURI(uri);
-               String blobCsid = null;
-               try {
-               assertStatusCode(res, testName);
-               blobCsid = extractId(res);
-               if (isBlobCleanup() == true) {
-                       allResourceIdsCreated.add(blobCsid);
-               }
-               } finally {
-                       if (res != null) {
+        Response res = null;
+        res = client.createBlobFromURI(uri);
+        String blobCsid = null;
+        try {
+            assertStatusCode(res, testName);
+            blobCsid = extractId(res);
+            if (isBlobCleanup()) {
+                allResourceIdsCreated.add(blobCsid);
+            }
+        } finally {
+            if (res != null) {
                 res.close();
             }
                }
@@ -243,13 +239,13 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
                dependsOnMethods = {"CRUDTests"})
     public void createBlobWithURL1(String testName) throws Exception {
-       createBlob(testName, true /*with URI*/, PUBLIC_URL_BIRD);
+       createBlob(testName, true /*with URI*/, StaticImage.BIRD.getUrl());
     }
 
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
                dependsOnMethods = {"CRUDTests"})
     public void createBlobWithURL2(String testName) throws Exception {
-       createBlob(testName, true /*with URI*/, PUBLIC_URL_DECK);
+       createBlob(testName, true /*with URI*/, StaticImage.DECK.getUrl());
     }
 
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
@@ -275,10 +271,8 @@ public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonLi
         PoxPayloadOut multipart = new PoxPayloadOut(BlobClient.SERVICE_PAYLOAD_NAME);
         PayloadOutputPart commonPart = multipart.addPart(client.getCommonPartName(), blob);
 
-        if (logger.isDebugEnabled()) {
-            logger.debug("to be created, blob common");
-            logger.debug(objectAsXmlString(blob, BlobsCommon.class));
-        }
+        logger.debug("to be created, blob common");
+        logger.debug(objectAsXmlString(blob, BlobsCommon.class));
 
         return multipart;
     }
index 16fa38bd51502d21596549975d17bdda76568b66..b484c38baad21a016d6fe56b5c1854e549594e3b 100644 (file)
@@ -13,6 +13,7 @@
     <url>http://www.collectionspace.org</url>
     
     <modules>
+        <module>blob-test-utils</module>
         <module>client</module>
         <module>3rdparty</module>
         <module>service</module>
diff --git a/services/blob/service/src/test/java/org/collectionspace/services/test/BlobServiceTest.java b/services/blob/service/src/test/java/org/collectionspace/services/test/BlobServiceTest.java
deleted file mode 100644 (file)
index 50eb4b7..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.collectionspace.services.test;
-
-//import org.collectionspace.services.blob.Blob;
-//import org.collectionspace.services.blob.BlobList;
-
-/**
- * Placeholder for server-side testing of Loan Out service code.
- * 
- * @version $Revision: 2108 $
- */
-public class BlobServiceTest {
-       //empty
-}
index 638fd70432cf1350024d5dad8755e9a47e8b2b59..14c06f01b9a5b7d2f9df288abed0e22ec24b8936 100644 (file)
             <artifactId>org.collectionspace.services.person.client</artifactId>
             <version>${project.version}</version>
         </dependency>
+      <dependency>
+        <groupId>org.collectionspace.services.blob</groupId>
+        <artifactId>blob-test-utils</artifactId>
+        <version>${project.version}</version>
+        <scope>test</scope>
+      </dependency>
 <!-- External dependencies -->
         <dependency>
             <groupId>org.testng</groupId>
     </dependencies>
 
     <build>
-        <finalName>collectionspace-services-media-client</finalName>
+      <finalName>collectionspace-services-media-client</finalName>
+
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-remote-resources-plugin</artifactId>
+          <configuration>
+            <resourceBundles>
+              <resourceBundle>org.collectionspace.services.blob:blob-test-utils:${project.version}</resourceBundle>
+            </resourceBundles>
+          </configuration>
+          <executions>
+            <execution>
+              <goals>
+                <goal>process</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>build-helper-maven-plugin</artifactId>
+          <version>3.6.0</version>
+          <configuration>
+            <portNames>
+              <portName>jetty.port</portName>
+              <portName>jetty.stop.port</portName>
+            </portNames>
+            <fileSet/>
+            <name/>
+            <regex/>
+            <source/>
+            <value/>
+          </configuration>
+          <executions>
+            <execution>
+              <id>reserve-port</id>
+              <phase>test-compile</phase>
+              <goals>
+                <goal>reserve-network-port</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>3.5.3</version>
+          <configuration>
+            <excludes>
+              <exclude>**/*IT.class</exclude>
+            </excludes>
+          </configuration>
+        </plugin>
+
+        <plugin>
+          <groupId>org.eclipse.jetty</groupId>
+          <artifactId>jetty-maven-plugin</artifactId>
+          <configuration>
+            <httpConnector>
+              <port>${jetty.port}</port>
+            </httpConnector>
+            <stopKey>quit</stopKey>
+            <stopPort>${jetty.stop.port}</stopPort>
+            <stopWait>10</stopWait>
+            <contextHandlers>
+              <contextHandler implementation="org.eclipse.jetty.server.handler.ContextHandler">
+                <contextPath>/static</contextPath>
+                <resourceBase>${project.build.directory}/maven-shared-archive-resources</resourceBase>
+                <handler implementation="org.eclipse.jetty.server.handler.ResourceHandler" />
+              </contextHandler>
+            </contextHandlers>
+            <supportedPackagings>jar</supportedPackagings>
+          </configuration>
+        </plugin>
+
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-failsafe-plugin</artifactId>
+          <configuration>
+            <systemPropertyVariables>
+              <jetty.port>${jetty.port}</jetty.port>
+            </systemPropertyVariables>
+          </configuration>
+        </plugin>
+      </plugins>
     </build>
 </project>
similarity index 96%
rename from services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java
rename to services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceIT.java
index fef0017ccec5dfb49f3d340622807acc0124ccef..245b6d403fa1da528285de15d978ad9ebc7f4948 100644 (file)
@@ -29,6 +29,7 @@ import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import org.collectionspace.serivces.blob.StaticImage;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.MediaClient;
 import org.collectionspace.services.client.PayloadOutputPart;
@@ -49,11 +50,9 @@ import org.slf4j.LoggerFactory;
  * $LastChangedRevision:  $
  * $LastChangedDate:  $
  */
-public class MediaServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, MediaCommon> {
+public class MediaServiceIT extends AbstractPoxServiceTestImpl<AbstractCommonList, MediaCommon> {
 
-    private final String CLASS_NAME = MediaServiceTest.class.getName();
-    private final Logger logger = LoggerFactory.getLogger(MediaServiceTest.class);
-    private final static String PUBLIC_URL_DECK = "https://farm8.staticflickr.com/7231/6962564226_4bdfc17599_k_d.jpg";
+    private final Logger logger = LoggerFactory.getLogger(MediaServiceIT.class);
 
     private boolean mediaCleanup = true;
 
@@ -77,7 +76,7 @@ public class MediaServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonL
     }
 
 
-    @Override
+       @Override
        public String getServicePathComponent() {
                return MediaClient.SERVICE_PATH_COMPONENT;
        }
@@ -206,7 +205,7 @@ public class MediaServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonL
     public void createMediaAndBlobWithUri(String testName) throws Exception {
                MediaClient client = new MediaClient();
                PoxPayloadOut multipart = createMediaInstance(createIdentifier());
-               Response mediaRes = client.createMediaAndBlobWithUri(multipart, PUBLIC_URL_DECK, true); // purge the original
+               Response mediaRes = client.createMediaAndBlobWithUri(multipart, StaticImage.DECK.getUrl(), true); // purge the original
                String mediaCsid = null;
                try {
                        assertStatusCode(mediaRes, testName);
index 1a3623c7fb096f9cb5f5d28c37c71276567e9a9e..2ccb0db6f12e2a7ecd9c89517caf6ef24455493f 100644 (file)
       <artifactId>org.collectionspace.services.restrictedmedia.jaxb</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.collectionspace.services</groupId>
+      <artifactId>org.collectionspace.services.person.client</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.collectionspace.services.blob</groupId>
+      <artifactId>blob-test-utils</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
 
     <!-- External dependencies -->
     <dependency>
 
   <build>
     <finalName>collectionspace-services-restrictedmedia-client</finalName>
+
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-remote-resources-plugin</artifactId>
+        <configuration>
+          <resourceBundles>
+            <resourceBundle>org.collectionspace.services.blob:blob-test-utils:${project.version}</resourceBundle>
+          </resourceBundles>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>process</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>3.6.0</version>
+        <configuration>
+          <portNames>
+            <portName>jetty.port</portName>
+            <portName>jetty.stop.port</portName>
+          </portNames>
+          <fileSet/>
+          <name/>
+          <regex/>
+          <source/>
+          <value/>
+        </configuration>
+        <executions>
+          <execution>
+            <id>reserve-port</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>reserve-network-port</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>3.5.3</version>
+        <configuration>
+          <excludes>
+            <exclude>**/*IT.class</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.eclipse.jetty</groupId>
+        <artifactId>jetty-maven-plugin</artifactId>
+        <configuration>
+          <httpConnector>
+            <port>${jetty.port}</port>
+          </httpConnector>
+          <stopKey>quit</stopKey>
+          <stopPort>${jetty.stop.port}</stopPort>
+          <stopWait>10</stopWait>
+          <contextHandlers>
+            <contextHandler implementation="org.eclipse.jetty.server.handler.ContextHandler">
+              <contextPath>/static</contextPath>
+              <resourceBase>${project.build.directory}/maven-shared-archive-resources</resourceBase>
+              <handler implementation="org.eclipse.jetty.server.handler.ResourceHandler" />
+            </contextHandler>
+          </contextHandlers>
+          <supportedPackagings>jar</supportedPackagings>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <configuration>
+          <systemPropertyVariables>
+            <jetty.port>${jetty.port}</jetty.port>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
-</project>
\ No newline at end of file
+</project>
@@ -28,6 +28,8 @@ import java.util.List;
 import java.util.UUID;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+
+import org.collectionspace.serivces.blob.StaticImage;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadOut;
@@ -45,10 +47,9 @@ import org.testng.annotations.Test;
 /**
  * RestrictedMediaServiceTest, carries out tests against a deployed and running Restricted Media Service.
  */
-public class RestrictedMediaServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, RestrictedMediaCommon> {
+public class RestrictedMediaServiceIT extends AbstractPoxServiceTestImpl<AbstractCommonList, RestrictedMediaCommon> {
 
-    private final Logger logger = LoggerFactory.getLogger(RestrictedMediaServiceTest.class);
-    private static final String PUBLIC_URL_DECK = "https://farm8.staticflickr.com/7231/6962564226_4bdfc17599_k_d.jpg";
+    private final Logger logger = LoggerFactory.getLogger(RestrictedMediaServiceIT.class);
 
     private boolean mediaCleanup = true;
 
@@ -199,7 +200,7 @@ public class RestrictedMediaServiceTest extends AbstractPoxServiceTestImpl<Abstr
         PoxPayloadOut multipart = createMediaInstance(createIdentifier());
 
         // purge the original
-        Response mediaRes = client.createMediaAndBlobWithUri(multipart, PUBLIC_URL_DECK, true);
+        Response mediaRes = client.createMediaAndBlobWithUri(multipart, StaticImage.DECK.getUrl(), true);
         String mediaCsid = null;
         try {
             assertStatusCode(mediaRes, testName);