zentol commented on a change in pull request #9258: [FLINK-13460][tests] Rework
SerializedThrowableTest to not use Unsafe#defineClass()
URL: https://github.com/apache/flink/pull/9258#discussion_r314187741
##########
File path:
flink-test-utils-parent/flink-test-utils-junit/src/test/java/org/apache/flink/core/testutils/CommonTestUtilsTest.java
##########
@@ -45,7 +47,29 @@ public void testObjectFromNewClassLoaderObject() throws
Exception {
@Test
public void testObjectFromNewClassLoaderClassLoaders() throws Exception
{
- final CommonTestUtils.ObjectAndClassLoader objectAndClassLoader
= CommonTestUtils.createObjectFromNewClassLoader();
+ final CommonTestUtils.ObjectAndClassLoader<Serializable>
objectAndClassLoader =
CommonTestUtils.createSerializableObjectFromNewClassLoader();
+
+ assertNotEquals(ClassLoader.getSystemClassLoader(),
objectAndClassLoader.getClassLoader());
+ assertEquals(ClassLoader.getSystemClassLoader(),
objectAndClassLoader.getClassLoader().getParent());
+ }
+
+ @Test
+ public void testExceptionObjectFromNewClassLoaderObject() throws
Exception {
+ final CommonTestUtils.ObjectAndClassLoader<Exception>
objectAndClassLoader =
CommonTestUtils.createExceptionObjectFromNewClassLoader();
+ final Object o = objectAndClassLoader.getObject();
+
+ assertNotEquals(ClassLoader.getSystemClassLoader(),
o.getClass().getClassLoader());
+
+ try {
+ Class.forName(o.getClass().getName());
+ fail("should not be able to load class from the system
class loader");
Review comment:
it's actually quite useful as a separate test, since you see at a glance
whether the core assumption holds or not.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services