use of nl.nn.adapterframework.testutil.TestConfiguration 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.testutil.TestConfiguration 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.testutil.TestConfiguration in project iaf by ibissource.
the class ConfigurationDigesterTest method testNewConfigurationPreParser.
// Both OLD and NEW configuration parsers should set the same values for 'loadedConfiguration': properties resolved, secrets hidden
// The new configuration parser returns the configuration with all property not yet resolved
@Test
public void testNewConfigurationPreParser() throws Exception {
ConfigurationDigester digester = new ConfigurationDigester();
Resource resource = Resource.getResource("/Digester/SimpleConfiguration/Configuration.xml");
Properties properties = new Properties();
properties.setProperty("HelloWorld.active", "false");
properties.setProperty("HelloBeautifulWorld.active", "!false");
// new style non-escaped property values
properties.setProperty("digester.property", "[ >\"< ]");
properties.setProperty("secret", "GEHEIM");
properties.setProperty("properties.hide", "secret");
Configuration configuration = new TestConfiguration();
XmlWriter loadedConfigWriter = new XmlWriter();
digester.parseAndResolveEntitiesAndProperties(loadedConfigWriter, configuration, resource, properties);
String result = loadedConfigWriter.toString();
String expected = TestFileUtils.getTestFile("/Digester/Loaded/SimpleConfigurationUnresolved.xml");
MatchUtils.assertXmlEquals(expected, result);
String storedResult = configuration.getLoadedConfiguration();
String storedExpected = TestFileUtils.getTestFile("/Digester/Loaded/SimpleConfigurationResolvedAndHidden.xml");
MatchUtils.assertXmlEquals(storedExpected, storedResult);
loadedConfigWriter = new XmlWriter();
properties.setProperty(STUB4TESTTOOL_CONFIGURATION_KEY, "true");
digester.parseAndResolveEntitiesAndProperties(loadedConfigWriter, configuration, resource, properties);
String stubbedExpected = TestFileUtils.getTestFile("/Digester/Loaded/SimpleConfigurationStubbed.xml");
MatchUtils.assertXmlEquals(stubbedExpected, loadedConfigWriter.toString());
}
use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.
the class OpenApiTestBase method setUp.
@Before
public void setUp() throws ServletException {
configuration = new TestConfiguration();
AppConstants.getInstance().setProperty("hostname", "hostname");
}
use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.
the class CleanupDatabaseJobTest method setup.
@Override
@Before
public void setup() throws Exception {
super.setup();
System.setProperty("tableName", tableName);
runMigrator(TEST_CHANGESET_PATH);
configuration = new TestConfiguration();
Adapter adapter = setupAdapter();
configuration.registerAdapter(adapter);
jobDef = new CleanupDatabaseJob() {
@Override
protected Set<String> getAllLockerDatasourceNames(IbisManager ibisManager) {
return Collections.singleton(getDataSourceName());
}
};
configuration.autowireByName(jobDef);
}
Aggregations