Add TCP Test Diagnostics
This commit is contained in:
@@ -36,7 +36,7 @@ import java.util.function.Function;
|
||||
import javax.net.ServerSocketFactory;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
@@ -54,6 +54,7 @@ import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionF
|
||||
import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.serializer.ByteArrayRawSerializer;
|
||||
import org.springframework.integration.ip.util.TestingUtilities;
|
||||
import org.springframework.integration.test.condition.LogLevels;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
@@ -292,6 +293,7 @@ public class TcpInboundGatewayTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@LogLevels(categories = "org.springframework.integration.ip", level = "DEBUG")
|
||||
public void testNetCloseStream() throws InterruptedException, IOException {
|
||||
testCloseStream(new TcpNetServerConnectionFactory(0),
|
||||
port -> new TcpNetClientConnectionFactory("localhost", port));
|
||||
|
||||
@@ -30,8 +30,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer;
|
||||
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
|
||||
@@ -39,7 +38,7 @@ import org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSe
|
||||
import org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.ip.util.TestingUtilities;
|
||||
import org.springframework.integration.test.support.LongRunningIntegrationTest;
|
||||
import org.springframework.integration.test.condition.LogLevels;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.ErrorMessage;
|
||||
|
||||
@@ -49,11 +48,9 @@ import org.springframework.messaging.support.ErrorMessage;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
//@LongRunningTest
|
||||
public class TcpNioConnectionReadTests {
|
||||
|
||||
@Rule
|
||||
public LongRunningIntegrationTest longRunningIntegrationTest = new LongRunningIntegrationTest();
|
||||
|
||||
private final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
private AbstractServerConnectionFactory getConnectionFactory(
|
||||
@@ -242,6 +239,7 @@ public class TcpNioConnectionReadTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@LogLevels(categories = "org.springframework.integration.ip", level = "DEBUG")
|
||||
public void testReadStxEtxOverflow() throws Exception {
|
||||
ByteArrayStxEtxSerializer serializer = new ByteArrayStxEtxSerializer();
|
||||
serializer.setMaxMessageSize(1024);
|
||||
@@ -251,6 +249,7 @@ public class TcpNioConnectionReadTests {
|
||||
|
||||
final CountDownLatch errorMessageLetch = new CountDownLatch(1);
|
||||
final AtomicReference<Throwable> errorMessageRef = new AtomicReference<>();
|
||||
final CountDownLatch openedLatch = new CountDownLatch(1);
|
||||
|
||||
AbstractServerConnectionFactory scf = getConnectionFactory(serializer, message -> {
|
||||
if (message instanceof ErrorMessage) {
|
||||
@@ -264,6 +263,7 @@ public class TcpNioConnectionReadTests {
|
||||
public void addNewConnection(TcpConnection connection) {
|
||||
added.add(connection);
|
||||
semaphore.release();
|
||||
openedLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,6 +277,7 @@ public class TcpNioConnectionReadTests {
|
||||
// Fire up the sender.
|
||||
|
||||
CountDownLatch done = SocketTestUtils.testSendStxEtxOverflow(scf.getPort());
|
||||
assertThat(openedLatch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
whileOpen(semaphore, added);
|
||||
assertThat(added.size()).isEqualTo(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user