use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.
the class ParameterTest method testPutInSessionPipeWithDomdocParamsUsedMoreThanOnce.
@Test
public // Test for #2256 PutParametersInSession with xpathExpression with type=domdoc results in "Content is not allowed in prolog"
void testPutInSessionPipeWithDomdocParamsUsedMoreThanOnce() throws Exception {
try (TestConfiguration configuration = new TestConfiguration()) {
PipeLine pipeline = configuration.createBean(PipeLine.class);
String firstPipe = "PutInSession under test";
String secondPipe = "PutInSession next pipe";
String testMessage = "<Test>\n" + " <Child><name>X</name></Child>\n" + " <Child><name>Y</name></Child>\n" + " <Child><name>Z</name></Child>\n" + "</Test>";
String testMessageChild1 = "<Child><name>X</name></Child>";
PutInSession pipe = configuration.createBean(PutInSession.class);
pipe.setName(firstPipe);
pipe.setPipeLine(pipeline);
Parameter p = new Parameter();
p.setName("xmlMessageChild");
p.setXpathExpression("Test/Child[1]");
p.setType(ParameterType.DOMDOC);
pipe.addParameter(p);
pipeline.addPipe(pipe);
PutInSession pipe2 = configuration.createBean(PutInSession.class);
pipe2.setName(secondPipe);
pipe2.setPipeLine(pipeline);
Parameter p2 = new Parameter();
p2.setName("xmlMessageChild2");
p2.setSessionKey("xmlMessageChild");
p2.setXpathExpression("Child/name/text()");
pipe2.addParameter(p2);
pipeline.addPipe(pipe2);
PipeLineExit exit = new PipeLineExit();
exit.setPath("exit");
exit.setState(ExitState.SUCCESS);
pipeline.registerPipeLineExit(exit);
pipeline.configure();
CorePipeLineProcessor cpp = configuration.createBean(CorePipeLineProcessor.class);
CorePipeProcessor pipeProcessor = configuration.createBean(CorePipeProcessor.class);
cpp.setPipeProcessor(pipeProcessor);
PipeLineSession session = configuration.createBean(PipeLineSession.class);
pipeline.setOwner(pipe);
PipeLineResult pipeRunResult = cpp.processPipeLine(pipeline, "messageId", new Message(testMessage), session, firstPipe);
assertEquals(ExitState.SUCCESS, pipeRunResult.getState());
assertEquals(testMessage, pipeRunResult.getResult().asString());
MatchUtils.assertXmlEquals(testMessageChild1, session.getMessage("xmlMessageChild").asString());
assertEquals("X", session.getMessage("xmlMessageChild2").asString());
}
}
use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.
the class CheckReloadJobTest method setup.
@Override
@Before
public void setup() throws Exception {
super.setup();
runMigrator("Migrator/Ibisconfig_4_unittests_changeset.xml");
configuration = new TestConfiguration();
jobDef = new CheckReloadJob() {
@Override
protected String getDataSource() {
return getDataSourceName();
}
};
jobDef.setName("CheckReloadJob");
configuration.autowireByName(jobDef);
configuration.configure();
}
use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.
the class DatabaseSchedulerTest method setup.
@Before
public void setup() throws Exception {
configuration = new TestConfiguration();
// Sets a dummy IbisManager if non is found
configuration.getIbisManager();
job = configuration.createBean(LoadDatabaseSchedulesJob.class);
job.setName("testJob");
job.configure();
}
use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.
the class ApiTestBase method setUp.
@Before
public void setUp() throws Exception {
// Remove old instance if present
ApplicationWarnings.removeInstance();
M resource = createJaxRsResource();
checkContextFields(resource);
jaxRsResource = spy(resource);
MockServletContext servletContext = new MockServletContext();
MockServletConfig servletConfig = new MockServletConfig(servletContext, "JAX-RS-MockDispatcher");
jaxRsResource.servletConfig = servletConfig;
jaxRsResource.securityContext = mock(SecurityContext.class);
IbisContext ibisContext = mock(IbisContext.class);
configuration = new TestConfiguration();
IbisManager ibisManager = configuration.getIbisManager();
ibisManager.setIbisContext(ibisContext);
doReturn(ibisManager).when(ibisContext).getIbisManager();
doReturn(ibisContext).when(jaxRsResource).getIbisContext();
doReturn(configuration.getBean("applicationWarnings")).when(ibisContext).getBean(eq("applicationWarnings"), any());
// we don't test the messages
doReturn(new MessageEventListener()).when(ibisContext).getBean(eq("MessageEventListener"), any());
registerAdapter(configuration);
dispatcher.register(jaxRsResource);
}
use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.
the class ApplicationMessageEventTest method testConfigurationMessageWithVersion.
@Test
public void testConfigurationMessageWithVersion() {
TestConfiguration configuration = new TestConfiguration();
configuration.setVersion("13-2342");
configuration.publishEvent(new ConfigurationMessageEvent(configuration, "test 123"));
MessageKeeper globalKeeper = configuration.getGlobalMessageKeeper();
assertEquals(2, globalKeeper.size());
assertEquals("INFO", globalKeeper.getMessage(1).getMessageLevel());
assertEquals("Configuration [TestConfiguration] [13-2342] test 123", globalKeeper.getMessage(1).getMessageText());
MessageKeeper configKeeper = configuration.getMessageKeeper();
assertEquals(2, configKeeper.size());
assertEquals("INFO", configKeeper.getMessage(1).getMessageLevel());
assertEquals("Configuration [TestConfiguration] [13-2342] test 123", configKeeper.getMessage(1).getMessageText());
}
Aggregations