MultipartHttpSender extends HttpSender { @Override public void configure() throws ConfigurationException { setMethodType("POST"); setInputMessageParam("message"); setParamsInUrl(false); setMultipart(true); super.configure(); }  @Override void configure();  }
@Test public void simpleMockedMultipartHttp1() throws Throwable { MultipartHttpSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); String xmlMultipart = "<parts><part type=\"file\" name=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes())); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedMultipartHttp1.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } finally { if (sender != null) { sender.close(); } } }
@Test public void simpleMockedMultipartHttp2() throws Throwable { MultipartHttpSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); String xmlMultipart = "<parts><part name=\"dummy\" filename=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes())); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedMultipartHttp2.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } finally { if (sender != null) { sender.close(); } } }
@Test public void simpleMockedMultipartHttp3() throws Throwable { MultipartHttpSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); String xmlMultipart = "<parts><part name=\"dummy\" " + "value=\"{json:true}\" size=\"72833\" " + "mimeType=\"application/json\"/></parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes())); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedMultipartHttp3.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } finally { if (sender != null) { sender.close(); } } }
@Test public void simpleMockedMultipartMtom1() throws Throwable { MultipartHttpSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); String xmlMultipart = "<parts><part type=\"file\" name=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes())); sender.setMtomEnabled(true); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedMultipartMtom1.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } finally { if (sender != null) { sender.close(); } } }
@Test public void simpleMockedMultipartMtom2() throws Throwable { MultipartHttpSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); String xmlMultipart = "<parts><part name=\"dummy\" filename=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes())); sender.setMtomEnabled(true); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedMultipartMtom2.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } finally { if (sender != null) { sender.close(); } } }
@Test public void simpleMockedMultipartMtom3() throws Throwable { MultipartHttpSender sender = getSender(); Message input = new Message("<xml>input</xml>"); try { IPipeLineSession pls = new PipeLineSessionBase(session); String xmlMultipart = "<parts><part name=\"dummy\" " + "value=\"{json:true}\" size=\"72833\" " + "mimeType=\"application/json\"/></parts>"; pls.put("multipartXml", xmlMultipart); pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes())); sender.setMtomEnabled(true); sender.setMultipartXmlSessionKey("multipartXml"); sender.configure(); sender.open(); String result = sender.sendMessage(input, pls).asString(); assertEquals(getFile("simpleMockedMultipartMtom3.txt"), result.trim()); } catch (SenderException e) { throw e.getCause(); } finally { if (sender != null) { sender.close(); } } }