twalthr commented on code in PR #27605:
URL: https://github.com/apache/flink/pull/27605#discussion_r2919154582
##########
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:
The two newly added tests are very similar. Can we introduce a helper method
to at least a bit reduce code deduplication?
##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/resource/ResourceManagerTest.java:
##########
@@ -248,11 +318,11 @@ public void testRegisterInvalidJarResource() throws
Exception {
CommonTestUtils.assertThrows(
String.format(
- "The registering or unregistering jar resource [%s] is
a directory that is not allowed.",
+ "The registering or unregistering jar or artifact
resource [%s] is a directory that is not allowed.",
Review Comment:
```suggestion
"The registering or unregistering resource [%s] is a
directory that is not allowed.",
```
--
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]