changeset 2622:e4f6006877d1

Enable more Windows JUnit tests This patch adds back some JUnit tests that had been disabled on Windows. Reviewed-by: neugens, sgehwolf Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-March/022508.html
author Simon Tooke <stooke@redhat.com>
date Mon, 20 Mar 2017 14:09:36 -0400
parents f763eea4655f
children d31777c74d57
files dev/perflog-analyzer/pom.xml dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/PerfLogAnalyzerTest.java dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/internal/QueueStatsTest.java dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/internal/StatementStatsTest.java system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/HostInfoBuilderTest.java system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/ProcessEnvironmentBuilderTest.java system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/SystemBackendTest.java web/server/pom.xml web/server/src/test/java/com/redhat/thermostat/web/server/WebStorageEndPointUnitTest.java
diffstat 9 files changed, 24 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/dev/perflog-analyzer/pom.xml	Wed Mar 15 12:06:53 2017 +0100
+++ b/dev/perflog-analyzer/pom.xml	Mon Mar 20 14:09:36 2017 -0400
@@ -69,6 +69,13 @@
       <version>${project.version}</version>
       <scope>test</scope>
     </dependency>
+
+
+    <dependency>
+      <groupId>com.redhat.thermostat</groupId>
+      <artifactId>thermostat-shared-config</artifactId>
+      <version>${project.version}</version>
+    </dependency>
   </dependencies>
   
   <build>
--- a/dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/PerfLogAnalyzerTest.java	Wed Mar 15 12:06:53 2017 +0100
+++ b/dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/PerfLogAnalyzerTest.java	Mon Mar 20 14:09:36 2017 -0400
@@ -44,6 +44,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.dev.perf.logs.PerfLogAnalyzer;
+import com.redhat.thermostat.shared.config.OS;
 
 public class PerfLogAnalyzerTest {
 
@@ -60,11 +61,11 @@
         
         String actual = baos.toString();
         StringBuilder builder = new StringBuilder();
-        builder.append("usage: java -cp thermostat-perflog-analyzer*.jar " + PerfLogAnalyzer.class.getName() + " [OPTIONS] <perflog-file>\n\n");
-        builder.append("  OPTIONS:\n");
-        builder.append("   --sort-by=<KEY>   <KEY> is one of: MIN, MAX, AVG, COUNT (AVG is default)\n");
-        builder.append("   --direction=<KEY>   <KEY> is one of: ASC, DSC (DSC is default)\n");
-        builder.append("   --show-backing   Shows stats analysis for backing storage (if any)\n");
+        builder.append("usage: java -cp thermostat-perflog-analyzer*.jar " + PerfLogAnalyzer.class.getName() + " [OPTIONS] <perflog-file>" + OS.EOL + OS.EOL);
+        builder.append("  OPTIONS:" + OS.EOL);
+        builder.append("   --sort-by=<KEY>   <KEY> is one of: MIN, MAX, AVG, COUNT (AVG is default)" + OS.EOL);
+        builder.append("   --direction=<KEY>   <KEY> is one of: ASC, DSC (DSC is default)" + OS.EOL);
+        builder.append("   --show-backing   Shows stats analysis for backing storage (if any)" + OS.EOL);
         String expected = builder.toString();
         assertEquals(expected, actual);
     }
--- a/dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/internal/QueueStatsTest.java	Wed Mar 15 12:06:53 2017 +0100
+++ b/dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/internal/QueueStatsTest.java	Mon Mar 20 14:09:36 2017 -0400
@@ -47,6 +47,7 @@
 import java.util.Date;
 import java.util.List;
 
+import com.redhat.thermostat.shared.config.OS;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -121,7 +122,7 @@
         PrintStream pStream = new PrintStream(baos);
         stats.printSummary(pStream);
         String summary = baos.toString();
-        assertEquals("Queue size stats (5 records): 12(max) 1(min) 5.60(avg)\n\n", summary);
+        assertEquals("Queue size stats (5 records): 12(max) 1(min) 5.60(avg)" + OS.EOL + OS.EOL, summary);
     }
     
     @Test
--- a/dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/internal/StatementStatsTest.java	Wed Mar 15 12:06:53 2017 +0100
+++ b/dev/perflog-analyzer/src/test/java/com/redhat/thermostat/dev/perf/logs/internal/StatementStatsTest.java	Mon Mar 20 14:09:36 2017 -0400
@@ -52,6 +52,7 @@
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
+import com.redhat.thermostat.shared.config.OS;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -222,12 +223,12 @@
         PrintStream pStream = new PrintStream(baos, false, "UTF-8");
         stats.setConfig(config);
         stats.printSummary(pStream);
