You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/04/15 04:22:16 UTC
svn commit: r1587385 - in
/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config:
ConfigurationTest.java FileOutputTest.java
Author: mattsicker
Date: Tue Apr 15 02:22:16 2014
New Revision: 1587385
URL: http://svn.apache.org/r1587385
Log:
Fix unit tests on Windows.
- Thanks to Bruce Brouwer for the fix!
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.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=1587385&r1=1587384&r2=1587385&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 Tue Apr 15 02:22:16 2014
@@ -36,6 +36,8 @@ import org.apache.logging.log4j.junit.In
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@@ -61,10 +63,9 @@ public class ConfigurationTest {
private final String logFileName;
@Rule
- public CleanFiles cleanFiles;
-
- @Rule
- public InitialLoggerContext init;
+ public RuleChain rules;
+
+ private InitialLoggerContext init;
private LoggerContext ctx;
@@ -72,17 +73,17 @@ public class ConfigurationTest {
public ConfigurationTest(final String configFileName, final String logFileName) {
this.logFileName = logFileName;
- this.cleanFiles = new CleanFiles(logFileName);
this.init = new InitialLoggerContext(configFileName);
+ rules = RuleChain.outerRule(new CleanFiles(logFileName)).around(this.init);
}
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(
new Object[][]{
- {"log4j-test1.xml", "target/test.log"},
- {"log4j-test1.json", "target/test.log"},
- {"log4j-test1.yaml", "target/test.log"}
+ {"classpath:log4j-test1.xml", "target/test.log"},
+ {"classpath:log4j-test1.json", "target/test.log"},
+ {"classpath:log4j-test1.yaml", "target/test.log"}
}
);
}
Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java?rev=1587385&r1=1587384&r2=1587385&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/FileOutputTest.java Tue Apr 15 02:22:16 2014
@@ -16,47 +16,32 @@
*/
package org.apache.logging.log4j.core.config;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.xml.XMLConfiguration;
+
+import org.apache.logging.log4j.junit.CleanFiles;
import org.apache.logging.log4j.junit.InitialLoggerContext;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
+import org.junit.rules.RuleChain;
/**
*
*/
public class FileOutputTest {
- private static final String CONFIG = "log4j-filetest.xml";
+ private static final String CONFIG = "classpath:log4j-filetest.xml";
private static final String STATUS_LOG = "target/status.log";
@Rule
- public InitialLoggerContext init = new InitialLoggerContext(CONFIG);
-
- @Before
- public void setupClass() {
- final LoggerContext ctx = this.init.getContext();
- final Configuration config = ctx.getConfiguration();
- if (config instanceof XMLConfiguration) {
- final String name = config.getName();
- if (name == null || !name.equals("XMLConfigTest")) {
- ctx.reconfigure();
- }
- } else {
- ctx.reconfigure();
- }
- }
+ public RuleChain rules = RuleChain.outerRule(new CleanFiles(STATUS_LOG)).around(new InitialLoggerContext(CONFIG));
@Test
public void testConfig() {
final File file = new File(STATUS_LOG);
assertTrue("Status output file does not exist", file.exists());
assertTrue("File is empty", file.length() > 0);
- assertTrue("Couldn't delete file " + file, file.delete());
}
}