azagrebin 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_r314248198
 
 

 ##########
 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:
   ok, I see, it is actually about object and class loader test separation.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to