Use new Java features (switch expressions, text blocks, new JDK methods)

Closes gh-29747
This commit is contained in:
Krzysztof Krason
2022-12-28 08:59:08 +01:00
committed by Sam Brannen
parent 48abd493fe
commit afb8a0d1b1
53 changed files with 498 additions and 552 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,13 +62,13 @@ public class ProtobufMessageConverterTests {
this.message = MessageBuilder.withPayload(this.testMsg.toByteArray())
.setHeader(CONTENT_TYPE, ProtobufMessageConverter.PROTOBUF).build();
this.messageWithoutContentType = MessageBuilder.withPayload(this.testMsg.toByteArray()).build();
this.messageJson = MessageBuilder.withPayload(
"{\n" +
" \"foo\": \"Foo\",\n" +
" \"blah\": {\n" +
" \"blah\": 123\n" +
" }\n" +
"}")
this.messageJson = MessageBuilder.withPayload("""
{
"foo": "Foo",
"blah": {
"blah": 123
}
}""".replace("\t", " "))
.setHeader(CONTENT_TYPE, APPLICATION_JSON)
.build();
}

View File

@@ -319,9 +319,7 @@ public class MessageHeaderAccessorTests {
})).isEqualTo(expected);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 80; i++) {
sb.append('a');
}
sb.append("a".repeat(80));
final String payload = sb.toString() + " > 80";
String actual = accessor.getShortLogMessage(payload);
@@ -355,10 +353,8 @@ public class MessageHeaderAccessorTests {
})).isEqualTo(expected);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 80; i++) {
sb.append('a');
}
final String payload = sb.toString() + " > 80";
sb.append("a".repeat(80));
final String payload = sb + " > 80";
String actual = accessor.getDetailedLogMessage(payload);
assertThat(actual).isEqualTo("headers={contentType=text/plain} payload=" + sb + " > 80");