use of org.jboss.arquillian.core.api.InstanceProducer in project keycloak by keycloak.
the class ModelTestExecutor method execute.
@Override
public void execute(LocalExecutionEvent event) throws Exception {
Method testMethod = event.getExecutor().getMethod();
ModelTest annotation = testMethod.getAnnotation(ModelTest.class);
if (annotation == null) {
// Not a model test
super.execute(event);
} else {
TestResult result = new TestResult();
try {
// Model test - wrap the call inside the
TestContext ctx = testContext.get();
KeycloakTestingClient testingClient = ctx.getTestingClient();
testingClient.server().runModelTest(testMethod.getDeclaringClass().getName(), testMethod.getName());
result.setStatus(TestResult.Status.PASSED);
} catch (Throwable e) {
result.setStatus(TestResult.Status.FAILED);
result.setThrowable(e);
} finally {
result.setEnd(System.currentTimeMillis());
}
// Need to use reflection this way...
Field testResultField = Reflections.findDeclaredField(LocalTestExecuter.class, "testResult");
testResultField.setAccessible(true);
InstanceProducer<TestResult> thisTestResult = (InstanceProducer<TestResult>) testResultField.get(this);
thisTestResult.set(result);
}
}
Aggregations