Commits

Sam Adams  committed 6178dba

Fix up dependencies

  • Participants
  • Parent commits e422032

Comments (0)

Files changed (17)

File acceptance-test-driver/pom.xml

         <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest-core</artifactId>
-            <version>1.2.1</version>
         </dependency>
 
         <dependency>

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

 
 import net.chempound.acceptance.dsl.driver.Resource;
 import net.chempound.acceptance.dsl.server.ChempoundServer;
-import org.hamcrest.Matcher;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import java.net.URI;
 import java.util.Random;
 
-import static java.util.Arrays.asList;
-import static org.junit.Assert.assertThat;
-
 /**
  * @author Sam Adams
  */
         return new Resource(testContext.actual(path), "mime/type", generateContent());
     }
 
-    @SuppressWarnings("unchecked")
-    protected static <T, U extends T> void verify(final U target, final Matcher<T> matcher) {
-        verify(target, asList(matcher));
-    }
-
-    @SuppressWarnings("unchecked")
-    protected static <T, U extends T> void verify(final U target, final Matcher<T> matcher1, final Matcher<T> matcher2) {
-        verify(target, asList(matcher1, matcher2));
-    }
-
-    protected static <T, U extends T> void verify(final U target, final Iterable<Matcher<T>> matchers) {
-        for (final Matcher<T> matcher : matchers) {
-            assertThat(target, matcher);
-        }
-    }
-
     private static byte[] generateContent() {
         final byte[] bytes = new byte[1024];
         final Random random = new Random();

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

+package net.chempound.acceptance.dsl;
+
+import org.hamcrest.Matcher;
+
+import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThat;
+
+public class Verifier {
+    @SuppressWarnings("unchecked")
+    public static <T, U extends T> void verify(final U target, final Matcher<T> matcher) {
+        verify(target, asList(matcher));
+    }
+
+    @SuppressWarnings("unchecked")
+    public static <T, U extends T> void verify(final U target, final Matcher<T> matcher1, final Matcher<T> matcher2) {
+        verify(target, asList(matcher1, matcher2));
+    }
+
+    public static <T, U extends T> void verify(final U target, final Iterable<Matcher<T>> matchers) {
+        for (final Matcher<T> matcher : matchers) {
+            assertThat(target, matcher);
+        }
+    }
+}

File acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/driver/api/PingbackDriver.java

 package net.chempound.acceptance.dsl.driver.api;
 
 import net.chempound.acceptance.dsl.TestContext;
-import net.chempound.webapp.pingback.PingbackFault;
 import nu.xom.Builder;
 import nu.xom.Document;
 import nu.xom.Nodes;

File acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/driver/api/PingbackFault.java

+package net.chempound.acceptance.dsl.driver.api;
+
+public enum PingbackFault {
+
+    GENERIC_FAULT(0),
+    SOURCE_URI_DOES_NOT_EXIST(16),
+    SOURCE_URI_DOES_NOT_LINK_TO_TARGET(17),
+    TARGET_URI_DOES_NOT_EXIST(32),
+    TARGET_URI_INVALID(33),
+    ALREADY_REGISTERED(48),
+    ACCESS_DENIED(49),
+    COMMUNICATION_ERROR(50);
+
+    private final int code;
+
+    private PingbackFault(final int code) {
+        this.code = code;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+}

File acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/driver/sword/SwordClientDriver.java

         swordClient.getStatement(statementUrl, new OreStatement(), null);
     }
 
-    public SwordResponse deleteItem(final String deleteUrl) throws Exception {
-        return swordClient.delete(deleteUrl, null);
+    public SwordResult deleteItem(final String deleteUrl) throws Exception {
+        return new SwordResult(swordClient.delete(deleteUrl, null));
     }
 
     public void deleteFileFromItem(final String deleteUrl) throws Exception {
         swordClient.delete(deleteUrl, null);
     }
 
-    public SwordResponse replaceItem(final String editUri, final DepositSpecification... specifications) throws Exception {
+    public SwordResult replaceItem(final String editUri, final DepositSpecification... specifications) throws Exception {
         final DepositInstruction instruction = createDepositInstruction(specifications);
-        return swordClient.replace(editUri, createDeposit(instruction), null);
+        return new SwordResult(swordClient.replace(editUri, createDeposit(instruction), null));
     }
 
-    public SwordResponse replaceMedia(final String editMediaUri, final DepositSpecification... specifications) throws Exception {
+    public SwordResult replaceMedia(final String editMediaUri, final DepositSpecification... specifications) throws Exception {
         final DepositInstruction instruction = createDepositInstruction(specifications);
-        return swordClient.replace(editMediaUri, createDeposit(instruction), null);
+        return new SwordResult(swordClient.replace(editMediaUri, createDeposit(instruction), null));
     }
 
     public SwordDepositReceipt addToItem(final String editUri, final DepositSpecification... specifications) throws Exception {
         return new SwordDepositReceipt(depositReceipt);
     }
 
-    public SwordResponse addToMedia(final String editMediaUri, final DepositSpecification... specifications) throws Exception {
+    public SwordResult addToMedia(final String editMediaUri, final DepositSpecification... specifications) throws Exception {
         final DepositInstruction instruction = createDepositInstruction(specifications);
-        return swordClient.addToMediaResource(editMediaUri, createDeposit(instruction), null);
+        return new SwordResult(swordClient.addToMediaResource(editMediaUri, createDeposit(instruction), null));
     }
 
     public void getContentAsZipFile(final String contentUri) throws Exception {

File acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/driver/sword/SwordResult.java

+package net.chempound.acceptance.dsl.driver.sword;
+
+import org.swordapp.client.SwordResponse;
+
+public class SwordResult {
+
+    private final SwordResponse response;
+
+    public SwordResult(final SwordResponse response) {
+        this.response = response;
+    }
+
+    public int getStatusCode() {
+        return response.getStatusCode();
+    }
+}

File acceptance-tests/pom.xml

     <dependencies>
 
         <dependency>
-            <groupId>net.chempound</groupId>
-            <artifactId>chempound-api</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>net.chempound</groupId>
-            <artifactId>chempound-webapp</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>net.chempound.compchem</groupId>
-            <artifactId>compchem-importer</artifactId>
-            <version>0.1-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>net.chempound.acceptance</groupId>
             <artifactId>acceptance-test-driver</artifactId>
             <version>0.1-SNAPSHOT</version>
         </dependency>
 
         <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-core</artifactId>
+            <scope>test</scope>
+        </dependency>
 
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <configuration>
+                    <usedDependencies>
+                        <usedDependency>org.hamcrest:hamcrest-core</usedDependency>
+                    </usedDependencies>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>

File acceptance-tests/src/test/java/net/chempound/acceptance/PingbackAcceptanceTest.java

 package net.chempound.acceptance;
 
 import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
+import net.chempound.acceptance.dsl.driver.api.PingbackFault;
 import net.chempound.acceptance.dsl.server.StubBlogServer;
 import net.chempound.acceptance.dsl.driver.api.APIDriver;
 import net.chempound.acceptance.dsl.driver.api.DepositReceipt;
 
 import static net.chempound.acceptance.dsl.driver.DepositSpecifications.withTitle;
 import static net.chempound.acceptance.dsl.driver.ItemMatchers.hasPingbacks;
-import static net.chempound.webapp.pingback.PingbackFault.*;
 
 /**
  * @author Sam Adams
 
         pingbackDriver.pingback(item.getUri(), blog);
 
-        pingbackDriver.pingback(item.getUri(), blog, ALREADY_REGISTERED);
+        pingbackDriver.pingback(item.getUri(), blog, PingbackFault.ALREADY_REGISTERED);
     }
 
     @Test
 
         URI blog = blogServer.addPost(itemUri);
 
-        pingbackDriver.doPingback(itemUri, blog, TARGET_URI_INVALID, testContext.getPingbackUrl());
+        pingbackDriver.doPingback(itemUri, blog, PingbackFault.TARGET_URI_INVALID, testContext.getPingbackUrl());
     }
 
     @Test
     public void shouldRejectPingbackWithBadSourceUrl() throws Exception {
         URI blog = blogServer.addPost(item.getUri());
 
-        pingbackDriver.pingback(item.getUri(), blog.resolve("--does-not-exist"), SOURCE_URI_DOES_NOT_EXIST);
+        pingbackDriver.pingback(item.getUri(), blog.resolve("--does-not-exist"), PingbackFault.SOURCE_URI_DOES_NOT_EXIST);
     }
 
     @Test
     public void shouldRejectPingbackThatDoesNotLinkToTargetPage() throws Exception {
         URI blog = blogServer.addPost(URI.create("http://www.example.com/other-target"));
 
-        pingbackDriver.pingback(item.getUri(), blog, SOURCE_URI_DOES_NOT_LINK_TO_TARGET);
+        pingbackDriver.pingback(item.getUri(), blog, PingbackFault.SOURCE_URI_DOES_NOT_LINK_TO_TARGET);
     }
 
     @Test

File acceptance-tests/src/test/java/net/chempound/acceptance/api/DepositAcceptanceTest.java

 package net.chempound.acceptance.api;
 
 import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
+import net.chempound.acceptance.dsl.Verifier;
 import net.chempound.acceptance.dsl.driver.Resource;
 import net.chempound.acceptance.dsl.driver.api.APIDriver;
 import net.chempound.acceptance.dsl.driver.api.DepositReceipt;
     public void shouldCreateItemOnMetadataOnlyDeposit() {
         DepositReceipt item = apiDriver.depositItem(withSlug("slug"), withTitle("title"));
 
-        verify(item, hasTitle("title"), hasSlug("slug"));
+        Verifier.verify(item, hasTitle("title"), hasSlug("slug"));
     }
 
     @Test
         
         DepositReceipt item = apiDriver.depositItem(withFile(file));
 
-        verify(item, hasFiles(file.getPath()));
+        Verifier.verify(item, hasFiles(file.getPath()));
     }
 
     @Test
 
         DepositReceipt item = apiDriver.depositItem(withFiles(file1, file2, file3));
 
-        verify(item, hasFiles(file1.getPath(), file2.getPath(), file3.getPath()));
+        Verifier.verify(item, hasFiles(file1.getPath(), file2.getPath(), file3.getPath()));
     }
 
     @Test
 
         DepositReceipt item = apiDriver.depositItem(withTitle("title"), withFile(file), asMultipart(true));
 
-        verify(item, hasTitle("title"), hasFiles(file.getPath()));
+        Verifier.verify(item, hasTitle("title"), hasFiles(file.getPath()));
     }
 
     @Test
 
         DepositReceipt item = apiDriver.depositItem(withTitle("title"), withFiles(file1, file2, file3), asMultipart(true));
 
-        verify(item, hasTitle("title"), hasFiles(file1.getPath(), file2.getPath(), file3.getPath()));
+        Verifier.verify(item, hasTitle("title"), hasFiles(file1.getPath(), file2.getPath(), file3.getPath()));
     }
 
     @Test
     public void shouldSupportInProgressDeposit() {
         DepositReceipt item = apiDriver.depositItem(withTitle("title"), inProgress(true));
 
-        verify(item, hasTitle("title"), isInProgress(true));
+        Verifier.verify(item, hasTitle("title"), isInProgress(true));
     }
 
 }

File acceptance-tests/src/test/java/net/chempound/acceptance/chemistry/GaussianLogAcceptanceTest.java

-package net.chempound.acceptance.chemistry;
-
-import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
-import net.chempound.acceptance.dsl.driver.api.APIDriver;
-import net.chempound.acceptance.dsl.driver.Resource;
-import net.chempound.compchem.gaussian.GaussianLogImporter;
-import net.chempound.content.DepositRequest;
-import net.chempound.storage.DepositResource;
-import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import static net.chempound.acceptance.dsl.driver.DepositSpecifications.*;
-
-/**
- * @author Sam Adams
- */
-@Ignore
-public class GaussianLogAcceptanceTest extends AbstractAcceptanceTest {
-
-    private APIDriver apiDriver;
-
-    @Before
-    public void setUp() throws Exception {
-        apiDriver = driverFactory.createAPIDriver();
-    }
-
-    @Test
-    public void shouldDepositGaussianLogFile() throws Exception {
-
-        final DepositRequest depositRequest;
-        final InputStream in = getClass().getResourceAsStream("gaussian.log");
-        try {
-            final GaussianLogImporter importer = new GaussianLogImporter();
-            importer.setLogFile(in, "gaussian.log");
-            depositRequest = importer.generateDepositRequest();
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
-
-        final List<Resource> files = new ArrayList<Resource>();
-        for (DepositResource resource : depositRequest.getAggregatedResources()) {
-            files.add(new Resource(resource.getURI(), resource.getMimeType().getName(), IOUtils.toByteArray(resource.openInputStream())));
-        }
-
-        apiDriver.depositItem(withSlug("slug"), withTitle("title"), withMetadata(depositRequest.getMetadataModel()), withFiles(files));
-
-        Assert.fail("work in progress");
-    }
-
-}

File acceptance-tests/src/test/java/net/chempound/acceptance/chemistry/NwChemLogAcceptanceTest.java

-package net.chempound.acceptance.chemistry;
-
-import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
-import net.chempound.acceptance.dsl.driver.api.APIDriver;
-import net.chempound.acceptance.dsl.driver.Resource;
-import net.chempound.compchem.nwchem.NWChemLogImporter;
-import net.chempound.content.DepositRequest;
-import net.chempound.storage.DepositResource;
-import org.apache.commons.io.IOUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import static net.chempound.acceptance.dsl.driver.DepositSpecifications.*;
-
-/**
- * @author Sam Adams
- */
-@Ignore
-public class NwChemLogAcceptanceTest extends AbstractAcceptanceTest {
-
-    private APIDriver apiDriver;
-
-    @Before
-    public void setUp() throws Exception {
-        apiDriver = driverFactory.createAPIDriver();
-    }
-
-    @Test
-    public void shouldDepositNwChemLogFile() throws Exception {
-
-        final DepositRequest depositRequest;
-        final InputStream in = getClass().getResourceAsStream("h2o_631gs.nwo");
-        try {
-            final NWChemLogImporter importer = new NWChemLogImporter();
-            importer.setLogFile(in, "h2o_631gs.nwo");
-            depositRequest = importer.generateDepositRequest();
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
-
-
-        final List<Resource> files = new ArrayList<Resource>();
-        for (DepositResource resource : depositRequest.getAggregatedResources()) {
-            files.add(new Resource(resource.getURI(), resource.getMimeType().getName(), IOUtils.toByteArray(resource.openInputStream())));
-        }
-
-        apiDriver.depositItem(withSlug("slug"), withTitle("title"), withMetadata(depositRequest.getMetadataModel()), withFiles(files));
-
-        Assert.fail("work in progress");
-    }
-
-}

File acceptance-tests/src/test/java/net/chempound/acceptance/sword/DeleteAcceptanceTest.java

 package net.chempound.acceptance.sword;
 
 import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
+import net.chempound.acceptance.dsl.Verifier;
 import net.chempound.acceptance.dsl.driver.Resource;
 import net.chempound.acceptance.dsl.driver.api.APIDriver;
 import net.chempound.acceptance.dsl.driver.api.DepositReceipt;
 import net.chempound.acceptance.dsl.driver.sword.SwordClientDriver;
 import net.chempound.acceptance.dsl.driver.sword.SwordCollection;
+import net.chempound.acceptance.dsl.driver.sword.SwordResult;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.swordapp.client.SwordResponse;
 
 import static net.chempound.acceptance.dsl.driver.DepositSpecifications.withFile;
 import static net.chempound.acceptance.dsl.driver.sword.SwordCollectionMatchers.doesNotHaveEntry;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
 
 public class DeleteAcceptanceTest extends AbstractAcceptanceTest {
 
 
     @Test
     public void shouldDeleteItem() throws Exception {
-        final SwordResponse response = swordDriver.deleteItem(item.getEditUri().toString());
+        final SwordResult response = swordDriver.deleteItem(item.getEditUri().toString());
 
         assertEquals(204, response.getStatusCode());
         apiDriver.verifyResourceDoesNotExist(item.getUri());
     @Test
 //    @Ignore("work in progress")
     public void shouldRemoveDeletedItemFromParentCollection() throws Exception {
-        final SwordResponse response = swordDriver.deleteItem(item.getEditUri().toString());
+        final SwordResult response = swordDriver.deleteItem(item.getEditUri().toString());
 
         assertEquals(204, response.getStatusCode());
         final SwordCollection collection = swordDriver.getCollection(testContext.getRootUri().resolve("sword/collection/"));
-        verify(collection, doesNotHaveEntry());
+        Verifier.verify(collection, doesNotHaveEntry());
     }
 
 
     @Test
     @Ignore("work in progress")
     public void shouldDeleteFileFromItem() throws Exception {
-        final SwordResponse response = swordDriver.deleteItem(item.getEditMediaUri().resolve(file.getPath()).toString());
+        final SwordResult response = swordDriver.deleteItem(item.getEditMediaUri().resolve(file.getPath()).toString());
         assertEquals(204, response.getStatusCode());
 
         apiDriver.verifyResourceDoesNotExist(item.getUri().resolve(file.getPath()));
     @Test
     @Ignore("work in progress")
     public void shouldNotDeleteUnknownItem() throws Exception {
-        final SwordResponse response = swordDriver.deleteItem(testContext.getRootUri().resolve("sword/edit/foo/").toString());
+        final SwordResult response = swordDriver.deleteItem(testContext.getRootUri().resolve("sword/edit/foo/").toString());
         assertEquals(404, response.getStatusCode());
     }
 
     @Test
     @Ignore("work in progress")
     public void shouldNotDeleteUnknownFile() throws Exception {
-        final SwordResponse response = swordDriver.deleteItem(testContext.getRootUri().resolve("sword/edit-media/foo/").toString());
+        final SwordResult response = swordDriver.deleteItem(testContext.getRootUri().resolve("sword/edit-media/foo/").toString());
         assertEquals(404, response.getStatusCode());
     }
 }

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

 package net.chempound.acceptance.sword;
 
 import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
+import net.chempound.acceptance.dsl.Verifier;
 import net.chempound.acceptance.dsl.driver.api.APIDriver;
 import net.chempound.acceptance.dsl.driver.sword.SwordClientDriver;
 import net.chempound.acceptance.dsl.driver.sword.SwordDepositReceipt;
 //    @Ignore("work in progress")
     public void shouldSupportMetaDataOnlyDeposit() throws Exception {
         final SwordDepositReceipt depositReceipt = swordDriver.depositItem(withSlug("slug"), withTitle("title"));
-        verify(depositReceipt, hasTitle("title"), hasSlug("slug"));
+        Verifier.verify(depositReceipt, hasTitle("title"), hasSlug("slug"));
     }
 
     @Test
 
         final SwordDepositReceipt copyOfDepositReceipt = swordDriver.getDepositReceipt(depositReceipt.getEditUri());
 
-        verify(copyOfDepositReceipt, hasSlug("slug"));
+        Verifier.verify(copyOfDepositReceipt, hasSlug("slug"));
     }
 }

File acceptance-tests/src/test/java/net/chempound/acceptance/sword/ListCollectionAcceptanceTest.java

 package net.chempound.acceptance.sword;
 
 import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
+import net.chempound.acceptance.dsl.Verifier;
 import net.chempound.acceptance.dsl.driver.api.APIDriver;
 import net.chempound.acceptance.dsl.driver.api.DepositReceipt;
 import net.chempound.acceptance.dsl.driver.sword.SwordClientDriver;
 
         final SwordCollection collection = swordDriver.getCollection(testContext.getRootUri().resolve("sword/collection/"));
 
-        verify(collection, SwordCollectionMatchers.hasEntry(SwordCollectionMatchers.hasId(depositReceipt.getUri()), SwordCollectionMatchers.hasTitle("title", testContext), SwordCollectionMatchers.hasEditUri(testContext.getRootUri())));
+        Verifier.verify(collection, SwordCollectionMatchers.hasEntry(SwordCollectionMatchers.hasId(depositReceipt.getUri()), SwordCollectionMatchers.hasTitle("title", testContext), SwordCollectionMatchers.hasEditUri(testContext.getRootUri())));
     }
 
 }

File acceptance-tests/src/test/java/net/chempound/acceptance/sword/ServiceDocumentAcceptanceTest.java

 package net.chempound.acceptance.sword;
 
 import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
+import net.chempound.acceptance.dsl.Verifier;
 import net.chempound.acceptance.dsl.driver.sword.SwordClientDriver;
 import net.chempound.acceptance.dsl.driver.sword.SwordServiceDocument;
 import org.junit.Before;
     @Test
     public void shouldProvideSwordStatement() throws Exception {
         final SwordServiceDocument serviceDocument = swordDriver.getServiceDocument();
-        verify(serviceDocument, hasVersion("2.0"), hasMaxUploadSize("-1"));
+        Verifier.verify(serviceDocument, hasVersion("2.0"), hasMaxUploadSize("-1"));
     }
 }
                 <version>${restlet.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>org.hamcrest</groupId>
+                <artifactId>hamcrest-core</artifactId>
+                <version>1.3</version>
+            </dependency>
+
         </dependencies>
 
     </dependencyManagement>