xushiyan commented on a change in pull request #1589:
URL: https://github.com/apache/incubator-hudi/pull/1589#discussion_r419131896
##########
File path:
hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHiveIncrementalPuller.java
##########
@@ -18,27 +18,26 @@
package org.apache.hudi.utilities;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
public class TestHiveIncrementalPuller {
private HiveIncrementalPuller.Config config;
- @Before
+ @BeforeEach
public void setup() {
config = new HiveIncrementalPuller.Config();
}
@Test
public void testInitHiveIncrementalPuller() {
- try {
+ assertDoesNotThrow(() -> {
new HiveIncrementalPuller(config);
- } catch (Exception e) {
- Assert.fail("Unexpected exception while initing HiveIncrementalPuller,
msg: " + e.getMessage());
- }
+ }, "Unexpected exception while initing HiveIncrementalPuller.");
Review comment:
`e.getMessage()` will be included in message printed by
`assertDoesNotThrow()` hence no need to concat it manually.
##########
File path:
hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieDeltaStreamer.java
##########
@@ -413,37 +412,33 @@ public void testKafkaConnectCheckpointProvider() throws
IOException {
HoodieTestDataGenerator dataGenerator = new HoodieTestDataGenerator();
Helpers.saveParquetToDFS(Helpers.toGenericRecords(dataGenerator.generateInserts("000",
100)), new Path(filePath));
HoodieDeltaStreamer deltaStreamer = new HoodieDeltaStreamer(cfg, jsc, dfs,
hdfsTestService.getHadoopConf(), props);
- assertEquals(deltaStreamer.getConfig().checkpoint, "kafka_topic1,0:200");
+ assertEquals("kafka_topic1,0:200", deltaStreamer.getConfig().checkpoint);
}
@Test
public void testPropsWithInvalidKeyGenerator() throws Exception {
- try {
+ Exception e = assertThrows(IOException.class, () -> {
String tableBasePath = dfsBasePath + "/test_table";
HoodieDeltaStreamer deltaStreamer =
new HoodieDeltaStreamer(TestHelpers.makeConfig(tableBasePath,
Operation.BULK_INSERT,
Collections.singletonList(TripsWithDistanceTransformer.class.getName()),
PROPS_FILENAME_TEST_INVALID, false), jsc);
deltaStreamer.sync();
- fail("Should error out when setting the key generator class property to
an invalid value");
- } catch (IOException e) {
- // expected
- LOG.error("Expected error during getting the key generator", e);
- assertTrue(e.getMessage().contains("Could not load key generator
class"));
- }
+ }, "Should error out when setting the key generator class property to an
invalid value");
+ // expected
+ LOG.debug("Expected error during getting the key generator", e);
+ assertTrue(e.getMessage().contains("Could not load key generator class"));
Review comment:
Changing log level from error to debug. It is a good practice to not
print anything unless test case failed thus we tend to mute the output here
when it's passing. Same to other similar changes below.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]