Search in sources :

Example 6 with EchoPipe

use of nl.nn.adapterframework.pipes.EchoPipe in project iaf by ibissource.

the class PipeLineTest method giveWarningWhenForwardIsAlreadyDefined.

@Test
public void giveWarningWhenForwardIsAlreadyDefined() 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", pipeForwardName));
    pipe.registerForward(new PipeForward("success", pipeForwardName));
    pipe.setPipeLine(pipeline);
    pipeline.addPipe(pipe);
    EchoPipe pipe2 = configuration.createBean(EchoPipe.class);
    pipe2.setName(pipeForwardName);
    pipe.registerForward(new PipeForward("success", "exit"));
    pipe.registerForward(new PipeForward("success", "exit"));
    pipe.registerForward(new PipeForward("success", "exit"));
    // Surprisingly this doesn't cause any warnings
    pipe.registerForward(new PipeForward("success", "exit"));
    pipe2.setPipeLine(pipeline);
    pipeline.addPipe(pipe2);
    PipeLineExit exit = new PipeLineExit();
    exit.setPath("exit");
    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 forward [success] which is already registered"));
    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 7 with EchoPipe

use of nl.nn.adapterframework.pipes.EchoPipe in project iaf by ibissource.

the class ClassLoaderManagerTest method createAdapter4ServiceClassLoader.

private static void createAdapter4ServiceClassLoader(String config4Adaptername) throws ConfigurationException {
    // Mock a configuration with an adapter in it
    IbisManager ibisManager = spy(new DefaultIbisManager());
    ibisManager.setIbisContext(ibisContext);
    Configuration configuration = new TestConfiguration();
    configuration.setName("dummyConfiguration");
    configuration.setVersion("1");
    configuration.setIbisManager(ibisManager);
    Adapter adapter = spy(new Adapter());
    adapter.setName(config4Adaptername);
    PipeLine pl = new PipeLine();
    pl.setFirstPipe("dummy");
    EchoPipe pipe = new EchoPipe();
    pipe.setName("dummy");
    pl.addPipe(pipe);
    PipeLineExit ple = new PipeLineExit();
    ple.setPath("success");
    ple.setState(ExitState.SUCCESS);
    pl.registerPipeLineExit(ple);
    adapter.setPipeLine(pl);
    doAnswer(new Answer<PipeLineResult>() {

        @Override
        public PipeLineResult answer(InvocationOnMock invocation) throws Throwable {
            PipeLineSession session = (PipeLineSession) invocation.getArguments()[2];
            URL file = this.getClass().getResource(JAR_FILE);
            session.put("configurationJar", Misc.streamToBytes(file.openStream()));
            return new PipeLineResult();
        }
    }).when(adapter).processMessage(anyString(), any(Message.class), any(PipeLineSession.class));
    adapter.setConfiguration(configuration);
    configuration.registerAdapter(adapter);
    ibisManager.addConfiguration(configuration);
    when(ibisContext.getIbisManager()).thenReturn(ibisManager);
}
Also used : DefaultIbisManager(nl.nn.adapterframework.unmanaged.DefaultIbisManager) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Message(nl.nn.adapterframework.stream.Message) EchoPipe(nl.nn.adapterframework.pipes.EchoPipe) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Adapter(nl.nn.adapterframework.core.Adapter) URL(java.net.URL) InvocationOnMock(org.mockito.invocation.InvocationOnMock) PipeLineResult(nl.nn.adapterframework.core.PipeLineResult) PipeLine(nl.nn.adapterframework.core.PipeLine) DefaultIbisManager(nl.nn.adapterframework.unmanaged.DefaultIbisManager) PipeLineExit(nl.nn.adapterframework.core.PipeLineExit)

Example 8 with EchoPipe

use of nl.nn.adapterframework.pipes.EchoPipe in project iaf by ibissource.

the class ApiTestBase method registerAdapter.

protected void registerAdapter(TestConfiguration configuration) throws Exception {
    Adapter adapter = configuration.createBean(Adapter.class);
    adapter.setName("dummyAdapter");
    try {
        PipeLine pipeline = new PipeLine();
        PipeLineExit exit = new PipeLineExit();
        exit.setPath("EXIT");
        exit.setState(ExitState.SUCCESS);
        pipeline.registerPipeLineExit(exit);
        EchoPipe pipe = new EchoPipe();
        pipe.setName("myPipe");
        pipeline.addPipe(pipe);
        adapter.setPipeLine(pipeline);
        configuration.registerAdapter(adapter);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail("error registering adapter [" + adapter + "] " + e.getMessage());
    }
    configuration.getConfigurationWarnings().add((Object) null, log, "hello I am a configuration warning!");
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) EchoPipe(nl.nn.adapterframework.pipes.EchoPipe) Adapter(nl.nn.adapterframework.core.Adapter) PipeLine(nl.nn.adapterframework.core.PipeLine) PipeLineExit(nl.nn.adapterframework.core.PipeLineExit)

Aggregations

EchoPipe (nl.nn.adapterframework.pipes.EchoPipe)8 TestConfiguration (nl.nn.adapterframework.testutil.TestConfiguration)5 Adapter (nl.nn.adapterframework.core.Adapter)4 PipeLine (nl.nn.adapterframework.core.PipeLine)4 PipeLineExit (nl.nn.adapterframework.core.PipeLineExit)4 Test (org.junit.Test)4 Message (nl.nn.adapterframework.stream.Message)2 URL (java.net.URL)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 PipeForward (nl.nn.adapterframework.core.PipeForward)1 PipeLineResult (nl.nn.adapterframework.core.PipeLineResult)1 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)1 DirectWrapperPipe (nl.nn.adapterframework.extensions.esb.DirectWrapperPipe)1 CorePipeProcessor (nl.nn.adapterframework.processors.CorePipeProcessor)1 DefaultIbisManager (nl.nn.adapterframework.unmanaged.DefaultIbisManager)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1