Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72CBD10B76 for ; Thu, 27 Mar 2014 02:29:36 +0000 (UTC) Received: (qmail 18006 invoked by uid 500); 27 Mar 2014 02:29:36 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 17981 invoked by uid 500); 27 Mar 2014 02:29:35 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 17974 invoked by uid 99); 27 Mar 2014 02:29:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Mar 2014 02:29:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Mar 2014 02:29:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 37CD6238889B; Thu, 27 Mar 2014 02:29:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1582154 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java Date: Thu, 27 Mar 2014 02:29:14 -0000 To: commits@logging.apache.org From: mattsicker@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140327022914.37CD6238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mattsicker Date: Thu Mar 27 02:29:13 2014 New Revision: 1582154 URL: http://svn.apache.org/r1582154 Log: Update test case to use CleanFiles rule. Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java?rev=1582154&r1=1582153&r2=1582154&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java (original) +++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java Thu Mar 27 02:29:13 2014 @@ -18,9 +18,7 @@ package org.apache.logging.log4j.core.config; import java.io.BufferedReader; -import java.io.FileOutputStream; import java.io.FileReader; -import java.io.IOException; import java.security.SecureRandom; import java.util.Arrays; import java.util.Collection; @@ -33,6 +31,7 @@ import org.apache.logging.log4j.core.App import org.apache.logging.log4j.core.Filter; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.filter.ThreadContextMapFilter; +import org.apache.logging.log4j.junit.CleanFiles; import org.apache.logging.log4j.junit.InitialLoggerContext; import org.junit.Before; import org.junit.Rule; @@ -59,10 +58,12 @@ public class ConfigurationTest { private static final String FILE_LOGGER_NAME = "org.apache.logging.log4j.test2.Test"; private static final String APPENDER_NAME = "STDOUT"; - private final String configFileName; private final String logFileName; @Rule + public CleanFiles cleanFiles; + + @Rule public InitialLoggerContext init; private LoggerContext ctx; @@ -70,8 +71,8 @@ public class ConfigurationTest { private SecureRandom random = new SecureRandom(); public ConfigurationTest(final String configFileName, final String logFileName) { - this.configFileName = configFileName; this.logFileName = logFileName; + this.cleanFiles = new CleanFiles(logFileName); this.init = new InitialLoggerContext(configFileName); } @@ -88,7 +89,6 @@ public class ConfigurationTest { @Before public void setUp() throws Exception { - clearLogFile(this.configFileName); this.ctx = this.init.getContext(); } @@ -139,12 +139,4 @@ public class ConfigurationTest { assertThat(line, endsWith(Long.toString(random))); } - private static void clearLogFile(final String file) throws IOException { - final FileOutputStream fos = new FileOutputStream(file, false); - try { - fos.flush(); - } finally { - fos.close(); - } - } }