refactoring and test run without errors
diff --git a/src/test/java/ClassLoaderTest.java b/src/test/java/de/ids_mannheim/korap/config/ClassLoaderTest.java
similarity index 77%
rename from src/test/java/ClassLoaderTest.java
rename to src/test/java/de/ids_mannheim/korap/config/ClassLoaderTest.java
index 207ef81..3303b37 100644
--- a/src/test/java/ClassLoaderTest.java
+++ b/src/test/java/de/ids_mannheim/korap/config/ClassLoaderTest.java
@@ -1,7 +1,10 @@
+package de.ids_mannheim.korap.config;
+
import de.ids_mannheim.korap.config.BeanConfiguration;
import de.ids_mannheim.korap.config.DefaultHandler;
-import de.ids_mannheim.korap.interfaces.AuditingIface;
+import de.ids_mannheim.korap.interfaces.db.AuditingIface;
import de.ids_mannheim.korap.interfaces.defaults.DefaultAuditing;
+import org.junit.After;
import org.junit.Test;
/**
@@ -10,10 +13,15 @@
*/
public class ClassLoaderTest {
+ @After
+ public void close() {
+ BeanConfiguration.closeApplication();
+ }
+
@Test
public void testBeanConfigurationLoaderThrowsNoException() {
- BeanConfiguration.loadClasspathContext("classpath-config.xml");
- assert BeanConfiguration.getBeans() != null;
+ BeanConfiguration.loadClasspathContext("default-config.xml");
+ assert BeanConfiguration.hasContext();
}
@Test
diff --git a/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java b/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
new file mode 100644
index 0000000..2c11019
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
@@ -0,0 +1,65 @@
+package de.ids_mannheim.korap.config;
+
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.utils.ServiceVersion;
+import de.ids_mannheim.korap.utils.TimeUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author hanl
+ * @date 02/09/2015
+ */
+public class ConfigTest {
+
+ @After
+ public void close() {
+ BeanConfiguration.closeApplication();
+ }
+
+ @Test
+ public void testServiceVersion() {
+ String v = ServiceVersion.getAPIVersion();
+ Assert.assertNotEquals("wrong version", "UNKNOWN", v);
+ }
+
+ @Test
+ public void testPropertiesOverride() {
+ BeanConfiguration.loadClasspathContext();
+
+ Assert.assertEquals("token layer does not match", "opennlp",
+ BeanConfiguration.getBeans().getConfiguration()
+ .getDefault_token());
+ Assert.assertEquals("token expiration does not match",
+ TimeUtils.convertTimeToSeconds("150D"),
+ BeanConfiguration.getBeans().getConfiguration()
+ .getLongTokenTTL());
+
+ BeanConfiguration.getBeans().getConfiguration().setPropertiesAsStream(
+ ConfigTest.class.getClassLoader()
+ .getResourceAsStream("kustvakt_test.conf"));
+
+ Assert.assertEquals("token layer does not match", "tt",
+ BeanConfiguration.getBeans().getConfiguration()
+ .getDefault_token());
+ Assert.assertEquals("token expiration does not match",
+ TimeUtils.convertTimeToSeconds("230D"),
+ BeanConfiguration.getBeans().getConfiguration()
+ .getLongTokenTTL());
+ }
+
+ @Test(expected = KustvaktException.class)
+ public void testBeanOverrideInjection() throws KustvaktException {
+ BeanConfiguration.loadClasspathContext("default-config.xml");
+
+ BeanConfiguration.getBeans().getConfiguration().setPropertiesAsStream(
+ ConfigTest.class.getClassLoader()
+ .getResourceAsStream("kustvakt_test.conf"));
+
+ String v = "testmail@ids-mannheim.de";
+ BeanConfiguration.getBeans().getEncryption().validateEmail(v);
+ }
+}
+
+
diff --git a/src/test/java/de/ids_mannheim/korap/config/TestHelper.java b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
new file mode 100644
index 0000000..cbfe2a0
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
@@ -0,0 +1,10 @@
+package de.ids_mannheim.korap.config;
+
+/**
+ *
+ *
+ * @author hanl
+ * @date 16/10/2015
+ */
+public class TestHelper {
+}
diff --git a/src/test/resources/kustvakt_test.conf b/src/test/resources/kustvakt_test.conf
new file mode 100644
index 0000000..887b854
--- /dev/null
+++ b/src/test/resources/kustvakt_test.conf
@@ -0,0 +1,37 @@
+## index dir
+lucene.indexDir = /Users/hanl/Projects/prep_corpus
+
+kustvakt.default.pos = tt
+kustvakt.default.lemma = tt
+kustvakt.default.token = opennlp
+kustvakt.default.dep = mate
+kustvakt.default.const = mate
+
+
+## options referring to the security module!
+
+## token expiration time in minutes!
+## decpricated, no function uses this anymore
+security.absoluteTimeoutDuration = 45M
+
+security.longTokenTTL=150D
+security.tokenTTL=72H
+security.shortTokenTTL=5S
+
+## specifies the user data field that is used to salt user passwords
+security.passcode.salt=accountCreation
+
+security.idleTimeoutDuration = 25M
+security.multipleLogIn = true
+security.loginAttemptNum = 3
+security.authAttemptTTL = 45M
+
+security.encryption.loadFactor = 8
+security.validation.stringLength = 150
+security.validation.emailLength = 50
+security.encryption.algo=BCRYPT
+security.sharedSecret=nHim5JB-YqkX7sS55jayGBnga8WmqgpkzieGe8UhojE
+security.adminToken=f61d02c04a0f18d60172f7b990955824
+
+## applicable: rewrite, foundry, filter, deny
+security.rewrite.strategies=filter, foundry, rewrite
\ No newline at end of file