mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
Update dependencies. Fixes Maven issues with initializing dspace.dir
This commit is contained in:
@@ -219,7 +219,7 @@
|
||||
(see: http://gmaven.codehaus.org/Executing+Groovy+Code )
|
||||
We are generating a OS-agnostic version (agnostic.build.dir) of
|
||||
the ${project.build.directory} property (full path of target dir).
|
||||
This is needed by the FileWeaver & Surefire plugins (see below)
|
||||
This is needed by the Surefire & Failsafe plugins (see below)
|
||||
to initialize the Unit Test environment's dspace.cfg file.
|
||||
Otherwise, the Unit Test Framework will not work on Windows OS.
|
||||
This Groovy code was mostly borrowed from:
|
||||
@@ -228,19 +228,18 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>groovy-maven-plugin</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>setproperty</id>
|
||||
<phase>generate-test-resources
|
||||
</phase> <!-- XXX I think this should be 'initialize' - MHW -->
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source>
|
||||
project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/');
|
||||
println("Initializing Maven property 'agnostic.build.dir' to: " + project.properties['agnostic.build.dir']);
|
||||
log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']);
|
||||
</source>
|
||||
</configuration>
|
||||
</execution>
|
||||
@@ -253,6 +252,7 @@
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- Specify the dspace.dir to use for test environment -->
|
||||
<!-- ${agnostic.build.dir} is set dynamically by groovy-maven-plugin above -->
|
||||
<!-- This system property is loaded by AbstractDSpaceTest to initialize the test environment -->
|
||||
<dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
|
||||
<!-- Turn off any DSpace logging -->
|
||||
@@ -278,6 +278,7 @@
|
||||
<configuration>
|
||||
<validationSets>
|
||||
<!-- validate ALL XML and XSL config files in the testing folder -->
|
||||
<!-- ${agnostic.build.dir} is set dynamically by groovy-maven-plugin above -->
|
||||
<validationSet>
|
||||
<dir>${agnostic.build.dir}/testing</dir>
|
||||
<includes>
|
||||
@@ -306,6 +307,7 @@
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- Specify the dspace.dir to use for test environment -->
|
||||
<!-- ${agnostic.build.dir} is set dynamically by groovy-maven-plugin above -->
|
||||
<dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
|
||||
<!-- Turn off any DSpace logging -->
|
||||
<dspace.log.init.disable>true</dspace.log.init.disable>
|
||||
@@ -505,7 +507,11 @@
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.rometools</groupId>
|
||||
<artifactId>rome-modules</artifactId>
|
||||
@@ -698,7 +704,7 @@
|
||||
<dependency>
|
||||
<groupId>org.xmlunit</groupId>
|
||||
<artifactId>xmlunit-matchers</artifactId>
|
||||
<version>2.6.2</version>
|
||||
<version>2.6.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -708,6 +714,12 @@
|
||||
<version>1.0.0.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.bcel</groupId>
|
||||
<artifactId>bcel</artifactId>
|
||||
<version>6.4.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@@ -15,15 +15,14 @@ import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import mockit.integration.junit4.JMockit;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.util.MockUtil;
|
||||
import org.dspace.servicemanager.DSpaceKernelImpl;
|
||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
/**
|
||||
* DSpace Unit Tests need to initialize the DSpace Kernel / Service Mgr
|
||||
@@ -39,7 +38,7 @@ import org.junit.runner.RunWith;
|
||||
* @see AbstractIntegrationTest
|
||||
*/
|
||||
@Ignore
|
||||
@RunWith(JMockit.class)
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AbstractDSpaceTest {
|
||||
|
||||
/**
|
||||
@@ -86,11 +85,9 @@ public class AbstractDSpaceTest {
|
||||
kernelImpl = DSpaceKernelInit.getKernel(null);
|
||||
if (!kernelImpl.isRunning()) {
|
||||
// NOTE: the "dspace.dir" system property MUST be specified via Maven
|
||||
// For example: by using <systemPropertyVariables> of maven-surefire-plugin or maven-failsafe-plugin
|
||||
kernelImpl.start(getDspaceDir()); // init the kernel
|
||||
}
|
||||
|
||||
// Initialize mock Util class (allows Util.getSourceVersion() to work in Unit tests)
|
||||
new MockUtil();
|
||||
} catch (IOException ex) {
|
||||
log.error("Error initializing tests", ex);
|
||||
fail("Error initializing tests: " + ex.getMessage());
|
||||
|
@@ -44,23 +44,34 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>groovy-maven-plugin</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>setproperty</id>
|
||||
<phase>generate-test-resources
|
||||
</phase> <!-- XXX I think this should be 'initialize' - MHW -->
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source>
|
||||
project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/');
|
||||
println("Initializing Maven property 'agnostic.build.dir' to: " + project.properties['agnostic.build.dir']);
|
||||
log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']);
|
||||
</source>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<!-- TODO: When Groovy 3.0.0 is released, we should upgrade to fix this warning
|
||||
(which appears in Maven builds) https://issues.apache.org/jira/browse/GROOVY-8339
|
||||
The below (commented out) dependency should let us upgrade to v3.0.0 once released. -->
|
||||
<!--<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>runtime</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>-->
|
||||
</plugin>
|
||||
|
||||
<!-- Run Unit Testing! This plugin just kicks off the tests (when enabled). -->
|
||||
@@ -69,6 +80,7 @@
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- Specify the dspace.dir to use for test environment -->
|
||||
<!-- ${agnostic.build.dir} is set dynamically by groovy-maven-plugin above -->
|
||||
<!-- For "dspace-services" we don't need a full test environment, we just need
|
||||
a valid "config-definition.xml" which exists in target/test-classes/ -->
|
||||
<dspace.dir>${agnostic.build.dir}/test-classes/</dspace.dir>
|
||||
|
@@ -7,14 +7,10 @@
|
||||
*/
|
||||
package org.dspace.test;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.dspace.kernel.DSpaceKernel;
|
||||
import org.dspace.kernel.ServiceManager;
|
||||
import org.dspace.servicemanager.DSpaceKernelImpl;
|
||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||
import org.dspace.servicemanager.config.DSpaceConfigurationService;
|
||||
import org.dspace.services.RequestService;
|
||||
|
||||
/**
|
||||
@@ -50,12 +46,9 @@ public abstract class DSpaceAbstractTest {
|
||||
* do not run this after each individual test
|
||||
*/
|
||||
public static void _initializeKernel() {
|
||||
// First, ensure DSPACE_HOME is set to our /src/test/resources directory.
|
||||
// This ensures Kernel finds our test configs in that directory
|
||||
Path resourceDirectory = Paths.get("src", "test", "resources");
|
||||
System.setProperty(DSpaceConfigurationService.DSPACE_HOME, resourceDirectory.toAbsolutePath().toString());
|
||||
|
||||
// Now, init the Kernel and start it
|
||||
// Init the Kernel and start it
|
||||
// NOTE: the "dspace.dir" system property MUST be specified via Maven
|
||||
// For example: by using <systemPropertyVariables> of maven-surefire-plugin or maven-failsafe-plugin
|
||||
kernelImpl = DSpaceKernelInit.getKernel(null);
|
||||
kernelImpl.start();
|
||||
kernel = kernelImpl.getManagedBean();
|
||||
|
@@ -139,19 +139,18 @@ just adding new jar in the classloader</description>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>groovy-maven-plugin</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>setproperty</id>
|
||||
<phase>generate-test-resources
|
||||
</phase> <!-- XXX I think this should be 'initialize' - MHW -->
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source>
|
||||
project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/');
|
||||
println("Initializing Maven property 'agnostic.build.dir' to: " + project.properties['agnostic.build.dir']);
|
||||
log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']);
|
||||
</source>
|
||||
</configuration>
|
||||
</execution>
|
||||
@@ -164,6 +163,7 @@ just adding new jar in the classloader</description>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- Specify the dspace.dir to use for test environment -->
|
||||
<!-- ${agnostic.build.dir} is set dynamically by groovy-maven-plugin above -->
|
||||
<!-- This system property is loaded by AbstractDSpaceTest to initialize the test environment -->
|
||||
<dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
|
||||
<!-- Turn off any DSpace logging -->
|
||||
@@ -179,6 +179,7 @@ just adding new jar in the classloader</description>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- Specify the dspace.dir to use for test environment -->
|
||||
<!-- ${agnostic.build.dir} is set dynamically by groovy-maven-plugin above -->
|
||||
<dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
|
||||
<!-- Turn off any DSpace logging -->
|
||||
<dspace.log.init.disable>true</dspace.log.init.disable>
|
||||
|
Reference in New Issue
Block a user