Add tests for [LOG4J2-1232] Incorrect log rotation in last week of year. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f28d3d8b Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f28d3d8b Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f28d3d8b
Branch: refs/heads/LOG4J-1181 Commit: f28d3d8b42d23109f400980ae5d93c5c953bab40 Parents: d7efe9a Author: ggregory <ggreg...@apache.org> Authored: Thu Dec 31 18:51:06 2015 -0800 Committer: ggregory <ggreg...@apache.org> Committed: Thu Dec 31 18:51:06 2015 -0800 ---------------------------------------------------------------------- .../core/appender/rolling/PatternProcessorTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f28d3d8b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java index cebb0f4..c06b815 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessorTest.java @@ -171,6 +171,19 @@ public class PatternProcessorTest { } @Test + public void testGetNextTimeHourlyReturnsFirstMinuteOfNextYear() { + final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH}.log.gz"); + final Calendar initial = Calendar.getInstance(); + initial.set(2015, Calendar.DECEMBER, 31, 23, 31, 59); + final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false); + + final Calendar expected = Calendar.getInstance(); + expected.set(2016, Calendar.JANUARY, 1, 0, 0, 0); + expected.set(Calendar.MILLISECOND, 0); + assertEquals(format(expected.getTimeInMillis()), format(actual)); + } + + @Test public void testGetNextTimeHourlyReturnsFirstMinuteOfNextHour2() { final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH}.log.gz"); final Calendar initial = Calendar.getInstance();