Repository: logging-log4j2 Updated Branches: refs/heads/master 5dde5e5ec -> b6afdc1d2
Move file clean up into an @After method. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b6afdc1d Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b6afdc1d Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b6afdc1d Branch: refs/heads/master Commit: b6afdc1d28d9b9fc3928a3b125444e8528c3d764 Parents: 5dde5e5 Author: Gary Gregory <ggreg...@apache.org> Authored: Thu Jun 23 17:57:30 2016 -0700 Committer: Gary Gregory <ggreg...@apache.org> Committed: Thu Jun 23 17:57:30 2016 -0700 ---------------------------------------------------------------------- .../rolling/RollingAppenderSizeTest.java | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b6afdc1d/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java index 020be61..92b44de 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java @@ -16,6 +16,15 @@ */ package org.apache.logging.log4j.core.appender.rolling; +import static org.apache.logging.log4j.hamcrest.Descriptors.that; +import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.hasItemInArray; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -35,6 +44,7 @@ import org.apache.commons.compress.utils.IOUtils; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.util.Closer; import org.apache.logging.log4j.junit.LoggerContextRule; +import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -43,12 +53,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import static org.apache.logging.log4j.hamcrest.Descriptors.that; -import static org.apache.logging.log4j.hamcrest.FileMatchers.hasName; -import static org.hamcrest.Matchers.endsWith; -import static org.hamcrest.Matchers.hasItemInArray; -import static org.junit.Assert.*; - /** * */ @@ -98,6 +102,11 @@ public class RollingAppenderSizeTest { this.logger = this.loggerContextRule.getLogger(RollingAppenderSizeTest.class.getName()); } + @After + public void tearDown() { + deleteDir(); + } + @Test public void testAppender() throws Exception { for (int i = 0; i < 100; ++i) { @@ -130,15 +139,14 @@ public class RollingAppenderSizeTest { final String text = new String(baos.toByteArray(), Charset.defaultCharset()); final String[] lines = text.split("[\\r\\n]+"); for (final String line : lines) { - assertTrue(line - .contains("DEBUG o.a.l.l.c.a.r.RollingAppenderSizeTest [main] This is test message number")); + assertTrue(line.contains( + "DEBUG o.a.l.l.c.a.r.RollingAppenderSizeTest [main] This is test message number")); } } finally { Closer.close(in); } } } - deleteDir(); } private static void deleteDir() { @@ -151,8 +159,8 @@ public class RollingAppenderSizeTest { } Files.delete(Paths.get(DIR)); } catch (final IOException ioe) { - fail("Unable to delete " + fileName + " due to " + ioe.getClass().getSimpleName() + ": " + - ioe.getMessage()); + fail("Unable to delete " + fileName + " due to " + ioe.getClass().getSimpleName() + ": " + + ioe.getMessage()); } } }