You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2015/07/29 00:15:46 UTC
[4/8] flink git commit: [FLINK-2421] [streaming] Add tests for basic
utility behavior of StreamRecordSerializer (fixed in previous commit).
[FLINK-2421] [streaming] Add tests for basic utility behavior of StreamRecordSerializer (fixed in previous commit).
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/2d237e18
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/2d237e18
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/2d237e18
Branch: refs/heads/master
Commit: 2d237e18a2f7cf21721340933c505bb518c4fc66
Parents: acae9ff
Author: Stephan Ewen <se...@apache.org>
Authored: Tue Jul 28 18:08:19 2015 +0200
Committer: Stephan Ewen <se...@apache.org>
Committed: Tue Jul 28 22:58:06 2015 +0200
----------------------------------------------------------------------
.../StreamRecordSerializerTest.java | 68 ++++++++++++++++++++
1 file changed, 68 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/2d237e18/flink-staging/flink-streaming/flink-streaming-core/src/test/java/org/apache/flink/streaming/runtime/streamrecord/StreamRecordSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-staging/flink-streaming/flink-streaming-core/src/test/java/org/apache/flink/streaming/runtime/streamrecord/StreamRecordSerializerTest.java b/flink-staging/flink-streaming/flink-streaming-core/src/test/java/org/apache/flink/streaming/runtime/streamrecord/StreamRecordSerializerTest.java
new file mode 100644
index 0000000..d48f7f4
--- /dev/null
+++ b/flink-staging/flink-streaming/flink-streaming-core/src/test/java/org/apache/flink/streaming/runtime/streamrecord/StreamRecordSerializerTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.streaming.runtime.streamrecord;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.base.LongSerializer;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class StreamRecordSerializerTest {
+
+ @Test
+ public void testDeepDuplication() {
+ try {
+ @SuppressWarnings("unchecked")
+ TypeSerializer<Long> serializer1 = (TypeSerializer<Long>) mock(TypeSerializer.class);
+ @SuppressWarnings("unchecked")
+ TypeSerializer<Long> serializer2 = (TypeSerializer<Long>) mock(TypeSerializer.class);
+
+ when(serializer1.duplicate()).thenReturn(serializer2);
+
+ StreamRecordSerializer<Long> streamRecSer = new StreamRecordSerializer<Long>(serializer1);
+ assertEquals(serializer1, streamRecSer.getContainedTypeSerializer());
+
+ StreamRecordSerializer<Long> copy = streamRecSer.duplicate();
+ assertNotEquals(copy, streamRecSer);
+ assertNotEquals(copy.getContainedTypeSerializer(), streamRecSer.getContainedTypeSerializer());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testBasicProperties() {
+ try {
+ StreamRecordSerializer<Long> streamRecSer = new StreamRecordSerializer<Long>(LongSerializer.INSTANCE);
+
+ assertFalse(streamRecSer.isImmutableType());
+ assertEquals(Long.class, streamRecSer.createInstance().getValue().getClass());
+ assertEquals(LongSerializer.INSTANCE.getLength(), streamRecSer.getLength());
+
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+}