Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Enable WebContainer integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Woods committed Aug 20, 2013
1 parent b8a8bed commit 443e523
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 11 deletions.
37 changes: 28 additions & 9 deletions pom.xml
Expand Up @@ -18,6 +18,7 @@
<activemq.version>5.7.0</activemq.version>
<abdera.version>1.1.3</abdera.version>
</properties>

<dependencies>
<dependency>
<groupId>javax.jms</groupId>
Expand Down Expand Up @@ -91,9 +92,20 @@
<artifactId>jersey-grizzly2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2-servlet</artifactId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -178,6 +190,12 @@
<artifactId>fcrepo-http-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-http-api</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-kernel</artifactId>
Expand All @@ -190,6 +208,13 @@
<version>${project.version}</version>
<scope>test</scope>
</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>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
Expand Down Expand Up @@ -238,14 +263,8 @@
</resources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<argLine>-Xms512m -Xmx512m -XX:MaxPermSize=256m</argLine>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
9 changes: 7 additions & 2 deletions src/test/java/org/fcrepo/indexer/FileSerializerIT.java
Expand Up @@ -2,6 +2,7 @@
package org.fcrepo.indexer;

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

import java.io.File;
Expand All @@ -27,7 +28,7 @@
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/spring-test/master.xml"})
@ContextConfiguration({"/spring-test/test-container.xml"})
public class FileSerializerIT {

protected static final int SERVER_PORT = Integer.parseInt(System
Expand All @@ -48,7 +49,6 @@ public class FileSerializerIT {

private static SimpleDateFormat fmt = new SimpleDateFormat("HHmmssSSS");

@Inject
private FileSerializer fileSerializer;
private File fileSerializerPath;

Expand All @@ -58,6 +58,7 @@ public FileSerializerIT() {

@Before
public void setup() {
fileSerializer = new FileSerializer();
fileSerializerPath = new File("./target/test-classes/fileSerializer."
+ fmt.format(new Date()) );
fileSerializer.setPath( fileSerializerPath.getAbsolutePath() );
Expand All @@ -72,6 +73,10 @@ public void indexerGroupTest() throws IOException {
// file should exist and contain triple starting with URI
//File fileSerializerPath = new File(
// "./target/test-classes/fileSerializer");
File[] files = fileSerializerPath.listFiles();
assertNotNull(files);
assertTrue("files[] should not be empty", files.length > 0);

File f = fileSerializerPath.listFiles()[0];
assertTrue("Filename doesn't match: " + f.getAbsolutePath(),
f.getName().startsWith(TEST_PID) );
Expand Down
15 changes: 15 additions & 0 deletions src/test/resources/spring-test/test-container.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:property-placeholder/>

<bean id="containerWrapper" class="org.fcrepo.http.commons.test.util.ContainerWrapper" init-method="start" destroy-method="stop" >
<property name="port" value="${test.port:8080}"/>
<property name="configLocation" value="classpath:web.xml" />
</bean>

</beans>
38 changes: 38 additions & 0 deletions src/test/resources/web.xml
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0" metadata-complete="false">

<display-name>Fedora-on-ModeShape</display-name>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-test/master.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>org.fcrepo.kernel.services, org.fcrepo.http, org.fcrepo.indexer</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>

0 comments on commit 443e523

Please sign in to comment.