Sam Adams avatar Sam Adams committed 707dd0e

Fixed matcher checking

Comments (0)

Files changed (3)

acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/AbstractAcceptanceTest.java

 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Stage;
+import net.chempound.acceptance.dsl.driver.Resource;
 import org.apache.commons.io.FileUtils;
 import org.hamcrest.Matcher;
 import org.junit.After;
 
 import java.io.File;
 import java.net.URI;
+import java.util.Random;
 import java.util.UUID;
 
+import static org.junit.Assert.assertThat;
+
 /**
  * @author Sam Adams
  */
 
     private static final URI ROOT = URI.create("http://localhost:12345/chempound/");
 
+    private static final String RESOURCE_CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-=";
+
     private static Component component;
     private static File workspace;
     private static int port;
         FileUtils.forceMkdir(workspace);
 
         final Injector injector = Guice.createInjector(Stage.DEVELOPMENT,
-            new ChempoundTestModule(port, workspace)
+                                                       new ChempoundTestModule(port, workspace)
         );
 
         component = injector.getInstance(Component.class);
         component.getServers().add(Protocol.HTTP, port)
-            .getContext().getParameters().add("maxThreads", "256");
+         .getContext().getParameters().add("maxThreads", "256");
         component.getDefaultHost()
-            .attach("/chempound", injector.getInstance(Application.class));
+         .attach("/chempound", injector.getInstance(Application.class));
 
         component.start();
     }
         }
     }
 
-    public static <T, U extends T> void check(final U target, final Matcher<T>... matchers) {
+    protected static <T, U extends T> void check(final U target, final Matcher<T>... matchers) {
+        for (final Matcher<T> matcher : matchers) {
+            assertThat(target, matcher);
+        }
+    }
 
+    protected Resource newResource(final String path) {
+        return new Resource(testContext.actual(path), "mime/type", generateContent());
+    }
+
+    private static byte[] generateContent() {
+        final byte[] bytes = new byte[1024];
+        final Random random = new Random();
+        for (int i = 0; i < bytes.length; i++) {
+            bytes[i] = (byte) (0xff & RESOURCE_CHARS.charAt(random.nextInt(RESOURCE_CHARS.length())));
+        }
+        return bytes;
     }
 
 }

acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/driver/APIDriver.java

 import net.chempound.storage.InMemoryResource;
 import net.chempound.storage.LocalResource;
 import net.chempound.util.MimeType;
+import org.hamcrest.Matcher;
 
 import java.net.URI;
 
+import static org.junit.Assert.assertThat;
+
 /**
  * @author Sam Adams
  */
     private static LocalResource createResource(final Resource file) {
         return new InMemoryResource(file.getPath(), new MimeType(file.getMimeType()), file.getContent());
     }
-
 }

acceptance-tests/src/test/java/net/chempound/acceptance/sword/DepositAcceptanceTest.java

         Assert.fail("work in progress");
     }
 
-    private Resource newResource(final String path) {
-        return new Resource(testContext.actual(path), "mime/type", generateContent());
-    }
-
-    private static byte[] generateContent() {
-        byte[] bytes = new byte[1024];
-        new Random().nextBytes(bytes);
-        return bytes;
-    }
-
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.