Search in sources :

Example 26 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.

the class XsltPipeErrorTest method importNotFound2.

@Test
public void importNotFound2() throws Exception {
    ErrorOutputStream errorOutputStream = new ErrorOutputStream();
    System.setErr(new PrintStream(errorOutputStream));
    XsltPipe xsltPipe = new XsltPipe();
    xsltPipe.registerForward(createPipeSuccessForward());
    xsltPipe.setStyleSheetName("/Xslt/importNotFound/root2.xsl");
    xsltPipe.setXslt2(true);
    String errorMessage = null;
    try {
        xsltPipe.configure();
    } catch (ConfigurationException e) {
        errorMessage = e.getMessage();
    }
    assertEquals(true, errorOutputStream.isEmpty());
    assertEquals(0, testAppender.getNumberOfAlerts());
    assertEquals(true, errorMessage.contains("Failed to compile stylesheet"));
}
Also used : PrintStream(java.io.PrintStream) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Test(org.junit.Test)

Example 27 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.

the class ShowConfigurationStatusTest method initTest.

@BeforeClass
public static void initTest() throws ConfigurationException, TransformerConfigurationException, IOException {
    URL adaptersUrl = ClassUtils.getResourceURL(ShowConfigurationStatusTest.class, adapters_xslt);
    if (adaptersUrl == null) {
        throw new ConfigurationException("cannot find resource [" + adapters_xslt + "]");
    }
    adaptersTransformer = XmlUtils.createTransformer(adaptersUrl, true);
    ibisTester = new IbisTester();
    System.setProperty("HelloWorld.job.active", "false");
    System.setProperty("junit.active", "true");
    System.setProperty("configurations.names", "${instance.name},NotExistingConfig");
    ibisTester.initTest();
    if (ibisTester.testStartAdapters()) {
        ibisContext = ibisTester.getIbisContext();
    }
    assertEquals(true, ibisContext != null);
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) IbisTester(nl.nn.adapterframework.extensions.test.IbisTester) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 28 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.

the class AbstractXmlValidatorTestBase method validate.

@Override
public String validate(String rootNamespace, String schemaLocation, boolean addNamespaceToSchema, boolean ignoreUnknownNamespaces, String inputfile, String[] expectedFailureReasons) throws ConfigurationException, InstantiationException, IllegalAccessException, XmlValidatorException, PipeRunException, IOException {
    AbstractXmlValidator instance = implementation.newInstance();
    instance.setSchemasProvider(getSchemasProvider(schemaLocation, addNamespaceToSchema));
    instance.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
    // instance.registerForward("success");
    instance.setThrowException(true);
    instance.setFullSchemaChecking(true);
    String testXml = inputfile != null ? getTestXml(inputfile + ".xml") : null;
    PipeLineSessionBase session = new PipeLineSessionBase();
    try {
        instance.configure("init");
        String result = instance.validate(testXml, session, "test", null, null, false);
        evaluateResult(result, session, null, expectedFailureReasons);
        return result;
    } catch (Exception e) {
        evaluateResult(null, session, e, expectedFailureReasons);
        return "Invalid XML";
    }
}
Also used : PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) PipeLineSessionBase(nl.nn.adapterframework.core.PipeLineSessionBase)

Example 29 with ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException 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 ConfigurationException

use of nl.nn.adapterframework.configuration.ConfigurationException 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

ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)113 IOException (java.io.IOException)26 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)20 PipeRunException (nl.nn.adapterframework.core.PipeRunException)17 ConfigurationWarnings (nl.nn.adapterframework.configuration.ConfigurationWarnings)16 URL (java.net.URL)13 ArrayList (java.util.ArrayList)12 Parameter (nl.nn.adapterframework.parameters.Parameter)12 ParameterList (nl.nn.adapterframework.parameters.ParameterList)11 File (java.io.File)7 Iterator (java.util.Iterator)6 ListenerException (nl.nn.adapterframework.core.ListenerException)6 PipeForward (nl.nn.adapterframework.core.PipeForward)6 PipeLineSessionBase (nl.nn.adapterframework.core.PipeLineSessionBase)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 StringTokenizer (java.util.StringTokenizer)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 FileNotFoundException (java.io.FileNotFoundException)4 LinkedList (java.util.LinkedList)4