This is an automated email from the ASF dual-hosted git repository. aljoscha pushed a commit to branch release-1.11 in repository https://gitbox.apache.org/repos/asf/flink.git
commit 12b6ba92c7547e66e540e5662a96df6249cf2ae1 Author: klion26 <[email protected]> AuthorDate: Sat Feb 15 21:17:54 2020 +0800 [FLINK-13632] Port ScalaEitherSerializer upgrade test to TypeSerializerUpgradeTestBase --- ...ScalaEitherSerializerSnapshotMigrationTest.java | 59 ------------ .../ScalaEitherSerializerUpgradeTest.java | 107 +++++++++++++++++++++ .../flink-1.6-scala-either-serializer-data | Bin 130 -> 0 bytes .../flink-1.6-scala-either-serializer-snapshot | Bin 1358 -> 0 bytes .../flink-1.7-scala-either-serializer-data | Bin 130 -> 0 bytes .../flink-1.7-scala-either-serializer-snapshot | Bin 381 -> 0 bytes 6 files changed, 107 insertions(+), 59 deletions(-) diff --git a/flink-scala/src/test/java/org/apache/flink/api/scala/typeutils/ScalaEitherSerializerSnapshotMigrationTest.java b/flink-scala/src/test/java/org/apache/flink/api/scala/typeutils/ScalaEitherSerializerSnapshotMigrationTest.java deleted file mode 100644 index 45339ab..0000000 --- a/flink-scala/src/test/java/org/apache/flink/api/scala/typeutils/ScalaEitherSerializerSnapshotMigrationTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.flink.api.scala.typeutils; - -import org.apache.flink.api.common.typeutils.TypeSerializerSnapshotMigrationTestBase; -import org.apache.flink.api.common.typeutils.base.IntSerializer; -import org.apache.flink.api.common.typeutils.base.StringSerializer; -import org.apache.flink.testutils.migration.MigrationVersion; - -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Collection; - -import scala.util.Either; - -/** - * Migration test for the {@link ScalaEitherSerializerSnapshot}. - */ -@RunWith(Parameterized.class) -public class ScalaEitherSerializerSnapshotMigrationTest extends TypeSerializerSnapshotMigrationTestBase<Either<Integer, String>> { - - private static final String SPEC_NAME = "scala-either-serializer"; - - public ScalaEitherSerializerSnapshotMigrationTest(TestSpecification<Either<Integer, String>> testSpecification) { - super(testSpecification); - } - - @SuppressWarnings("unchecked") - @Parameterized.Parameters(name = "Test Specification = {0}") - public static Collection<TestSpecification<?>> testSpecifications() { - - final TestSpecifications testSpecifications = new TestSpecifications(MigrationVersion.v1_6, MigrationVersion.v1_7); - - testSpecifications.add( - SPEC_NAME, - EitherSerializer.class, - ScalaEitherSerializerSnapshot.class, - () -> new EitherSerializer<>(IntSerializer.INSTANCE, StringSerializer.INSTANCE)); - - return testSpecifications.get(); - } -} diff --git a/flink-scala/src/test/java/org/apache/flink/api/scala/typeutils/ScalaEitherSerializerUpgradeTest.java b/flink-scala/src/test/java/org/apache/flink/api/scala/typeutils/ScalaEitherSerializerUpgradeTest.java new file mode 100644 index 0000000..c2a2eda --- /dev/null +++ b/flink-scala/src/test/java/org/apache/flink/api/scala/typeutils/ScalaEitherSerializerUpgradeTest.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.scala.typeutils; + +import org.apache.flink.api.common.typeutils.TypeSerializer; +import org.apache.flink.api.common.typeutils.TypeSerializerMatchers; +import org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility; +import org.apache.flink.api.common.typeutils.TypeSerializerUpgradeTestBase; +import org.apache.flink.api.common.typeutils.base.IntSerializer; +import org.apache.flink.api.common.typeutils.base.StringSerializer; +import org.apache.flink.testutils.migration.MigrationVersion; + +import org.hamcrest.Matcher; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.ArrayList; +import java.util.Collection; + +import scala.util.Either; +import scala.util.Right; + +import static org.hamcrest.Matchers.is; + +/** + * A {@link TypeSerializerUpgradeTestBase} for {@link ScalaEitherSerializerSnapshot}. + */ +@RunWith(Parameterized.class) +public class ScalaEitherSerializerUpgradeTest extends TypeSerializerUpgradeTestBase<Either<Integer, String>, Either<Integer, String>> { + + private static final String SPEC_NAME = "scala-either-serializer"; + + public ScalaEitherSerializerUpgradeTest(TestSpecification<Either<Integer, String>, Either<Integer, String>> testSpecification) { + super(testSpecification); + } + + @Parameterized.Parameters(name = "Test Specification = {0}") + public static Collection<TestSpecification<?, ?>> testSpecifications() throws Exception { + + ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>(); + for (MigrationVersion migrationVersion : MIGRATION_VERSIONS) { + testSpecifications.add( + new TestSpecification<>( + SPEC_NAME, + migrationVersion, + EitherSerializerSetup.class, + EitherSerializerVerifier.class)); + } + return testSpecifications; + } + + // ---------------------------------------------------------------------------------------------- + // Specification for "either-serializer-left" + // ---------------------------------------------------------------------------------------------- + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class EitherSerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<Either<Integer, String>> { + @Override + public TypeSerializer<Either<Integer, String>> createPriorSerializer() { + return new EitherSerializer<>(IntSerializer.INSTANCE, StringSerializer.INSTANCE); + } + + @Override + public Either<Integer, String> createTestData() { + return new Right<>("Hello world"); + } + } + + /** + * This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. + */ + public static final class EitherSerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<Either<Integer, String>> { + @Override + public TypeSerializer<Either<Integer, String>> createUpgradedSerializer() { + return new EitherSerializer<>(IntSerializer.INSTANCE, StringSerializer.INSTANCE); + } + + @Override + public Matcher<Either<Integer, String>> testDataMatcher() { + return is(new Right<>("Hello world")); + } + + @Override + public Matcher<TypeSerializerSchemaCompatibility<Either<Integer, String>>> schemaCompatibilityMatcher(MigrationVersion version) { + return TypeSerializerMatchers.isCompatibleAsIs(); + } + } + +} diff --git a/flink-scala/src/test/resources/flink-1.6-scala-either-serializer-data b/flink-scala/src/test/resources/flink-1.6-scala-either-serializer-data deleted file mode 100644 index 203067c..0000000 Binary files a/flink-scala/src/test/resources/flink-1.6-scala-either-serializer-data and /dev/null differ diff --git a/flink-scala/src/test/resources/flink-1.6-scala-either-serializer-snapshot b/flink-scala/src/test/resources/flink-1.6-scala-either-serializer-snapshot deleted file mode 100644 index 1239406..0000000 Binary files a/flink-scala/src/test/resources/flink-1.6-scala-either-serializer-snapshot and /dev/null differ diff --git a/flink-scala/src/test/resources/flink-1.7-scala-either-serializer-data b/flink-scala/src/test/resources/flink-1.7-scala-either-serializer-data deleted file mode 100644 index 203067c..0000000 Binary files a/flink-scala/src/test/resources/flink-1.7-scala-either-serializer-data and /dev/null differ diff --git a/flink-scala/src/test/resources/flink-1.7-scala-either-serializer-snapshot b/flink-scala/src/test/resources/flink-1.7-scala-either-serializer-snapshot deleted file mode 100644 index 3e12866..0000000 Binary files a/flink-scala/src/test/resources/flink-1.7-scala-either-serializer-snapshot and /dev/null differ
