Switch extends ServiceImp { public List<Case> getCases() { return cases; } Switch(); @Override void doService(AdaptrisMessage msg); @Override void prepare(); @Override void start(); @Override void stop(); List<Case> getCases(); void setCases(List<Case> cases); Switch withCases(List<Case> cases); Switch withCases(Case... cases);  }
@Test public void testService_Failure() throws Exception { Switch service = createForTests(); service.getCases().add(new Case().withCondition(new CaseDefault()) .withService(new ThrowExceptionService(new ConfiguredException("always-fail")))); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(); msg.addMetadata("myKey", "17"); try { execute(service, msg); fail(); } catch (ServiceException expected) { } }