Search in sources :

Example 26 with PipeForward

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

the class ShowConfigurationStatusTest method createPipeSuccessForward.

private PipeForward createPipeSuccessForward() {
    PipeForward pipeForward = new PipeForward();
    pipeForward.setName("success");
    return pipeForward;
}
Also used : PipeForward(nl.nn.adapterframework.core.PipeForward)

Example 27 with PipeForward

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

the class Json2WsdlXmlValidatorTest method validatePlainText.

public void validatePlainText(String input, String expectedError) throws Exception {
    String wsdl = "/GetPolicyDetailsTravel/wsdl/GetPolicyDetailsTravel.wsdl";
    String soapBody = "GetPolicyDetailsTravel_Response";
    WsdlXmlValidator val = new WsdlXmlValidator();
    val.setWsdl(wsdl);
    val.setThrowException(true);
    val.registerForward(new PipeForward("success", null));
    val.setSoapBody(soapBody);
    val.configure();
    PipeRunResult result;
    try {
        result = val.doPipe(input, session);
        String resultStr = (String) result.getResult();
        fail("expected error [" + expectedError + "]");
    } catch (PipeRunException e) {
        String msg = e.getMessage();
        if (msg == null || msg.indexOf(expectedError) < 0) {
            fail("expected [" + expectedError + "] in error message, but was [" + msg + "]");
        }
    }
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) PipeForward(nl.nn.adapterframework.core.PipeForward)

Example 28 with PipeForward

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

the class PipeTestBase method setup.

@Before
public void setup() {
    pipe = createPipe();
    pipe.registerForward(new PipeForward("success", null));
}
Also used : PipeForward(nl.nn.adapterframework.core.PipeForward) Before(org.junit.Before)

Example 29 with PipeForward

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

the class Json2XmlValidatorTest method validate.

@Override
public String validate(String rootNamespace, String schemaLocation, boolean addNamespaceToSchema, boolean ignoreUnknownNamespaces, String inputFile, String[] expectedFailureReasons) throws IOException, ConfigurationException, PipeRunException {
    init();
    PipeLineSessionBase session = new PipeLineSessionBase();
    // instance.setSchemasProvider(getSchemasProvider(schemaLocation, addNamespaceToSchema));
    instance.setSchemaLocation(schemaLocation);
    instance.setAddNamespaceToSchema(addNamespaceToSchema);
    instance.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
    // instance.registerForward("success");
    instance.setThrowException(true);
    instance.setFullSchemaChecking(true);
    instance.setTargetNamespace(rootNamespace);
    instance.registerForward(new PipeForward("failure", null));
    instance.registerForward(new PipeForward("parserError", null));
    instance.configure(null);
    validator.setSchemasProvider(getSchemasProvider(schemaLocation, addNamespaceToSchema));
    validator.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
    validator.configure("setup");
    String testXml = inputFile != null ? getTestXml(inputFile + ".xml") : null;
    System.out.println("testXml [" + inputFile + ".xml] contents [" + testXml + "]");
    String xml2json = (String) jsonPipe.doPipe(testXml, session).getResult();
    System.out.println("testXml [" + inputFile + ".xml] to json [" + xml2json + "]");
    String testJson = inputFile != null ? getTestXml(inputFile + ".json") : null;
    System.out.println("testJson [" + testJson + "]");
    try {
        PipeRunResult prr = instance.doPipe(testJson, session);
        String result = (String) prr.getResult();
        System.out.println("result [" + ToStringBuilder.reflectionToString(prr) + "]");
        String event;
        if (prr.getPipeForward().getName().equals("success")) {
            event = "valid XML";
        } else {
            if (prr.getPipeForward().getName().equals("failure")) {
                event = "Invalid XML";
            } else {
                event = prr.getPipeForward().getName();
            }
        }
        evaluateResult(event, session, null, expectedFailureReasons);
        try {
            String validationResult = validator.validate(result, session, "check result", null, null, false);
            evaluateResult(validationResult, session, null, expectedFailureReasons);
            return result;
        } catch (Exception e) {
            fail("result XML must be valid");
        }
        return result;
    } catch (PipeRunException pre) {
        evaluateResult("Invalid XML", session, pre, expectedFailureReasons);
    }
    return null;
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException) PipeForward(nl.nn.adapterframework.core.PipeForward) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase)

Example 30 with PipeForward

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

the class Json2XmlValidatorTest method init.

protected void init() throws ConfigurationException {
    jsonPipe = new JsonPipe();
    jsonPipe.setName("xml2json");
    jsonPipe.registerForward(new PipeForward("success", null));
    jsonPipe.setDirection("xml2json");
    jsonPipe.configure();
    try {
        validator = implementation.newInstance();
    } catch (IllegalAccessException e) {
        throw new ConfigurationException(e);
    } catch (InstantiationException e) {
        throw new ConfigurationException(e);
    }
    validator.setThrowException(true);
    validator.setFullSchemaChecking(true);
    instance = new Json2XmlValidator();
    instance.registerForward(new PipeForward("success", null));
    instance.setSoapNamespace(null);
    instance.setFailOnWildcards(false);
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Json2XmlValidator(nl.nn.adapterframework.pipes.Json2XmlValidator) JsonPipe(nl.nn.adapterframework.pipes.JsonPipe) PipeForward(nl.nn.adapterframework.core.PipeForward)

Aggregations

PipeForward (nl.nn.adapterframework.core.PipeForward)49 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)23 PipeRunException (nl.nn.adapterframework.core.PipeRunException)21 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)10 Test (org.junit.Test)8 IOException (java.io.IOException)7 ParameterResolutionContext (nl.nn.adapterframework.parameters.ParameterResolutionContext)7 ParameterException (nl.nn.adapterframework.core.ParameterException)6 ParameterList (nl.nn.adapterframework.parameters.ParameterList)6 IPipe (nl.nn.adapterframework.core.IPipe)4 Map (java.util.Map)3 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)3 ConfigurationWarnings (nl.nn.adapterframework.configuration.ConfigurationWarnings)3 IPipeLineSession (nl.nn.adapterframework.core.IPipeLineSession)3 ITransactionalStorage (nl.nn.adapterframework.core.ITransactionalStorage)3 PipeLineSessionBase (nl.nn.adapterframework.core.PipeLineSessionBase)3 ApiWsdlXmlValidator (nl.nn.adapterframework.extensions.api.ApiWsdlXmlValidator)3 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)3 StatisticsKeeper (nl.nn.adapterframework.statistics.StatisticsKeeper)3 InputStream (java.io.InputStream)2