Skip to content

Commit

Permalink
Integrate the LDP test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Oct 6, 2014
1 parent 0981d03 commit 28670cd
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -13,3 +13,5 @@ ObjectStore/
*~
fcrepo4-data/
*.iml
fcrepo-integration-ldp/report
fcrepo-integration-ldp/test-output
178 changes: 178 additions & 0 deletions fcrepo-integration-ldp/pom.xml
@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>fcrepo</artifactId>
<groupId>org.fcrepo</groupId>
<version>4.0.0-beta-04-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<name>Fedora Repository LDP integration tests Module</name>
<description>Packaging the LDP integration test suite for fcrepo4</description>
<artifactId>fcrepo-integration-ldp</artifactId>

<dependencies>
<!-- test gear -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-configs</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</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-http-commons</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-auth-common</artifactId>
<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.glassfish.grizzly</groupId>
<artifactId>grizzly-http-server</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<scope>test</scope>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey.version}</version>
</dependency>

<dependency>
<groupId>org.w3</groupId>
<artifactId>ldp-testsuite</artifactId>
<version>0.1.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-sail-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-sail-memory</artifactId>
</exclusion>
<exclusion>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-queryresultio-api</artifactId>
</exclusion>
<exclusion>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
<exclusion>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- fixes for ldp-testsuite convergence problems -->
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-sail-api</artifactId>
<version>2.7.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-sail-memory</artifactId>
<version>2.7.13</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-queryresultio-api</artifactId>
<version>2.7.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
@@ -0,0 +1,79 @@
/**
* Copyright 2014 DuraSpace, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fcrepo.integration.ldp;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3.ldp.testsuite.LdpTestSuite;

import java.io.IOException;
import java.util.HashMap;
import java.util.UUID;

import static java.lang.Integer.MAX_VALUE;
import static java.lang.Integer.parseInt;
import static javax.ws.rs.core.Response.Status.CREATED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
* @author cabeer
* @since 10/6/14
*/

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

protected static final int SERVER_PORT = parseInt(System.getProperty(
"test.port", "8080"));

protected static final String HOSTNAME = "localhost";

protected static final String PROTOCOL = "http";

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

protected static HttpClient client = createClient();

protected static HttpClient createClient() {
return HttpClientBuilder.create().setMaxConnPerRoute(MAX_VALUE)
.setMaxConnTotal(MAX_VALUE).build();
}

@Test
public void runLDPTestSuite() throws IOException {
final String pid = "ldp-test-" + UUID.randomUUID().toString().substring(0,5);

final HttpResponse response = client.execute(new HttpPut(serverAddress + pid));
assertEquals(CREATED.getStatusCode(), response.getStatusLine().getStatusCode());

final HashMap<String, String> options = new HashMap<>();
options.put("server", serverAddress + pid);
options.put("direct", "true");
options.put("non-rdf", "true");
final LdpTestSuite testSuite = new LdpTestSuite(options);
testSuite.run();
assertTrue("The LDP test suite is only informational", true);
}
}
12 changes: 12 additions & 0 deletions fcrepo-integration-ldp/src/test/resources/spring-test/master.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<!-- Master context for the test application. -->

<import resource="classpath:/spring-test/repo.xml"/>
<import resource="classpath:/spring-test/rest.xml"/>

</beans>
22 changes: 22 additions & 0 deletions fcrepo-integration-ldp/src/test/resources/spring-test/repo.xml
@@ -0,0 +1,22 @@
<?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"
xmlns:p="http://www.springframework.org/schema/p"
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 that supports the actual ModeShape JCR itself -->

<context:annotation-config/>

<bean name="modeshapeRepofactory"
class="org.fcrepo.kernel.impl.spring.ModeShapeRepositoryFactoryBean"
p:repositoryConfiguration="${fcrepo.modeshape.configuration:test_repository.json}"/>

<bean class="org.modeshape.jcr.ModeShapeEngine" init-method="start"/>

<bean id="connectionManager" class="org.apache.http.impl.conn.PoolingHttpClientConnectionManager"/>

</beans>
23 changes: 23 additions & 0 deletions fcrepo-integration-ldp/src/test/resources/spring-test/rest.xml
@@ -0,0 +1,23 @@
<?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"
xmlns:util="http://www.springframework.org/schema/util"
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 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

<bean class="org.fcrepo.http.commons.session.SessionFactory"/>

<!-- Mints PIDs-->
<bean class="org.fcrepo.kernel.impl.identifiers.UUIDPidMinter"/>

<!-- Identifier translation chain -->
<util:list id="translationChain" value-type="org.fcrepo.kernel.identifiers.InternalIdentifierConverter">
<bean class="org.fcrepo.kernel.impl.identifiers.NamespaceConverter"/>
</util:list>

<context:annotation-config/>

<context:component-scan base-package="org.fcrepo"/>

</beans>
@@ -0,0 +1,16 @@
<?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"
xmlns:p="http://www.springframework.org/schema/p"
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" p:port="${test.port:8080}"
p:configLocation="classpath:web.xml"/>

</beans>
19 changes: 19 additions & 0 deletions fcrepo-integration-ldp/src/test/resources/test_repository.json
@@ -0,0 +1,19 @@
{
"name" : "repo",
"jndiName" : "",
"workspaces" : {
"predefined" : [],
"default" : "default",
"allowCreation" : true
},
"security" : {
"anonymous" : {
"roles" : ["readonly","readwrite","admin"],
"useOnFailedLogin" : false
},
"providers" : [
{ "classname" : "org.fcrepo.auth.common.BypassSecurityServletAuthenticationProvider" }
]
},
"node-types" : ["fedora-node-types.cnd"]
}

0 comments on commit 28670cd

Please sign in to comment.