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