-        String expected = "Statement statistics (6 records): 3 distinct statements (5 reads, 1 writes)\n" +
-                          "\n" +
-                          "Statement details (sorted by avg exec time):\n" +
-                          "Total #: 2, 300µs (min), 333µs (max), 316.50µs (avg), DESCRIPTOR: QUERY foo-bar WHERE 'x' = ?l\n" +
-                          "Total #: 3, 2ms (min), 120ms (max), 44.67ms (avg), DESCRIPTOR: QUERY foo WHERE 'a' = ?s\n" +
-                          "Total #: 1, 44ns (min), 44ns (max), 44.00ns (avg), DESCRIPTOR: ADD foo SET 'a' = ?s\n\n";
+        String expected = "Statement statistics (6 records): 3 distinct statements (5 reads, 1 writes)" + OS.EOL +
+                          OS.EOL +
+                          "Statement details (sorted by avg exec time):" + OS.EOL +
+                          "Total #: 2, 300µs (min), 333µs (max), 316.50µs (avg), DESCRIPTOR: QUERY foo-bar WHERE 'x' = ?l" + OS.EOL +
+                          "Total #: 3, 2ms (min), 120ms (max), 44.67ms (avg), DESCRIPTOR: QUERY foo WHERE 'a' = ?s" + OS.EOL +
+                          "Total #: 1, 44ns (min), 44ns (max), 44.00ns (avg), DESCRIPTOR: ADD foo SET 'a' = ?s" + OS.EOL + OS.EOL;
         String summary = baos.toString("UTF-8");
         assertEquals(expected, summary);
     }
--- a/system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/HostInfoBuilderTest.java	Wed Mar 15 12:06:53 2017 +0100
+++ b/system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/HostInfoBuilderTest.java	Mon Mar 20 14:09:36 2017 -0400
@@ -68,9 +68,7 @@
         when(helper.getTotalMemory()).thenReturn(9876L);
     }
 
-    // TODO - This test currently fails on Windows because the helper DLL isn't on the execution path
     @Test
-    @Ignore
     public void testSimpleBuild() {
         Assume.assumeTrue(OS.IS_WINDOWS);
         HostInfo info = new HostInfoBuilderImpl(writerId).build();
--- a/system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/ProcessEnvironmentBuilderTest.java	Wed Mar 15 12:06:53 2017 +0100
+++ b/system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/ProcessEnvironmentBuilderTest.java	Mon Mar 20 14:09:36 2017 -0400
@@ -78,9 +78,7 @@
         when(whelp.getEnvironment(eq(FAKE_PID))).thenReturn(goodMap);
     }
 
-    // TODO - This test currently fails on Windows because the helper DLL isn't on the execution path
     @Test
-    @Ignore
     public void testSimpleBuild() {
         Assume.assumeTrue(OS.IS_WINDOWS);
         final Map<String,String> info = new ProcessEnvironmentBuilderImpl().build(FAKE_PID);
--- a/system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/SystemBackendTest.java	Wed Mar 15 12:06:53 2017 +0100
+++ b/system-backend/src/test/java/com/redhat/thermostat/backend/system/internal/SystemBackendTest.java	Mon Mar 20 14:09:36 2017 -0400
@@ -79,8 +79,6 @@
 
     @Test
     public void testBasicBackend() {
-        // TODO - this test currently fails on Windows because the DLL isn't along the classpath
-        Assume.assumeTrue(OS.IS_UNIX);
         assertFalse(b.isActive());
         b.activate();
         assertTrue(b.isActive());
@@ -90,8 +88,6 @@
 
     @Test
     public void testActivateTwice() {
-        // TODO - this test currently fails on Windows because the DLL isn't along the classpath
-        Assume.assumeTrue(OS.IS_UNIX);
         b.activate();
         b.activate();
         assertTrue(b.isActive());
--- a/web/server/pom.xml	Wed Mar 15 12:06:53 2017 +0100
+++ b/web/server/pom.xml	Mon Mar 20 14:09:36 2017 -0400
@@ -50,18 +50,6 @@
 
   <name>Thermostat Web Server</name>
 
-  <profiles>
-    <profile>
-      <id>windows</id>
-      <activation>
-        <os><family>Windows</family></os>
-      </activation>
-      <properties>
-        <maven.test.skip>true</maven.test.skip>
-      </properties>
-    </profile>
-  </profiles>
-
   <dependencies>
   
     <dependency>
--- a/web/server/src/test/java/com/redhat/thermostat/web/server/WebStorageEndPointUnitTest.java	Wed Mar 15 12:06:53 2017 +0100
+++ b/web/server/src/test/java/com/redhat/thermostat/web/server/WebStorageEndPointUnitTest.java	Mon Mar 20 14:09:36 2017 -0400
@@ -65,6 +65,7 @@
 import javax.servlet.ServletException;
 
 import com.redhat.thermostat.common.internal.test.Bug;
+import com.redhat.thermostat.shared.config.OS;
 import com.redhat.thermostat.storage.core.Storage;
 import org.junit.After;
 import org.junit.Assume;
@@ -190,6 +191,7 @@
     
     @Test
     public void initThrowsRuntimeExceptionIfSSLPropertiesNotReadable() throws Exception {
+        Assume.assumeTrue(!OS.IS_WINDOWS); // Windows can't set directories readable
         ThCreatorResult result = null;
         try {
             result = creatWorkingThermostatHome();