GrabberService extends AbstractExecutionThreadService { @Override protected void startUp() throws GrabberServiceException { serviceThread = Optional.of(Thread.currentThread()); try { frameGrabber = frameGrabberSupplier.get(); frameGrabber.start(); } catch (FrameGrabber.Exception ex) { throw new GrabberServiceException("Failed to start", ex); } } GrabberService(String name, Supplier<FrameGrabber> frameGrabberSupplier, CameraSourceUpdater
      updater, Runnable exceptionClearedCallback);   }
@Test(expected = IllegalStateException.class) public void testStartUpRethrowsConstructorException() throws GrabberService .GrabberServiceException { try { final GrabberService grabberService = createSimpleGrabberService(ConstructorThrowingFrameGrabber::new); grabberService.startUp(); fail("This should have thrown an exception"); } catch (IllegalStateException e) { assertThat(e).hasMessageThat() .contains(ConstructorThrowingFrameGrabber.CONSTRUCTOR_EXCEPTION_MESSAGE); throw e; } fail("This should have rethrown an exception"); }
@Test(expected = GrabberService.GrabberServiceException.class) public void testStartUpRethrowsFrameGrabberExceptionAsGrabberServiceException() throws GrabberService.GrabberServiceException { final String exceptionMessage = "Start: Kaboom!"; try { final GrabberService grabberService = createSimpleGrabberService( () -> new SimpleMockFrameGrabber() { @Override public void start() throws FrameGrabber.Exception { throw new FrameGrabber.Exception(exceptionMessage); } }); grabberService.startUp(); fail("Should have thrown an exception when starting"); } catch (GrabberService.GrabberServiceException e) { assertThat(e.getCause()).hasMessageThat().contains(exceptionMessage); throw e; } fail("Should have rethrown the exception in the catch block"); }