Search in sources :

Example 1 with ConfigurationMessageEventListener

use of nl.nn.adapterframework.testutil.ConfigurationMessageEventListener in project iaf by ibissource.

the class MigratorTest method testScriptExecutionLogs.

@Test
public void testScriptExecutionLogs() throws Exception {
    AppConstants.getInstance().setProperty("liquibase.changeLogFile", "/Migrator/DatabaseChangelog.xml");
    TestAppender appender = TestAppender.newBuilder().useIbisPatternLayout("%level - %m").build();
    try {
        Configurator.reconfigure();
        TestAppender.addToRootLogger(appender);
        migrator.validate();
        // Validate Liquibase logs on INFO level
        assertTrue(appender.contains("Successfully acquired change log lock"));
        // Capture all loggers (at debug level)
        Configurator.setRootLevel(Level.DEBUG);
        // Exclude Frank!Framework loggers
        Configurator.setLevel("nl.nn", Level.WARN);
        // Set all Liquibase loggers to WARN
        Configurator.setLevel("liquibase", Level.WARN);
        appender.clearLogs();
        migrator.update();
        String msg = "LiquiBase applied [2] change(s) and added tag [two:Niels Meijer]";
        // Validate Liquibase doesn't log
        assertFalse("expected message not to be logged but found [" + appender.getLogLines() + "]", appender.contains(msg));
        ConfigurationMessageEventListener configurationMessages = configuration.getBean("ConfigurationMessageListener", ConfigurationMessageEventListener.class);
        // Validate Liquibase did run
        assertTrue(configurationMessages.contains(msg));
    } finally {
        TestAppender.removeAppender(appender);
        Configurator.reconfigure();
    }
}
Also used : TestAppender(nl.nn.adapterframework.testutil.TestAppender) ConfigurationMessageEventListener(nl.nn.adapterframework.testutil.ConfigurationMessageEventListener) Test(org.junit.Test)

Aggregations

ConfigurationMessageEventListener (nl.nn.adapterframework.testutil.ConfigurationMessageEventListener)1 TestAppender (nl.nn.adapterframework.testutil.TestAppender)1 Test (org.junit.Test)1