Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Log start/finish for each Arquillian test
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed May 29, 2015
1 parent 3991bfa commit 96c3b24
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
17 changes: 15 additions & 2 deletions zanata-war/src/test/java/org/zanata/RestTest.java
Expand Up @@ -38,6 +38,8 @@
import org.jboss.seam.util.Naming;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.zanata.arquillian.RemoteAfter;
import org.zanata.arquillian.RemoteBefore;
Expand Down Expand Up @@ -132,13 +134,20 @@ public void cleanDataAfterTest() {
dbUnitProvider.cleanDataAfterTest();
}

@Rule
public final TestName testName = new TestName();

@Before
public void signalBeforeTest() {
ClientRequest clientRequest =
new ClientRequest(getRestEndpointUrl() + "test/remote/signal/before");
clientRequest.header("X-Auth-User", ADMIN);
clientRequest.header("X-Auth-Token", ADMIN_KEY);
try {
clientRequest.queryParameter("c", this.getClass().getName()).post();
clientRequest
.queryParameter("c", this.getClass().getName())
.queryParameter("m", testName.getMethodName())
.post();
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -148,9 +157,13 @@ public void signalBeforeTest() {
public void signalAfterTest() {
ClientRequest clientRequest =
new ClientRequest(getRestEndpointUrl() + "test/remote/signal/after");
clientRequest.header("X-Auth-User", ADMIN);
clientRequest.header("X-Auth-Token", ADMIN_KEY);
try {
clientRequest.queryParameter("c", this.getClass().getName()).post();
clientRequest
.queryParameter("c", this.getClass().getName())
.queryParameter("m", testName.getMethodName())
.post();
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Expand Up @@ -34,11 +34,11 @@
public interface RemoteTestSignaler {
@POST
@Path("/before")
public void signalBeforeTest(@QueryParam("c") String testClass)
public void signalBeforeTest(@QueryParam("c") String testClass, @QueryParam("m") String testMethod)
throws Exception;

@POST
@Path("/after")
public void signalAfterTest(@QueryParam("c") String testClass)
public void signalAfterTest(@QueryParam("c") String testClass, @QueryParam("m") String testMethod)
throws Exception;
}
Expand Up @@ -28,6 +28,7 @@

import javax.ws.rs.Path;

import lombok.extern.slf4j.Slf4j;
import org.jboss.arquillian.seam2.ReflectionHelper;
import org.jboss.seam.annotations.Name;
import org.zanata.arquillian.RemoteAfter;
Expand All @@ -42,21 +43,24 @@
*/
@Path("/test/remote/signal")
@Name("remoteTestSignalerImpl")
@Slf4j
public class RemoteTestSignalerImpl implements RemoteTestSignaler {
@Override
public void signalBeforeTest(String testClass) throws Exception {
public void signalBeforeTest(String testClass, String testMethod) throws Exception {
log.info("Starting test {}:{}", testClass, testMethod);
Class<?> testCls = Class.forName(testClass);
Object testInstance = testCls.newInstance();

invokeAnnotatedMethods(testInstance, RemoteBefore.class);
}

@Override
public void signalAfterTest(String testClass) throws Exception {
public void signalAfterTest(String testClass, String testMethod) throws Exception {
Class<?> testCls = Class.forName(testClass);
Object testInstance = testCls.newInstance();

invokeAnnotatedMethods(testInstance, RemoteAfter.class);
log.info("Finished test {}:{}", testClass, testMethod);
}

private void invokeAnnotatedMethods(Object o,
Expand Down

0 comments on commit 96c3b24

Please sign in to comment.