guoweiM commented on a change in pull request #14120:
URL: https://github.com/apache/flink/pull/14120#discussion_r530162870
##########
File path:
flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/EitherSerializerTest.java
##########
@@ -157,38 +192,41 @@ public void testEitherWithObjectReuse() {
}
@Test
- public void testSerializeIndividually() throws IOException {
- EitherTypeInfo<LongValue, DoubleValue> eitherTypeInfo = new
EitherTypeInfo<>(
- ValueTypeInfo.LONG_VALUE_TYPE_INFO,
ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO);
- EitherSerializer<LongValue, DoubleValue> eitherSerializer =
- (EitherSerializer<LongValue, DoubleValue>)
eitherTypeInfo.createSerializer(new ExecutionConfig());
-
- LongValue lv = new LongValue();
- DoubleValue dv = new DoubleValue();
-
- Either<LongValue, DoubleValue> left = Left(lv);
- Either<LongValue, DoubleValue> right = Right(dv);
-
- TestOutputView out = new TestOutputView();
- eitherSerializer.serialize(left, out);
- eitherSerializer.serialize(right, out);
- eitherSerializer.serialize(left, out);
-
- TestInputView in = out.getInputView();
- // the first deserialization creates a new instance of Left
- Either<LongValue, DoubleValue> copy0 =
eitherSerializer.deserialize(right, in);
-
- // then the cross-references are used for future copies
- Either<LongValue, DoubleValue> copy1 =
eitherSerializer.deserialize(copy0, in);
- Either<LongValue, DoubleValue> copy2 =
eitherSerializer.deserialize(copy1, in);
-
- // validate reference equality
- assertSame(right, copy1);
- assertSame(copy0, copy2);
-
- // validate reference equality of contained objects
- assertSame(right.right(), copy1.right());
- assertSame(copy0.left(), copy2.left());
+ public void testSerializeIndividually() {
Review comment:
Maybe we need to change the name for example testEitherWithLongAndDoulbe.
Or the parent test would not run.
##########
File path:
flink-tests/src/test/java/org/apache/flink/test/completeness/TypeInfoTestCoverageTest.java
##########
@@ -50,10 +50,11 @@ public void testTypeInfoTestCoverage() {
// we skip abstract classes and inner classes to skip
type information defined in test classes
if (Modifier.isAbstract(typeInfo.getModifiers()) ||
Modifier.isPrivate(typeInfo.getModifiers()) ||
- typeInfo.getName().contains("Test$") ||
-
typeInfo.getName().contains("TestBase$") ||
- typeInfo.getName().contains("ITCase$")
||
- typeInfo.getName().contains("$$anon") ||
+ typeInfo.getName().contains("test") ||
+ typeInfo.getName().contains("Test") ||
+ typeInfo.getName().contains("ITCase") ||
+ typeInfo.getName().contains("$") ||
Review comment:
I think we could not exclude all the internal classes.
##########
File path:
flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/EnumSerializerTest.java
##########
@@ -36,15 +37,38 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class EnumSerializerTest extends TestLogger {
+/**
+ * Tests for {@link EnumSerializer}.
+ */
+public class EnumSerializerTest extends
SerializerTestBase<EnumSerializerTest.PublicEnum> {
+
+ @Override
+ protected TypeSerializer<PublicEnum> createSerializer() {
+ return new EnumSerializer<>(PublicEnum.class);
+ }
+
+ @Override
+ protected int getLength() {
+ return 4;
+ }
+
+ @Override
+ protected Class<PublicEnum> getTypeClass() {
+ return PublicEnum.class;
+ }
+
+ @Override
+ protected PublicEnum[] getTestData() {
+ return new PublicEnum[]{PublicEnum.FOO, PublicEnum.BAR};
+ }
@Test
- public void testPublicEnum() {
+ public void testPrivateEnum() {
testEnumSerializer(PrivateEnum.ONE, PrivateEnum.TWO,
PrivateEnum.THREE);
}
@Test
- public void testPrivateEnum() {
+ public void testPublicEnum() {
Review comment:
see above
##########
File path:
flink-core/src/test/java/org/apache/flink/api/common/typeutils/base/EnumSerializerTest.java
##########
@@ -36,15 +37,38 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class EnumSerializerTest extends TestLogger {
+/**
+ * Tests for {@link EnumSerializer}.
+ */
+public class EnumSerializerTest extends
SerializerTestBase<EnumSerializerTest.PublicEnum> {
+
+ @Override
+ protected TypeSerializer<PublicEnum> createSerializer() {
+ return new EnumSerializer<>(PublicEnum.class);
+ }
+
+ @Override
+ protected int getLength() {
+ return 4;
+ }
+
+ @Override
+ protected Class<PublicEnum> getTypeClass() {
+ return PublicEnum.class;
+ }
+
+ @Override
+ protected PublicEnum[] getTestData() {
+ return new PublicEnum[]{PublicEnum.FOO, PublicEnum.BAR};
+ }
@Test
- public void testPublicEnum() {
+ public void testPrivateEnum() {
Review comment:
maybe we could open another commit/pr for this
##########
File path:
flink-core/src/test/java/org/apache/flink/api/java/typeutils/runtime/Tuple0SerializerTest.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.SerializerTestBase;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.java.tuple.Tuple0;
+
+/**
+ * Tests for {@link Tuple0Serializer}.
+ */
+public class Tuple0SerializerTest extends SerializerTestBase<Tuple0> {
+
+ @Override
+ protected TypeSerializer<Tuple0> createSerializer() {
+ return Tuple0Serializer.INSTANCE;
+ }
+
+ @Override
+ protected int getLength() {
+ return 1;
+ }
+
+ @Override
+ protected Class<Tuple0> getTypeClass() {
+ return Tuple0.class;
+ }
+
+ @Override
+ protected Tuple0[] getTestData() {
+ return new Tuple0[]{Tuple0.INSTANCE, Tuple0.INSTANCE,
Tuple0.INSTANCE};
Review comment:
maybe one is enough. :-)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]