Skip to content

Commit

Permalink
[FLINK-27727][tests] Migrate TypeSerializerUpgradeTestBase to JUnit5
Browse files Browse the repository at this point in the history
  • Loading branch information
snuyanzin authored and XComp committed Oct 10, 2022
1 parent fcae848 commit 5be0ada
Show file tree
Hide file tree
Showing 39 changed files with 273 additions and 529 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import org.apache.flink.streaming.connectors.kafka.internals.FlinkKafkaInternalProducer;

import org.hamcrest.Matcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.mockito.Mockito;

import java.util.ArrayList;
Expand All @@ -41,15 +39,9 @@
* A {@link TypeSerializerUpgradeTestBase} for {@link FlinkKafkaProducer.TransactionStateSerializer}
* and {@link FlinkKafkaProducer.ContextStateSerializer}.
*/
@RunWith(Parameterized.class)
public class KafkaSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> {
class KafkaSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> {

public KafkaSerializerUpgradeTest(TestSpecification<Object, Object> testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

import org.apache.hadoop.io.Writable;
import org.hamcrest.Matcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.DataInput;
import java.io.DataOutput;
Expand All @@ -40,17 +38,10 @@
import static org.hamcrest.Matchers.is;

/** A {@link TypeSerializerUpgradeTestBase} for {@link WritableSerializer}. */
@RunWith(Parameterized.class)
public class WritableSerializerUpgradeTest
class WritableSerializerUpgradeTest
extends TypeSerializerUpgradeTestBase<WritableName, WritableName> {

public WritableSerializerUpgradeTest(
TestSpecification<WritableName, WritableName> testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,16 @@
import org.apache.flink.types.Either;

import org.hamcrest.Matcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;

import static org.hamcrest.Matchers.is;

/** A {@link TypeSerializerUpgradeTestBase} for {@link GenericArraySerializer}. */
@RunWith(Parameterized.class)
public class CompositeTypeSerializerUpgradeTest
extends TypeSerializerUpgradeTestBase<Object, Object> {
class CompositeTypeSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> {

public CompositeTypeSerializerUpgradeTest(TestSpecification<Object, Object> testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,13 @@
import org.apache.flink.FlinkVersion;
import org.apache.flink.api.common.typeutils.TypeSerializerUpgradeTestBase;

import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;

/** A {@link TypeSerializerUpgradeTestBase} for BaseType Serializers. */
@RunWith(Parameterized.class)
public class BasicTypeSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> {

public BasicTypeSerializerUpgradeTest(TestSpecification<Object, Object> testSpecification) {
super(testSpecification);
}
class BasicTypeSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> {

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -39,16 +37,10 @@
import static org.hamcrest.Matchers.is;

/** Migration tests for {@link EnumSerializer}. */
@RunWith(Parameterized.class)
public class EnumSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<TestEnum, TestEnum> {
class EnumSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<TestEnum, TestEnum> {
private static final String SPEC_NAME = "enum-serializer";

public EnumSerializerUpgradeTest(TestSpecification<TestEnum, TestEnum> enumSerializer) {
super(enumSerializer);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.apache.flink.api.common.typeutils.TypeSerializerUpgradeTestBase;

import org.hamcrest.Matcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -35,19 +33,11 @@
import static org.hamcrest.Matchers.is;

/** A {@link TypeSerializerUpgradeTestBase} for {@link ListSerializerSnapshot}. */
@RunWith(Parameterized.class)
public class ListSerializerUpgradeTest
extends TypeSerializerUpgradeTestBase<List<String>, List<String>> {
class ListSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<List<String>, List<String>> {

private static final String SPEC_NAME = "list-serializer";

public ListSerializerUpgradeTest(
TestSpecification<List<String>, List<String>> testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.apache.flink.api.common.typeutils.TypeSerializerUpgradeTestBase;

import org.hamcrest.Matcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -36,19 +34,12 @@
import static org.hamcrest.Matchers.is;

/** A {@link TypeSerializerUpgradeTestBase} for {@link MapSerializerSnapshot}. */
@RunWith(Parameterized.class)
public class MapSerializerUpgradeTest
class MapSerializerUpgradeTest
extends TypeSerializerUpgradeTestBase<Map<Integer, String>, Map<Integer, String>> {

private static final String SPEC_NAME = "map-serializer";

public MapSerializerUpgradeTest(
TestSpecification<Map<Integer, String>, Map<Integer, String>> testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,13 @@
import org.apache.flink.FlinkVersion;
import org.apache.flink.api.common.typeutils.TypeSerializerUpgradeTestBase;

import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;

/** Migration tests for primitive array type serializers' snapshots. */
@RunWith(Parameterized.class)
public class PrimitiveArraySerializerUpgradeTest
extends TypeSerializerUpgradeTestBase<Object, Object> {
public PrimitiveArraySerializerUpgradeTest(
TestSpecification<Object, Object> testSpecification) {
super(testSpecification);
}
class PrimitiveArraySerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> {

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {
ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
testSpecifications.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,20 @@
import org.apache.flink.types.CopyableValue;

import org.hamcrest.Matcher;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;

/** A {@link TypeSerializerUpgradeTestBase} for {@link CopyableValueSerializer}. */
@RunWith(Parameterized.class)
public class CopyableSerializerUpgradeTest
class CopyableSerializerUpgradeTest
extends TypeSerializerUpgradeTestBase<SimpleCopyable, SimpleCopyable> {

public CopyableSerializerUpgradeTest(
TestSpecification<SimpleCopyable, SimpleCopyable> testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {
ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
testSpecifications.add(
Expand Down Expand Up @@ -168,8 +159,8 @@ public Matcher<SimpleCopyable> testDataMatcher() {
}

@Test
public void testF() {
void testSimpleCopyableEqualsImplementation() {
SimpleCopyable a = new SimpleCopyable(123456);
Assert.assertThat(a, is(new SimpleCopyable(123456)));
assertThat(a).isEqualTo(new SimpleCopyable(123456));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,16 @@
import org.apache.flink.api.common.typeutils.base.LongSerializer;

import org.hamcrest.Matcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;

import static org.hamcrest.CoreMatchers.is;

/** A {@link TypeSerializerUpgradeTestBase} for {@link NullableSerializer}. */
@RunWith(Parameterized.class)
public class NullableSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Long, Long> {
class NullableSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Long, Long> {

public NullableSerializerUpgradeTest(TestSpecification<Long, Long> testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,14 @@
import org.apache.flink.FlinkVersion;
import org.apache.flink.api.common.typeutils.TypeSerializerUpgradeTestBase;

import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/** A {@link TypeSerializerUpgradeTestBase} for the {@link PojoSerializer}. */
@RunWith(Parameterized.class)
public class PojoSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> {

public PojoSerializerUpgradeTest(TestSpecification<Object, Object> testSpecification) {
super(testSpecification);
}
class PojoSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Object, Object> {

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {
ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
// for PojoSerializer we also test against 1.7, 1.8, and 1.9 because we have snapshots
// for this which go beyond what we have for the usual subclasses of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.flink.api.java.typeutils.runtime;

import org.apache.flink.FlinkVersion;
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeutils.TypeSerializer;
Expand All @@ -30,8 +31,6 @@
import org.apache.flink.types.RowKind;

import org.hamcrest.Matcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -40,15 +39,10 @@
import static org.hamcrest.Matchers.is;

/** A {@link TypeSerializerUpgradeTestBase} for {@link RowSerializer}. */
@RunWith(Parameterized.class)
@VisibleForTesting
public class RowSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Row, Row> {

public RowSerializerUpgradeTest(TestSpecification<Row, Row> testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {
ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
// for RowSerializer we also test against 1.10 and newer because we have snapshots
// for this which go beyond what we have for the usual subclasses of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,18 @@
import org.apache.flink.api.java.tuple.Tuple3;

import org.hamcrest.Matcher;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.Collection;

import static org.hamcrest.Matchers.is;

/** {@link TupleSerializer} upgrade test. */
@RunWith(Parameterized.class)
public class TupleSerializerUpgradeTest
class TupleSerializerUpgradeTest
extends TypeSerializerUpgradeTestBase<
Tuple3<String, String, Integer>, Tuple3<String, String, Integer>> {

public TupleSerializerUpgradeTest(
TestSpecification<Tuple3<String, String, Integer>, Tuple3<String, String, Integer>>
testSpecification) {
super(testSpecification);
}

@Parameterized.Parameters(name = "Test Specification = {0}")
public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception {
public Collection<TestSpecification<?, ?>> createTestSpecifications() throws Exception {

ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>();
for (FlinkVersion flinkVersion : MIGRATION_VERSIONS) {
Expand Down
Loading

0 comments on commit 5be0ada

Please sign in to comment.