Search in sources :

Example 1 with TestConfiguration

use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.

the class ValidateAttributeRuleTest method runRule.

// Run the ValidateAttributeRule, returns the beanClass to validate setters being called
private <T> T runRule(Class<T> beanClass, Map<String, String> attributes) throws Exception {
    configuration = new TestConfiguration();
    T topBean = beanClass.newInstance();
    ValidateAttributeRule rule = new ValidateAttributeRule() {

        @Override
        public Object getBean() {
            return topBean;
        }
    };
    configuration.autowireByName(rule);
    rule.begin(null, beanClass.getSimpleName(), copyMapToAttrs(attributes));
    // Test the bean name with and without INamedObject interface
    if (topBean instanceof ConfigWarningTestClass) {
        assertEquals("ConfigWarningTestClass [name here]", rule.getObjectName());
    }
    if (topBean instanceof DeprecatedTestClass) {
        assertEquals("DeprecatedTestClass", rule.getObjectName());
    }
    return topBean;
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration)

Example 2 with TestConfiguration

use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.

the class ApplicationMessageEventTest method testGlobalMessage.

@Test
public void testGlobalMessage() {
    TestConfiguration configuration = new TestConfiguration();
    configuration.setVersion("13-2342");
    configuration.publishEvent(new ApplicationMessageEvent(configuration, "test 123"));
    MessageKeeper globalKeeper = configuration.getGlobalMessageKeeper();
    assertEquals(2, globalKeeper.size());
    assertEquals("INFO", globalKeeper.getMessage(1).getMessageLevel());
    assertEquals("Application [TestConfiguration] test 123", globalKeeper.getMessage(1).getMessageText());
    MessageKeeper configKeeper = configuration.getMessageKeeper();
    assertEquals(1, configKeeper.size());
    assertEquals("INFO", configKeeper.getMessage(0).getMessageLevel());
    assertThat(configKeeper.getMessage(0).getMessageText(), Matchers.containsString("Configuration [TestConfiguration] configured in "));
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) MessageKeeper(nl.nn.adapterframework.util.MessageKeeper) ApplicationMessageEvent(nl.nn.adapterframework.lifecycle.ApplicationMessageEvent) Test(org.junit.Test)

Example 3 with TestConfiguration

use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.

the class PipeLineTest method testNonFixedForwardPipesWithNoForwardToNextPipe.

@Test
public void testNonFixedForwardPipesWithNoForwardToNextPipe() throws ConfigurationException {
    TestConfiguration configuration = new TestConfiguration();
    PipeLine pipeline = configuration.createBean(PipeLine.class);
    String pipeForwardName = "EchoPipe next pipe";
    IExtendedPipe pipe = configuration.createBean(NonFixedForwardPipe.class);
    pipe.setName(pipe.getClass().getSimpleName() + " under test");
    pipe.registerForward(new PipeForward("success", pipeForwardName));
    pipe.setPipeLine(pipeline);
    pipeline.addPipe(pipe);
    IExtendedPipe pipe2 = configuration.createBean(NonFixedForwardPipe.class);
    pipe2.setName(pipeForwardName);
    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("pipe should cause 1 configuration warnings", 0, configuration.getConfigurationWarnings().getWarnings().size());
    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 not have a pipe-forward", 0, pipe2.getForwards().size());
    configuration.close();
    configuration = null;
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Test(org.junit.Test)

Example 4 with TestConfiguration

use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.

the class PipeLineTest method testPipesWithNormalForwardToNextPipe.

@Test
public void testPipesWithNormalForwardToNextPipe() throws ConfigurationException {
    TestConfiguration configuration = new TestConfiguration();
    PipeLine pipeline = configuration.createBean(PipeLine.class);
    String pipeForwardName = "EchoPipe next pipe";
    IExtendedPipe pipe = configuration.createBean(EchoPipe.class);
    pipe.setName(pipe.getClass().getSimpleName() + " under test");
    pipe.registerForward(new PipeForward("success", pipeForwardName));
    pipe.setPipeLine(pipeline);
    pipeline.addPipe(pipe);
    IExtendedPipe pipe2 = configuration.createBean(EchoPipe.class);
    pipe2.setName(pipeForwardName);
    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();
    assertTrue("pipe should not cause any configuration warnings", configuration.getConfigurationWarnings().getWarnings().isEmpty());
    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 : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Test(org.junit.Test)

Example 5 with TestConfiguration

use of nl.nn.adapterframework.testutil.TestConfiguration in project iaf by ibissource.

the class PipeLineTest method testDirectWrapperPipeSuccessForward.

// Should add tests to assertThat(configuration.getConfigWarning(0), StringEndsWith.endsWith("] has no pipe forwards defined"));
@Test
public void testDirectWrapperPipeSuccessForward() throws ConfigurationException, PipeRunException {
    TestConfiguration configuration = new TestConfiguration();
    PipeLine pipeline = configuration.createBean(PipeLine.class);
    PipeForward pf = configuration.createBean(PipeForward.class);
    pf.setName("success");
    pf.setPath("nextPipe");
    PipeForward toExit = configuration.createBean(PipeForward.class);
    toExit.setName("success");
    toExit.setPath("EXIT");
    DirectWrapperPipe pipe = configuration.createBean(DirectWrapperPipe.class);
    pipe.setName("DirectWrapperPipe");
    pipe.registerForward(pf);
    pipeline.addPipe(pipe);
    EchoPipe echoPipe = configuration.createBean(EchoPipe.class);
    echoPipe.setName("nextPipe");
    echoPipe.setPipeLine(pipeline);
    echoPipe.registerForward(toExit);
    pipeline.addPipe(echoPipe);
    PipeLineExit exit = configuration.createBean(PipeLineExit.class);
    exit.setPath("exit");
    exit.setState(ExitState.SUCCESS);
    pipeline.registerPipeLineExit(exit);
    pipeline.setOwner(pipe);
    pipeline.configure();
    CorePipeProcessor cpp = configuration.createBean(CorePipeProcessor.class);
    PipeLineSession ps = configuration.createBean(PipeLineSession.class);
    PipeRunResult pipeRunResult = cpp.processPipe(pipeline, pipe, new Message("<dummy/>"), ps);
    PipeForward pipeForward = pipeRunResult.getPipeForward();
    IForwardTarget target = pipeline.resolveForward(pipe, pipeForward);
    assertNotNull(target);
    configuration.close();
    configuration = null;
}
Also used : Message(nl.nn.adapterframework.stream.Message) EchoPipe(nl.nn.adapterframework.pipes.EchoPipe) CorePipeProcessor(nl.nn.adapterframework.processors.CorePipeProcessor) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) DirectWrapperPipe(nl.nn.adapterframework.extensions.esb.DirectWrapperPipe) 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