jmxTestRunner = new JMXTestRunner() {
@Override
public TestResult runTestMethod(String className, String methodName, Map<String, String> props) {
Map<String, Object> properties = Collections.<String, Object> singletonMap(TEST_CLASS_PROPERTY, className);
ContextManager contextManager = initializeContextManager(className, properties);
try {
// actually run the tests
return super.runTestMethod(className, methodName, props);
} finally {
contextManager.teardown(properties);
}
}
@Override
public InputStream runTestMethodEmbedded(String className, String methodName, Map<String, String> props) {
Map<String, Object> properties = Collections.<String, Object> singletonMap(TEST_CLASS_PROPERTY, className);
ContextManager contextManager = initializeContextManager(className, properties);
try {
// actually run the tests
return super.runTestMethodEmbedded(className, methodName, props);
} finally {
contextManager.teardown(properties);
}
}
@Override
protected TestClassLoader getTestClassLoader() {
return testClassLoader;
}
private ContextManager initializeContextManager(String className, Map<String, Object> properties) {
final ContextManagerBuilder builder = new ContextManagerBuilder();
ArquillianConfig config = getConfig(className);
if (config != null) {
final DeploymentUnit deployment = config.getDeploymentUnitContext();
final Module module = deployment.getAttachment(Attachments.MODULE);
if (module != null) {
builder.add(new TCCLSetup(module.getClassLoader()));
}
builder.addAll(deployment);
}
ContextManager contextManager = builder.build();
contextManager.setup(properties);
return contextManager;
}
};
jmxTestRunner.registerMBean(mbeanServer);
} catch (Throwable t) {