qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject qpid-broker-j git commit: NO-JIRA: [Unit Tests] Fix unit test failures on Windows
Date Wed, 04 Apr 2018 12:52:18 GMT
Repository: qpid-broker-j
Updated Branches:
  refs/heads/master cfb113bf3 -> 4716b3aa8


NO-JIRA: [Unit Tests] Fix unit test failures on Windows


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/4716b3aa
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/4716b3aa
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/4716b3aa

Branch: refs/heads/master
Commit: 4716b3aa81e1349fe1afb217e1fadd3f88ea8d6b
Parents: cfb113b
Author: Keith Wall <kwall@apache.org>
Authored: Wed Apr 4 13:39:21 2018 +0100
Committer: Keith Wall <kwall@apache.org>
Committed: Wed Apr 4 13:39:21 2018 +0100

----------------------------------------------------------------------
 .../server/store/JsonFileConfigStoreTest.java   |  7 ++-
 .../disttest/results/ResultsXmlWriterTest.java  | 33 +++++-------
 .../disttest/charting/writer/ChartWriter.java   | 57 +++++++-------------
 3 files changed, 38 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4716b3aa/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
b/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
index c1da8da..2320610 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
@@ -20,9 +20,12 @@
  */
 package org.apache.qpid.server.store;
 
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.argThat;
 import static org.mockito.Mockito.inOrder;
@@ -113,7 +116,9 @@ public class JsonFileConfigStoreTest extends UnitTestBase
     @Test
     public void testInvalidStorePath() throws Exception
     {
-        when(_parent.getStorePath()).thenReturn(System.getProperty("file.separator"));
+        String unwritablePath = System.getProperty("file.separator");
+        assumeThat(new File(unwritablePath).canWrite(), is(equalTo(false)));
+        when(_parent.getStorePath()).thenReturn(unwritablePath);
         try
         {
             _store.init(_parent);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4716b3aa/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
b/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
index 3b380a0..d4edcd4 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
@@ -44,16 +44,7 @@ import org.apache.qpid.test.utils.TestFileUtils;
 import org.junit.Test;
 
 import org.apache.qpid.test.utils.UnitTestBase;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertNotNull;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
 
 public class ResultsXmlWriterTest extends UnitTestBase
 {
@@ -72,8 +63,8 @@ public class ResultsXmlWriterTest extends UnitTestBase
     {
         ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
 
-        String expectedXmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-                                    + "<testsuite tests=\"0\"/>\n";
+        String expectedXmlContent = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n"
+                + "<testsuite tests=\"0\"/>%n");
 
         _resultsFileWriter.writeResults(resultsForAllTests, "config.json");
 
@@ -91,10 +82,10 @@ public class ResultsXmlWriterTest extends UnitTestBase
         ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
         when(resultsForAllTests.getTestResults()).thenReturn(Collections.singletonList(test));
 
-        String expectedXmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-                                    + "<testsuite tests=\"1\">\n"
-                                    + "  <testcase classname=\"config.json\" name=\"mytest\"/>\n"
-                                    + "</testsuite>\n";
+        String expectedXmlContent = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n"
+                + "<testsuite tests=\"1\">%n"
+                + "  <testcase classname=\"config.json\" name=\"mytest\"/>%n"
+                + "</testsuite>%n");
 
         _resultsFileWriter.writeResults(resultsForAllTests, "config.json");
 
@@ -118,12 +109,12 @@ public class ResultsXmlWriterTest extends UnitTestBase
         ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
         when(resultsForAllTests.getTestResults()).thenReturn(Collections.singletonList(test));
 
-        String expectedXmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-                                     + "<testsuite tests=\"1\">\n"
-                                     + "  <testcase classname=\"config.json\" name=\"mytest\">\n"
-                                     + "    <error message=\"something went wrong\"/>\n"
-                                     + "  </testcase>\n"
-                                     + "</testsuite>\n";
+        String expectedXmlContent = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n"
+                + "<testsuite tests=\"1\">%n"
+                + "  <testcase classname=\"config.json\" name=\"mytest\">%n"
+                + "    <error message=\"something went wrong\"/>%n"
+                + "  </testcase>%n"
+                + "</testsuite>%n");
 
         _resultsFileWriter.writeResults(resultsForAllTests, "config.json");
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/4716b3aa/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java
----------------------------------------------------------------------
diff --git a/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java
b/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java
index 0ea5807..92361ad 100644
--- a/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java
+++ b/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java
@@ -88,45 +88,42 @@ public class ChartWriter
         }
 
         String htmlHeader = String.format(
-            "<html>\n" +
-            "    <head>\n" +
-            "        <title>%s</title>\n" +
-            "        <style type='text/css'>figure { float: left; display: table; width:
87px;}</style>\n" +
-            "    </head>\n" +
-            "    <body>\n" +
-            "        <h1>%s</h1>\n", summaryPageTitle, summaryPageTitle);
+            "<html>%n" +
+            "    <head>%n" +
+            "        <title>%s</title>%n" +
+            "        <style type='text/css'>figure { float: left; display: table; width:
87px;}</style>%n" +
+            "    </head>%n" +
+            "    <body>%n" +
+            "        <h1>%s</h1>%n", summaryPageTitle, summaryPageTitle);
 
         String htmlFooter =
