Skip to content
Permalink
Browse files

Improved shutdown behavior when Cucumber test init fails

  • Loading branch information...
Alex Stockinger
Alex Stockinger committed Aug 11, 2017
1 parent dea9195 commit 4230414197cae514f27894c10968638a30add83c
@@ -4,6 +4,7 @@ Version 0.5.0
- Fixed injection of EJBs in base classes of EJBs
- Fixed issue when injecting EJBs with @EJB via one of theis interfaces
- Vastly improved mocking
- Improved shutdown behavior when Cucumber test init fails

Version 0.4.3
- Fixed issue in fi.testee.spi.base.BeanReplacementManager where new EJBs were instantiated on each call when being injected with @Inject
@@ -36,7 +36,6 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -149,13 +148,19 @@ private synchronized ConnectionFactory connectionFactoryManager(TestDataSource t

public TestInstance prepareTestInstance(final String id, final Object testInstance, final Method method) {
LOG.debug("Instantiating test run '{}' for class {}", id, testInstance.getClass().getName());
return new TestInstanceRealm().init(
runtime.getBeanArchiveDiscorvery(),
id,
testInstance,
method,
asList(createSetupResources(true))
);
final TestInstanceRealm context = new TestInstanceRealm();
try {
return context.init(
runtime.getBeanArchiveDiscorvery(),
id,
testInstance,
method,
asList(createSetupResources(true))
);
} catch (final RuntimeException e) {
context.shutdown();
throw e;
}
}

@Override
@@ -72,7 +72,12 @@ public void start() {
} catch (final InstantiationException | IllegalAccessException e) {
throw new TestEEfiException("Failed to instantiate cucumber test setup class", e);
}
context = testSetup.prepareTestInstance(id, setupInstance, null);
try {
context = testSetup.prepareTestInstance(id, setupInstance, null);
}catch(final RuntimeException e) {
testSetup.shutdown();
throw e;
}
releaser = new Releaser();
}

0 comments on commit 4230414

Please sign in to comment.
You can’t perform that action at this time.