@Test
public void testJavaExecutorReleasedAfterException() {

    final JavaExecutor javaExecutor = mock(JavaExecutor.class);
    final String gav = "";
    final String className = "";
    final String methodName = "";
    JavaExecutionParametersProvider provider = null;
    when(javaExecutor.execute(className, methodName, provider)).thenThrow(new IllegalArgumentException(""));
    JavaExecutionCachedEngine engine = new JavaExecutionCachedEngine() {
        public JavaExecutor allocateExecutor(Set<String> dependencies) {
            return javaExecutor;
        }
    };
    try {
        engine.execute(gav, className, methodName, provider);
    } catch (Throwable t) {
        assertTrue(t instanceof IllegalArgumentException);
    }
    verify(javaExecutor).release();
}