flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [3/4] flink git commit: [FLINK-5576] [queryable state] Add tests to for KvStateRequestSerializerTest
Date Sun, 22 Jan 2017 14:55:17 GMT
[FLINK-5576] [queryable state] Add tests to for KvStateRequestSerializerTest

These tests ensure that some special cases not properly tested before are
handled correctly in future.

This closes #3174.
This closes #3139 (left over).


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/563c3a4a
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/563c3a4a
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/563c3a4a

Branch: refs/heads/master
Commit: 563c3a4a54535ae6cb3812303812b0d337d62ef2
Parents: 3fe2cf5
Author: Nico Kruber <nico@data-artisans.com>
Authored: Thu Jan 19 17:12:02 2017 +0100
Committer: Ufuk Celebi <uce@apache.org>
Committed: Sun Jan 22 11:59:11 2017 +0100

----------------------------------------------------------------------
 .../message/KvStateRequestSerializerTest.java   | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/563c3a4a/flink-runtime/src/test/java/org/apache/flink/runtime/query/netty/message/KvStateRequestSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/query/netty/message/KvStateRequestSerializerTest.java
b/flink-runtime/src/test/java/org/apache/flink/runtime/query/netty/message/KvStateRequestSerializerTest.java
index 9552531..9d6d27c 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/query/netty/message/KvStateRequestSerializerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/query/netty/message/KvStateRequestSerializerTest.java
@@ -342,6 +342,35 @@ public class KvStateRequestSerializerTest {
 		assertEquals(expectedValue, actualValue.get(0).longValue());
 	}
 
+	/**
+	 * Tests list deserialization with too few bytes.
+	 */
+	@Test
+	public void testDeserializeListEmpty() throws Exception {
+		List<Long> actualValue = KvStateRequestSerializer
+			.deserializeList(new byte[] {}, LongSerializer.INSTANCE);
+		assertEquals(0, actualValue.size());
+	}
+
+	/**
+	 * Tests list deserialization with too few bytes.
+	 */
+	@Test(expected = IOException.class)
+	public void testDeserializeListTooShort1() throws Exception {
+		// 1 byte (incomplete Long)
+		KvStateRequestSerializer.deserializeList(new byte[] {1}, LongSerializer.INSTANCE);
+	}
+
+	/**
+	 * Tests list deserialization with too few bytes.
+	 */
+	@Test(expected = IOException.class)
+	public void testDeserializeListTooShort2() throws Exception {
+		// Long + 1 byte (separator) + 1 byte (incomplete Long)
+		KvStateRequestSerializer.deserializeList(new byte[] {1, 1, 1, 1, 1, 1, 1, 1, 2, 3},
+			LongSerializer.INSTANCE);
+	}
+
 	private byte[] randomByteArray(int capacity) {
 		byte[] bytes = new byte[capacity];
 		ThreadLocalRandom.current().nextBytes(bytes);


Mime
View raw message