Search in sources :

Example 16 with ResourceLock

use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.

the class CollectionLoggingTest method testSystemProperties.

@Test
@ResourceLock(value = Resources.SYSTEM_PROPERTIES, mode = ResourceAccessMode.READ)
public void testSystemProperties(final LoggerContext context) {
    final Logger logger = context.getLogger(CollectionLoggingTest.class.getName());
    logger.error(System.getProperties());
// logger.error(new MapMessage(System.getProperties()));
// TODO: some assertions
}
Also used : Logger(org.apache.logging.log4j.Logger) Test(org.junit.jupiter.api.Test) ResourceLock(org.junit.jupiter.api.parallel.ResourceLock)

Example 17 with ResourceLock

use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.

the class FileSizeTest method testParseInEurope.

@Test
@ResourceLock(Resources.LOCALE)
public void testParseInEurope() {
    // Caveat: Breaks the ability for this test to run in parallel with other tests :(
    Locale previousDefault = Locale.getDefault();
    try {
        Locale.setDefault(new Locale("de", "DE"));
        assertEquals(1000, FileSize.parse("1,000", 0));
    } finally {
        Locale.setDefault(previousDefault);
    }
}
Also used : Locale(java.util.Locale) Test(org.junit.jupiter.api.Test) ResourceLock(org.junit.jupiter.api.parallel.ResourceLock)

Example 18 with ResourceLock

use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.

the class PropertiesUtilTest method testPublish.

@Test
@ResourceLock(value = Resources.SYSTEM_PROPERTIES, mode = ResourceAccessMode.READ)
public void testPublish() {
    final Properties props = new Properties();
    final PropertiesUtil util = new PropertiesUtil(props);
    String value = System.getProperty("Application");
    assertNotNull(value, "System property was not published");
    assertEquals("Log4j", value);
}
Also used : Properties(java.util.Properties) Test(org.junit.jupiter.api.Test) ResourceLock(org.junit.jupiter.api.parallel.ResourceLock)

Example 19 with ResourceLock

use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.

the class PropertiesUtilTest method testNonStringSystemProperties.

@Test
@ResourceLock(Resources.SYSTEM_PROPERTIES)
public void testNonStringSystemProperties() {
    Object key1 = "1";
    Object key2 = new Object();
    System.getProperties().put(key1, new Object());
    System.getProperties().put(key2, "value-2");
    try {
        final PropertiesUtil util = new PropertiesUtil(new Properties());
        assertNull(util.getStringProperty("1"));
    } finally {
        System.getProperties().remove(key1);
        System.getProperties().remove(key2);
    }
}
Also used : Properties(java.util.Properties) Test(org.junit.jupiter.api.Test) ResourceLock(org.junit.jupiter.api.parallel.ResourceLock)

Example 20 with ResourceLock

use of org.junit.jupiter.api.parallel.ResourceLock in project logging-log4j2 by apache.

the class PatternProcessorTest method testGetNextTimeSecondlyReturnsFirstMillisecOfNextSecond.

@Test
@ResourceLock(value = Resources.LOCALE, mode = ResourceAccessMode.READ)
public void testGetNextTimeSecondlyReturnsFirstMillisecOfNextSecond() {
    final PatternProcessor pp = new PatternProcessor("logs/app-%d{yyyy-MM-dd-HH-mm-ss}.log.gz");
    final Calendar initial = Calendar.getInstance();
    // Tue, March 4, 2014, 10:31:53
    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:54
    final Calendar expected = Calendar.getInstance();
    expected.set(2014, Calendar.MARCH, 4, 10, 31, 54);
    expected.set(Calendar.MILLISECOND, 0);
    assertEquals(format(expected.getTimeInMillis()), format(actual));
}
Also used : Calendar(java.util.Calendar) Test(org.junit.jupiter.api.Test) ResourceLock(org.junit.jupiter.api.parallel.ResourceLock)

Aggregations

Test (org.junit.jupiter.api.Test)30 ResourceLock (org.junit.jupiter.api.parallel.ResourceLock)30 Calendar (java.util.Calendar)14 Locale (java.util.Locale)6 Transaction (org.neo4j.graphdb.Transaction)4 IndexCreator (org.neo4j.graphdb.schema.IndexCreator)4 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)4 Schema (org.neo4j.graphdb.schema.Schema)4 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)4 Charset (java.nio.charset.Charset)2 Properties (java.util.Properties)2 Logger (org.apache.logging.log4j.Logger)2 StatusData (org.apache.logging.log4j.status.StatusData)2 HashMap (java.util.HashMap)1 StringMapMessage (org.apache.logging.log4j.message.StringMapMessage)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Nested (org.junit.jupiter.api.Nested)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 Resources (org.junit.jupiter.api.parallel.Resources)1