Search in sources :

Example 11 with TestConfiguration

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

the class ApplicationMessageEventTest method testConfigurationMessage.

@Test
public void testConfigurationMessage() {
    TestConfiguration configuration = new TestConfiguration();
    configuration.publishEvent(new ConfigurationMessageEvent(configuration, "test 123"));
    MessageKeeper globalKeeper = configuration.getGlobalMessageKeeper();
    assertEquals(2, globalKeeper.size());
    assertEquals("INFO", globalKeeper.getMessage(1).getMessageLevel());
    assertEquals("Configuration [TestConfiguration] test 123", globalKeeper.getMessage(1).getMessageText());
    MessageKeeper configKeeper = configuration.getMessageKeeper();
    assertEquals(2, configKeeper.size());
    assertEquals("INFO", configKeeper.getMessage(1).getMessageLevel());
    assertEquals("Configuration [TestConfiguration] test 123", configKeeper.getMessage(1).getMessageText());
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) MessageKeeper(nl.nn.adapterframework.util.MessageKeeper) Test(org.junit.Test)

Example 12 with TestConfiguration

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

the class TestApplicationWarnings method setUp.

@Before
public void setUp() {
    // Remove old instance if present
    ApplicationWarnings.removeInstance();
    configuration = new TestConfiguration();
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Before(org.junit.Before)

Example 13 with TestConfiguration

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

the class PipeLineTest method testDuplicateExits.

@Test
public void testDuplicateExits() throws ConfigurationException {
    TestConfiguration configuration = new TestConfiguration();
    Adapter adapter = new Adapter();
    PipeLine pipeline = new PipeLine();
    pipeline.setApplicationContext(configuration);
    PipeLineExit exit = new PipeLineExit();
    exit.setPath("success");
    exit.setState(ExitState.SUCCESS);
    pipeline.registerPipeLineExit(exit);
    pipeline.registerPipeLineExit(exit);
    adapter.setPipeLine(pipeline);
    List<String> warnings = configuration.getConfigurationWarnings().getWarnings();
    assertEquals(warnings.size(), 1);
    String lastWarning = warnings.get(warnings.size() - 1);
    assertThat(lastWarning, StringEndsWith.endsWith("PipeLine exit named [success] already exists"));
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Test(org.junit.Test)

Example 14 with TestConfiguration

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

the class PipeLineTest method testFixedForwardPipesWithNoForwardShouldDefaultToNextPipe.

@Test
public void testFixedForwardPipesWithNoForwardShouldDefaultToNextPipe() throws ConfigurationException {
    TestConfiguration configuration = new TestConfiguration();
    PipeLine pipeline = configuration.createBean(PipeLine.class);
    String pipeForwardName = "EchoPipe next pipe";
    EchoPipe pipe = configuration.createBean(EchoPipe.class);
    pipe.setName(pipe.getClass().getSimpleName() + " under test");
    pipe.setPipeLine(pipeline);
    pipeline.addPipe(pipe);
    EchoPipe pipe2 = configuration.createBean(EchoPipe.class);
    pipe2.setName(pipeForwardName);
    pipe2.setPipeLine(pipeline);
    pipeline.addPipe(pipe2);
    PipeLineExit exit = new PipeLineExit();
    exit.setPath("exit");
    exit.setState(ExitState.SUCCESS);
    pipeline.registerPipeLineExit(exit);
    pipeline.configure();
    assertTrue("pipe should not cause any configuration warnings", configuration.getConfigurationWarnings().getWarnings().isEmpty());
    assertEquals("pipe1 should only have 1 pipe-forward", 1, pipe.getForwards().size());
    assertEquals("pipe1 forward should default to next pipe", pipeForwardName, pipe.getForwards().get(PipeForward.SUCCESS_FORWARD_NAME).getPath());
    assertEquals("pipe2 should only have 1 pipe-forward", 1, pipe2.getForwards().size());
    assertEquals("pipe2 forward should default to pipeline-exit", "exit", pipe2.getForwards().get(PipeForward.SUCCESS_FORWARD_NAME).getPath());
    configuration.close();
    configuration = null;
}
Also used : EchoPipe(nl.nn.adapterframework.pipes.EchoPipe) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Test(org.junit.Test)

Example 15 with TestConfiguration

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

the class PipeLineTest method giveWarningWhenForwardToNonExistingPipe.

@Test
public void giveWarningWhenForwardToNonExistingPipe() throws ConfigurationException {
    TestConfiguration configuration = new TestConfiguration();
    PipeLine pipeline = configuration.createBean(PipeLine.class);
    String pipeForwardName = "EchoPipe next pipe";
    EchoPipe pipe = configuration.createBean(EchoPipe.class);
    pipe.setName(pipe.getClass().getSimpleName() + " under test");
    pipe.registerForward(new PipeForward("success", "the next pipe"));
    pipe.setPipeLine(pipeline);
    pipeline.addPipe(pipe);
    EchoPipe pipe2 = configuration.createBean(EchoPipe.class);
    pipe2.setName(pipeForwardName);
    pipe2.setPipeLine(pipeline);
    pipeline.addPipe(pipe2);
    PipeLineExit exit = new PipeLineExit();
    exit.setPath("special exit name");
    exit.setState(ExitState.SUCCESS);
    pipeline.registerPipeLineExit(exit);
    pipeline.configure();
    assertEquals("pipes should cause a configuration warning", 1, configuration.getConfigurationWarnings().getWarnings().size());
    assertThat(configuration.getConfigWarning(0), StringEndsWith.endsWith("] has a forward of which the pipe to execute [the next pipe] is not defined"));
    assertEquals("pipe1 should only have 1 pipe-forward", 1, pipe.getForwards().size());
    assertEquals("pipe1 forward should exist even though next pipe doesn't exist", "the next pipe", pipe.getForwards().get(PipeForward.SUCCESS_FORWARD_NAME).getPath());
    assertEquals("pipe2 should only have 1 pipe-forward", 1, pipe2.getForwards().size());
    assertEquals("pipe2 forward should default to pipeline-exit", "special exit name", pipe2.getForwards().get(PipeForward.SUCCESS_FORWARD_NAME).getPath());
    configuration.close();
    configuration = null;
}
Also used : EchoPipe(nl.nn.adapterframework.pipes.EchoPipe) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Test(org.junit.Test)

Aggregations

TestConfiguration (nl.nn.adapterframework.testutil.TestConfiguration)21 Test (org.junit.Test)12 Before (org.junit.Before)7 EchoPipe (nl.nn.adapterframework.pipes.EchoPipe)5 Message (nl.nn.adapterframework.stream.Message)3 MessageKeeper (nl.nn.adapterframework.util.MessageKeeper)3 Configuration (nl.nn.adapterframework.configuration.Configuration)2 IbisManager (nl.nn.adapterframework.configuration.IbisManager)2 Adapter (nl.nn.adapterframework.core.Adapter)2 PipeLine (nl.nn.adapterframework.core.PipeLine)2 PipeLineExit (nl.nn.adapterframework.core.PipeLineExit)2 PipeLineResult (nl.nn.adapterframework.core.PipeLineResult)2 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)2 CorePipeProcessor (nl.nn.adapterframework.processors.CorePipeProcessor)2 URL (java.net.URL)1 Properties (java.util.Properties)1 Set (java.util.Set)1 SecurityContext (javax.ws.rs.core.SecurityContext)1 ConfigurationDigester (nl.nn.adapterframework.configuration.ConfigurationDigester)1 IbisContext (nl.nn.adapterframework.configuration.IbisContext)1