30
30
31
31
import javax .net .SocketFactory ;
32
32
33
- import org .junit .Rule ;
34
- import org .junit .Test ;
33
+ import org .junit .jupiter .api .Test ;
35
34
36
35
import org .springframework .integration .ip .tcp .serializer .AbstractByteArraySerializer ;
37
36
import org .springframework .integration .ip .tcp .serializer .ByteArrayCrLfSerializer ;
38
37
import org .springframework .integration .ip .tcp .serializer .ByteArrayLengthHeaderSerializer ;
39
38
import org .springframework .integration .ip .tcp .serializer .ByteArrayStxEtxSerializer ;
40
39
import org .springframework .integration .ip .util .SocketTestUtils ;
41
40
import org .springframework .integration .ip .util .TestingUtilities ;
42
- import org .springframework .integration .test .support . LongRunningIntegrationTest ;
41
+ import org .springframework .integration .test .condition . LogLevels ;
43
42
import org .springframework .messaging .Message ;
44
43
import org .springframework .messaging .support .ErrorMessage ;
45
44
49
48
*
50
49
* @since 2.0
51
50
*/
51
+ //@LongRunningTest
52
52
public class TcpNioConnectionReadTests {
53
53
54
- @ Rule
55
- public LongRunningIntegrationTest longRunningIntegrationTest = new LongRunningIntegrationTest ();
56
-
57
54
private final CountDownLatch latch = new CountDownLatch (1 );
58
55
59
56
private AbstractServerConnectionFactory getConnectionFactory (
@@ -242,6 +239,7 @@ public void removeDeadConnection(TcpConnection connection) {
242
239
}
243
240
244
241
@ Test
242
+ @ LogLevels (categories = "org.springframework.integration.ip" , level = "DEBUG" )
245
243
public void testReadStxEtxOverflow () throws Exception {
246
244
ByteArrayStxEtxSerializer serializer = new ByteArrayStxEtxSerializer ();
247
245
serializer .setMaxMessageSize (1024 );
@@ -251,6 +249,7 @@ public void testReadStxEtxOverflow() throws Exception {
251
249
252
250
final CountDownLatch errorMessageLetch = new CountDownLatch (1 );
253
251
final AtomicReference <Throwable > errorMessageRef = new AtomicReference <>();
252
+ final CountDownLatch openedLatch = new CountDownLatch (1 );
254
253
255
254
AbstractServerConnectionFactory scf = getConnectionFactory (serializer , message -> {
256
255
if (message instanceof ErrorMessage ) {
@@ -264,6 +263,7 @@ public void testReadStxEtxOverflow() throws Exception {
264
263
public void addNewConnection (TcpConnection connection ) {
265
264
added .add (connection );
266
265
semaphore .release ();
266
+ openedLatch .countDown ();
267
267
}
268
268
269
269
@ Override
@@ -277,6 +277,7 @@ public void removeDeadConnection(TcpConnection connection) {
277
277
// Fire up the sender.
278
278
279
279
CountDownLatch done = SocketTestUtils .testSendStxEtxOverflow (scf .getPort ());
280
+ assertThat (openedLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
280
281
whileOpen (semaphore , added );
281
282
assertThat (added .size ()).isEqualTo (1 );
282
283
0 commit comments