Search in sources :

Example 1 with PipeLineSessionBase

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

the class TestPipeLine method processMessage.

private PipeLineResult processMessage(IAdapter adapter, String message, boolean writeSecLogMessage) {
    String messageId = "testmessage" + Misc.createSimpleUUID();
    IPipeLineSession pls = new PipeLineSessionBase();
    Map ibisContexts = XmlUtils.getIbisContext(message);
    String technicalCorrelationId = null;
    if (ibisContexts != null) {
        String contextDump = "ibisContext:";
        for (Iterator it = ibisContexts.keySet().iterator(); it.hasNext(); ) {
            String key = (String) it.next();
            String value = (String) ibisContexts.get(key);
            if (log.isDebugEnabled()) {
                contextDump = contextDump + "\n " + key + "=[" + value + "]";
            }
            if (key.equals(IPipeLineSession.technicalCorrelationIdKey)) {
                technicalCorrelationId = value;
            } else {
                pls.put(key, value);
            }
        }
        if (log.isDebugEnabled()) {
            log.debug(contextDump);
        }
    }
    Date now = new Date();
    PipeLineSessionBase.setListenerParameters(pls, messageId, technicalCorrelationId, now, now);
    if (writeSecLogMessage) {
        secLog.info("message [" + message + "]");
    }
    // Temporarily change threadName so logging for pipeline to test will
    // not be suppressed (see property 'log.thread.rejectRegex')
    String ctName = Thread.currentThread().getName();
    String ntName = StringUtils.replace(ctName, "WebControlTestPipeLine", "WCTestPipeLine");
    try {
        Thread.currentThread().setName(ntName);
        return adapter.processMessage(messageId, message, pls);
    } finally {
        Thread.currentThread().setName(ctName);
    }
}
Also used : Iterator(java.util.Iterator) IPipeLineSession(nl.nn.adapterframework.core.IPipeLineSession) Map(java.util.Map) Date(java.util.Date) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase)

Example 2 with PipeLineSessionBase

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

the class XmlValidatorTest method validationUnknownNamespaceSwitchedOff.

@Test(expected = XmlValidatorException.class)
public void validationUnknownNamespaceSwitchedOff() throws PipeRunException, ConfigurationException, IOException, XmlValidatorException {
    XmlValidator validator = getValidator("http://schemas.xmlsoap.org/soap/envelope/ " + // every other namespace is thus unknown
    "/Tibco/xsd/soap/envelope.xsd ");
    validator.setIgnoreUnknownNamespaces(false);
    validator.validate(getTestXml("/Tibco/in/step5error_unknown_namespace.xml"), new PipeLineSessionBase());
}
Also used : AbstractXmlValidator(nl.nn.adapterframework.validation.AbstractXmlValidator) XercesXmlValidator(nl.nn.adapterframework.validation.XercesXmlValidator) JavaxXmlValidator(nl.nn.adapterframework.validation.JavaxXmlValidator) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase) Test(org.junit.Test)

Example 3 with PipeLineSessionBase

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

the class XmlValidatorTest method addNamespaceToSchemaWithErrors.

@Test(expected = XmlValidatorException.class)
public void addNamespaceToSchemaWithErrors() throws ConfigurationException, IOException, PipeRunException, XmlValidatorException {
    XmlValidator validator = getValidator("http://www.ing.com/testxmlns " + "/Basic/xsd/A_without_targetnamespace.xsd", true);
    validator.validate(getTestXml("/Basic/in/with_errors.xml"), new PipeLineSessionBase());
}
Also used : AbstractXmlValidator(nl.nn.adapterframework.validation.AbstractXmlValidator) XercesXmlValidator(nl.nn.adapterframework.validation.XercesXmlValidator) JavaxXmlValidator(nl.nn.adapterframework.validation.JavaxXmlValidator) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase) Test(org.junit.Test)

Example 4 with PipeLineSessionBase

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

the class XmlValidatorTest method addNamespaceToSchemaNamesspaceMismatch.

@Test(expected = XmlValidatorException.class)
public void addNamespaceToSchemaNamesspaceMismatch() throws ConfigurationException, IOException, PipeRunException, XmlValidatorException {
    XmlValidator validator = getValidator("http://www.ing.com/testxmlns_mismatch " + "/Basic/xsd/A_without_targetnamespace.xsd", true);
    validator.validate(getTestXml("/Basic/in/ok.xml"), new PipeLineSessionBase());
}
Also used : AbstractXmlValidator(nl.nn.adapterframework.validation.AbstractXmlValidator) XercesXmlValidator(nl.nn.adapterframework.validation.XercesXmlValidator) JavaxXmlValidator(nl.nn.adapterframework.validation.JavaxXmlValidator) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase) Test(org.junit.Test)

Example 5 with PipeLineSessionBase

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

the class XmlValidatorTest method step5ValidationUnknownNamespaces.

@Test(expected = XmlValidatorException.class)
@Ignore("This fails in JavaXmlValidator, and this is actually defendable, because the soap envelope accepts any children, so also the namespace doesn't really matter.")
public void step5ValidationUnknownNamespaces() throws PipeRunException, ConfigurationException, IOException, XmlValidatorException {
    XmlValidator validator = getValidator("http://schemas.xmlsoap.org/soap/envelope/ " + "/Tibco/xsd/soap/envelope.xsd ");
    validator.validate(getTestXml("/Tibco/in/step5.xml"), new PipeLineSessionBase());
}
Also used : AbstractXmlValidator(nl.nn.adapterframework.validation.AbstractXmlValidator) XercesXmlValidator(nl.nn.adapterframework.validation.XercesXmlValidator) JavaxXmlValidator(nl.nn.adapterframework.validation.JavaxXmlValidator) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

PipeLineSessionBase (nl.nn.adapterframework.core.PipeLineSessionBase)38 Test (org.junit.Test)14 IPipeLineSession (nl.nn.adapterframework.core.IPipeLineSession)12 IOException (java.io.IOException)8 AbstractXmlValidator (nl.nn.adapterframework.validation.AbstractXmlValidator)8 JavaxXmlValidator (nl.nn.adapterframework.validation.JavaxXmlValidator)8 XercesXmlValidator (nl.nn.adapterframework.validation.XercesXmlValidator)8 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)6 Iterator (java.util.Iterator)5 Map (java.util.Map)5 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)5 HashMap (java.util.HashMap)4 ListenerException (nl.nn.adapterframework.core.ListenerException)4 PipeForward (nl.nn.adapterframework.core.PipeForward)4 ParameterResolutionContext (nl.nn.adapterframework.parameters.ParameterResolutionContext)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 PipeRunException (nl.nn.adapterframework.core.PipeRunException)3 SenderException (nl.nn.adapterframework.core.SenderException)3 ParseException (java.text.ParseException)2