Skip to content

Commit e84d13a

Browse files
committed
Simplify the initialization of the codec attribute
1 parent 46de930 commit e84d13a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.ByteArrayOutputStream;
2121
import java.net.InetAddress;
2222
import java.net.Socket;
23+
import java.nio.charset.StandardCharsets;
2324
import java.util.Collections;
2425
import java.util.Map;
2526

@@ -34,7 +35,6 @@
3435
import org.springframework.integration.IntegrationMessageHeaderAccessor;
3536
import org.springframework.integration.codec.Codec;
3637
import org.springframework.integration.codec.CodecMessageConverter;
37-
import org.springframework.integration.codec.CompositeCodec;
3838
import org.springframework.integration.codec.kryo.MessageCodec;
3939
import org.springframework.integration.ip.IpHeaders;
4040
import org.springframework.integration.ip.tcp.serializer.MapJsonSerializer;
@@ -67,12 +67,11 @@ public class TcpMessageMapperTests {
6767

6868
@BeforeEach
6969
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();
7371
}
7472

7573
@Test
74+
@SuppressWarnings("NullAway")
7675
public void testToMessage() {
7776
TcpMessageMapper mapper = new TcpMessageMapper();
7877
TcpConnection connection = creatMockTcpConcnection(TEST_PAYLOAD.getBytes(), "MyHost", "1.1.1.1", 1234);
@@ -90,6 +89,7 @@ public void testToMessage() {
9089
}
9190

9291
@Test
92+
@SuppressWarnings("NullAway")
9393
public void testToMessageWithContentType() {
9494
TcpMessageMapper mapper = new TcpMessageMapper();
9595
mapper.setAddContentTypeHeader(true);
@@ -111,6 +111,7 @@ public void testToMessageWithContentType() {
111111
}
112112

113113
@Test
114+
@SuppressWarnings("NullAway")
114115
public void testToMessageWithCustomContentType() {
115116
TcpMessageMapper mapper = new TcpMessageMapper();
116117
mapper.setAddContentTypeHeader(true);
@@ -142,6 +143,7 @@ public void testToMessageWithBadContentType() {
142143
}
143144

144145
@Test
146+
@SuppressWarnings("NullAway")
145147
public void testToMessageSequence() throws Exception {
146148
TcpMessageMapper mapper = new TcpMessageMapper();
147149
Socket socket = SocketFactory.getDefault().createSocket();
@@ -217,6 +219,7 @@ public SSLSession getSslSession() {
217219
}
218220

219221
@Test
222+
@SuppressWarnings("NullAway")
220223
public void testToMessageSequenceNewWithCustomHeader() throws Exception {
221224
TcpMessageMapper mapper = new TcpMessageMapper() {
222225

@@ -340,11 +343,12 @@ public void testMapMessageConvertingOutboundJson() throws Exception {
340343
MapJsonSerializer serializer = new MapJsonSerializer();
341344
ByteArrayOutputStream baos = new ByteArrayOutputStream();
342345
serializer.serialize(map, baos);
343-
assertThat(new String(baos.toByteArray(), "UTF-8"))
346+
assertThat(baos.toString(StandardCharsets.UTF_8))
344347
.isEqualTo("{\"headers\":{\"bar\":\"baz\"},\"payload\":\"foo\"}\n");
345348
}
346349

347350
@Test
351+
@SuppressWarnings("NullAway")
348352
public void testMapMessageConvertingInboundJson() throws Exception {
349353
String json = "{\"headers\":{\"bar\":\"baz\"},\"payload\":\"foo\"}\n";
350354
MapMessageConverter converter = new MapMessageConverter();
@@ -364,6 +368,7 @@ public void testMapMessageConvertingInboundJson() throws Exception {
364368
}
365369

366370
@Test
371+
@SuppressWarnings("NullAway")
367372
public void testMapMessageConvertingBothWaysJava() throws Exception {
368373
Message<String> outMessage = MessageBuilder.withPayload("foo")
369374
.setHeader("bar", "baz")
@@ -390,6 +395,7 @@ public void testMapMessageConvertingBothWaysJava() throws Exception {
390395
}
391396

392397
@Test
398+
@SuppressWarnings("NullAway")
393399
public void testCodecMessageConvertingBothWaysJava() {
394400
Message<String> outMessage = MessageBuilder.withPayload("foo")
395401
.setHeader("bar", "baz")
@@ -410,6 +416,7 @@ public void testCodecMessageConvertingBothWaysJava() {
410416
}
411417

412418
@Test
419+
@SuppressWarnings("NullAway")
413420
public void testWithBytesMapper() {
414421
Message<String> outMessage = MessageBuilder.withPayload("foo")
415422
.setHeader("bar", "baz")

0 commit comments

Comments
 (0)