Log name of test for WebSocket integration tests

This makes it easier to trace log output on the CI server where the
output is per class.
This commit is contained in:
Rossen Stoyanchev
2014-07-02 14:26:51 -04:00
parent 59e02e63c4
commit 6d15fcc4a6
3 changed files with 21 additions and 3 deletions

View File

@@ -30,8 +30,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestName;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
@@ -56,6 +58,9 @@ import static org.junit.Assert.*;
*/ */
public class StompBrokerRelayMessageHandlerIntegrationTests { public class StompBrokerRelayMessageHandlerIntegrationTests {
@Rule
public final TestName testName = new TestName();
private static final Log logger = LogFactory.getLog(StompBrokerRelayMessageHandlerIntegrationTests.class); private static final Log logger = LogFactory.getLog(StompBrokerRelayMessageHandlerIntegrationTests.class);
private static final Charset UTF_8 = Charset.forName("UTF-8"); private static final Charset UTF_8 = Charset.forName("UTF-8");
@@ -75,14 +80,12 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
logger.debug("Setting up '" + this.testName.getMethodName() + "'");
this.port = SocketUtils.findAvailableTcpPort(61613); this.port = SocketUtils.findAvailableTcpPort(61613);
this.responseChannel = new ExecutorSubscribableChannel(); this.responseChannel = new ExecutorSubscribableChannel();
this.responseHandler = new TestMessageHandler(); this.responseHandler = new TestMessageHandler();
this.responseChannel.subscribe(this.responseHandler); this.responseChannel.subscribe(this.responseHandler);
this.eventPublisher = new TestEventPublisher(); this.eventPublisher = new TestEventPublisher();
startActiveMqBroker(); startActiveMqBroker();
createAndStartRelay(); createAndStartRelay();
} }

View File

@@ -23,6 +23,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameter;
import org.springframework.context.Lifecycle; import org.springframework.context.Lifecycle;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@@ -53,6 +55,9 @@ public abstract class AbstractWebSocketIntegrationTests {
upgradeStrategyConfigTypes.put(UndertowTestServer.class, UndertowUpgradeStrategyConfig.class); upgradeStrategyConfigTypes.put(UndertowTestServer.class, UndertowUpgradeStrategyConfig.class);
} }
@Rule
public final TestName testName = new TestName();
@Parameter(0) @Parameter(0)
public WebSocketTestServer server; public WebSocketTestServer server;
@@ -65,6 +70,10 @@ public abstract class AbstractWebSocketIntegrationTests {
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
logger.debug("Setting up '" + this.testName.getMethodName() + "', client=" +
this.webSocketClient.getClass().getSimpleName() + ", server=" +
this.server.getClass().getSimpleName());
this.wac = new AnnotationConfigWebApplicationContext(); this.wac = new AnnotationConfigWebApplicationContext();
this.wac.register(getAnnotatedConfigClasses()); this.wac.register(getAnnotatedConfigClasses());
this.wac.register(upgradeStrategyConfigTypes.get(this.server.getClass())); this.wac.register(upgradeStrategyConfigTypes.get(this.server.getClass()));

View File

@@ -21,7 +21,9 @@ import org.apache.commons.logging.LogFactory;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestName;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -75,6 +77,9 @@ import static org.junit.Assert.fail;
*/ */
public abstract class AbstractSockJsIntegrationTests { public abstract class AbstractSockJsIntegrationTests {
@Rule
public final TestName testName = new TestName();
protected Log logger = LogFactory.getLog(getClass()); protected Log logger = LogFactory.getLog(getClass());
private WebSocketTestServer server; private WebSocketTestServer server;
@@ -88,6 +93,7 @@ public abstract class AbstractSockJsIntegrationTests {
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
logger.debug("Setting up '" + this.testName.getMethodName() + "'");
this.errorFilter = new ErrorFilter(); this.errorFilter = new ErrorFilter();
this.wac = new AnnotationConfigWebApplicationContext(); this.wac = new AnnotationConfigWebApplicationContext();
this.wac.register(TestConfig.class, upgradeStrategyConfigClass()); this.wac.register(TestConfig.class, upgradeStrategyConfigClass());