[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [collector/master] Implement #19373 and add one word to comment in build.xml.



commit 0d9a197f1c512f318b225d07d8e764212954e10f
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date:   Wed Jul 6 20:22:13 2016 +0200

    Implement #19373 and add one word to comment in build.xml.
---
 build.xml                                          |  2 +-
 .../java/org/torproject/collector/MainTest.java    | 24 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

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..55b0569 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,26 @@ 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 + ".");
+      }
+    }
+  }
 }
+

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits