mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
Fix unit testing framework. Upgrade to latest m-assembly-p. Remove custom hibernate spring config and use testEnvironment.properties.
This commit is contained in:
@@ -259,7 +259,16 @@
|
||||
<phase>process-test-resources</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<!-- Ant task to copy dspace.cfg.woven to location of test dspace.cfg file -->
|
||||
<copy file="${agnostic.build.dir}/testing/dspace.cfg.woven" tofile="${agnostic.build.dir}/testing/dspace/config/dspace.cfg" />
|
||||
<!-- Now, do one final filter of our Test configs, replacing any remaining "${dspace.dir}"
|
||||
placeholders, with the full path of our Unit Test directory -->
|
||||
<!-- NOTE: This final filtering is necessary, because dspace.dir doesn't get filled out
|
||||
in our test dspace.cfg until Fileweaver runs above. -->
|
||||
<replace dir="${agnostic.build.dir}/testing/dspace/config/" value="${agnostic.build.dir}/testing/dspace">
|
||||
<include name="**/*"/>
|
||||
<replacetoken>${dspace.dir}</replacetoken>
|
||||
</replace>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
|
@@ -1,18 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||
<!--
|
||||
A slightly custom version of hibernate.cfg.xml which is used for Unit Testing and the H2 database.
|
||||
This OVERRIDES the default [dspace]/config/hibernate.cfg.xml. So it should be kept in sync with that file!
|
||||
-->
|
||||
<hibernate-configuration>
|
||||
<session-factory>
|
||||
<!--
|
||||
NOTE: If you are looking for the Hibernate database connection info
|
||||
(driver, url, username, pwd), it is initialized in the 'dataSource'
|
||||
bean in [dspace.dir]/config/spring/api/core-hibernate.xml
|
||||
-->
|
||||
|
||||
|
||||
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
|
||||
|
||||
|
||||
<property name="hibernate.hbm2ddl.auto">update</property>
|
||||
|
||||
|
||||
|
||||
<property name="hibernate.dialect">${db.dialect}</property>
|
||||
<!--
|
||||
Schema name - if your database contains multiple schemas, you can avoid
|
||||
problems with retrieving the definitions of duplicate object names by
|
||||
specifying the schema name that is used for DSpace.
|
||||
ORACLE USAGE NOTE: In Oracle, schema is equivalent to "username". This means
|
||||
specifying a "db.schema" is often unnecessary (i.e. you can leave it blank),
|
||||
UNLESS your Oracle DB Account (in db.username) has access to multiple schemas.
|
||||
-->
|
||||
<!-- H2 doesn't use schemas -->
|
||||
<!--<property name="hibernate.default_schema"></property>-->
|
||||
<property name="hibernate.hbm2ddl.auto">update</property> <!-- custom for H2 -->
|
||||
<property name="hibernate.hbm2ddl.import_files_sql_extractor">org.hibernate.tool.hbm2ddl.SingleLineSqlCommandExtractor</property>
|
||||
<property name="hibernate.connection.autocommit">false</property>
|
||||
<property name="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property>
|
||||
@@ -21,9 +33,9 @@
|
||||
|
||||
<!--Connection pool parameters -->
|
||||
<!-- Maximum number of DB connections in pool -->
|
||||
<property name="hibernate.c3p0.max_size">30</property>
|
||||
<property name="hibernate.c3p0.max_size">${db.maxconnections}</property>
|
||||
<!-- Determine the number of statements to be cached. -->
|
||||
<property name="hibernate.c3p0.max_statements">50</property>
|
||||
<property name="hibernate.c3p0.max_statements">${db.statementpool.cache}</property>
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +75,6 @@
|
||||
<mapping class="org.dspace.eperson.EPerson"/>
|
||||
<mapping class="org.dspace.eperson.Group"/>
|
||||
<mapping class="org.dspace.eperson.Group2GroupCache"/>
|
||||
<!--<mapping class="org.dspace.eperson.Group2Group"/>-->
|
||||
<mapping class="org.dspace.eperson.RegistrationData"/>
|
||||
<mapping class="org.dspace.eperson.Subscription"/>
|
||||
|
@@ -1,20 +0,0 @@
|
||||
<?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.xsd" default-lazy-init="true">
|
||||
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" lazy-init="true">
|
||||
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" lazy-init="true" destroy-method="close">
|
||||
<property name="driverClassName" value="org.h2.Driver"/>
|
||||
<property name="url" value="jdbc:h2:mem:test;LOCK_TIMEOUT=10000;MVCC=true"/>
|
||||
<property name="username" value="sa"/>
|
||||
<property name="password" value=""/>
|
||||
</bean>
|
||||
|
||||
<bean name="org.dspace.core.DBConnection" class="org.dspace.core.HibernateDBConnection" lazy-init="true"/>
|
||||
|
||||
</beans>
|
@@ -71,7 +71,6 @@
|
||||
<mapping class="org.dspace.eperson.EPerson"/>
|
||||
<mapping class="org.dspace.eperson.Group"/>
|
||||
<mapping class="org.dspace.eperson.Group2GroupCache"/>
|
||||
<!--<mapping class="org.dspace.eperson.Group2Group"/>-->
|
||||
<mapping class="org.dspace.eperson.RegistrationData"/>
|
||||
<mapping class="org.dspace.eperson.Subscription"/>
|
||||
|
||||
|
4
pom.xml
4
pom.xml
@@ -89,7 +89,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<!-- Allow for the ability to pass JVM memory flags for Unit Tests. Since
|
||||
maven-surefire-plugin forks a new JVM, it ignores MAVEN_OPTS.-->
|
||||
@@ -130,7 +130,7 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<version>2.5.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@@ -24,50 +24,69 @@
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
|
||||
<!-- First, copy the following from our 'dspace' subfolder assembly project into the
|
||||
same subdirectory in the final ZIP file. NOTE: We do this in a <fileSet> INSTEAD
|
||||
of a <moduleSet> so that we don't have to first build the "dspace" module. -->
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<!-- Copy necessary DSpace subdirectories into Test environment -->
|
||||
<includes>
|
||||
<include>dspace/bin/**</include>
|
||||
<include>dspace/config/**</include>
|
||||
<include>dspace/etc/**</include>
|
||||
<include>dspace/solr/**</include>
|
||||
</includes>
|
||||
<!-- But, exclude specific configs (which require filtering) -->
|
||||
<excludes>
|
||||
<exclude>dspace/config/dspace.cfg</exclude>
|
||||
<exclude>dspace/config/log4j.properties</exclude>
|
||||
<exclude>dspace/config/modules/**</exclude>
|
||||
</excludes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<!-- Copy specific configs (filtering their content) also into Test environment -->
|
||||
<includes>
|
||||
<include>dspace/config/modules/**</include>
|
||||
<include>dspace/config/dspace.cfg</include>
|
||||
<include>dspace/config/log4j.properties</include>
|
||||
</includes>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<!-- NOTE: first file in wins when using maven-assembly-plugin. So, overriden
|
||||
files have to be included first. -->
|
||||
<moduleSets>
|
||||
<!-- Next, search for a 'src/test/data/dspaceFolder' data directory in
|
||||
<!-- FIRST, search for a 'src/test/data/dspaceFolder' data directory in
|
||||
ANY of our modules. If found, copy its contents into the same "dspace"
|
||||
subdirectory in the final ZIP file, as this is data to be used in testing.
|
||||
NOTE: This *might* overwrite/overlay default files copied from above. -->
|
||||
NOTE: This *might* overwrite/overlay default files copied below. -->
|
||||
<moduleSet>
|
||||
<!-- Enable access to all projects in the current multimodule build! -->
|
||||
<useAllReactorProjects>true</useAllReactorProjects>
|
||||
<includes>
|
||||
<include>org.dspace:*</include>
|
||||
</includes>
|
||||
<sources>
|
||||
<outputDirectoryMapping>dspace</outputDirectoryMapping>
|
||||
<fileSets>
|
||||
<!-- First, copy over custom/overridden configs, filtering each of them -->
|
||||
<fileSet>
|
||||
<directory>src/test/data/dspaceFolder/config</directory>
|
||||
<outputDirectory>config</outputDirectory>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
<!-- Then copy over everything else (EXCEPT configs) -->
|
||||
<fileSet>
|
||||
<directory>src/test/data/dspaceFolder</directory>
|
||||
<excludes>
|
||||
<exclude>config/**</exclude>
|
||||
</excludes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</sources>
|
||||
</moduleSet>
|
||||
<!-- NEXT, we add in the default configuration/settings from the
|
||||
DSpace Assembly module. -->
|
||||
<moduleSet>
|
||||
<includes>
|
||||
<include>org.dspace:dspace</include>
|
||||
</includes>
|
||||
<sources>
|
||||
<outputDirectoryMapping>dspace</outputDirectoryMapping>
|
||||
<fileSets>
|
||||
<!-- First add in the config directory, filtering all config files -->
|
||||
<fileSet>
|
||||
<!-- Include the config directory and all subdirectories
|
||||
(without this explicit include, the "modules"
|
||||
subdirectory is strangely excluded) -->
|
||||
<includes>
|
||||
<include>config/**</include>
|
||||
</includes>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
<!-- Then add in other necessary directories -->
|
||||
<fileSet>
|
||||
<directory>bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>etc</directory>
|
||||
<outputDirectory>etc</outputDirectory>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>solr</directory>
|
||||
<outputDirectory>solr</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</sources>
|
||||
|
@@ -1,18 +1,7 @@
|
||||
# DSpace build.properties
|
||||
# This file should be customised to suit your build environment.
|
||||
# Note that not all configuration is handled here, only the most common
|
||||
# properties that tend to differ between build environments.
|
||||
# For adjusting global settings or more complex settings, edit the relevant config file.
|
||||
#
|
||||
# IMPORTANT: Do not remove or comment out settings in build.properties
|
||||
# When you edit the "build.properties" file (or a custom *.properties file),
|
||||
# take care not to remove or comment out any settings. Doing so, may cause
|
||||
# your final "dspace.cfg" file to be misconfigured with regards to that
|
||||
# particular setting. Instead, if you wish to remove/disable a particular
|
||||
# setting, just clear out its value. For example, if you don't want to be
|
||||
# notified of new user registrations, ensure the "mail.registration.notify"
|
||||
# setting has no value, e.g. "mail.registration.notify="
|
||||
#
|
||||
# This file is a custom version of "build.properties" which is used
|
||||
# specifically for Unit Testing.
|
||||
|
||||
##########################
|
||||
# SERVER CONFIGURATION #
|
||||
@@ -53,33 +42,24 @@ default.language = en_US
|
||||
##########################
|
||||
# DATABASE CONFIGURATION #
|
||||
##########################
|
||||
# For Unit Testing we use H2 running in "Oracle mode"
|
||||
db.driver = org.h2.Driver
|
||||
# Use a 10 second database lock timeout to avoid occasional JDBC lock timeout errors
|
||||
db.url = jdbc:h2:mem:test;MODE=Oracle;LOCK_TIMEOUT=10000
|
||||
db.username = sa
|
||||
db.password = sa
|
||||
|
||||
# Schema name - if your database contains multiple schemas, you can avoid problems with
|
||||
# retrieving the definitions of duplicate object names by specifying
|
||||
# the schema name here that is used for DSpace by uncommenting the following entry
|
||||
# For Unit Testing we use the H2 (in memory) database
|
||||
db.driver = org.h2.Driver
|
||||
db.dialect=org.hibernate.dialect.H2Dialect
|
||||
# Use H2 running in "Oracle mode"
|
||||
# Use a 10 second database lock timeout to avoid occasional JDBC lock timeout errors
|
||||
db.url = jdbc:h2:mem:test;LOCK_TIMEOUT=10000;MVCC=true
|
||||
#db.url = jdbc:h2:mem:test;MODE=Oracle;LOCK_TIMEOUT=10000
|
||||
db.username = sa
|
||||
db.password =
|
||||
# H2 doesn't use schemas
|
||||
db.schema =
|
||||
|
||||
# Maximum number of DB connections in pool
|
||||
db.maxconnections = 30
|
||||
|
||||
# Maximum time to wait before giving up if all connections in pool are busy (milliseconds)
|
||||
db.maxwait = 5000
|
||||
|
||||
# Maximum number of idle connections in pool (-1 = unlimited)
|
||||
db.maxidle = -1
|
||||
|
||||
# Determine if prepared statement should be cached. (default is true)
|
||||
db.statementpool = true
|
||||
|
||||
# Specify a name for the connection pool (useful if you have multiple applications sharing Tomcat's dbcp)
|
||||
# If not specified, defaults to 'dspacepool'
|
||||
db.poolname = dspacepool
|
||||
# Determine the number of statements that can be cached (set to 0 to disable caching)
|
||||
db.statementpool.cache = 50
|
||||
|
||||
#######################
|
||||
# EMAIL CONFIGURATION #
|
||||
|
Reference in New Issue
Block a user