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 InvalidClassException}.
	 */
Verifies deserialization failure cases when reading a serializer from bytes, in the
case of a  InvalidClassException.
Verifies deserialization failure cases when reading a serializer from bytes in the case of a InvalidClassException .
@Test
	public void testSerializerSerializationWithInvalidClass() throws Exception {
		TypeSerializer<?> serializer = IntSerializer.INSTANCE;
		byte[] serialized;
		try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) {
			TypeSerializerSerializationUtil.writeSerializer(new DataOutputViewStreamWrapper(out), serializer);
			serialized = out.toByteArray();
		}
		TypeSerializer<?> deserializedSerializer;
		TypeSerializerSerializationUtil.TypeSerializerSerializationProxy<?> mockProxy =
				mock(TypeSerializerSerializationUtil.TypeSerializerSerializationProxy.class);
		doThrow(new IOException()).when(mockProxy).read(any(DataInputViewStreamWrapper.class));
		PowerMockito.whenNew(TypeSerializerSerializationUtil.TypeSerializerSerializationProxy.class).withAnyArguments().thenReturn(mockProxy);
		try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) {
			deserializedSerializer = TypeSerializerSerializationUtil.tryReadSerializer(
				new DataInputViewStreamWrapper(in), Thread.currentThread().getContextClassLoader());
		}
		Assert.assertEquals(null, deserializedSerializer);
	}
@ Test public void testSerializerSerializationWithInvalidClass ( ) throws Exception { TypeSerializer < ? > serializer = IntSerializer . INSTANCE ; byte [ ] serialized ; try ( ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos ( ) ) { TypeSerializerSerializationUtil . writeSerializer ( new DataOutputViewStreamWrapper ( out ) , serializer ) ; serialized = out . toByteArray ( ) ; } TypeSerializer < ? > deserializedSerializer ; TypeSerializerSerializationUtil . TypeSerializerSerializationProxy < ? > mockProxy = mock ( TypeSerializerSerializationUtil . TypeSerializerSerializationProxy . class ) ; doThrow ( new IOException ( ) ) . when ( mockProxy ) . read ( any ( DataInputViewStreamWrapper . class ) ) ; PowerMockito . whenNew ( TypeSerializerSerializationUtil . TypeSerializerSerializationProxy . class ) . withAnyArguments ( ) . thenReturn ( mockProxy ) ; try ( ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos ( serialized ) ) { deserializedSerializer = TypeSerializerSerializationUtil . tryReadSerializer ( new DataInputViewStreamWrapper ( in ) , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } Assert . assertEquals ( null , deserializedSerializer ) ; }
Verifies deserialization failure cases when reading a serializer from bytes, in the
 case of a {@link InvalidClassException}.
Verifies deserialization failure cases when reading a serializer from bytes in the case of a { @link InvalidClassException } .
// mock failure when deserializing serializers