From f2bff261516699f19cc75f688ccb13aa79a0ee02 Mon Sep 17 00:00:00 2001 From: Aaron Coburn Date: Thu, 23 Apr 2015 17:56:03 -0400 Subject: [PATCH] Add test gear for fcrepo integration testing Related to: https://jira.duraspace.org/browse/FCREPO-1481 --- README.md | 2 +- pom.xml | 53 +++++++++++++++++-- .../audit/integration/FcrepoAuditIT.java | 52 ++++++++++++++++++ .../resources/config/test_repository.json | 19 +++++++ src/test/resources/logback-test.xml | 19 +++++++ src/test/resources/spring-test/master.xml | 12 +++++ src/test/resources/spring-test/repo.xml | 24 +++++++++ src/test/resources/spring-test/rest.xml | 31 +++++++++++ .../resources/spring-test/test-container.xml | 21 ++++++++ src/test/resources/web.xml | 36 +++++++++++++ 10 files changed, 265 insertions(+), 4 deletions(-) create mode 100644 src/test/java/org/fcrepo/audit/integration/FcrepoAuditIT.java create mode 100644 src/test/resources/config/test_repository.json create mode 100644 src/test/resources/logback-test.xml create mode 100644 src/test/resources/spring-test/master.xml create mode 100644 src/test/resources/spring-test/repo.xml create mode 100644 src/test/resources/spring-test/rest.xml create mode 100644 src/test/resources/spring-test/test-container.xml create mode 100644 src/test/resources/web.xml diff --git a/README.md b/README.md index af7e5e5..e62c617 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ fcrepo-audit [![Build Status](https://travis-ci.org/fcrepo4-exts/fcrepo-audit.png?branch=master)](https://travis-ci.org/fcrepo4-exts/fcrepo-audit) -Provides audit functionality for the Fedora Commons repository framework. The [fcrepo-webapp-plus](https://github.com/fcrepo4-exts/fcrepo-webapp-plus) project provides a convenient option to build fcrepo-webapp packaged with fcrepo-audit module. +Provides audit functionality for the Fedora Commons repository framework. The [fcrepo-webapp-plus](https://github.com/fcrepo4-exts/fcrepo-webapp-plus) project provides a convenient option to build fcrepo-webapp packaged with fcrepo-audit module. \ No newline at end of file diff --git a/pom.xml b/pom.xml index 27bab09..9f518c1 100644 --- a/pom.xml +++ b/pom.xml @@ -99,14 +99,47 @@ ${guava.version} - com.fasterxml.jackson.core - jackson-core - + com.fasterxml.jackson.core + jackson-core + ch.qos.logback logback-classic provided + + + + org.fcrepo + fcrepo-http-commons + ${project.version} + test + + + org.fcrepo + fcrepo-http-commons + ${project.version} + test + test-jar + + + org.fcrepo + fcrepo-auth-common + ${project.version} + test + + + org.glassfish.grizzly + grizzly-http-servlet + ${grizzly.version} + test + + + org.glassfish.jersey.test-framework.providers + jersey-test-framework-provider-grizzly2 + ${jersey.version} + test + junit junit @@ -115,16 +148,23 @@ org.springframework spring-test ${spring.version} + test org.mockito mockito-core ${mockito.version} + test + + + maven-failsafe-plugin + + org.apache.felix maven-bundle-plugin @@ -143,6 +183,7 @@ + org.apache.maven.plugins maven-war-plugin @@ -155,6 +196,12 @@ maven-javadoc-plugin 2.10.3 + + + + org.codehaus.mojo + build-helper-maven-plugin + diff --git a/src/test/java/org/fcrepo/audit/integration/FcrepoAuditIT.java b/src/test/java/org/fcrepo/audit/integration/FcrepoAuditIT.java new file mode 100644 index 0000000..6b0ec09 --- /dev/null +++ b/src/test/java/org/fcrepo/audit/integration/FcrepoAuditIT.java @@ -0,0 +1,52 @@ +/* + * Licensed to DuraSpace under one or more contributor license agreements. + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * DuraSpace licenses this file to you 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.audit.integration; + +import static org.junit.Assert.assertEquals; + +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; + +/** + * Integration tests for the audit system + * + * @author acoburn + * @since 2015-04-23 + */ +@ContextConfiguration({"/spring-test/test-container.xml"}) +@RunWith(SpringJUnit4ClassRunner.class) +public class FcrepoAuditIT { + + protected Logger logger = LoggerFactory.getLogger(FcrepoAuditIT.class); + + protected static final int SERVER_PORT = Integer.parseInt(System.getProperty("fcrepo.dynamic.test.port", "8080")); + + protected static final String HOSTNAME = "localhost"; + + protected static final String serverAddress = "http://" + HOSTNAME + ":" + + SERVER_PORT; + + @Test + public void testAudit() throws Exception { + assertEquals(1 + 1, 2); + } +} diff --git a/src/test/resources/config/test_repository.json b/src/test/resources/config/test_repository.json new file mode 100644 index 0000000..66518dd --- /dev/null +++ b/src/test/resources/config/test_repository.json @@ -0,0 +1,19 @@ +{ + "name" : "repo", + "jndiName" : "", + "workspaces" : { + "predefined" : ["default"], + "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"] +} diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000..17115a2 --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,19 @@ + + + + + + %p %d{HH:mm:ss.SSS} \(%c{0}\) %m%n + + + + + + + + + + + + + diff --git a/src/test/resources/spring-test/master.xml b/src/test/resources/spring-test/master.xml new file mode 100644 index 0000000..3755d89 --- /dev/null +++ b/src/test/resources/spring-test/master.xml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/src/test/resources/spring-test/repo.xml b/src/test/resources/spring-test/repo.xml new file mode 100644 index 0000000..fcbf304 --- /dev/null +++ b/src/test/resources/spring-test/repo.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + diff --git a/src/test/resources/spring-test/rest.xml b/src/test/resources/spring-test/rest.xml new file mode 100644 index 0000000..ddb1b7e --- /dev/null +++ b/src/test/resources/spring-test/rest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/spring-test/test-container.xml b/src/test/resources/spring-test/test-container.xml new file mode 100644 index 0000000..6d12160 --- /dev/null +++ b/src/test/resources/spring-test/test-container.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/src/test/resources/web.xml b/src/test/resources/web.xml new file mode 100644 index 0000000..cd8562f --- /dev/null +++ b/src/test/resources/web.xml @@ -0,0 +1,36 @@ + + + + + Fedora-on-ModeShape + + + contextConfigLocation + classpath:spring-test/master.xml + + + + org.springframework.web.context.ContextLoaderListener + + + + jersey-servlet + org.glassfish.jersey.servlet.ServletContainer + + + javax.ws.rs.Application + org.fcrepo.http.commons.FedoraApplication + + + 1 + + + + jersey-servlet + /* + + +