You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/08/27 06:56:02 UTC

[33/42] logging-log4j2 git commit: [LOG4J2-1548] [CronTriggeringPolicy] ConfigurationScheduler schedules the task infinitely after first fire. Better test from Pierrick HYMBERT: Added a constant RollingAppenderCronOnceADayTest.CRON_DELAY set to 10 second

[LOG4J2-1548] [CronTriggeringPolicy] ConfigurationScheduler schedules
the task infinitely after first fire. Better test from Pierrick HYMBERT:
Added a constant RollingAppenderCronOnceADayTest.CRON_DELAY set to 10
seconds (instead of 45s previously). Checked that test still failed in
this condition with previous revision of
ConfigurationScheduler.CronRunnable.run(). Test is run in 18s on
Pierrick HYMBERT's environment and cron rename action is scheduled. Test
ran in 17.645 in my Eclipse environment. Full Maven build  with 'mvn
clean test' is .

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

Branch: refs/heads/LOG4J2-1349-gcfree-threadcontext
Commit: 3e55d6817ac54f0b0890bc2cc0367855e0487c1e
Parents: 38f1497
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 26 12:28:23 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 26 12:28:23 2016 -0700

----------------------------------------------------------------------
 .../appender/rolling/RollingAppenderCronOnceADayTest.java   | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3e55d681/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
index 2e091c4..b6ee09d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderCronOnceADayTest.java
@@ -46,6 +46,7 @@ import org.junit.rules.RuleChain;
  */
 public class RollingAppenderCronOnceADayTest {
 
+    private static final int CRON_DELAY = 10;
     private static final String UTF_8 = "UTF-8";
     private static final String CONFIG = "log4j-rolling-cron-once-a-day.xml";
     private static final String CONFIG_TARGET = "log4j-rolling-cron-once-a-day-target.xml";
@@ -62,7 +63,7 @@ public class RollingAppenderCronOnceADayTest {
       final Path src = FileSystems.getDefault().getPath(TARGET_TEST_CLASSES, CONFIG);
       String content = new String(Files.readAllBytes(src), UTF_8);
       Calendar cal = Calendar.getInstance();
-      cal.add(Calendar.SECOND, 45);
+      cal.add(Calendar.SECOND, CRON_DELAY);
       remainingTime = cal.getTimeInMillis() - System.currentTimeMillis();
       cronExpression =  String.format("%d %d %d * * ?",
           cal.get(Calendar.SECOND),
@@ -104,11 +105,7 @@ public class RollingAppenderCronOnceADayTest {
         final File dir = new File(DIR);
         assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
 
-        for (int i = 1; i < 20; i++) {
-          logger.debug("Adding again event {}", i);
-        }
-        Thread.sleep(1000);
-        for (int i = 1; i < 10; i++) {
+        for (int i = 1; i < 5; i++) {
           logger.debug("Adding some more event {}", i);
           Thread.sleep(1000);
         }