|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.messaging.converter;
|
18 | 18 |
|
| 19 | +import java.nio.charset.StandardCharsets; |
19 | 20 | import java.util.Map;
|
20 | 21 |
|
21 | 22 | import org.junit.jupiter.api.Test;
|
@@ -49,14 +50,14 @@ class ProtobufMessageConverterTests {
|
49 | 50 |
|
50 | 51 | private Message<byte[]> messageWithoutContentType = MessageBuilder.withPayload(this.testMsg.toByteArray()).build();
|
51 | 52 |
|
52 |
| - private final Message<String> messageJson = MessageBuilder.withPayload(""" |
| 53 | + private final Message<byte[]> messageJson = MessageBuilder.withPayload(""" |
53 | 54 | {
|
54 | 55 | "foo": "Foo",
|
55 | 56 | "blah": {
|
56 | 57 | "blah": 123
|
57 | 58 | }
|
58 | 59 | }
|
59 |
| - """) |
| 60 | + """.getBytes(StandardCharsets.UTF_8)) |
60 | 61 | .setHeader(CONTENT_TYPE, APPLICATION_JSON)
|
61 | 62 | .build();
|
62 | 63 |
|
@@ -113,10 +114,10 @@ void jsonWithGoogleProtobuf() throws Exception {
|
113 | 114 | Message<?> message = converter.toMessage(testMsg, new MessageHeaders(Map.of(CONTENT_TYPE, APPLICATION_JSON)));
|
114 | 115 | assertThat(message).isNotNull();
|
115 | 116 | assertThat(message.getHeaders().get(CONTENT_TYPE)).isEqualTo(APPLICATION_JSON);
|
116 |
| - JSONAssert.assertEquals(messageJson.getPayload(), message.getPayload().toString(), true); |
| 117 | + JSONAssert.assertEquals(new String(messageJson.getPayload()), message.getPayload().toString(), true); |
117 | 118 |
|
118 | 119 | //convertFrom
|
119 |
| - assertThat(converter.fromMessage(message, Msg.class)).isEqualTo(testMsg); |
| 120 | + assertThat(converter.fromMessage(messageJson, Msg.class)).isEqualTo(testMsg); |
120 | 121 | }
|
121 | 122 |
|
122 | 123 | }
|
0 commit comments