Repository: logging-log4j2
Updated Branches:
  refs/heads/master 97ebed83b -> c185dfb55


Be a little more lenient in allowing more time for certain tests to run.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c185dfb5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c185dfb5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c185dfb5

Branch: refs/heads/master
Commit: c185dfb55c30f5c16b507b915723fa235e0b46c2
Parents: 97ebed8
Author: Gary Gregory <[email protected]>
Authored: Wed Mar 25 10:14:50 2015 -0700
Committer: Gary Gregory <[email protected]>
Committed: Wed Mar 25 10:14:50 2015 -0700

----------------------------------------------------------------------
 .../apache/logging/log4j/core/LoggerTest.java    |  3 +++
 .../log4j/core/async/AsyncLoggerConfigTest.java  | 19 ++++++++++---------
 .../log4j/core/config/TestConfigurator.java      | 15 ++++++++++++---
 3 files changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c185dfb5/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
index 62a6e68..2e27bf4 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
@@ -207,6 +207,9 @@ public class LoggerTest {
             logger.debug("Reconfigure");
         }
         Thread.sleep(100);
+        if (context.getConfiguration() != oldConfig) {
+            Thread.sleep(500);
+        }
         final Configuration newConfig = context.getConfiguration();
         assertNotNull("No configuration", newConfig);
         assertNotSame("Reconfiguration failed", newConfig, oldConfig);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c185dfb5/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
index ea176ad..f4d8171 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
@@ -33,32 +33,33 @@ public class AsyncLoggerConfigTest {
 
     @BeforeClass
     public static void beforeClass() {
-        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
-                "AsyncLoggerConfigTest.xml");
+        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, 
"AsyncLoggerConfigTest.xml");
     }
 
     @Test
     public void testAdditivity() throws Exception {
-        final File f = new File("target", "AsyncLoggerConfigTest.log");
-        assertTrue("Deleted old file before test", !f.exists() || f.delete());
-        
+        final File file = new File("target", "AsyncLoggerConfigTest.log");
+        assertTrue("Deleted old file before test", !file.exists() || 
file.delete());
+
         final Logger log = LogManager.getLogger("com.foo.Bar");
         final String msg = "Additive logging: 2 for the price of 1!";
         log.info(msg);
         ((LifeCycle) LogManager.getContext()).stop(); // stop async thread
+        if (file.length() == 0) {
+            Thread.sleep(500);
+        }
 
-        final BufferedReader reader = new BufferedReader(new FileReader(f));
+        final BufferedReader reader = new BufferedReader(new FileReader(file));
         final String line1 = reader.readLine();
         final String line2 = reader.readLine();
         reader.close();
-        f.delete();
+        file.delete();
         assertNotNull("line1", line1);
         assertNotNull("line2", line2);
         assertTrue("line1 correct", line1.contains(msg));
         assertTrue("line2 correct", line2.contains(msg));
 
         final String location = "testAdditivity";
-        assertTrue("location",
-                line1.contains(location) || line2.contains(location));
+        assertTrue("location", line1.contains(location) || 
line2.contains(location));
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c185dfb5/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
index c54ef5c..52e4055 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
@@ -233,13 +233,22 @@ public class TestConfigurator {
         assertNotNull("Appenders map should not be null.", map);
         assertThat(map, hasSize(greaterThan(0)));
         assertThat("Wrong configuration", map, hasKey("List"));
-
-        Thread.sleep(500);
+        
+        // Sleep and check
+        Thread.sleep(50);
+        if (!file.setLastModified(System.currentTimeMillis())) {
+            Thread.sleep(500);
+        }
         assertTrue("setLastModified should have succeeded.", 
file.setLastModified(System.currentTimeMillis()));
         for (int i = 0; i < 17; ++i) {
             logger.debug("Test message " + i);
         }
-        Thread.sleep(100);
+        
+        // Sleep and check        
+        Thread.sleep(50);            
+        if (is(theInstance(config)).matches(ctx.getConfiguration())) {
+            Thread.sleep(500);            
+        }
         final Configuration newConfig = ctx.getConfiguration();
         assertThat("Configuration not reset", newConfig, 
is(not(theInstance(config))));
         Configurator.shutdown(ctx);

Reply via email to