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 59fd396a8c3b2c79fd52d819d7755e74ee3a66df
Author: klion26 <[email protected]>
AuthorDate: Tue Jan 21 10:07:45 2020 +0800

    [FLINK-13632] Port ValueSerializer upgrade test to 
TypeSerializerUpgradeTestBase
---
 .../runtime/ValueSerializerMigrationTest.java      |  88 -------------
 .../runtime/ValueSerializerUpgradeTest.java        | 138 +++++++++++++++++++++
 .../test/resources/flink-1.6-value-serializer-data | Bin 150 -> 0 bytes
 .../resources/flink-1.6-value-serializer-snapshot  | Bin 1310 -> 0 bytes
 .../test/resources/flink-1.7-value-serializer-data | Bin 150 -> 0 bytes
 .../resources/flink-1.7-value-serializer-snapshot  | Bin 1298 -> 0 bytes
 6 files changed, 138 insertions(+), 88 deletions(-)

diff --git 
a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerMigrationTest.java
 
b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerMigrationTest.java
deleted file mode 100644
index 55a1bae..0000000
--- 
a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerMigrationTest.java
+++ /dev/null
@@ -1,88 +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.java.typeutils.runtime;
-
-import 
org.apache.flink.api.common.typeutils.TypeSerializerSnapshotMigrationTestBase;
-import 
org.apache.flink.api.java.typeutils.runtime.ValueSerializer.ValueSerializerSnapshot;
-import 
org.apache.flink.api.java.typeutils.runtime.ValueSerializerMigrationTest.NameValue;
-import org.apache.flink.core.memory.DataInputView;
-import org.apache.flink.core.memory.DataOutputView;
-import org.apache.flink.testutils.migration.MigrationVersion;
-import org.apache.flink.types.Value;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * State migration test for {@link RowSerializer}.
- */
-@RunWith(Parameterized.class)
-public class ValueSerializerMigrationTest extends 
TypeSerializerSnapshotMigrationTestBase<NameValue> {
-
-       public ValueSerializerMigrationTest(TestSpecification<NameValue> 
testSpecification) {
-               super(testSpecification);
-       }
-
-       @SuppressWarnings("unchecked")
-       @Parameterized.Parameters(name = "Test Specification = {0}")
-       public static Collection<TestSpecification<?>> testSpecifications() {
-
-               TestSpecifications testSpecifications = new 
TestSpecifications(MigrationVersion.v1_6, MigrationVersion.v1_7);
-
-               testSpecifications.add(
-                       "value-serializer",
-                       ValueSerializer.class,
-                       ValueSerializerSnapshot.class,
-                       () -> new ValueSerializer<>(NameValue.class));
-
-               return testSpecifications.get();
-       }
-
-       /**
-        * A dummy class used for this test.
-        */
-       public static final class NameValue implements Value {
-
-               public static final long serialVersionUID = 
2277251654485371327L;
-
-               private String name;
-
-               public String getName() {
-                       return name;
-               }
-
-               public void setName(String name) {
-                       this.name = name;
-               }
-
-               @Override
-               public void write(DataOutputView out) throws IOException {
-                       out.writeUTF(name);
-               }
-
-               @Override
-               public void read(DataInputView in) throws IOException {
-                       name = in.readUTF();
-               }
-       }
-
-}
diff --git 
a/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUpgradeTest.java
 
