From commits-return-44583-archive-asf-public=cust-asf.ponee.io@qpid.apache.org Wed Apr 4 14:52:20 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id C3AB618064F for ; Wed, 4 Apr 2018 14:52:19 +0200 (CEST) Received: (qmail 97971 invoked by uid 500); 4 Apr 2018 12:52:18 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 97962 invoked by uid 99); 4 Apr 2018 12:52:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Apr 2018 12:52:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C90F8EABD8; Wed, 4 Apr 2018 12:52:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kwall@apache.org To: commits@qpid.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: qpid-broker-j git commit: NO-JIRA: [Unit Tests] Fix unit test failures on Windows Date: Wed, 4 Apr 2018 12:52:18 +0000 (UTC) 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 Authored: Wed Apr 4 13:39:21 2018 +0100 Committer: Keith Wall 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 = "\n" - + "\n"; + String expectedXmlContent = String.format("%n" + + "%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 = "\n" - + "\n" - + " \n" - + "\n"; + String expectedXmlContent = String.format("%n" + + "%n" + + " %n" + + "%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 = "\n" - + "\n" - + " \n" - + " \n" - + " \n" - + "\n"; + String expectedXmlContent = String.format("%n" + + "%n" + + " %n" + + " %n" + + " %n" + + "%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( - "\n" + - " \n" + - " %s\n" + - " \n" + - " \n" + - " \n" + - "

%s

\n", summaryPageTitle, summaryPageTitle); + "%n" + + " %n" + + " %s%n" + + " %n" + + " %n" + + " %n" + + "

%s

%n", summaryPageTitle, summaryPageTitle); String htmlFooter = - " \n" + - ""; + String.format(" %n" + + ""); - 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("
    \n"); + writer.write(String.format(" \n"); + writer.write(String.format("
%n")); for (File chartFile : _chartFilesToChartDef.keySet()) { ChartingDefinition def = _chartFilesToChartDef.get(chartFile); - writer.write("
\n"); - writer.write(" \n"); - writer.write(" \n"); + writer.write(String.format("
%n")); + writer.write(String.format(" %n")); + writer.write(String.format(" %n")); if (def.getChartDescription() != null) { - writer.write("
" + def.getChartDescription() + "
\n"); + writer.write(String.format("
%s
%n", def.getChartDescription())); } - writer.write("
\n"); + writer.write(String.format("
%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