autophagy commented on code in PR #27605:
URL: https://github.com/apache/flink/pull/27605#discussion_r2923510994


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/resource/ResourceManagerTest.java:
##########
@@ -141,6 +150,67 @@ public void testRegisterJarResource() throws Exception {
         assertEquals(clazz1, clazz2);
     }
 
+    @Test
+    public void testRegisterArtifactResource() throws Exception {
+        URLClassLoader userClassLoader = resourceManager.getUserClassLoader();
+
+        // test class loading before register resource
+        CommonTestUtils.assertThrows(
+                "LowerUDF",
+                ClassNotFoundException.class,
+                () -> Class.forName(GENERATED_LOWER_UDF_CLASS, false, 
userClassLoader));
+
+        ResourceUri resourceUri = new ResourceUri(ResourceType.ARTIFACT, 
udfArtifact.getPath());
+        // register the same artifact repeatedly
+        resourceManager.registerResources(Arrays.asList(resourceUri, 
resourceUri));
+
+        // assert resource infos
+        Map<ResourceUri, URL> expected =
+                Collections.singletonMap(
+                        resourceUri,
+                        resourceManager.getURLFromPath(new 
Path(udfArtifact.getPath())));
+
+        assertEquals(expected, resourceManager.getResources());
+
+        // test load class
+        final Class<?> clazz1 = Class.forName(GENERATED_LOWER_UDF_CLASS, 
false, userClassLoader);
+        final Class<?> clazz2 = Class.forName(GENERATED_LOWER_UDF_CLASS, 
false, userClassLoader);
+
+        assertEquals(clazz1, clazz2);
+    }
+
+    @Test
+    public void testRegisterMixedResources() throws Exception {

Review Comment:
   I think since the mixed test duplicates the testing criteria of both, the 
jar/artifact specific ones can be removed.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to