@Test @Ignore public void shouldCleanupResourcesIfAProcessorFails() throws Exception { I_EncodeBusinessProcess mockBusinessProcess = mockControl.createMock(I_EncodeBusinessProcess.class); I_Work mockWork = mockControl.createMock(I_Work.class); CleanableProcessExtByRef mockCleanableProcess = mockControl.createMock(CleanableProcessExtByRef.class); CleanableProcessExtByRefBuilder mockCleanableProcessBuilder = mockControl.createMock(CleanableProcessExtByRefBuilder.class); expectEvaluateCalled(mockBusinessProcess, mockCleanableProcess, mockCleanableProcessBuilder); mockControl.replay(); I_DefineTask task = createTask(mockCleanableProcessBuilder); try { task.evaluate(mockBusinessProcess, mockWork); fail(); } catch (TaskFailedException e) { assertThat(e.getCause(), notNullValue()); assertTrue( "Expected IllegalStateException. Got " + e.getCause(), e.getCause().getClass() == IllegalStateException.class); mockControl.verify(); } }
@SuppressWarnings({"ThrowableInstanceNeverThrown"}) @Test @Ignore public void shouldRethrowAnExceptionIfTheTaskFails() throws Exception { I_EncodeBusinessProcess mockBusinessProcess = mockControl.createMock(I_EncodeBusinessProcess.class); I_Work mockWork = mockControl.createMock(I_Work.class); CleanableProcessExtByRefBuilder mockCleanableProcessBuilder = mockControl.createMock(CleanableProcessExtByRefBuilder.class); EasyMock.expect(mockBusinessProcess.getProperty(DIRECTORY_KEY)) .andThrow(new IllegalArgumentException()); mockControl.replay(); I_DefineTask task = createTask(mockCleanableProcessBuilder); try { task.evaluate(mockBusinessProcess, mockWork); fail(); } catch (TaskFailedException e) { assertThat(e.getCause(), notNullValue()); assertTrue( "Expected IllegalArgumentException. Got " + e.getCause(), e.getCause().getClass() == IllegalArgumentException.class); mockControl.verify(); } }