Search in sources :

Example 66 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testDefaultValueMethodPattern.

@Test
public void testDefaultValueMethodPattern() throws Exception {
    Parameter p = new Parameter();
    p.setXpathExpression("*/*");
    p.setValue("<doc/>");
    p.setDefaultValue("fakeDefaultValue");
    p.setSessionKey("sessionKeyForDefaultValue");
    p.setPattern("{sessionKeyForPattern}");
    p.setDefaultValueMethods("pattern");
    p.configure();
    PipeLineSession session = new PipeLineSession();
    session.put("sessionKeyForDefaultValue", "fakeDefaultValueSessionKey");
    session.put("sessionKeyForPattern", "fakePatternSessionKey");
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    String result = (String) p.getValue(alreadyResolvedParameters, message, session, false);
    assertEquals("fakePatternSessionKey", result);
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 67 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testParameterFromURLToDomTypeHelper.

public <T> void testParameterFromURLToDomTypeHelper(ParameterType type, boolean removeNamespaces, Class<T> c) throws Exception {
    URL originalMessage = TestFileUtils.getTestFileURL("/Xslt/MultiNamespace/in.xml");
    PipeLineSession session = new PipeLineSession();
    session.put("originalMessage", Message.asMessage(originalMessage));
    Parameter inputMessage = new Parameter();
    inputMessage.setName("InputMessage");
    inputMessage.setSessionKey("originalMessage");
    inputMessage.setType(type);
    inputMessage.setRemoveNamespaces(removeNamespaces);
    inputMessage.configure();
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    Object result = inputMessage.getValue(alreadyResolvedParameters, message, session, false);
    assertTrue(c + " is expected type but was: " + result.getClass(), c.isAssignableFrom(result.getClass()));
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) URL(java.net.URL)

Example 68 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testPatternUnknownSessionVariableOrParameter.

@Test
public void testPatternUnknownSessionVariableOrParameter() throws ConfigurationException, ParameterException {
    Parameter p = new Parameter();
    p.setName("dummy");
    p.setPattern("{unknown}");
    p.configure();
    PipeLineSession session = new PipeLineSession();
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    exception.expectMessage("Parameter or session variable with name [unknown] in pattern [{unknown}] cannot be resolved");
    p.getValue(alreadyResolvedParameters, null, session, false);
}
Also used : PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 69 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testFixedDate.

@Test
public void testFixedDate() throws Exception {
    Parameter p = new Parameter();
    System.getProperties().setProperty(ConfigurationUtils.STUB4TESTTOOL_CONFIGURATION_KEY, "true");
    try {
        p.setName("date");
        p.setPattern("{fixedDate}");
        p.setType(ParameterType.DATE);
        p.configure();
        PipeLineSession session = new PipeLineSession();
        ParameterValueList alreadyResolvedParameters = new ParameterValueList();
        Message message = new Message("fakeMessage");
        // Should return PutSystemDateInSession.FIXEDDATETIME
        Object result = p.getValue(alreadyResolvedParameters, message, session, false);
        assertTrue(result instanceof Date);
        Date resultDate = (Date) result;
        SimpleDateFormat sdf = new SimpleDateFormat(Parameter.TYPE_DATE_PATTERN);
        String formattedDate = sdf.format(resultDate);
        assertEquals("2001-12-17", formattedDate);
    } finally {
        System.getProperties().setProperty(ConfigurationUtils.STUB4TESTTOOL_CONFIGURATION_KEY, "false");
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 70 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testDefaultValueMethodMultiLoose.

@Test
public void testDefaultValueMethodMultiLoose() throws Exception {
    Parameter p = new Parameter();
    p.setXpathExpression("*/*");
    p.setValue("<doc/>");
    p.setDefaultValue("fakeDefaultValue");
    p.setPattern("{sessionKeyForPattern}");
    p.setDefaultValueMethods("SessionKey, VALUE, Pattern");
    p.configure();
    PipeLineSession session = new PipeLineSession();
    session.put("sessionKeyForDefaultValue", "fakeDefaultValueSessionKey");
    session.put("sessionKeyForPattern", "fakePatternSessionKey");
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    String result = (String) p.getValue(alreadyResolvedParameters, message, session, false);
    assertEquals("<doc/>", result);
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Aggregations

PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)270 Message (nl.nn.adapterframework.stream.Message)210 Test (org.junit.Test)202 SenderException (nl.nn.adapterframework.core.SenderException)43 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)33 UrlMessage (nl.nn.adapterframework.stream.UrlMessage)30 ByteArrayInputStream (java.io.ByteArrayInputStream)26 IOException (java.io.IOException)25 Parameter (nl.nn.adapterframework.parameters.Parameter)23 PipeForward (nl.nn.adapterframework.core.PipeForward)21 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)17 Date (java.util.Date)15 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)14 InputStream (java.io.InputStream)11 TimeoutException (nl.nn.adapterframework.core.TimeoutException)11 ParameterList (nl.nn.adapterframework.parameters.ParameterList)11 Map (java.util.Map)10 SimpleDateFormat (java.text.SimpleDateFormat)9 SOAPMessage (javax.xml.soap.SOAPMessage)9 URL (java.net.URL)8