RocMarshal commented on code in PR #27897:
URL: https://github.com/apache/flink/pull/27897#discussion_r3090546806
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/formats/raw/RawFormatLineDelimiterTest.java:
##########
@@ -68,37 +72,49 @@ void testDeserializeWithoutDelimiter_singleRow() throws
Exception {
void testDeserializeWithNewlineDelimiter_multipleRows() throws Exception {
RawFormatDeserializationSchema schema =
new RawFormatDeserializationSchema(
- STRING_TYPE, TypeInformation.of(RowData.class),
"UTF-8", true, "\n");
+ STRING_TYPE,
+ TypeInformation.of(RowData.class),
+ StandardCharsets.UTF_8.name(),
+ true,
+ "\n");
openDeser(schema);
byte[] message =
"line1\nline2\nline3".getBytes(StandardCharsets.UTF_8);
List<RowData> rows = collectRows(schema, message);
assertThat(rows).hasSize(3);
- assertThat(rows.get(0).getString(0).toString()).isEqualTo("line1");
- assertThat(rows.get(1).getString(0).toString()).isEqualTo("line2");
- assertThat(rows.get(2).getString(0).toString()).isEqualTo("line3");
+ assertThat(rows.get(0).getString(0)).hasToString("line1");
+ assertThat(rows.get(1).getString(0)).hasToString("line2");
+ assertThat(rows.get(2).getString(0)).hasToString("line3");
}
@Test
void testDeserializeWithCustomMultiCharDelimiter() throws Exception {
RawFormatDeserializationSchema schema =
new RawFormatDeserializationSchema(
- STRING_TYPE, TypeInformation.of(RowData.class),
"UTF-8", true, "||");
+ STRING_TYPE,
+ TypeInformation.of(RowData.class),
+ StandardCharsets.UTF_8.name(),
+ true,
+ "||");
openDeser(schema);
byte[] message =
"record1||record2||record3".getBytes(StandardCharsets.UTF_8);
List<RowData> rows = collectRows(schema, message);
assertThat(rows).hasSize(3);
- assertThat(rows.get(0).getString(0).toString()).isEqualTo("record1");
- assertThat(rows.get(1).getString(0).toString()).isEqualTo("record2");
- assertThat(rows.get(2).getString(0).toString()).isEqualTo("record3");
+ assertThat(rows.get(0).getString(0)).hasToString("record1");
+ assertThat(rows.get(1).getString(0)).hasToString("record2");
+ assertThat(rows.get(2).getString(0)).hasToString("record3");
}
@Test
void testDeserializeWithNullMessage_noOutput() throws Exception {
RawFormatDeserializationSchema schema =
new RawFormatDeserializationSchema(
- STRING_TYPE, TypeInformation.of(RowData.class),
"UTF-8", true, "\n");
+ STRING_TYPE,
+ TypeInformation.of(RowData.class),
+ StandardCharsets.UTF_8.name(),
Review Comment:
Nice!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]