forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-13632] Port NullableSerializer test to TypeSerializerUpgradeTe…
…stBase
- Loading branch information
Showing
10 changed files
with
146 additions
and
83 deletions.
There are no files selected for viewing
83 changes: 0 additions & 83 deletions
83
...est/java/org/apache/flink/api/java/typeutils/runtime/NullableSerializerMigrationTest.java
This file was deleted.
Oops, something went wrong.
146 changes: 146 additions & 0 deletions
146
.../test/java/org/apache/flink/api/java/typeutils/runtime/NullableSerializerUpgradeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* 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.api.common.typeutils.base.LongSerializer; | ||
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 static org.hamcrest.CoreMatchers.is; | ||
|
||
/** | ||
* A {@link TypeSerializerUpgradeTestBase} for {@link NullableSerializer}. | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public 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 { | ||
|
||
ArrayList<TestSpecification<?, ?>> testSpecifications = new ArrayList<>(); | ||
for (MigrationVersion migrationVersion : MIGRATION_VERSIONS) { | ||
testSpecifications.add( | ||
new TestSpecification<>( | ||
"nullable-padded-serializer", | ||
migrationVersion, | ||
NullablePaddedSerializerSetup.class, | ||
NullablePaddedSerializerVerifier.class)); | ||
|
||
testSpecifications.add( | ||
new TestSpecification<>( | ||
"nullable-not-padded-serializer", | ||
migrationVersion, | ||
NullableNotPaddedSerializerSetup.class, | ||
NullableNotPaddedSerializerVerifier.class)); | ||
} | ||
return testSpecifications; | ||
} | ||
|
||
// ---------------------------------------------------------------------------------------------- | ||
// Specification for "nullable-padded-serializer" | ||
// ---------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. | ||
*/ | ||
public static final class NullablePaddedSerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<Long> { | ||
@Override | ||
public TypeSerializer<Long> createPriorSerializer() { | ||
return NullableSerializer.wrap(LongSerializer.INSTANCE, true); | ||
} | ||
|
||
@Override | ||
public Long createTestData() { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. | ||
*/ | ||
public static final class NullablePaddedSerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<Long> { | ||
@Override | ||
public TypeSerializer<Long> createUpgradedSerializer() { | ||
return NullableSerializer.wrap(LongSerializer.INSTANCE, true); | ||
} | ||
|
||
@Override | ||
public Matcher<Long> testDataMatcher() { | ||
return is((Long) null); | ||
} | ||
|
||
@Override | ||
public Matcher<TypeSerializerSchemaCompatibility<Long>> schemaCompatibilityMatcher(MigrationVersion version) { | ||
return TypeSerializerMatchers.isCompatibleAsIs(); | ||
} | ||
} | ||
|
||
// ---------------------------------------------------------------------------------------------- | ||
// Specification for "nullable-not-padded-serializer" | ||
// ---------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. | ||
*/ | ||
public static final class NullableNotPaddedSerializerSetup implements TypeSerializerUpgradeTestBase.PreUpgradeSetup<Long> { | ||
@Override | ||
public TypeSerializer<Long> createPriorSerializer() { | ||
return NullableSerializer.wrap(LongSerializer.INSTANCE, false); | ||
} | ||
|
||
@Override | ||
public Long createTestData() { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* This class is only public to work with {@link org.apache.flink.api.common.typeutils.ClassRelocator}. | ||
*/ | ||
public static final class NullableNotPaddedSerializerVerifier implements TypeSerializerUpgradeTestBase.UpgradeVerifier<Long> { | ||
@Override | ||
public TypeSerializer<Long> createUpgradedSerializer() { | ||
return NullableSerializer.wrap(LongSerializer.INSTANCE, false); | ||
} | ||
|
||
@Override | ||
public Matcher<Long> testDataMatcher() { | ||
return is((Long) null); | ||
} | ||
|
||
@Override | ||
public Matcher<TypeSerializerSchemaCompatibility<Long>> schemaCompatibilityMatcher(MigrationVersion version) { | ||
return TypeSerializerMatchers.isCompatibleAsIs(); | ||
} | ||
} | ||
} |
Binary file removed
BIN
-58 Bytes
flink-core/src/test/resources/flink-1.6-nullable-not-padded-serializer-data
Binary file not shown.
Binary file removed
BIN
-944 Bytes
flink-core/src/test/resources/flink-1.6-nullable-not-padded-serializer-snapshot
Binary file not shown.
Binary file removed
BIN
-90 Bytes
flink-core/src/test/resources/flink-1.6-nullable-padded-serializer-data
Binary file not shown.
Binary file removed
BIN
-952 Bytes
flink-core/src/test/resources/flink-1.6-nullable-padded-serializer-snapshot
Binary file not shown.
Binary file removed
BIN
-58 Bytes
flink-core/src/test/resources/flink-1.7-nullable-not-padded-serializer-data
Binary file not shown.
Binary file removed
BIN
-941 Bytes
flink-core/src/test/resources/flink-1.7-nullable-not-padded-serializer-snapshot
Binary file not shown.
Binary file removed
BIN
-90 Bytes
flink-core/src/test/resources/flink-1.7-nullable-padded-serializer-data
Binary file not shown.
Binary file removed
BIN
-949 Bytes
flink-core/src/test/resources/flink-1.7-nullable-padded-serializer-snapshot
Binary file not shown.