use of org.apache.flink.runtime.rpc.messages.RemoteRpcInvocation in project flink by apache.
the class FlinkUserCodeClassLoadersTest method testMessageDecodingWithUnavailableClass.
@Test
public void testMessageDecodingWithUnavailableClass() throws Exception {
final ClassLoader systemClassLoader = getClass().getClassLoader();
final String className = "UserClass";
final URLClassLoader userClassLoader = ClassLoaderUtils.compileAndLoadJava(temporaryFolder.newFolder(), className + ".java", "import java.io.Serializable;\n" + "public class " + className + " implements Serializable {}");
RemoteRpcInvocation method = new RemoteRpcInvocation(className, "test", new Class<?>[] { int.class, Class.forName(className, false, userClassLoader) }, new Object[] { 1, Class.forName(className, false, userClassLoader).newInstance() });
SerializedValue<RemoteRpcInvocation> serializedMethod = new SerializedValue<>(method);
expectedException.expect(ClassNotFoundException.class);
expectedException.expect(allOf(isA(ClassNotFoundException.class), hasProperty("suppressed", hasItemInArray(allOf(isA(ClassNotFoundException.class), hasProperty("message", containsString("Could not deserialize 1th parameter type of method test(int, ...).")))))));
RemoteRpcInvocation deserializedMethod = serializedMethod.deserializeValue(systemClassLoader);
deserializedMethod.getMethodName();
userClassLoader.close();
}
Aggregations