FilenameSwitch extends AbstractPipe { @Override public PipeRunResult doPipe(Message message, IPipeLineSession session) throws PipeRunException { String forward=""; String sInput; try { sInput = message.asString(); } catch (IOException e) { throw new PipeRunException(this, getLogPrefix(session)+"cannot open stream", e); } PipeForward pipeForward=null; int slashPos=sInput.lastIndexOf('/'); if (slashPos>0) { sInput=sInput.substring(slashPos+1); } slashPos=sInput.lastIndexOf('\\'); if (slashPos>0) { sInput=sInput.substring(slashPos+1); } forward=sInput; if (isToLowercase()) { forward=forward.toLowerCase(); } log.debug(getLogPrefix(session)+ "determined forward ["+forward+"]"); if (findForward(forward) != null) pipeForward=findForward(forward); else { log.info(getLogPrefix(session)+"determined forward ["+forward+"], which is not defined. Will use ["+getNotFoundForwardName()+"] instead"); pipeForward=findForward(getNotFoundForwardName()); } if (pipeForward==null) { throw new PipeRunException (this, getLogPrefix(session)+"cannot find forward or pipe named ["+forward+"]"); } return new PipeRunResult(pipeForward, message); }  @Override void configure(); @Override PipeRunResult doPipe(Message message, IPipeLineSession session); @IbisDoc({"forward returned when the forward or pipename derived from the filename that was the input could not be found.", ""}) void setNotFoundForwardName(String notFound); String getNotFoundForwardName(); @IbisDoc({"convert the result to lowercase, before searching for a corresponding forward", "true"}) void setToLowercase(boolean b); boolean isToLowercase();  }
@Test public void testValidForwardName() throws Exception { PipeRunResult res = doPipe(pipe, "CreateHelloWorld/success", session); assertEquals("success", res.getPipeForward().getName()); }