Search in sources :

Example 6 with TestConfiguration

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());
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) CorePipeProcessor(nl.nn.adapterframework.processors.CorePipeProcessor) PipeLineResult(nl.nn.adapterframework.core.PipeLineResult) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) PipeLine(nl.nn.adapterframework.core.PipeLine) PutInSession(nl.nn.adapterframework.pipes.PutInSession) CorePipeLineProcessor(nl.nn.adapterframework.processors.CorePipeLineProcessor) PipeLineExit(nl.nn.adapterframework.core.PipeLineExit) Test(org.junit.Test)

Example 7 with TestConfiguration

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();
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) CheckReloadJob(nl.nn.adapterframework.scheduler.job.CheckReloadJob) Before(org.junit.Before)

Example 8 with TestConfiguration

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();
}
Also used : LoadDatabaseSchedulesJob(nl.nn.adapterframework.scheduler.job.LoadDatabaseSchedulesJob) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Before(org.junit.Before)

Example 9 with TestConfiguration

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);
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) IbisManager(nl.nn.adapterframework.configuration.IbisManager) MessageEventListener(nl.nn.adapterframework.lifecycle.MessageEventListener) SecurityContext(javax.ws.rs.core.SecurityContext) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) MockServletConfig(org.springframework.mock.web.MockServletConfig) MockServletContext(org.springframework.mock.web.MockServletContext) Before(org.junit.Before)

Example 10 with TestConfiguration

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());
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) MessageKeeper(nl.nn.adapterframework.util.MessageKeeper) 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