Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add additional sanity checks for optional components we're wiring int…
…o kitchen sink
  • Loading branch information
cbeer committed Jun 11, 2013
1 parent dd123ee commit 23a3011
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 3 deletions.
14 changes: 14 additions & 0 deletions pom.xml
Expand Up @@ -29,6 +29,11 @@
<artifactId>fcrepo-rss</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-metrics</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-legacy-api</artifactId>
Expand Down Expand Up @@ -155,6 +160,15 @@
<artifactId>fcrepo-fixity-corrupter</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-http-commons</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>

<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/spring/master.xml
Expand Up @@ -9,10 +9,10 @@
<import resource="classpath:/spring/eventing.xml"/>
<import resource="classpath:/spring/generator.xml"/>
<import resource="classpath:/spring/repo.xml"/>
<import resource="classpath:/spring/rest.xml"/>
<import resource="classpath:/spring/transactions.xml"/>
<import resource="classpath:/spring/atom_jms.xml"/>
<import resource="classpath:/spring/optional_modules.xml"/>
<import resource="classpath:/spring/rest.xml"/>
<import resource="classpath:/spring/transactions.xml"/>
<import resource="classpath:/spring/metrics_reporting.xml"/>
<import resource="classpath:/spring/policy_driven_storage.xml"/>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/spring/optional_modules.xml
Expand Up @@ -12,6 +12,6 @@
<context:annotation-config/>

<context:component-scan
base-package="org.fcrepo.syndication, org.fcrepo.webhooks"/>
base-package="org.fcrepo.syndication, org.fcrepo.webhooks, org.fcrepo.legacy"/>

</beans>
25 changes: 25 additions & 0 deletions src/test/java/org/fcrepo/integration/KitchenSinkIT.java
Expand Up @@ -2,16 +2,22 @@
package org.fcrepo.integration;

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

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.update.GraphStore;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.fcrepo.RdfLexicon;
import org.fcrepo.test.util.TestHelpers;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -62,6 +68,20 @@ public void doASanityCheck() throws IOException {
"rest/")));
}

@Test
public void shouldContainOptionalServicesLinks() throws IOException {
final HttpGet httpGet = new HttpGet(serverAddress + "rest/");
final HttpResponse response = client.execute(httpGet);

assertEquals(200, response.getStatusLine().getStatusCode());

final GraphStore graphStore = TestHelpers.parseTriples(response.getEntity().getContent());

assertTrue("expected to find fcr:rss link", graphStore.contains(Node.ANY, Node.createURI(serverAddress + "rest/"), RdfLexicon.HAS_FEED.asNode(), Node.createURI(serverAddress + "rest/fcr:rss")));
assertTrue("expected to find fcr:webhooks link", graphStore.contains(Node.ANY, Node.createURI(serverAddress + "rest/"), RdfLexicon.HAS_SUBSCRIPTION_SERVICE.asNode(), Node.createURI(serverAddress + "rest/fcr:webhooks")));

}

@Test
public void doAnRssSanityCheck() throws IOException {
assertEquals(200, getStatus(new HttpGet(serverAddress + "rest/fcr:rss")));
Expand All @@ -72,6 +92,11 @@ public void doWebhooksSanityCheck() throws IOException {
assertEquals(200, getStatus(new HttpGet(serverAddress + "rest/fcr:webhooks")));
}

@Test
public void doV3SanityCheck() throws IOException {
assertEquals(200, getStatus(new HttpGet(serverAddress + "rest/v3/describe")));
}

protected int getStatus(final HttpUriRequest method)
throws ClientProtocolException, IOException {
logger.debug("Executing: " + method.getMethod() + " to " +
Expand Down
72 changes: 72 additions & 0 deletions src/test/java/org/fcrepo/integration/MetricsIT.java
@@ -0,0 +1,72 @@
package org.fcrepo.integration;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;

public class MetricsIT {

/**
* The server port of the application, set as system property by
* maven-failsafe-plugin.
*/
private static final String SERVER_PORT = System.getProperty("test.port");

/**
* The context path of the application (including the leading "/"), set as
* system property by maven-failsafe-plugin.
*/
private static final String CONTEXT_PATH = System
.getProperty("test.context.path");

protected Logger logger;

@Before
public void setLogger() {
logger = LoggerFactory.getLogger(this.getClass());
}

protected static final String HOSTNAME = "localhost";

protected static final String serverAddress = "http://" + HOSTNAME + ":" +
SERVER_PORT + CONTEXT_PATH;

protected static final PoolingClientConnectionManager connectionManager =
new PoolingClientConnectionManager();

protected static HttpClient client;

static {
connectionManager.setMaxTotal(Integer.MAX_VALUE);
connectionManager.setDefaultMaxPerRoute(5);
connectionManager.closeIdleConnections(3, TimeUnit.SECONDS);
client = new DefaultHttpClient(connectionManager);
}

@Test
public void doASanityCheck() throws IOException {
assertEquals(200, getStatus(new HttpGet(serverAddress +
"metrics/")));
}



protected int getStatus(final HttpUriRequest method)
throws ClientProtocolException, IOException {
logger.debug("Executing: " + method.getMethod() + " to " +
method.getURI());
return client.execute(method).getStatusLine().getStatusCode();
}
}

0 comments on commit 23a3011

Please sign in to comment.