| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 1 | package de.ids_mannheim.korap.config; |
| 2 | |
| margaretha | 0209cb7 | 2017-09-28 16:20:31 +0200 | [diff] [blame] | 3 | import static org.junit.Assert.assertEquals; |
| 4 | import static org.junit.Assert.assertNotEquals; |
| 5 | import static org.junit.Assert.assertNotNull; |
| margaretha | 0209cb7 | 2017-09-28 16:20:31 +0200 | [diff] [blame] | 6 | |
| margaretha | 0209cb7 | 2017-09-28 16:20:31 +0200 | [diff] [blame] | 7 | import java.io.IOException; |
| 8 | import java.io.InputStream; |
| margaretha | 5225ed0 | 2018-06-25 18:38:40 +0200 | [diff] [blame^] | 9 | import java.net.URISyntaxException; |
| margaretha | 0209cb7 | 2017-09-28 16:20:31 +0200 | [diff] [blame] | 10 | import java.util.Map; |
| 11 | import java.util.Properties; |
| 12 | |
| margaretha | 0209cb7 | 2017-09-28 16:20:31 +0200 | [diff] [blame] | 13 | import org.junit.Ignore; |
| 14 | import org.junit.Test; |
| 15 | |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 16 | import de.ids_mannheim.korap.exceptions.KustvaktException; |
| Michael Hanl | cb2d3f9 | 2016-06-02 17:34:06 +0200 | [diff] [blame] | 17 | import de.ids_mannheim.korap.interfaces.EncryptionIface; |
| Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 18 | import de.ids_mannheim.korap.utils.ServiceInfo; |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 19 | import de.ids_mannheim.korap.utils.TimeUtils; |
| Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 20 | |
| margaretha | 843c463 | 2017-10-25 19:16:12 +0200 | [diff] [blame] | 21 | /** EM: To do: fix tests |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 22 | * @author hanl |
| 23 | * @date 02/09/2015 |
| 24 | */ |
| margaretha | 843c463 | 2017-10-25 19:16:12 +0200 | [diff] [blame] | 25 | @Ignore |
| Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 26 | public class ConfigTest extends BeanConfigTest { |
| Michael Hanl | f1e85e7 | 2016-01-21 16:55:45 +0100 | [diff] [blame] | 27 | |
| Michael Hanl | cb2d3f9 | 2016-06-02 17:34:06 +0200 | [diff] [blame] | 28 | |
| 29 | @Test |
| Michael Hanl | c0ed00f | 2016-06-23 14:33:10 +0200 | [diff] [blame] | 30 | 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 Hanl | f1e85e7 | 2016-01-21 16:55:45 +0100 | [diff] [blame] | 42 | @Test |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 43 | public void testServiceInfo () { |
| Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 44 | String version = ServiceInfo.getInfo().getVersion(); |
| 45 | String name = ServiceInfo.getInfo().getName(); |
| 46 | assertNotEquals("wrong version", "UNKNOWN", version); |
| 47 | assertNotEquals("wrong name", "UNKNOWN", name); |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 48 | } |
| 49 | |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 50 | |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 51 | @Test |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 52 | public void testProperties () { |
| 53 | assertEquals("token layer does not match", "opennlp", helper() |
| 54 | .getContext().getConfiguration().getDefault_token()); |
| Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 55 | assertEquals("token expiration does not match", |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 56 | TimeUtils.convertTimeToSeconds("1D"), helper().getContext() |
| 57 | .getConfiguration().getLongTokenTTL()); |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 58 | } |
| 59 | |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 60 | |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 61 | @Test(expected = KustvaktException.class) |
| Michael Hanl | c0ed00f | 2016-06-23 14:33:10 +0200 | [diff] [blame] | 62 | @Ignore |
| margaretha | 5225ed0 | 2018-06-25 18:38:40 +0200 | [diff] [blame^] | 63 | public void testBeanOverrideInjection () throws KustvaktException, URISyntaxException { |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 64 | helper().getContext() |
| 65 | .getConfiguration() |
| 66 | .setPropertiesAsStream( |
| 67 | ConfigTest.class.getClassLoader().getResourceAsStream( |
| 68 | "kustvakt.conf")); |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 69 | } |
| Michael Hanl | c444602 | 2016-02-12 18:03:17 +0100 | [diff] [blame] | 70 | |
| Michael Hanl | c0ed00f | 2016-06-23 14:33:10 +0200 | [diff] [blame] | 71 | @Test |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 72 | public void testBootConfigDependencyOrder () { |
| Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 73 | // todo: |
| 74 | |
| 75 | } |
| 76 | |
| 77 | @Override |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 78 | public void initMethod () throws KustvaktException { |
| Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 79 | |
| 80 | } |
| Michael Hanl | deb3c21 | 2015-10-16 23:02:24 +0200 | [diff] [blame] | 81 | } |