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);
}
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()));
}
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);
}
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");
}
}
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);
}
Aggregations