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;
}
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);
}
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!");
}
Aggregations