SharedService extends SharedServiceImpl { @Override public void doService(AdaptrisMessage msg) throws ServiceException { applyService(getProxiedService(), msg); } SharedService();  SharedService(String lookupName); @Override void init(); @Override void start(); @Override void stop(); @Override void close(); @Override void prepare(); @Override void doService(AdaptrisMessage msg); @Override boolean isBranching(); Boolean getCloneService(); void setCloneService(Boolean cloneService);  }
@Test public void testDoService() throws Exception { MockService mockService = new MockService(getName()); SharedService sharedService = new SharedService(getName()); Adapter adapter = createAdapterForSharedService(sharedService, mockService); try { LifecycleHelper.initAndStart(adapter); AdaptrisMessage msg = DefaultMessageFactory.getDefaultInstance().newMessage(); sharedService.doService(msg); assertEquals(1, ((MockService) sharedService.getClonedService()).callCount); MleMarker marker = msg.getMessageLifecycleEvent().getMleMarkers().get(0); assertEquals(MockService.class.getName(), marker.getName()); assertEquals(getName(), marker.getQualifier()); assertEquals(true, marker.getWasSuccessful()); } finally { LifecycleHelper.stopAndClose(adapter); } }
@Test public void testDoService_WithFailure() throws Exception { ThrowExceptionService mockService = new ThrowExceptionService(getName(), new ConfiguredException("Fail")); SharedService sharedService = new SharedService(getName()); Adapter adapter = createAdapterForSharedService(sharedService, mockService); AdaptrisMessage msg = DefaultMessageFactory.getDefaultInstance().newMessage(); try { LifecycleHelper.initAndStart(adapter); sharedService.doService(msg); fail(); } catch (ServiceException expected) { MleMarker marker = msg.getMessageLifecycleEvent().getMleMarkers().get(0); assertEquals(ThrowExceptionService.class.getName(), marker.getName()); assertEquals(getName(), marker.getQualifier()); assertEquals(false, marker.getWasSuccessful()); } finally { LifecycleHelper.stopAndClose(adapter); } }