[hotfix][cdc-composor] Adjust test of cdc composer from junit4 to junit5

pull/3399/head
Hongshun Wang 8 months ago committed by GitHub
parent e2ccc836a0
commit ed4cd40afc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -27,14 +27,14 @@ import org.apache.flink.cdc.composer.utils.factory.DataSinkFactory1;
import org.apache.flink.shaded.guava31.com.google.common.collect.ImmutableMap; import org.apache.flink.shaded.guava31.com.google.common.collect.ImmutableMap;
import org.junit.Assert; import org.junit.jupiter.api.Assertions;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** A test for the {@link FlinkPipelineComposer}. */ /** A test for the {@link FlinkPipelineComposer}. */
public class FlinkPipelineComposerTest { class FlinkPipelineComposerTest {
@Test @Test
public void testCreateDataSinkFromSinkDef() { void testCreateDataSinkFromSinkDef() {
SinkDef sinkDef = SinkDef sinkDef =
new SinkDef( new SinkDef(
"data-sink-factory-1", "data-sink-factory-1",
@ -55,7 +55,7 @@ public class FlinkPipelineComposerTest {
new Configuration(), new Configuration(),
Thread.currentThread().getContextClassLoader())); Thread.currentThread().getContextClassLoader()));
Assert.assertTrue(dataSink instanceof DataSinkFactory1.TestDataSink); Assertions.assertTrue(dataSink instanceof DataSinkFactory1.TestDataSink);
Assert.assertEquals("0.0.0.0", ((DataSinkFactory1.TestDataSink) dataSink).getHost()); Assertions.assertEquals("0.0.0.0", ((DataSinkFactory1.TestDataSink) dataSink).getHost());
} }
} }

@ -29,17 +29,17 @@ import org.apache.flink.streaming.api.transformations.OneInputTransformation;
import org.apache.flink.shaded.guava31.com.google.common.collect.Lists; import org.apache.flink.shaded.guava31.com.google.common.collect.Lists;
import org.junit.Assert; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
/** A test for {@link DataSinkTranslator}. */ /** A test for {@link DataSinkTranslator}. */
public class DataSinkTranslatorTest { class DataSinkTranslatorTest {
@Test @Test
public void testPreWriteWithoutCommitSink() { void testPreWriteWithoutCommitSink() {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
ArrayList<Event> mockEvents = Lists.newArrayList(new EmptyEvent(), new EmptyEvent()); ArrayList<Event> mockEvents = Lists.newArrayList(new EmptyEvent(), new EmptyEvent());
DataStreamSource<Event> inputStream = env.fromCollection(mockEvents); DataStreamSource<Event> inputStream = env.fromCollection(mockEvents);
@ -60,7 +60,7 @@ public class DataSinkTranslatorTest {
OneInputTransformation<Event, Event> oneInputTransformation = OneInputTransformation<Event, Event> oneInputTransformation =
(OneInputTransformation) env.getTransformations().get(0); (OneInputTransformation) env.getTransformations().get(0);
Transformation<?> reblanceTransformation = oneInputTransformation.getInputs().get(0); Transformation<?> reblanceTransformation = oneInputTransformation.getInputs().get(0);
Assert.assertEquals(uid, reblanceTransformation.getUserProvidedNodeHash()); Assertions.assertEquals(uid, reblanceTransformation.getUserProvidedNodeHash());
} }
private static class EmptyEvent implements Event {} private static class EmptyEvent implements Event {}

@ -27,14 +27,14 @@ import org.apache.flink.cdc.composer.utils.factory.DataSourceFactory1;
import org.apache.flink.shaded.guava31.com.google.common.collect.ImmutableMap; import org.apache.flink.shaded.guava31.com.google.common.collect.ImmutableMap;
import org.junit.Assert; import org.junit.jupiter.api.Assertions;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** A test for the {@link DataSourceTranslator}. */ /** A test for the {@link DataSourceTranslator}. */
public class DataSourceTranslatorTest { class DataSourceTranslatorTest {
@Test @Test
public void testCreateDataSourceFromSourceDef() { void testCreateDataSourceFromSourceDef() {
SourceDef sourceDef = SourceDef sourceDef =
new SourceDef( new SourceDef(
"data-source-factory-1", "data-source-factory-1",
@ -55,7 +55,8 @@ public class DataSourceTranslatorTest {
new Configuration(), new Configuration(),
Thread.currentThread().getContextClassLoader())); Thread.currentThread().getContextClassLoader()));
Assert.assertTrue(dataSource instanceof DataSourceFactory1.TestDataSource); Assertions.assertTrue(dataSource instanceof DataSourceFactory1.TestDataSource);
Assert.assertEquals("0.0.0.0", ((DataSourceFactory1.TestDataSource) dataSource).getHost()); Assertions.assertEquals(
"0.0.0.0", ((DataSourceFactory1.TestDataSource) dataSource).getHost());
} }
} }

Loading…
Cancel
Save