Jiabao-Sun commented on code in PR #24612:
URL: https://github.com/apache/flink/pull/24612#discussion_r1565548513
##########
flink-core/src/test/java/org/apache/flink/configuration/MemorySizePrettyPrintingTest.java:
##########
@@ -45,13 +46,13 @@ public static Object[][] parameters() {
};
}
- @Parameterized.Parameter public MemorySize memorySize;
+ @Parameter private MemorySize memorySize;
- @Parameterized.Parameter(1)
+ @Parameter(value = 1)
Review Comment:
value can be ignored and expectedString can be private.
##########
flink-core/src/test/java/org/apache/flink/configuration/ReadableWritableConfigurationTest.java:
##########
@@ -169,7 +170,7 @@ void testGetOptionalFromObject() {
testSpec.setValue(configuration);
Optional<?> optional = configuration.getOptional(testSpec.getOption());
- assertThat(optional.get(), equalTo(testSpec.getValue()));
+ assertThat(optional.get()).isEqualTo(testSpec.getValue());
Review Comment:
```suggestion
assertThat(optional).hasValue(testSpec.getValue());
```
##########
flink-core/src/test/java/org/apache/flink/configuration/GlobalConfigurationTest.java:
##########
@@ -42,57 +42,48 @@ class GlobalConfigurationTest {
@TempDir private File tmpDir;
@Test
- void testConfigurationWithLegacyYAML() {
+ void testConfigurationWithLegacyYAML() throws FileNotFoundException {
File confFile = new File(tmpDir,
GlobalConfiguration.LEGACY_FLINK_CONF_FILENAME);
-
- try {
- try (final PrintWriter pw = new PrintWriter(confFile)) {
-
- pw.println("###########################"); // should be skipped
- pw.println("# Some : comments : to skip"); // should be skipped
- pw.println("###########################"); // should be skipped
- pw.println("mykey1: myvalue1"); // OK, simple correct case
- pw.println("mykey2 : myvalue2"); // OK, whitespace
before colon is correct
- pw.println("mykey3:myvalue3"); // SKIP, missing white space
after colon
- pw.println(" some nonsense without colon and whitespace
separator"); // SKIP
- pw.println(" : "); // SKIP
- pw.println(" "); // SKIP (silently)
- pw.println(" "); // SKIP (silently)
- pw.println("mykey4: myvalue4# some comments"); // OK, skip
comments only
- pw.println(" mykey5 : myvalue5 "); // OK, trim
unnecessary whitespace
- pw.println("mykey6: my: value6"); // OK, only use first ': '
as separator
- pw.println("mykey7: "); // SKIP, no value provided
- pw.println(": myvalue8"); // SKIP, no key provided
-
- pw.println("mykey9: myvalue9"); // OK
- pw.println("mykey9: myvalue10"); // OK, overwrite last value
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
-
- Configuration conf =
GlobalConfiguration.loadConfiguration(tmpDir.getAbsolutePath());
-
- // all distinct keys from confFile1 + confFile2 key
- assertThat(conf.keySet()).hasSize(6);
-
- // keys 1, 2, 4, 5, 6, 7, 8 should be OK and match the expected
values
- assertThat(conf.getString("mykey1", null)).isEqualTo("myvalue1");
- assertThat(conf.getString("mykey1", null)).isEqualTo("myvalue1");
- assertThat(conf.getString("mykey2", null)).isEqualTo("myvalue2");
- assertThat(conf.getString("mykey3", "null")).isEqualTo("null");
- assertThat(conf.getString("mykey4", null)).isEqualTo("myvalue4");
- assertThat(conf.getString("mykey5", null)).isEqualTo("myvalue5");
- assertThat(conf.getString("mykey6", null)).isEqualTo("my: value6");
- assertThat(conf.getString("mykey7", "null")).isEqualTo("null");
- assertThat(conf.getString("mykey8", "null")).isEqualTo("null");
- assertThat(conf.getString("mykey9", null)).isEqualTo("myvalue10");
- } finally {
- // Clear the standard yaml flag to avoid impact to other cases.
- GlobalConfiguration.setStandardYaml(true);
- confFile.delete();
- tmpDir.delete();
+ try (PrintWriter pw = new PrintWriter(confFile)) {
+ pw.println("###########################"); // should be skipped
+ pw.println("# Some : comments : to skip"); // should be skipped
+ pw.println("###########################"); // should be skipped
+ pw.println("mykey1: myvalue1"); // OK, simple correct case
+ pw.println("mykey2 : myvalue2"); // OK, whitespace before
colon is correct
+ pw.println("mykey3:myvalue3"); // SKIP, missing white space after
colon
+ pw.println(" some nonsense without colon and whitespace
separator"); // SKIP
+ pw.println(" : "); // SKIP
+ pw.println(" "); // SKIP (silently)
+ pw.println(" "); // SKIP (silently)
+ pw.println("mykey4: myvalue4# some comments"); // OK, skip
comments only
+ pw.println(" mykey5 : myvalue5 "); // OK, trim
unnecessary whitespace
+ pw.println("mykey6: my: value6"); // OK, only use first ': ' as
separator
+ pw.println("mykey7: "); // SKIP, no value provided
+ pw.println(": myvalue8"); // SKIP, no key provided
+
+ pw.println("mykey9: myvalue9"); // OK
+ pw.println("mykey9: myvalue10"); // OK, overwrite last value
}
+ Configuration conf =
GlobalConfiguration.loadConfiguration(tmpDir.getAbsolutePath());
+
+ // all distinct keys from confFile1 + confFile2 key
+ assertThat(conf.keySet()).hasSize(6);
+
+ // keys 1, 2, 4, 5, 6, 7, 8 should be OK and match the expected values
+ assertThat(conf.getString("mykey1", null)).isEqualTo("myvalue1");
+ assertThat(conf.getString("mykey1", null)).isEqualTo("myvalue1");
+ assertThat(conf.getString("mykey2", null)).isEqualTo("myvalue2");
+ assertThat(conf.getString("mykey3", "null")).isEqualTo("null");
+ assertThat(conf.getString("mykey4", null)).isEqualTo("myvalue4");
+ assertThat(conf.getString("mykey5", null)).isEqualTo("myvalue5");
+ assertThat(conf.getString("mykey6", null)).isEqualTo("my: value6");
+ assertThat(conf.getString("mykey7", "null")).isEqualTo("null");
+ assertThat(conf.getString("mykey8", "null")).isEqualTo("null");
+ assertThat(conf.getString("mykey9", null)).isEqualTo("myvalue10");
+ // Clear the standard yaml flag to avoid impact to other cases.
+ GlobalConfiguration.setStandardYaml(true);
+ confFile.delete();
+ tmpDir.delete();
Review Comment:
In exceptional scenarios, will the deletion of temporary directories be
ignored?
--
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]