Revision 8f62dcad
Added by Andreas Kohlbecker over 5 years ago
src/test/java/unitils/AlternativeUnitilsJUnit4TestClassRunner.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package unitils; |
|
10 |
|
|
11 |
import org.junit.internal.runners.InitializationError; |
|
12 |
import org.junit.runner.notification.RunNotifier; |
|
13 |
import org.unitils.UnitilsJUnit4TestClassRunner; |
|
14 |
|
|
15 |
/** |
|
16 |
* A runner which causes the {@link org.unitils.core.ConfigurationLoader} to load <code>unitils-alternativeRunner.properties</code> |
|
17 |
* instead of <code>unitils.properties</code>. |
|
18 |
* |
|
19 |
* @author a.kohlbecker |
|
20 |
* @since Nov 23, 2017 |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class AlternativeUnitilsJUnit4TestClassRunner extends UnitilsJUnit4TestClassRunner { |
|
24 |
|
|
25 |
/** |
|
26 |
* @param testClass |
|
27 |
* @throws InitializationError |
|
28 |
*/ |
|
29 |
public AlternativeUnitilsJUnit4TestClassRunner(Class<?> testClass) throws InitializationError { |
|
30 |
super(testClass); |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* {@inheritDoc} |
|
35 |
*/ |
|
36 |
@Override |
|
37 |
public void run(RunNotifier notifier) { |
|
38 |
System.setProperty("unitils.configuration.customFileName", "unitils-alternativeRunner.properties"); |
|
39 |
super.run(notifier); |
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
} |
src/test/resources/unitils-alternativeRunner.properties | ||
---|---|---|
1 |
# |
|
2 |
# This is the configuration loaded by the AlternativeUnitilsJUnit4TestClassRunner |
|
3 |
# |
|
4 |
# This configuration |
|
5 |
# |
|
6 |
# |
|
7 |
######################################################################## |
|
8 |
# |
|
9 |
# NOTE: this is the unitils.properties file for the cdmlib-persistence module |
|
10 |
# a separate unitils.properties exists for cdmlib-io and for cdmlib-services |
|
11 |
# |
|
12 |
# |
|
13 |
# the list of all properties is found in |
|
14 |
# http://unitils.org/unitils-default.properties |
|
15 |
# |
|
16 |
|
|
17 |
### Unitils Modules ### |
|
18 |
# |
|
19 |
# List of modules that is loaded. Overloading this list is normally not useful, unless you want to add a custom |
|
20 |
# module. Disabling a module can be performed by setting unitils.module.<modulename>.enabled to false. |
|
21 |
# If a module's specific dependencies are not found (e.g. hibernate is not in you classpath), this module is not loaded, |
|
22 |
# even if it is in this list and the enabled property is set to true. It's therefore not strictly necessary to disable |
|
23 |
# any of these modules. |
|
24 |
#DEFAULT: unitils.modules=database,dbunit,hibernate,mock,easymock,inject,spring,jpa |
|
25 |
unitils.module.easymock.enabled=false |
|
26 |
unitils.module.mock.enabled=false |
|
27 |
|
|
28 |
|
|
29 |
### Database ### |
|
30 |
# |
|
31 |
# Name or path of the user specific properties file. This file should contain the necessary parameters to connect to the |
|
32 |
# developer's own unit test schema. It is recommended to override the name of this file in the project specific properties |
|
33 |
# file, to include the name of the project. The system will try to find this file in the classpath, the user home folder |
|
34 |
# (recommended) or the local filesystem. |
|
35 |
# |
|
36 |
unitils.configuration.localFileName=unitils-cdmlib-local.properties |
|
37 |
|
|
38 |
# H2 # |
|
39 |
database.driverClassName=org.h2.Driver |
|
40 |
database.url=jdbc:h2:mem:cdm |
|
41 |
database.dialect=h2 |
|
42 |
database.userName=sa |
|
43 |
database.password= |
|
44 |
database.schemaNames=PUBLIC |
|
45 |
org.dbunit.dataset.datatype.IDataTypeFactory.implClassName.h2=org.dbunit.ext.h2.H2DataTypeFactory |
|
46 |
org.unitils.core.dbsupport.DbSupport.implClassName.h2=eu.etaxonomy.cdm.database.H2DbSupport |
|
47 |
database.storedIndentifierCase.h2=auto |
|
48 |
|
|
49 |
#Since Hibernate 5 (or earlier > 4.1.10) using the Proxy does not correctly release |
|
50 |
#the connections to the pool after transaction finishes. |
|
51 |
dataSource.wrapInTransactionalProxy=false |
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
Also available in: Unified diff
implementing AlternativeUnitilsJUnit4TestClassRunner to load unitils-alternativeRunner.properties when used as runner