flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-core/src/test/java/org/apache/flink/api/common/typeutils/TypeSerializerSerializationUtilTest.java
/**
	 * Verifies deserialization failure cases when reading a serializer from bytes, in the
	 * case of a {@link ClassNotFoundException}.
	 */
Verifies deserialization failure cases when reading a serializer from bytes, in the
case of a  ClassNotFoundException.
Verifies deserialization failure cases when reading a serializer from bytes in the case of a ClassNotFoundException .
@Test
	public void testSerializerSerializationWithClassNotFound() throws Exception {
		TypeSerializer<?> serializer = IntSerializer.INSTANCE;
		byte[] serialized;
		try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) {
			TypeSerializerSerializationUtil.writeSerializer(new DataOutputViewStreamWrapper(out), serializer);
			serialized = out.toByteArray();
		}
		TypeSerializer<?> deserializedSerializer;
		try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) {
			deserializedSerializer = TypeSerializerSerializationUtil.tryReadSerializer(
				new DataInputViewStreamWrapper(in), new URLClassLoader(new URL[0], null));
		}
		Assert.assertEquals(null, deserializedSerializer);
		try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) {
			deserializedSerializer = TypeSerializerSerializationUtil.tryReadSerializer(
				new DataInputViewStreamWrapper(in), new URLClassLoader(new URL[0], null), true);
		}
		Assert.assertTrue(deserializedSerializer instanceof UnloadableDummyTypeSerializer);
		Assert.assertArrayEquals(
				InstantiationUtil.serializeObject(serializer),
				((UnloadableDummyTypeSerializer<?>) deserializedSerializer).getActualBytes());
	}
@ Test public void testSerializerSerializationWithClassNotFound ( ) throws Exception { TypeSerializer < ? > serializer = IntSerializer . INSTANCE ; byte [ ] serialized ; try ( ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos ( ) ) { TypeSerializerSerializationUtil . writeSerializer ( new DataOutputViewStreamWrapper ( out ) , serializer ) ; serialized = out . toByteArray ( ) ; } TypeSerializer < ? > deserializedSerializer ; try ( ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos ( serialized ) ) { deserializedSerializer = TypeSerializerSerializationUtil . tryReadSerializer ( new DataInputViewStreamWrapper ( in ) , new URLClassLoader ( new URL [ 0 ] , null ) ) ; } Assert . assertEquals ( null , deserializedSerializer ) ; try ( ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos ( serialized ) ) { deserializedSerializer = TypeSerializerSerializationUtil . tryReadSerializer ( new DataInputViewStreamWrapper ( in ) , new URLClassLoader ( new URL [ 0 ] , null ) , true ) ; } Assert . assertTrue ( deserializedSerializer instanceof UnloadableDummyTypeSerializer ) ; Assert . assertArrayEquals ( InstantiationUtil . serializeObject ( serializer ) , ( ( UnloadableDummyTypeSerializer < ? > ) deserializedSerializer ) . getActualBytes ( ) ) ; }
Verifies deserialization failure cases when reading a serializer from bytes, in the
 case of a {@link ClassNotFoundException}.
Verifies deserialization failure cases when reading a serializer from bytes in the case of a { @link ClassNotFoundException } .