-            "    </body>\n" +
-            "</html>";
+                String.format("    </body>%n" +
+                        "</html>");
 
-        BufferedWriter writer = null;
-        try
+        File summaryFile = new File(_chartDirectory, SUMMARY_FILE_NAME);
+        LOGGER.debug("About to produce HTML summary file " + summaryFile.getAbsolutePath()
+ " from charts " + _chartFilesToChartDef);
+        try(BufferedWriter writer = new BufferedWriter(new FileWriter(summaryFile)))
         {
-            File summaryFile = new File(_chartDirectory, SUMMARY_FILE_NAME);
-            LOGGER.debug("About to produce HTML summary file " + summaryFile.getAbsolutePath()
+ " from charts " + _chartFilesToChartDef);
-
-            writer = new BufferedWriter(new FileWriter(summaryFile));
             writer.write(htmlHeader);
 
-            writer.write("        <ul>\n");
+            writer.write(String.format("        <ul>%n"));
             for (File chartFile : _chartFilesToChartDef.keySet())
             {
-                writer.write("            <li><a href='#"+ chartFile.getName() +"'>"
+ chartFile.getName() + "</a></li>\n");
+                writer.write(String.format("            <li><a href='#" + chartFile.getName()
+ "'>" + chartFile.getName() + "</a></li>%n"));
             }
-            writer.write("        </ul>\n");
+            writer.write(String.format("        </ul>%n"));
 
             for (File chartFile : _chartFilesToChartDef.keySet())
             {
                 ChartingDefinition def = _chartFilesToChartDef.get(chartFile);
-                writer.write("        <figure>\n");
-                writer.write("          <a name='" + chartFile.getName() + "'/>\n");
-                writer.write("          <img src='" + chartFile.getName() + "'/>\n");
+                writer.write(String.format("        <figure>%n"));
+                writer.write(String.format("          <a name='" + chartFile.getName()
+ "'/>%n"));
+                writer.write(String.format("          <img src='" + chartFile.getName()
+ "'/>%n"));
                 if (def.getChartDescription() != null)
                 {
-                    writer.write("          <figcaption>" + def.getChartDescription()
+ "</figcaption>\n");
+                    writer.write(String.format("          <figcaption>%s</figcaption>%n",
def.getChartDescription()));
                 }
-                writer.write("        </figure>\n");
+                writer.write(String.format("        </figure>%n"));
             }
             writer.write(htmlFooter);
             writer.close();
@@ -135,20 +132,6 @@ public class ChartWriter
         {
             throw new ChartingException("Failed to create HTML summary file", e);
         }
-        finally
-        {
-            if(writer != null)
-            {
-                try
-                {
-                    writer.close();
-                }
-                catch(IOException e)
-                {
-                    throw new ChartingException("Failed to create HTML summary file", e);
-                }
-            }
-        }
     }
 
     public void setOutputDirectory(final File chartDirectory)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message