Skip to content

Commit 055eadc

Browse files
committed
Add TCP Test Diagnostics
1 parent 09ab0af commit 055eadc

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpInboundGatewayTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import javax.net.ServerSocketFactory;
3737
import javax.net.SocketFactory;
3838

39-
import org.junit.Test;
39+
import org.junit.jupiter.api.Test;
4040

4141
import org.springframework.beans.factory.BeanFactory;
4242
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@@ -54,6 +54,7 @@
5454
import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory;
5555
import org.springframework.integration.ip.tcp.serializer.ByteArrayRawSerializer;
5656
import org.springframework.integration.ip.util.TestingUtilities;
57+
import org.springframework.integration.test.condition.LogLevels;
5758
import org.springframework.messaging.Message;
5859
import org.springframework.messaging.MessageChannel;
5960
import org.springframework.messaging.SubscribableChannel;
@@ -292,6 +293,7 @@ public void testErrorFlow() throws Exception {
292293
}
293294

294295
@Test
296+
@LogLevels(categories = "org.springframework.integration.ip", level = "DEBUG")
295297
public void testNetCloseStream() throws InterruptedException, IOException {
296298
testCloseStream(new TcpNetServerConnectionFactory(0),
297299
port -> new TcpNetClientConnectionFactory("localhost", port));

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionReadTests.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@
3030

3131
import javax.net.SocketFactory;
3232

33-
import org.junit.Rule;
34-
import org.junit.Test;
33+
import org.junit.jupiter.api.Test;
3534

3635
import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer;
3736
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
3837
import org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSerializer;
3938
import org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer;
4039
import org.springframework.integration.ip.util.SocketTestUtils;
4140
import org.springframework.integration.ip.util.TestingUtilities;
42-
import org.springframework.integration.test.support.LongRunningIntegrationTest;
41+
import org.springframework.integration.test.condition.LogLevels;
4342
import org.springframework.messaging.Message;
4443
import org.springframework.messaging.support.ErrorMessage;
4544

@@ -49,11 +48,9 @@
4948
*
5049
* @since 2.0
5150
*/
51+
//@LongRunningTest
5252
public class TcpNioConnectionReadTests {
5353

54-
@Rule
55-
public LongRunningIntegrationTest longRunningIntegrationTest = new LongRunningIntegrationTest();
56-
5754
private final CountDownLatch latch = new CountDownLatch(1);
5855

5956
private AbstractServerConnectionFactory getConnectionFactory(
@@ -242,6 +239,7 @@ public void removeDeadConnection(TcpConnection connection) {
242239
}
243240

244241
@Test
242+
@LogLevels(categories = "org.springframework.integration.ip", level = "DEBUG")
245243
public void testReadStxEtxOverflow() throws Exception {
246244
ByteArrayStxEtxSerializer serializer = new ByteArrayStxEtxSerializer();
247245
serializer.setMaxMessageSize(1024);
@@ -251,6 +249,7 @@ public void testReadStxEtxOverflow() throws Exception {
251249

252250
final CountDownLatch errorMessageLetch = new CountDownLatch(1);
253251
final AtomicReference<Throwable> errorMessageRef = new AtomicReference<>();
252+
final CountDownLatch openedLatch = new CountDownLatch(1);
254253

255254
AbstractServerConnectionFactory scf = getConnectionFactory(serializer, message -> {
256255
if (message instanceof ErrorMessage) {
@@ -264,6 +263,7 @@ public void testReadStxEtxOverflow() throws Exception {
264263
public void addNewConnection(TcpConnection connection) {
265264
added.add(connection);
266265
semaphore.release();
266+
openedLatch.countDown();
267267
}
268268

269269
@Override
@@ -277,6 +277,7 @@ public void removeDeadConnection(TcpConnection connection) {
277277
// Fire up the sender.
278278

279279
CountDownLatch done = SocketTestUtils.testSendStxEtxOverflow(scf.getPort());
280+
assertThat(openedLatch.await(10, TimeUnit.SECONDS)).isTrue();
280281
whileOpen(semaphore, added);
281282
assertThat(added.size()).isEqualTo(1);
282283

0 commit comments

Comments
 (0)