Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More tests. It's what we do.
  • Loading branch information
ajs6f committed Feb 6, 2013
1 parent 185c431 commit 7ed1c9a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
Expand Up @@ -5,7 +5,10 @@

@XmlRootElement(name = "fedoraRepository", namespace = "http://www.fedora.info/definitions/1/0/access/")
public class DescribeRepository {

public static final String FEDORA_VERSION = "4.0-modeshape-candidate";

@XmlElement
protected String repositoryVersion = "4.0-modeshape-candidate";
protected String repositoryVersion = FEDORA_VERSION;

}
8 changes: 4 additions & 4 deletions src/test/java/org/fcrepo/modeshape/FedoraIdentifiersTest.java
@@ -1,6 +1,7 @@
package org.fcrepo.modeshape;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void testGetNextHasAPid() throws HttpException, IOException {
logger.debug("Executed testGetNextHasAPid()");
String response = method.getResponseBodyAsString(Integer.MAX_VALUE);
logger.debug("Only to find:\n" + response);
assertEquals("Didn't find a single dang PID!", true,
assertTrue("Didn't find a single dang PID!",
Pattern.compile("<pid>.*?</pid>").matcher(response).find());
}

Expand All @@ -58,12 +59,11 @@ public void testGetNextHasTwoPids() throws HttpException, IOException {
+ "/nextPID?numPids=2");
method.addRequestHeader("Accepts", "text/xml");
client.executeMethod(method);
logger.debug("Executed testGetNextHasAPid()");
logger.debug("Executed testGetNextHasTwoPids()");
String response = method.getResponseBodyAsString(Integer.MAX_VALUE);
logger.debug("Only to find:\n" + response);
assertEquals(
assertTrue(
"Didn't find a two dang PIDs!",
true,
Pattern.compile("<pid>.*?</pid>.*?<pid>.*?</pid>",
Pattern.DOTALL).matcher(response).find());
}
Expand Down
26 changes: 21 additions & 5 deletions src/test/java/org/fcrepo/modeshape/FedoraRepositoryTest.java
@@ -1,21 +1,31 @@
package org.fcrepo.modeshape;

import static javax.ws.rs.core.MediaType.TEXT_XML;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.regex.Pattern;

import javax.ws.rs.core.MediaType;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/testContext.xml")
public class FedoraRepositoryTest {


int SERVER_PORT = 9999;

final private Logger logger = LoggerFactory
.getLogger(FedoraRepositoryTest.class);

@Test
public void testDescribeModeshape() throws Exception {
HttpClient client = new HttpClient();
Expand All @@ -26,20 +36,26 @@ public void testDescribeModeshape() throws Exception {
}

@Test
public void testDescribe() throws Exception {
public void testGetObjects() throws Exception {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://localhost:" + SERVER_PORT
+ "/describe");
+ "/objects");
int status = client.executeMethod(method);
assertEquals(200, status);
}

@Test
public void testGetObjects() throws Exception {
public void testDescribe() throws Exception {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://localhost:" + SERVER_PORT
+ "/objects");
+ "/describe");
method.addRequestHeader("Accept", TEXT_XML);
int status = client.executeMethod(method);
assertEquals(200, status);
final String description = method.getResponseBodyAsString();
logger.debug("Found a repository description:\n" + description);
assertTrue("Failed to find a proper repo versiom",
Pattern.compile("<repositoryVersion>.*?</repositoryVersion>")
.matcher(description).find());
}
}

0 comments on commit 7ed1c9a

Please sign in to comment.