20
20
import java .io .ByteArrayOutputStream ;
21
21
import java .net .InetAddress ;
22
22
import java .net .Socket ;
23
+ import java .nio .charset .StandardCharsets ;
23
24
import java .util .Collections ;
24
25
import java .util .Map ;
25
26
34
35
import org .springframework .integration .IntegrationMessageHeaderAccessor ;
35
36
import org .springframework .integration .codec .Codec ;
36
37
import org .springframework .integration .codec .CodecMessageConverter ;
37
- import org .springframework .integration .codec .CompositeCodec ;
38
38
import org .springframework .integration .codec .kryo .MessageCodec ;
39
39
import org .springframework .integration .ip .IpHeaders ;
40
40
import org .springframework .integration .ip .tcp .serializer .MapJsonSerializer ;
@@ -67,12 +67,11 @@ public class TcpMessageMapperTests {
67
67
68
68
@ BeforeEach
69
69
public void setup () {
70
- MessageCodec messageCodec = new MessageCodec ();
71
- Map <Class <?>, Codec > codecs = Map .of (messageCodec .getClass (), messageCodec );
72
- this .codec = new CompositeCodec (codecs , new MessageCodec ());
70
+ this .codec = new MessageCodec ();
73
71
}
74
72
75
73
@ Test
74
+ @ SuppressWarnings ("NullAway" )
76
75
public void testToMessage () {
77
76
TcpMessageMapper mapper = new TcpMessageMapper ();
78
77
TcpConnection connection = creatMockTcpConcnection (TEST_PAYLOAD .getBytes (), "MyHost" , "1.1.1.1" , 1234 );
@@ -90,6 +89,7 @@ public void testToMessage() {
90
89
}
91
90
92
91
@ Test
92
+ @ SuppressWarnings ("NullAway" )
93
93
public void testToMessageWithContentType () {
94
94
TcpMessageMapper mapper = new TcpMessageMapper ();
95
95
mapper .setAddContentTypeHeader (true );
@@ -111,6 +111,7 @@ public void testToMessageWithContentType() {
111
111
}
112
112
113
113
@ Test
114
+ @ SuppressWarnings ("NullAway" )
114
115
public void testToMessageWithCustomContentType () {
115
116
TcpMessageMapper mapper = new TcpMessageMapper ();
116
117
mapper .setAddContentTypeHeader (true );
@@ -142,6 +143,7 @@ public void testToMessageWithBadContentType() {
142
143
}
143
144
144
145
@ Test
146
+ @ SuppressWarnings ("NullAway" )
145
147
public void testToMessageSequence () throws Exception {
146
148
TcpMessageMapper mapper = new TcpMessageMapper ();
147
149
Socket socket = SocketFactory .getDefault ().createSocket ();
@@ -217,6 +219,7 @@ public SSLSession getSslSession() {
217
219
}
218
220
219
221
@ Test
222
+ @ SuppressWarnings ("NullAway" )
220
223
public void testToMessageSequenceNewWithCustomHeader () throws Exception {
221
224
TcpMessageMapper mapper = new TcpMessageMapper () {
222
225
@@ -340,11 +343,12 @@ public void testMapMessageConvertingOutboundJson() throws Exception {
340
343
MapJsonSerializer serializer = new MapJsonSerializer ();
341
344
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
342
345
serializer .serialize (map , baos );
343
- assertThat (new String ( baos .toByteArray (), "UTF-8" ))
346
+ assertThat (baos .toString ( StandardCharsets . UTF_8 ))
344
347
.isEqualTo ("{\" headers\" :{\" bar\" :\" baz\" },\" payload\" :\" foo\" }\n " );
345
348
}
346
349
347
350
@ Test
351
+ @ SuppressWarnings ("NullAway" )
348
352
public void testMapMessageConvertingInboundJson () throws Exception {
349
353
String json = "{\" headers\" :{\" bar\" :\" baz\" },\" payload\" :\" foo\" }\n " ;
350
354
MapMessageConverter converter = new MapMessageConverter ();
@@ -364,6 +368,7 @@ public void testMapMessageConvertingInboundJson() throws Exception {
364
368
}
365
369
366
370
@ Test
371
+ @ SuppressWarnings ("NullAway" )
367
372
public void testMapMessageConvertingBothWaysJava () throws Exception {
368
373
Message <String > outMessage = MessageBuilder .withPayload ("foo" )
369
374
.setHeader ("bar" , "baz" )
@@ -390,6 +395,7 @@ public void testMapMessageConvertingBothWaysJava() throws Exception {
390
395
}
391
396
392
397
@ Test
398
+ @ SuppressWarnings ("NullAway" )
393
399
public void testCodecMessageConvertingBothWaysJava () {
394
400
Message <String > outMessage = MessageBuilder .withPayload ("foo" )
395
401
.setHeader ("bar" , "baz" )
@@ -410,6 +416,7 @@ public void testCodecMessageConvertingBothWaysJava() {
410
416
}
411
417
412
418
@ Test
419
+ @ SuppressWarnings ("NullAway" )
413
420
public void testWithBytesMapper () {
414
421
Message <String > outMessage = MessageBuilder .withPayload ("foo" )
415
422
.setHeader ("bar" , "baz" )
0 commit comments