[HUDI-809] Migrate CommonTestHarness to JUnit 5 (#1530)
This commit is contained in:
@@ -18,28 +18,28 @@
|
||||
|
||||
package org.apache.hudi.utilities;
|
||||
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.HoodieTestDataGenerator;
|
||||
import org.apache.hudi.common.fs.FSUtils;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.testutils.HoodieCommonTestHarnessJunit5;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.spark.SparkConf;
|
||||
import org.apache.spark.api.java.JavaSparkContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestHoodieSnapshotCopier extends HoodieCommonTestHarness {
|
||||
public class TestHoodieSnapshotCopier extends HoodieCommonTestHarnessJunit5 {
|
||||
|
||||
private static final String TEST_WRITE_TOKEN = "1-0-1";
|
||||
|
||||
@@ -49,10 +49,10 @@ public class TestHoodieSnapshotCopier extends HoodieCommonTestHarness {
|
||||
private FileSystem fs = null;
|
||||
private JavaSparkContext jsc = null;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() throws IOException {
|
||||
// Prepare directories
|
||||
rootPath = "file://" + folder.getRoot().getAbsolutePath();
|
||||
rootPath = "file://" + tempDir.toString();
|
||||
basePath = rootPath + "/" + HoodieTestUtils.RAW_TRIPS_TEST_NAME;
|
||||
outputPath = rootPath + "/output";
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TestHoodieSnapshotCopier extends HoodieCommonTestHarness {
|
||||
assertTrue(fs.exists(new Path(outputPath + "/_SUCCESS")));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void cleanup() {
|
||||
if (rootPath != null) {
|
||||
new File(rootPath).delete();
|
||||
|
||||
@@ -18,24 +18,26 @@
|
||||
|
||||
package org.apache.hudi.utilities.checkpointing;
|
||||
|
||||
import org.apache.hudi.common.HoodieCommonTestHarness;
|
||||
import org.apache.hudi.common.config.TypedProperties;
|
||||
import org.apache.hudi.common.model.HoodieTestUtils;
|
||||
import org.apache.hudi.common.testutils.HoodieCommonTestHarnessJunit5;
|
||||
import org.apache.hudi.exception.HoodieException;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class TestKafkaConnectHdfsProvider extends HoodieCommonTestHarnessJunit5 {
|
||||
|
||||
public class TestKafkaConnectHdfsProvider extends HoodieCommonTestHarness {
|
||||
private String topicPath = null;
|
||||
private Configuration hadoopConf = null;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
// Prepare directories
|
||||
initPath();
|
||||
@@ -71,10 +73,10 @@ public class TestKafkaConnectHdfsProvider extends HoodieCommonTestHarness {
|
||||
props.put("hoodie.deltastreamer.checkpoint.provider.path", topicPath);
|
||||
final InitialCheckPointProvider provider = new KafkaConnectHdfsProvider(props);
|
||||
provider.init(hadoopConf);
|
||||
assertEquals(provider.getCheckpoint(), "topic1,0:300,1:200");
|
||||
assertEquals("topic1,0:300,1:200", provider.getCheckpoint());
|
||||
}
|
||||
|
||||
@Test(expected = HoodieException.class)
|
||||
@Test
|
||||
public void testMissingPartition() throws Exception {
|
||||
topicPath = basePath + "/topic2";
|
||||
new File(topicPath).mkdirs();
|
||||
@@ -92,6 +94,6 @@ public class TestKafkaConnectHdfsProvider extends HoodieCommonTestHarness {
|
||||
props.put("hoodie.deltastreamer.checkpoint.provider.path", topicPath);
|
||||
final InitialCheckPointProvider provider = new KafkaConnectHdfsProvider(props);
|
||||
provider.init(hadoopConf);
|
||||
provider.getCheckpoint();
|
||||
assertThrows(HoodieException.class, provider::getCheckpoint);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user