use of org.jboss.arquillian.test.spi.TestResult 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);
}
}
use of org.jboss.arquillian.test.spi.TestResult in project wildfly-swarm by wildfly-swarm.
the class DaemonMethodExecutor method invoke.
/**
* {@inheritDoc}
*
* @see org.jboss.arquillian.container.test.spi.ContainerMethodExecutor#invoke(org.jboss.arquillian.test.spi.TestMethodExecutor)
*/
@Override
public TestResult invoke(final TestMethodExecutor testMethodExecutor) {
assert testMethodExecutor != null : "Test method executor is required";
// Build the String request according to the wire protocol
final StringBuilder builder = new StringBuilder();
builder.append(WireProtocol.COMMAND_TEST_PREFIX);
builder.append(testMethodExecutor.getInstance().getClass().getName());
builder.append(SPACE);
builder.append(testMethodExecutor.getMethod().getName());
builder.append(WireProtocol.COMMAND_EOF_DELIMITER);
final String testCommand = builder.toString();
final PrintWriter writer = this.context.getWriter();
// Request
writer.write(testCommand);
writer.flush();
try {
// Read response
final ObjectInputStream response = new ObjectInputStream(new NoCloseInputStream(context.getSocketInstream()));
final TestResult testResult = (TestResult) response.readObject();
response.close();
return testResult;
} catch (final IOException ioe) {
throw new RuntimeException("Could not get test results", ioe);
} catch (final ClassNotFoundException cnfe) {
throw new RuntimeException("test result not on the client classpath", cnfe);
}
}
Aggregations