use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class PatternProcessorTest method testGetNextTimeMonthlyReturnsFirstDayOfNextYear.
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
public void testGetNextTimeMonthlyReturnsFirstDayOfNextYear() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
final Calendar initial = Calendar.getInstance();
initial.set(2015, Calendar.DECEMBER, 28, 0, 0, 0);
final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
// We expect 1st day of next month
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));
}
use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class PatternProcessorTest method testGetNextTimeWeeklyReturnsFirstWeekInYear_US.
/**
* Tests https://issues.apache.org/jira/browse/LOG4J2-1232
*/
@Test
@ResourceLock(Resources.LOCALE)
public void testGetNextTimeWeeklyReturnsFirstWeekInYear_US() {
final Locale old = Locale.getDefault();
// force 1st day of the week to be Sunday
Locale.setDefault(Locale.US);
try {
final PatternProcessor pp = new PatternProcessor("logs/market_data_msg.log-%d{yyyy-MM-'W'W}");
final Calendar initial = Calendar.getInstance();
// Monday, December 28, 2015
initial.set(2015, Calendar.DECEMBER, 28, 0, 0, 0);
final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
// expect Sunday January 3, 2016
final Calendar expected = Calendar.getInstance();
expected.set(2016, Calendar.JANUARY, 3, 0, 0, 0);
expected.set(Calendar.MILLISECOND, 0);
assertEquals(format(expected.getTimeInMillis()), format(actual));
} finally {
Locale.setDefault(old);
}
}
use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class PatternProcessorTest method testGetNextTimeHourlyReturnsFirstMinuteOfNextYear.
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
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));
}
use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class PatternProcessorTest method testGetNextTimeMinutelyReturnsFirstSecondOfNextMinute.
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
public void testGetNextTimeMinutelyReturnsFirstSecondOfNextMinute() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm}.log.gz");
final Calendar initial = Calendar.getInstance();
// Tue, March 4, 2014, 10:31
initial.set(2014, Calendar.MARCH, 4, 10, 31, 59);
initial.set(Calendar.MILLISECOND, 0);
assertEquals("2014/03/04 10:31:59.000", format(initial.getTimeInMillis()));
final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
// expect Tue, March 4, 2014, 10:32
final Calendar expected = Calendar.getInstance();
expected.set(2014, Calendar.MARCH, 4, 10, 32, 0);
expected.set(Calendar.MILLISECOND, 0);
assertEquals(format(expected.getTimeInMillis()), format(actual));
}
use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class PatternProcessorTest method testGetNextTimeMonthlyReturnsFirstDayOfNextMonth2.
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
public void testGetNextTimeMonthlyReturnsFirstDayOfNextMonth2() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM}.log.gz");
final Calendar initial = Calendar.getInstance();
// 2014 Jan 31st
initial.set(2014, Calendar.JANUARY, 31, 10, 31, 59);
final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
// Expect 1st of next month: 2014 Feb 1st
final Calendar expected = Calendar.getInstance();
expected.set(2014, Calendar.FEBRUARY, 1, 0, 0, 0);
expected.set(Calendar.MILLISECOND, 0);
assertEquals(format(expected.getTimeInMillis()), format(actual));
}
Aggregations