IfMultipart extends AbstractPipe { @Override public PipeRunResult doPipe(Message message, IPipeLineSession session) throws PipeRunException { String forward; PipeForward pipeForward = null; if (message == null || message.asObject() == null) { forward = elseForwardName; } else { if (!(message.asObject() instanceof HttpServletRequest)) { throw new PipeRunException(this, getLogPrefix(null) + "expected HttpServletRequest as input, got [" + ClassUtils.nameOf(message) + "]"); } HttpServletRequest request = (HttpServletRequest) message.asObject(); String contentType = request.getContentType(); if (StringUtils.isNotEmpty(contentType) && contentType.startsWith("multipart")) { forward = thenForwardName; } else { forward = elseForwardName; } } log.debug(getLogPrefix(session) + "determined forward [" + forward + "]"); pipeForward = findForward(forward); if (pipeForward == null) { throw new PipeRunException(this, getLogPrefix(null) + "cannot find forward or pipe named [" + forward + "]"); } log.debug(getLogPrefix(session) + "resolved forward [" + forward + "] to path [" + pipeForward.getPath() + "]"); return new PipeRunResult(pipeForward, message); }  @Override PipeRunResult doPipe(Message message, IPipeLineSession session); void setThenForwardName(String thenForwardName); String getThenForwardName(); void setElseForwardName(String elseForwardName); String getElseForwardName();  }
@Test public void testInputNotHTTPRequest() throws Exception { exception.expect(PipeRunException.class); exception.expectMessage("Pipe [IfMultipart under test] expected HttpServletRequest as input, got [Message]"); doPipe(pipe, "i am a string not a http req", session); fail("this is expected to fail"); }