You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/04/05 21:34:44 UTC
qpid-broker-j git commit: NO-JIRA: [Unit Tests] Fix unit test
failures on Windows - 2nd attempt
Repository: qpid-broker-j
Updated Branches:
refs/heads/master 4716b3aa8 -> 5b2b590ce
NO-JIRA: [Unit Tests] Fix unit test failures on Windows - 2nd attempt
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/5b2b590c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/5b2b590c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/5b2b590c
Branch: refs/heads/master
Commit: 5b2b590ce8d312d77826eded98572cb356eb4460
Parents: 4716b3a
Author: Keith Wall <kw...@apache.org>
Authored: Thu Apr 5 22:31:35 2018 +0100
Committer: Keith Wall <kw...@apache.org>
Committed: Thu Apr 5 22:31:45 2018 +0100
----------------------------------------------------------------------
.../charting/writer/ChartWriterTest.java | 50 ++++++--------------
1 file changed, 14 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/5b2b590c/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java
----------------------------------------------------------------------
diff --git a/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java b/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java
index eea07ee..65d55fb 100644
--- a/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java
+++ b/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java
@@ -20,39 +20,28 @@
*/
package org.apache.qpid.disttest.charting.writer;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.File;
import java.io.FileWriter;
-import java.io.InputStream;
-import java.util.Scanner;
-
-import org.apache.qpid.disttest.charting.definition.ChartingDefinition;
-import org.apache.qpid.test.utils.TestFileUtils;
-import org.apache.qpid.server.util.FileUtils;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.List;
+import com.google.common.io.Resources;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;
-import org.junit.Assert;
-
-import org.junit.Assert;
import org.junit.Before;
-import org.junit.After;
import org.junit.Test;
+import org.apache.qpid.disttest.charting.definition.ChartingDefinition;
+import org.apache.qpid.test.utils.TestFileUtils;
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 ChartWriterTest extends UnitTestBase
{
@@ -111,11 +100,10 @@ public class ChartWriterTest extends UnitTestBase
_writer.writeHtmlSummaryToFileSystem("Performance Charts");
- InputStream expectedSummaryFileInputStream = getClass().getResourceAsStream("expected-chart-summary.html");
- String expectedSummaryContent = new Scanner(expectedSummaryFileInputStream).useDelimiter("\\A").next();
- String actualSummaryContent = FileUtils.readFileAsString(summaryFile);
-
- assertEquals("HTML summary file has unexpected content", expectedSummaryContent, actualSummaryContent);
+ List<String> expected = Resources.readLines(Resources.getResource(getClass(), "expected-chart-summary.html"),
+ StandardCharsets.UTF_8);
+ List<String> actual = Files.readAllLines(summaryFile.toPath(), StandardCharsets.UTF_8);
+ assertEquals("HTML summary file has unexpected content", expected, actual);
}
@Test
@@ -137,19 +125,9 @@ public class ChartWriterTest extends UnitTestBase
private void writeDummyContentToSummaryFileToEnsureItGetsOverwritten(File summaryFile) throws Exception
{
- FileWriter writer = null;
- try
+ try(FileWriter writer = new FileWriter(summaryFile))
{
- writer = new FileWriter(summaryFile);
writer.write("dummy content");
- writer.close();
- }
- finally
- {
- if (writer != null)
- {
- writer.close();
- }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org