blob: ed263c0d3fbe564646bdc90e7c8b086a14d44c1e [file] [log] [blame]
Michael Hanldeb3c212015-10-16 23:02:24 +02001package de.ids_mannheim.korap.config;
2
margaretha0209cb72017-09-28 16:20:31 +02003import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertNotEquals;
5import static org.junit.Assert.assertNotNull;
margaretha0209cb72017-09-28 16:20:31 +02006
margaretha0209cb72017-09-28 16:20:31 +02007import java.io.IOException;
8import java.io.InputStream;
margaretha5225ed02018-06-25 18:38:40 +02009import java.net.URISyntaxException;
margaretha0209cb72017-09-28 16:20:31 +020010import java.util.Map;
11import java.util.Properties;
12
margaretha0209cb72017-09-28 16:20:31 +020013import org.junit.Ignore;
14import org.junit.Test;
15
Michael Hanldeb3c212015-10-16 23:02:24 +020016import de.ids_mannheim.korap.exceptions.KustvaktException;
Michael Hanlcb2d3f92016-06-02 17:34:06 +020017import de.ids_mannheim.korap.interfaces.EncryptionIface;
Michael Hanldaf86602016-05-12 14:31:52 +020018import de.ids_mannheim.korap.utils.ServiceInfo;
Michael Hanldeb3c212015-10-16 23:02:24 +020019import de.ids_mannheim.korap.utils.TimeUtils;
Michael Hanldaf86602016-05-12 14:31:52 +020020
margaretha843c4632017-10-25 19:16:12 +020021/** EM: To do: fix tests
Michael Hanldeb3c212015-10-16 23:02:24 +020022 * @author hanl
23 * @date 02/09/2015
24 */
margaretha843c4632017-10-25 19:16:12 +020025@Ignore
Michael Hanldaf86602016-05-12 14:31:52 +020026public class ConfigTest extends BeanConfigTest {
Michael Hanlf1e85e72016-01-21 16:55:45 +010027
Michael Hanlcb2d3f92016-06-02 17:34:06 +020028
29 @Test
Michael Hanlc0ed00f2016-06-23 14:33:10 +020030 public void testConfigLoader () {
31 InputStream stream = ConfigLoader.loadConfigStream("kustvakt.conf");
32 assertNotNull(stream);
33 }
34
35
36 @Test
37 public void testPropertyLoader () throws IOException {
38 Properties p = ConfigLoader.loadProperties("kustvakt.conf");
39 assertNotNull(p);
40 }
41
Michael Hanlf1e85e72016-01-21 16:55:45 +010042 @Test
Michael Hanl8abaf9e2016-05-23 16:46:35 +020043 public void testServiceInfo () {
Michael Hanldaf86602016-05-12 14:31:52 +020044 String version = ServiceInfo.getInfo().getVersion();
45 String name = ServiceInfo.getInfo().getName();
46 assertNotEquals("wrong version", "UNKNOWN", version);
47 assertNotEquals("wrong name", "UNKNOWN", name);
Michael Hanldeb3c212015-10-16 23:02:24 +020048 }
49
Michael Hanl8abaf9e2016-05-23 16:46:35 +020050
Michael Hanldeb3c212015-10-16 23:02:24 +020051 @Test
Michael Hanl8abaf9e2016-05-23 16:46:35 +020052 public void testProperties () {
53 assertEquals("token layer does not match", "opennlp", helper()
54 .getContext().getConfiguration().getDefault_token());
Michael Hanldaf86602016-05-12 14:31:52 +020055 assertEquals("token expiration does not match",
Michael Hanl8abaf9e2016-05-23 16:46:35 +020056 TimeUtils.convertTimeToSeconds("1D"), helper().getContext()
57 .getConfiguration().getLongTokenTTL());
Michael Hanldeb3c212015-10-16 23:02:24 +020058 }
59
Michael Hanl8abaf9e2016-05-23 16:46:35 +020060
Michael Hanldeb3c212015-10-16 23:02:24 +020061 @Test(expected = KustvaktException.class)
Michael Hanlc0ed00f2016-06-23 14:33:10 +020062 @Ignore
margaretha5225ed02018-06-25 18:38:40 +020063 public void testBeanOverrideInjection () throws KustvaktException, URISyntaxException {
Michael Hanl8abaf9e2016-05-23 16:46:35 +020064 helper().getContext()
65 .getConfiguration()
66 .setPropertiesAsStream(
67 ConfigTest.class.getClassLoader().getResourceAsStream(
68 "kustvakt.conf"));
Michael Hanldeb3c212015-10-16 23:02:24 +020069 }
Michael Hanlc4446022016-02-12 18:03:17 +010070
Michael Hanlc0ed00f2016-06-23 14:33:10 +020071 @Test
Michael Hanl8abaf9e2016-05-23 16:46:35 +020072 public void testBootConfigDependencyOrder () {
Michael Hanldaf86602016-05-12 14:31:52 +020073 // todo:
74
75 }
76
77 @Override
Michael Hanl8abaf9e2016-05-23 16:46:35 +020078 public void initMethod () throws KustvaktException {
Michael Hanldaf86602016-05-12 14:31:52 +020079
80 }
Michael Hanldeb3c212015-10-16 23:02:24 +020081}