use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ListeningTestLoggerTest method testEmptyLine.
/**
* Checks blank lines matching.
*/
@Test
public void testEmptyLine() {
LogListener emptyLineLsnr = LogListener.matches("").build();
log.registerListener(emptyLineLsnr);
log.info("");
assertTrue(emptyLineLsnr.check());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ListeningTestLoggerTest method testMultiRange.
/**
* Checks that only last value is taken into account.
*/
@Test
public void testMultiRange() {
String msg = "multi range";
LogListener atMost3 = LogListener.matches(msg).times(1).times(2).atMost(3).build();
log.registerListener(atMost3);
for (int i = 0; i < 6; i++) {
if (i < 4)
assertTrue(atMost3.check());
else
assertFalse(atMost3.check());
log.info(msg);
}
LogListener lsnr4 = LogListener.matches(msg).atLeast(2).atMost(3).times(4).build();
log.registerListener(lsnr4);
for (int i = 1; i < 6; i++) {
log.info(msg);
if (i == 4)
assertTrue(lsnr4.check());
else
assertFalse(lsnr4.check());
}
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ListeningTestLoggerTest method testRegister.
/**
* Ensures that listener will be re-registered only once.
*/
@Test
public void testRegister() {
AtomicInteger cntr = new AtomicInteger();
LogListener lsnr3 = LogListener.matches(m -> cntr.incrementAndGet() > 0).build();
log.registerListener(lsnr3);
log.registerListener(lsnr3);
log.info("1");
assertEquals(1, cntr.get());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ListeningTestLoggerTest method testNotPresent.
/**
* Checks that substring was not found in the log messages.
*/
@Test
public void testNotPresent() {
String msg = "vacuum";
LogListener notPresent = LogListener.matches(msg).times(0).build();
log.registerListener(notPresent);
log.info("1");
assertTrue(notPresent.check());
log.info(msg);
assertFalse(notPresent.check());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class CheckpointStartLoggingTest method testCheckpointLogging.
/**
* @throws Exception if failed.
*/
@Test
public void testCheckpointLogging() throws Exception {
LogListener lsnr = LogListener.matches(Pattern.compile(CHECKPOINT_STARTED_LOG_FORMAT)).build();
testLogger.registerListener(lsnr);
Ignite ignite = startGrid();
ignite.cluster().active(true);
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
for (int i = 0; i < 1000; i++) cache.put(i, i);
forceCheckpoint();
assertTrue(lsnr.check());
}
Aggregations