Search in sources :

Example 31 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class XpathMetadataServiceTest method testDoService_DisableDocType.

@Test
public void testDoService_DisableDocType() throws CoreException {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_WITH_DOCTYPE);
    XpathMetadataService service = new XpathMetadataService();
    // Shouldn't matter what the query actually is.
    service.setXpathQueries(new ArrayList<XpathQuery>(Arrays.asList(new ConfiguredXpathQuery("source", "//source-id"), new ConfiguredXpathQuery("destination", "//destination-id"))));
    DocumentBuilderFactoryBuilder builder = new DocumentBuilderFactoryBuilder();
    builder.getFeatures().add(new KeyValuePair("http://apache.org/xml/features/disallow-doctype-decl", "true"));
    service.setXmlDocumentFactoryConfig(builder);
    try {
        execute(service, msg);
        fail();
    } catch (ServiceException expected) {
        assertTrue(expected.getMessage().contains("DOCTYPE is disallowed"));
    }
}
Also used : XpathQuery(com.adaptris.core.services.metadata.xpath.XpathQuery) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) MetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MetadataXpathQuery) MultiItemMetadataXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemMetadataXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) KeyValuePair(com.adaptris.util.KeyValuePair) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MultiItemConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.MultiItemConfiguredXpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) DocumentBuilderFactoryBuilder(com.adaptris.core.util.DocumentBuilderFactoryBuilder) Test(org.junit.Test)

Example 32 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class XpathObjectMetadataServiceTest method createContextEntries.

private KeyValuePairSet createContextEntries() {
    KeyValuePairSet contextEntries = new KeyValuePairSet();
    contextEntries.add(new KeyValuePair("svrl", "http://purl.oclc.org/dsdl/svrl"));
    contextEntries.add(new KeyValuePair("xsd", "http://www.w3.org/2001/XMLSchema"));
    contextEntries.add(new KeyValuePair("xs", "http://www.w3.org/2001/XMLSchema"));
    contextEntries.add(new KeyValuePair("sch", "http://www.ascc.net/xml/schematron"));
    contextEntries.add(new KeyValuePair("iso", "http://purl.oclc.org/dsdl/schematron"));
    contextEntries.add(new KeyValuePair("dp", "http://www.dpawson.co.uk/ns#"));
    return contextEntries;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 33 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class IntegerValueMatcherTest method create.

private static KeyValuePairSet create() {
    KeyValuePairSet result = new KeyValuePairSet();
    result.addKeyValuePair(new KeyValuePair("=10", EQUALS));
    // Natural sort order let's me get away with this!
    result.addKeyValuePair(new KeyValuePair("<5", LESS_THAN));
    result.addKeyValuePair(new KeyValuePair("<=9", LESS_THAN_EQUAL));
    // Natural sort order let's me get away with this!
    result.addKeyValuePair(new KeyValuePair(">100", GREATER_THAN1));
    result.addKeyValuePair(new KeyValuePair(">=15", GREATER_THAN_EQUAL));
    return result;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 34 with KeyValuePair

use of com.adaptris.util.KeyValuePair in project interlok by adaptris.

the class XPathServiceTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    MetadataDataOutputParameter metadataDataDestination1 = new MetadataDataOutputParameter("targetMetadataKey");
    MetadataDataInputParameter metadataDataDestination2 = new MetadataDataInputParameter("sourceXpathMetadataKey");
    ConstantDataInputParameter constantDataDestination = new ConstantDataInputParameter("//my/xpath/expression");
    constantDataDestination.setValue("//my/xpath/expression");
    Execution execution1 = new Execution();
    execution1.setSource(constantDataDestination);
    execution1.setTarget(metadataDataDestination1);
    Execution execution2 = new Execution();
    execution2.setSource(metadataDataDestination2);
    execution2.setTarget(new MetadataDataOutputParameter("targetMetadataKey2"));
    List<Execution> executions = new ArrayList<Execution>();
    executions.add(execution1);
    executions.add(execution2);
    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);
    return service;
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) MetadataDataInputParameter(com.adaptris.core.common.MetadataDataInputParameter) KeyValuePair(com.adaptris.util.KeyValuePair) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) ArrayList(java.util.ArrayList) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 35 with KeyValuePair

use of com.adaptris.util.KeyValuePair 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());
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) MetadataDataInputParameter(com.adaptris.core.common.MetadataDataInputParameter) KeyValuePair(com.adaptris.util.KeyValuePair) ArrayList(java.util.ArrayList) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) StringPayloadDataOutputParameter(com.adaptris.core.common.StringPayloadDataOutputParameter) Test(org.junit.Test)

Aggregations

KeyValuePair (com.adaptris.util.KeyValuePair)143 Test (org.junit.Test)79 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)55 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)26 KeyValuePairList (com.adaptris.util.KeyValuePairList)12 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)11 StandaloneProducer (com.adaptris.core.StandaloneProducer)10 Channel (com.adaptris.core.Channel)9 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)9 TimeInterval (com.adaptris.util.TimeInterval)9 ServiceException (com.adaptris.core.ServiceException)7 JmsConnection (com.adaptris.core.jms.JmsConnection)6 ArrayList (java.util.ArrayList)6 CoreException (com.adaptris.core.CoreException)5 StandardWorkflow (com.adaptris.core.StandardWorkflow)5 PasProducer (com.adaptris.core.jms.PasProducer)5 MetadataCollection (com.adaptris.core.MetadataCollection)4 MetadataElement (com.adaptris.core.MetadataElement)4 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3