use of com.adaptris.core.common.StringPayloadDataOutputParameter in project interlok by adaptris.
the class XPathServiceTest method testPayloadSimpleValueXPathIntoPayload.
@Test
public void testPayloadSimpleValueXPathIntoPayload() throws Exception {
message.setContent(sampleXml, message.getContentEncoding());
message.addMetadata("sourceXpathMetadataKey", "//some/random/xml/node1/text()");
MetadataDataInputParameter metadataDataDestination1 = new MetadataDataInputParameter("sourceXpathMetadataKey");
Execution execution = new Execution(metadataDataDestination1, new StringPayloadDataOutputParameter());
List<Execution> executions = new ArrayList<>();
executions.add(execution);
service.setXmlSource(new StringPayloadDataInputParameter());
service.setExecutions(executions);
execute(service, message);
assertEquals("value1", message.getContent());
}
use of com.adaptris.core.common.StringPayloadDataOutputParameter in project interlok by adaptris.
the class XPathServiceTest method testPayloadSimpleValueXPathIntoPayloadWithHeaderNamespaces.
@Test
public void testPayloadSimpleValueXPathIntoPayloadWithHeaderNamespaces() throws Exception {
message.setContent(sampleXmlWithHeaderNamespaces, message.getContentEncoding());
message.addMetadata("sourceXpathMetadataKey", "//some:some/random/xml/n1:node1/text()");
MetadataDataInputParameter metadataDataDestination1 = new MetadataDataInputParameter("sourceXpathMetadataKey");
Execution execution = new Execution(metadataDataDestination1, new StringPayloadDataOutputParameter());
List<Execution> executions = new ArrayList<>();
executions.add(execution);
// Add the namespace mappings
KeyValuePairSet namespaceMappings = new KeyValuePairSet();
namespaceMappings.addKeyValuePair(new KeyValuePair("some", "http://adaptris.com/xml/some"));
namespaceMappings.addKeyValuePair(new KeyValuePair("n1", "http://adaptris.com/xml/n1"));
namespaceMappings.addKeyValuePair(new KeyValuePair("n2", "http://adaptris.com/xml/n2"));
namespaceMappings.addKeyValuePair(new KeyValuePair("n3", "http://adaptris.com/xml/n3"));
service.setNamespaceContext(namespaceMappings);
service.setXmlSource(new StringPayloadDataInputParameter());
service.setExecutions(executions);
execute(service, message);
assertEquals("value1", message.getContent());
}
use of com.adaptris.core.common.StringPayloadDataOutputParameter in project interlok by adaptris.
the class XPathServiceTest method testPayloadSimpleValueXPathIntoPayloadWithNamespace.
@Test
public void testPayloadSimpleValueXPathIntoPayloadWithNamespace() throws Exception {
message.setContent(sampleXmlWithInternalNamespaces, message.getContentEncoding());
message.addMetadata("sourceXpathMetadataKey", "//some/random/xml/node1/text()");
MetadataDataInputParameter metadataDataDestination1 = new MetadataDataInputParameter("sourceXpathMetadataKey");
Execution execution = new Execution(metadataDataDestination1, new StringPayloadDataOutputParameter());
List<Execution> executions = new ArrayList<>();
executions.add(execution);
service.setXmlSource(new StringPayloadDataInputParameter());
service.setExecutions(executions);
execute(service, message);
assertEquals("value1", message.getContent());
}
Aggregations