summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriwakeh <iwakeh@torproject.org>2016-07-06 20:22:13 +0200
committeriwakeh <iwakeh@torproject.org>2016-07-06 20:24:12 +0200
commitac00d7a02e2864ad813d230affd0242876b9a3b5 (patch)
tree1650ea30c43d5b419b0b60b9fa1f53a47f81a60b
parent050a88ffcf2b205a63741d4848951ce91c0bd02f (diff)
Implement #19373 and add one word to comment in build.xml.task-19373
-rw-r--r--build.xml2
-rw-r--r--src/test/java/org/torproject/collector/MainTest.java23
2 files changed, 24 insertions, 1 deletions
diff --git a/build.xml b/build.xml
index ffb1fca..099eb8b 100644
--- a/build.xml
+++ b/build.xml
@@ -224,7 +224,7 @@
</target>
<target name="test" depends="compile,compile-tests">
<junit fork="true" haltonfailure="true" printsummary="off">
- <!-- The following jvmargs prevent test access to the network. -->
+ <!-- The following two jvmargs prevent test access to the network. -->
<jvmarg value="-Djava.security.policy=${testresources}/junittest.policy"/>
<jvmarg value="-Djava.security.manager"/>
<jvmarg value="-DLOGBASE=${generated}/test-logs"/>
diff --git a/src/test/java/org/torproject/collector/MainTest.java b/src/test/java/org/torproject/collector/MainTest.java
index f83cab5..92ee3bc 100644
--- a/src/test/java/org/torproject/collector/MainTest.java
+++ b/src/test/java/org/torproject/collector/MainTest.java
@@ -7,6 +7,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
import org.torproject.collector.conf.Key;
import org.torproject.collector.conf.ConfigurationException;
@@ -23,6 +24,7 @@ import java.security.AccessControlException;
import java.security.Policy;
import java.util.Arrays;
import java.util.List;
+import java.util.Properties;
import java.util.Random;
import org.junit.rules.TemporaryFolder;
@@ -69,4 +71,25 @@ public class MainTest {
bw.close();
}
+ /* Verifies the contents of the default collector.properties file.
+ All properties specified have to be present but nothing else. */
+ @Test()
+ public void testPropertiesFile() throws Exception {
+ Properties props = new Properties();
+ props.load(getClass().getClassLoader().getResourceAsStream(Main.CONF_FILE));
+ for (Key key : Key.values()) {
+ assertNotNull("Property '" + key.name() + "' not specified in "
+ + Main.CONF_FILE + ".",
+ props.getProperty(key.name()));
+ }
+ for (String propName : props.stringPropertyNames()) {
+ try {
+ Key.valueOf(propName);
+ } catch (IllegalArgumentException ex) {
+ fail("Invalid property name '" + propName + "' found in "
+ + Main.CONF_FILE + ".");
+ }
+ }
+ }
+
}