use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class LocalizedMessageTest method testMessageUsingBaseName.
@Test
@ResourceLock(Resources.LOCALE)
public void testMessageUsingBaseName() {
// LOG4J2-2850
final Locale defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
try {
final String testMsg = "hello_world";
final LocalizedMessage msg = new LocalizedMessage("MF", testMsg, null);
assertEquals("Hello world.", msg.getFormattedMessage());
} finally {
Locale.setDefault(defaultLocale);
}
}
use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class PropertiesUtilTest method testGetMappedProperty_sun_stderr_encoding.
@Test
@ResourceLock(value = Resources.SYSTEM_PROPERTIES, mode = ResourceAccessMode.READ)
public void testGetMappedProperty_sun_stderr_encoding() {
final PropertiesUtil pu = new PropertiesUtil(System.getProperties());
Charset expected = System.console() == null ? Charset.defaultCharset() : StandardCharsets.UTF_8;
assertEquals(expected, pu.getCharsetProperty("sun.err.encoding"));
}
use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class PropertiesUtilTest method testGetMappedProperty_sun_stdout_encoding.
@Test
@ResourceLock(value = Resources.SYSTEM_PROPERTIES, mode = ResourceAccessMode.READ)
public void testGetMappedProperty_sun_stdout_encoding() {
final PropertiesUtil pu = new PropertiesUtil(System.getProperties());
Charset expected = System.console() == null ? Charset.defaultCharset() : StandardCharsets.UTF_8;
assertEquals(expected, pu.getCharsetProperty("sun.stdout.encoding"));
}
use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.
the class PatternProcessorTest method testGetNextTimeWeeklyReturnsFirstDayOfNextWeek_FRANCE.
@Test
@ResourceLock(Resources.LOCALE)
public void testGetNextTimeWeeklyReturnsFirstDayOfNextWeek_FRANCE() {
final Locale old = Locale.getDefault();
// force 1st day of the week to be Monday
Locale.setDefault(Locale.FRANCE);
try {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-W}.log.gz");
final Calendar initial = Calendar.getInstance();
// Tue, March 4, 2014
initial.set(2014, Calendar.MARCH, 4, 10, 31, 59);
final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
// expect Monday, March 10, 2014
final Calendar expected = Calendar.getInstance();
expected.set(2014, Calendar.MARCH, 10, 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 testGetNextTimeMillisecondlyReturnsNextMillisec.
@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
public void testGetNextTimeMillisecondlyReturnsNextMillisec() {
final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm-ss.SSS}.log.gz");
final Calendar initial = Calendar.getInstance();
// Tue, March 4, 2014, 10:31:53.123
initial.set(2014, Calendar.MARCH, 4, 10, 31, 53);
initial.set(Calendar.MILLISECOND, 123);
assertEquals("2014/03/04 10:31:53.123", format(initial.getTimeInMillis()));
final long actual = pp.getNextTime(initial.getTimeInMillis(), 1, false);
// expect Tue, March 4, 2014, 10:31:53.124
final Calendar expected = Calendar.getInstance();
expected.set(2014, Calendar.MARCH, 4, 10, 31, 53);
expected.set(Calendar.MILLISECOND, 124);
assertEquals(format(expected.getTimeInMillis()), format(actual));
}
Aggregations