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 6c7cdd63b79f80f65a1584fbfe7d8ce09795ef5d
Author: klion26 <[email protected]>
AuthorDate: Thu Apr 2 17:46:38 2020 +0800

    [FLINK-13632] Port JavaSerializer upgrade test to 
TypeSerializerUpgradeTestBase
---
 .../apache/flink/runtime/state/JavaSerializer.java |   8 +-
 .../state/JavaSerializerSnapshotMigrationTest.java |  57 -----------
 .../runtime/state/JavaSerializerUpgradeTest.java   | 105 +++++++++++++++++++++
 .../test/resources/flink-1.6-java-serializer-data  | Bin 180 -> 0 bytes
 .../resources/flink-1.6-java-serializer-snapshot   | Bin 366 -> 0 bytes
 .../test/resources/flink-1.7-java-serializer-data  | Bin 180 -> 0 bytes
 .../resources/flink-1.7-java-serializer-snapshot   | Bin 354 -> 0 bytes
 7 files changed, 112 insertions(+), 58 deletions(-)

diff --git 
a/flink-runtime/src/main/java/org/apache/flink/runtime/state/JavaSerializer.java
 
b/flink-runtime/src/main/java/org/apache/flink/runtime/state/JavaSerializer.java
index 9e00985..20d53d1 100644
--- 
a/flink-runtime/src/main/java/org/apache/flink/runtime/state/JavaSerializer.java
+++ 
b/flink-runtime/src/main/java/org/apache/flink/runtime/state/JavaSerializer.java
@@ -19,6 +19,7 @@
 package org.apache.flink.runtime.state;
 
 import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.VisibleForTesting;
 import org.apache.flink.api.common.typeutils.SimpleTypeSerializerSnapshot;
 import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot;
 import org.apache.flink.api.common.typeutils.base.TypeSerializerSingleton;
@@ -32,8 +33,13 @@ import org.apache.flink.util.InstantiationUtil;
 import java.io.IOException;
 import java.io.Serializable;
 
+/**
+ * A {@link org.apache.flink.api.common.typeutils.TypeSerializer} that uses 
Java serialization. This
+ * should not be used for anything.
+ */
 @Internal
