Commit adf03f41 authored by Ralph Goers's avatar Ralph Goers
Browse files

Hopefully fix unit test

parent 1f15422a
Showing with 14 additions and 7 deletions
+14 -7
......@@ -20,6 +20,7 @@ import java.net.URI;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.junit.LoggerContextRule;
import org.junit.Before;
import org.junit.Rule;
......@@ -35,6 +36,8 @@ public class RollingAppenderDirectWriteWithReconfigureTest {
private static final String DIR = "target/rolling-direct-reconfigure";
private static final int MAX_TRIES = 10;
public static LoggerContextRule loggerContextRule = LoggerContextRule
.createShutdownTimeoutLoggerContextRule(CONFIG);
......@@ -54,14 +57,18 @@ public class RollingAppenderDirectWriteWithReconfigureTest {
@SuppressWarnings("resource") // managed by the rule.
final LoggerContext context = loggerContextRule.getLoggerContext();
Configuration config = context.getConfiguration();
context.setConfigLocation(new URI(CONFIG));
context.reconfigure();
Thread.sleep(2000);
logger.debug("After reconfigure");
logger.debug("Force a rollover");
final File dir = new File(DIR);
for (int i = 0; i < MAX_TRIES; ++i) {
Thread.sleep(200);
if (config != context.getConfiguration()) {
break;
}
}
assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
final File[] files = dir.listFiles();
assertNotNull(files);
......
......@@ -27,11 +27,11 @@
<Console name="STDOUT">
<PatternLayout pattern="%m%n" />
</Console>
<RollingFile name="RollingFile" filePattern="${LOG_DIR}/test1-%d{MM-dd-yy-HH-mm-ss}.log">
<RollingFile name="RollingFile" filePattern="${LOG_DIR}/test1-$${date:MM-dd-yy-HH-mm-ss-SSS}.log">
<PatternLayout>
<Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
</PatternLayout>
<CronTriggeringPolicy schedule="0/1 * * * * ?" />
<SizeBasedTriggeringPolicy size="25" />
</RollingFile>
</Appenders>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment