implementing AlternativeUnitilsJUnit4TestClassRunner to load unitils-alternativeRunne...
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Thu, 23 Nov 2017 14:39:21 +0000 (15:39 +0100)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Thu, 23 Nov 2017 14:39:21 +0000 (15:39 +0100)
src/test/java/unitils/AlternativeUnitilsJUnit4TestClassRunner.java [new file with mode: 0644]
src/test/resources/unitils-alternativeRunner.properties [new file with mode: 0755]

diff --git a/src/test/java/unitils/AlternativeUnitilsJUnit4TestClassRunner.java b/src/test/java/unitils/AlternativeUnitilsJUnit4TestClassRunner.java
new file mode 100644 (file)
index 0000000..07a42dd
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package unitils;
+
+import org.junit.internal.runners.InitializationError;
+import org.junit.runner.notification.RunNotifier;
+import org.unitils.UnitilsJUnit4TestClassRunner;
+
+/**
+ * A runner which causes the {@link org.unitils.core.ConfigurationLoader} to load <code>unitils-alternativeRunner.properties</code>
+ * instead of <code>unitils.properties</code>.
+ *
+ * @author a.kohlbecker
+ * @since Nov 23, 2017
+ *
+ */
+public class AlternativeUnitilsJUnit4TestClassRunner extends UnitilsJUnit4TestClassRunner {
+
+    /**
+     * @param testClass
+     * @throws InitializationError
+     */
+    public AlternativeUnitilsJUnit4TestClassRunner(Class<?> testClass) throws InitializationError {
+        super(testClass);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void run(RunNotifier notifier) {
+        System.setProperty("unitils.configuration.customFileName", "unitils-alternativeRunner.properties");
+        super.run(notifier);
+    }
+
+
+
+}
diff --git a/src/test/resources/unitils-alternativeRunner.properties b/src/test/resources/unitils-alternativeRunner.properties
new file mode 100755 (executable)
index 0000000..2629394
--- /dev/null
@@ -0,0 +1,59 @@
+#
+# This is the configuration loaded by the AlternativeUnitilsJUnit4TestClassRunner
+#
+# This configuration
+#
+# 
+########################################################################
+#
+# NOTE: this is the unitils.properties file for the cdmlib-persistence module
+# a separate unitils.properties exists for cdmlib-io and for cdmlib-services
+#
+#
+# the list of all properties is found in
+# http://unitils.org/unitils-default.properties
+#
+
+### Unitils Modules ###
+#
+# List of modules that is loaded. Overloading this list is normally not useful, unless you want to add a custom
+# module. Disabling a module can be performed by setting unitils.module.<modulename>.enabled to false.
+# If a module's specific dependencies are not found (e.g. hibernate is not in you classpath), this module is not loaded,
+# even if it is in this list and the enabled property is set to true. It's therefore not strictly necessary to disable
+# any of these modules.
+#DEFAULT: unitils.modules=database,dbunit,hibernate,mock,easymock,inject,spring,jpa
+unitils.module.easymock.enabled=false
+unitils.module.mock.enabled=false
+
+
+### Database ###
+#
+# Name or path of the user specific properties file. This file should contain the necessary parameters to connect to the
+# developer's own unit test schema. It is recommended to override the name of this file in the project specific properties
+# file, to include the name of the project. The system will try to find this file in the classpath, the user home folder
+# (recommended) or the local filesystem.
+#
+unitils.configuration.localFileName=unitils-cdmlib-local.properties
+
+# H2 #
+database.driverClassName=org.h2.Driver
+database.url=jdbc:h2:mem:cdm
+database.dialect=h2
+database.userName=sa
+database.password=
+database.schemaNames=PUBLIC
+org.dbunit.dataset.datatype.IDataTypeFactory.implClassName.h2=org.dbunit.ext.h2.H2DataTypeFactory
+org.unitils.core.dbsupport.DbSupport.implClassName.h2=eu.etaxonomy.cdm.database.H2DbSupport
+database.storedIndentifierCase.h2=auto
+
+#Since Hibernate 5 (or earlier > 4.1.10) using the Proxy does not correctly release 
+#the connections to the pool after transaction finishes.
+dataSource.wrapInTransactionalProxy=false
+
+
+
+
+
+
+
+