Search in sources :

Example 86 with PipeRunResult

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

the class StreamPipeTest method doPipeHttpRequestTest.

@Test
public void doPipeHttpRequestTest() throws Exception {
    StreamPipe streamPipe = new StreamPipe();
    streamPipe.registerForward(createPipeSuccessForward());
    MockMultipartHttpServletRequest request = createMultipartHttpRequest();
    streamPipe.addParameter(createHttpRequestParameter(request, session));
    streamPipe.configure();
    PipeRunResult pipeRunResult = streamPipe.doPipe("", session);
    assertEquals("success", pipeRunResult.getPipeForward().getName());
    String expectedResult = "<parts>" + "<part type=\"string\" name=\"string1\" sessionKey=\"part_string\" size=\"19\"/>" + "<part type=\"file\" name=\"doc001.pdf\" sessionKey=\"part_file\" size=\"26358\" mimeType=\"application/octet-stream; charset=ISO-8859-1\"/>" + "<part type=\"file\" name=\"doc002.pdf\" sessionKey=\"part_file2\" size=\"25879\" mimeType=\"application/octet-stream; charset=ISO-8859-1\"/>" + "</parts>";
    assertEquals(expectedResult, pipeRunResult.getResult());
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) MockMultipartHttpServletRequest(org.springframework.mock.web.MockMultipartHttpServletRequest) Test(org.junit.Test)

Example 87 with PipeRunResult

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

the class StreamPipeTest method doPipeHttpRequestAntiVirusTest.

@Test
public void doPipeHttpRequestAntiVirusTest() throws Exception {
    StreamPipe streamPipe = new StreamPipe();
    streamPipe.registerForward(createPipeSuccessForward());
    MockMultipartHttpServletRequest request = createMultipartHttpRequest(streamPipe, true);
    streamPipe.addParameter(createHttpRequestParameter(request, session));
    streamPipe.configure();
    PipeRunResult pipeRunResult = streamPipe.doPipe("", session);
    assertEquals("success", pipeRunResult.getPipeForward().getName());
    String expectedResult = "<parts>" + "<part type=\"string\" name=\"string1\" sessionKey=\"part_string\" size=\"19\"/>" + "<part type=\"file\" name=\"doc001.pdf\" sessionKey=\"part_file\" size=\"26358\" mimeType=\"application/octet-stream; charset=ISO-8859-1\"/>" + "<part type=\"string\" name=\"antivirus_rc\" sessionKey=\"part_string2\" size=\"4\"/>" + "<part type=\"file\" name=\"doc002.pdf\" sessionKey=\"part_file2\" size=\"25879\" mimeType=\"application/octet-stream; charset=ISO-8859-1\"/>" + "<part type=\"string\" name=\"antivirus_rc\" sessionKey=\"part_string3\" size=\"4\"/>" + "</parts>";
    assertEquals(expectedResult, pipeRunResult.getResult());
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) MockMultipartHttpServletRequest(org.springframework.mock.web.MockMultipartHttpServletRequest) Test(org.junit.Test)

Example 88 with PipeRunResult

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

the class HashPipeTest method md5.

@Test
public void md5() throws ConfigurationException, PipeStartException, IOException, PipeRunException {
    pipe.setSecret("Potato");
    pipe.setAlgorithm("HmacMD5");
    pipe.configure();
    pipe.start();
    PipeRunResult prr = pipe.doPipe("hash me plz", session);
    String hash = (String) prr.getResult();
    assertEquals("TwGD5U8BwKoLn8u/F+4R/g==", hash);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) Test(org.junit.Test)

Example 89 with PipeRunResult

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

the class Json2WsdlXmlValidatorTest method validate.

public void validate(String description, WsdlXmlValidator val, String input, String outputFormat, boolean compactJsonArrays, String targetContent1, String targetContent2) {
    val.setCompactJsonArrays(compactJsonArrays);
    if (compactJsonArrays) {
        description += " (compact)";
    } else {
        description += " (straight)";
    }
    System.out.println("-- " + description + " --");
    System.out.println("input [" + input + "]");
    if (outputFormat != null) {
        session.put("outputFormat", outputFormat);
    } else {
        session.remove("outputFormat");
    }
    PipeRunResult result;
    try {
        result = val.doPipe(input, session);
        String resultStr = (String) result.getResult();
        System.out.println("result of [" + description + "]\n" + resultStr);
        if (resultStr.indexOf(targetContent1) < 0) {
            fail("result of [" + description + "] does not contain target content [" + targetContent1 + "]");
        }
        if (resultStr.indexOf(targetContent2) < 0) {
            fail("result of [" + description + "] does not contain target content [" + targetContent2 + "]");
        }
    // if ("xml".equals(outputFormat)) {
    // result=val.doPipe(resultStr, session);
    // resultStr=(String)result.getResult();
    // System.out.println("back to json:"+resultStr);
    // }
    } catch (PipeRunException e) {
        e.printStackTrace();
        fail(description + ": " + e.getMessage());
    }
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) PipeRunException(nl.nn.adapterframework.core.PipeRunException)

Aggregations

PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)89 PipeRunException (nl.nn.adapterframework.core.PipeRunException)65 PipeForward (nl.nn.adapterframework.core.PipeForward)23 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)22 ParameterResolutionContext (nl.nn.adapterframework.parameters.ParameterResolutionContext)21 IOException (java.io.IOException)17 ParameterException (nl.nn.adapterframework.core.ParameterException)14 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)11 Test (org.junit.Test)11 File (java.io.File)10 Map (java.util.Map)10 ParameterList (nl.nn.adapterframework.parameters.ParameterList)8 InputStream (java.io.InputStream)7 DomBuilderException (nl.nn.adapterframework.util.DomBuilderException)7 Parameter (nl.nn.adapterframework.parameters.Parameter)6 FileInputStream (java.io.FileInputStream)4 StringReader (java.io.StringReader)4 Iterator (java.util.Iterator)4 StringTokenizer (java.util.StringTokenizer)4 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)4