Search in sources :

Example 1 with DeleteAction

use of org.apache.logging.log4j.core.appender.rolling.action.DeleteAction in project logging-log4j2 by apache.

the class DeleteActionTest method testGetFiltersReturnsConstructorValue.

@Test
public void testGetFiltersReturnsConstructorValue() {
    final PathCondition[] filters = { new FixedCondition(true), new FixedCondition(false) };
    final DeleteAction delete = create("any", true, 0, false, filters);
    assertEquals(Arrays.asList(filters), delete.getPathConditions());
}
Also used : PathCondition(org.apache.logging.log4j.core.appender.rolling.action.PathCondition) DeleteAction(org.apache.logging.log4j.core.appender.rolling.action.DeleteAction) Test(org.junit.Test)

Example 2 with DeleteAction

use of org.apache.logging.log4j.core.appender.rolling.action.DeleteAction in project logging-log4j2 by apache.

the class DeleteActionTest method testGetBasePathStringReturnsOriginalParam.

@Test
public void testGetBasePathStringReturnsOriginalParam() {
    final DeleteAction delete = createAnyFilter("${sys:user.home}/a/b/c", false, 1, false);
    assertEquals("${sys:user.home}/a/b/c", delete.getBasePathString());
}
Also used : DeleteAction(org.apache.logging.log4j.core.appender.rolling.action.DeleteAction) Test(org.junit.Test)

Example 3 with DeleteAction

use of org.apache.logging.log4j.core.appender.rolling.action.DeleteAction in project logging-log4j2 by apache.

the class DeleteActionTest method testGetBasePathResolvesLookups.

@Test
public void testGetBasePathResolvesLookups() {
    final DeleteAction delete = createAnyFilter("${sys:user.home}/a/b/c", false, 1, false);
    final Path actual = delete.getBasePath();
    final String expected = System.getProperty("user.home") + "/a/b/c";
    assertEquals(FileSystems.getDefault().getPath(expected), actual);
}
Also used : Path(java.nio.file.Path) DeleteAction(org.apache.logging.log4j.core.appender.rolling.action.DeleteAction) Test(org.junit.Test)

Example 4 with DeleteAction

use of org.apache.logging.log4j.core.appender.rolling.action.DeleteAction in project logging-log4j2 by apache.

the class DeleteActionTest method testCreateFileVisitorTestModeIsActionTestMode.

@Test
public void testCreateFileVisitorTestModeIsActionTestMode() {
    final DeleteAction delete = createAnyFilter("any", true, 0, false);
    assertFalse(delete.isTestMode());
    final FileVisitor<Path> visitor = delete.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
    assertTrue(visitor instanceof DeletingVisitor);
    assertFalse(((DeletingVisitor) visitor).isTestMode());
    final DeleteAction deleteTestMode = createAnyFilter("any", true, 0, true);
    assertTrue(deleteTestMode.isTestMode());
    final FileVisitor<Path> testVisitor = deleteTestMode.createFileVisitor(delete.getBasePath(), delete.getPathConditions());
    assertTrue(testVisitor instanceof DeletingVisitor);
    assertTrue(((DeletingVisitor) testVisitor).isTestMode());
}
Also used : Path(java.nio.file.Path) DeletingVisitor(org.apache.logging.log4j.core.appender.rolling.action.DeletingVisitor) DeleteAction(org.apache.logging.log4j.core.appender.rolling.action.DeleteAction) Test(org.junit.Test)

Example 5 with DeleteAction

use of org.apache.logging.log4j.core.appender.rolling.action.DeleteAction in project logging-log4j2 by apache.

the class DeleteActionTest method testGetMaxDepthReturnsConstructorValue.

@Test
public void testGetMaxDepthReturnsConstructorValue() {
    final DeleteAction delete = createAnyFilter("any", false, 23, false);
    assertEquals(23, delete.getMaxDepth());
}
Also used : DeleteAction(org.apache.logging.log4j.core.appender.rolling.action.DeleteAction) Test(org.junit.Test)

Aggregations

DeleteAction (org.apache.logging.log4j.core.appender.rolling.action.DeleteAction)9 Test (org.junit.Test)8 Path (java.nio.file.Path)3 DeletingVisitor (org.apache.logging.log4j.core.appender.rolling.action.DeletingVisitor)2 BasicConfigurationFactory (org.apache.logging.log4j.core.BasicConfigurationFactory)1 PathCondition (org.apache.logging.log4j.core.appender.rolling.action.PathCondition)1 Configuration (org.apache.logging.log4j.core.config.Configuration)1