From 7e8ad682f213d046d5034b6d2101a222970028b3 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 12 Feb 2015 13:25:22 -0500 Subject: [PATCH] Add TCP Interceptor Test Diagnostics --- .../tcp/InterceptedSharedConnectionTests.java | 38 ++++++++++++++----- .../tcp/connection/HelloWorldInterceptor.java | 8 +++- .../src/test/resources/log4j.properties | 2 +- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java index 8ec93e816e..dea76dc4bc 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,16 +20,20 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import org.apache.log4j.Level; +import org.apache.log4j.LogManager; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.support.MessageBuilder; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageChannel; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -40,22 +44,36 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class InterceptedSharedConnectionTests { - + @Autowired AbstractApplicationContext ctx; - + @Autowired @Qualifier(value="inboundServer") TcpReceivingChannelAdapter listener; - + + private static Level existingLogLevel; + + // temporary hooks to investigate CI failures + @BeforeClass + public static void setup() { + existingLogLevel = LogManager.getLogger("org.springframework.integration").getLevel(); + LogManager.getLogger("org.springframework.integration").setLevel(Level.DEBUG); + } + + @AfterClass + public static void tearDown() { + LogManager.getLogger("org.springframework.integration").setLevel(existingLogLevel); + } + /** * Tests a loopback. The client-side outbound adapter sends a message over - * a connection from the client connection factory; the server side + * a connection from the client connection factory; the server side * receives the message, puts in on a channel which is the input channel - * for the outbound adapter that's sharing the connections. The response - * comes back to an inbound adapter that is sharing the client's + * for the outbound adapter that's sharing the connections. The response + * comes back to an inbound adapter that is sharing the client's * connection and we verify we get the echo back as expected. - * + * * @throws Exception */ @Test diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptor.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptor.java index bb019faed4..3760daada7 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptor.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -142,6 +142,10 @@ public class HelloWorldInterceptor extends TcpConnectionInterceptorSupport { } } - + @Override + public String toString() { + return "HelloWorldInterceptor [negotiated=" + negotiated + ", hello=" + hello + ", world=" + world + + ", closeReceived=" + closeReceived + ", pendingSend=" + pendingSend + "]"; + } } diff --git a/spring-integration-ip/src/test/resources/log4j.properties b/spring-integration-ip/src/test/resources/log4j.properties index c38d3b65db..4b6a87af5e 100644 --- a/spring-integration-ip/src/test/resources/log4j.properties +++ b/spring-integration-ip/src/test/resources/log4j.properties @@ -5,4 +5,4 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %c{1} [%t] : %m%n log4j.category.org.springframework.integration=WARN -log4j.category.org.springframework.integration.ip=WARN +#log4j.category.org.springframework.integration.ip=WARN