use of org.apache.logging.log4j.core.test.appender.rolling.action.DummyFileAttributes in project logging-log4j2 by apache.
the class IfLastModifiedTest method testAcceptsIfFileAgeExceedsDuration.
@Test
public void testAcceptsIfFileAgeExceedsDuration() {
final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"));
final DummyFileAttributes attrs = new DummyFileAttributes();
final long age = 33 * 1000 + 5;
attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - age);
assertTrue(filter.accept(null, null, attrs));
}
use of org.apache.logging.log4j.core.test.appender.rolling.action.DummyFileAttributes in project logging-log4j2 by apache.
the class IfLastModifiedTest method testDoesNotAcceptIfFileAgeLessThanDuration.
@Test
public void testDoesNotAcceptIfFileAgeLessThanDuration() {
final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"));
final DummyFileAttributes attrs = new DummyFileAttributes();
final long age = 33 * 1000 - 5;
attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - age);
assertFalse(filter.accept(null, null, attrs));
}
use of org.apache.logging.log4j.core.test.appender.rolling.action.DummyFileAttributes in project logging-log4j2 by apache.
the class IfAccumulatedFileSizeTest method testAcceptOnceThresholdExceeded.
@Test
public void testAcceptOnceThresholdExceeded() {
final DummyFileAttributes attribs = new DummyFileAttributes();
final String[] sizes = { "2KB", "3MB", "4GB", "5TB" };
for (final String size : sizes) {
final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition(size);
final long quarter = condition.getThresholdBytes() / 4;
attribs.size = quarter;
assertFalse(condition.accept(null, null, attribs));
assertFalse(condition.accept(null, null, attribs));
assertFalse(condition.accept(null, null, attribs));
assertFalse(condition.accept(null, null, attribs));
assertTrue(condition.accept(null, null, attribs));
}
}
Aggregations