b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUpgradeTest.java
new file mode 100644
index 0000000..12d4a97
--- /dev/null
+++ 
b/flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/ValueSerializerUpgradeTest.java
@@ -0,0 +1,138 @@
+/*
+ * 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.java.typeutils.runtime;
+
+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.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataOutputView;
+import org.apache.flink.testutils.migration.MigrationVersion;
+import org.apache.flink.types.Value;
+
+import org.hamcrest.Matcher;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Objects;
+
+import static org.hamcrest.Matchers.is;
+
+/**
+ * State migration test for {@link RowSerializer}.
+ */
+@RunWith(Parameterized.class)
+public class ValueSerializerUpgradeTest extends 
TypeSerializerUpgradeTestBase<ValueSerializerUpgradeTest.NameValue, 
ValueSerializerUpgradeTest.NameValue> {
+       public ValueSerializerUpgradeTest(TestSpecification<NameValue, 
NameValue> 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<>(
+                                       "value-serializer",
+                                       migrationVersion,
+                                       ValueSerializerSetup.class,
+                                       ValueSerializerVerifier.class));
+               }
+
+               return testSpecifications;
+       }
+
+       public static final class ValueSerializerSetup implements 
TypeSerializerUpgradeTestBase.PreUpgradeSetup<NameValue> {
+               @Override
+               public TypeSerializer<NameValue> createPriorSerializer() {
+                       return new ValueSerializer<>(NameValue.class);
+               }
+
+               @Override
+               public NameValue createTestData() {
+                       NameValue value = new NameValue();
+                       value.setName("klion26");
+                       return value;
+               }
+       }
+
+       public static final class ValueSerializerVerifier implements 
TypeSerializerUpgradeTestBase.UpgradeVerifier<NameValue> {
+               @Override
+               public TypeSerializer<NameValue> createUpgradedSerializer() {
+                       return new ValueSerializer<>(NameValue.class);
+               }
+
+               @Override
+               public Matcher<NameValue> testDataMatcher() {
+                       NameValue value = new NameValue();
+                       value.setName("klion26");
+                       return is(value);
+               }
+
+               @Override
+               public Matcher<TypeSerializerSchemaCompatibility<NameValue>> 
schemaCompatibilityMatcher(MigrationVersion version) {
+                       return TypeSerializerMatchers.isCompatibleAsIs();
+               }
+       }
+
+       /**
+        * A dummy class used for this test.
+        */
+       public static final class NameValue implements Value {
+
+               public static final long serialVersionUID = 
2277251654485371327L;
+
+               private String name;
+
+               public String getName() {
+                       return name;
+               }
+
+               public void setName(String name) {
+                       this.name = name;
+               }
+
+               @Override
+               public void write(DataOutputView out) throws IOException {
+                       out.writeUTF(name);
+               }
+
+               @Override
+               public void read(DataInputView in) throws IOException {
+                       name = in.readUTF();
+               }
+
+               @Override
+               public boolean equals(Object obj) {
+                       if (obj == this) {
+                               return true;
+                       }
+                       if (!(obj instanceof NameValue)) {
+                               return false;
+                       }
+
+                       NameValue other = (NameValue) obj;
+                       return Objects.equals(this.name, other.name);
+               }
+       }
+}
diff --git a/flink-core/src/test/resources/flink-1.6-value-serializer-data 
b/flink-core/src/test/resources/flink-1.6-value-serializer-data
deleted file mode 100644
index f2bb149..0000000
Binary files a/flink-core/src/test/resources/flink-1.6-value-serializer-data 
and /dev/null differ
diff --git a/flink-core/src/test/resources/flink-1.6-value-serializer-snapshot 
b/flink-core/src/test/resources/flink-1.6-value-serializer-snapshot
deleted file mode 100644
index 90cbdcf..0000000
Binary files 
a/flink-core/src/test/resources/flink-1.6-value-serializer-snapshot and 
/dev/null differ
diff --git a/flink-core/src/test/resources/flink-1.7-value-serializer-data 
b/flink-core/src/test/resources/flink-1.7-value-serializer-data
deleted file mode 100644
index cbd0d18..0000000
Binary files a/flink-core/src/test/resources/flink-1.7-value-serializer-data 
and /dev/null differ
diff --git a/flink-core/src/test/resources/flink-1.7-value-serializer-snapshot 
b/flink-core/src/test/resources/flink-1.7-value-serializer-snapshot
deleted file mode 100644
index 5194920..0000000
Binary files 
a/flink-core/src/test/resources/flink-1.7-value-serializer-snapshot and 
/dev/null differ

Reply via email to