-final class JavaSerializer<T extends Serializable> extends 
TypeSerializerSingleton<T> {
+@VisibleForTesting
+public final class JavaSerializer<T extends Serializable> extends 
TypeSerializerSingleton<T> {
 
        private static final long serialVersionUID = 5067491650263321234L;
 
diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/state/JavaSerializerSnapshotMigrationTest.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/state/JavaSerializerSnapshotMigrationTest.java
deleted file mode 100644
index bcf18f5..0000000
--- 
a/flink-runtime/src/test/java/org/apache/flink/runtime/state/JavaSerializerSnapshotMigrationTest.java
+++ /dev/null
@@ -1,57 +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.runtime.state;
-
-import 
org.apache.flink.api.common.typeutils.TypeSerializerSnapshotMigrationTestBase;
-import org.apache.flink.testutils.migration.MigrationVersion;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-/**
- * Migration test for the {@link JavaSerializer}.
- */
-@RunWith(Parameterized.class)
-public class JavaSerializerSnapshotMigrationTest extends 
TypeSerializerSnapshotMigrationTestBase<Serializable> {
-
-       private static final String SPEC_NAME = "java-serializer";
-
-       public 
JavaSerializerSnapshotMigrationTest(TestSpecification<Serializable> 
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,
-                       JavaSerializer.class,
-                       JavaSerializer.JavaSerializerSnapshot.class,
-                       () -> new JavaSerializer<>());
-
-               return testSpecifications.get();
-       }
-}
-
diff --git 
a/flink-runtime/src/test/java/org/apache/flink/runtime/state/JavaSerializerUpgradeTest.java
 
b/flink-runtime/src/test/java/org/apache/flink/runtime/state/JavaSerializerUpgradeTest.java
new file mode 100644
index 0000000..40bddd1
--- /dev/null
+++ 
b/flink-runtime/src/test/java/org/apache/flink/runtime/state/JavaSerializerUpgradeTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.runtime.state;
+
+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.testutils.migration.MigrationVersion;
+
+import org.hamcrest.Matcher;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import static org.hamcrest.Matchers.is;
+
+/**
+ * A {@link TypeSerializerUpgradeTestBase} for {@link JavaSerializer}.
+ */
+@RunWith(Parameterized.class)
+public class JavaSerializerUpgradeTest extends 
TypeSerializerUpgradeTestBase<Serializable, Serializable> {
+
+       private static final String SPEC_NAME = "java-serializer";
+
+       public JavaSerializerUpgradeTest(TestSpecification<Serializable, 
Serializable> 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,
+                                       JavaSerializerSetup.class,
+                                       JavaSerializerVerifier.class));
+               }
+
+               return testSpecifications;
+       }
+
+       // 
----------------------------------------------------------------------------------------------
+       //  Specification for "java-serializer"
+       // 
----------------------------------------------------------------------------------------------
+
+       /**
+        * This class is only public to work with {@link 
org.apache.flink.api.common.typeutils.ClassRelocator}.
+        */
+       public static final class JavaSerializerSetup implements 
TypeSerializerUpgradeTestBase.PreUpgradeSetup<Serializable> {
+               @Override
+               public TypeSerializer<Serializable> createPriorSerializer() {
+                       return new JavaSerializer<>();
+               }
+
+               @Override
+               public Serializable createTestData() {
+                       return 26;
+               }
+       }
+
+       /**
+        * This class is only public to work with {@link 
org.apache.flink.api.common.typeutils.ClassRelocator}.
+        */
+       public static final class JavaSerializerVerifier implements 
TypeSerializerUpgradeTestBase.UpgradeVerifier<Serializable> {
+               @Override
+               public TypeSerializer<Serializable> createUpgradedSerializer() {
+                       return new JavaSerializer<>();
+               }
+
+               @Override
+               public Matcher<Serializable> testDataMatcher() {
+                       return is(26);
+               }
+
+               @Override
+               public Matcher<TypeSerializerSchemaCompatibility<Serializable>> 
schemaCompatibilityMatcher(MigrationVersion version) {
+                       return TypeSerializerMatchers.isCompatibleAsIs();
+               }
+       }
+}
+
diff --git a/flink-runtime/src/test/resources/flink-1.6-java-serializer-data 
b/flink-runtime/src/test/resources/flink-1.6-java-serializer-data
deleted file mode 100644
index 7579df03..0000000
Binary files a/flink-runtime/src/test/resources/flink-1.6-java-serializer-data 
and /dev/null differ
diff --git 
a/flink-runtime/src/test/resources/flink-1.6-java-serializer-snapshot 
b/flink-runtime/src/test/resources/flink-1.6-java-serializer-snapshot
deleted file mode 100644
index cec8f75..0000000
Binary files 
a/flink-runtime/src/test/resources/flink-1.6-java-serializer-snapshot and 
/dev/null differ
diff --git a/flink-runtime/src/test/resources/flink-1.7-java-serializer-data 
b/flink-runtime/src/test/resources/flink-1.7-java-serializer-data
deleted file mode 100644
index 7579df03..0000000
Binary files a/flink-runtime/src/test/resources/flink-1.7-java-serializer-data 
and /dev/null differ
diff --git 
a/flink-runtime/src/test/resources/flink-1.7-java-serializer-snapshot 
b/flink-runtime/src/test/resources/flink-1.7-java-serializer-snapshot
deleted file mode 100644
index 0bb9093..0000000
Binary files 
a/flink-runtime/src/test/resources/flink-1.7-java-serializer-snapshot and 
/dev/null differ

Reply via email to