Skip to content

Commit dfa1ec9

Browse files
committed
Adds unit test for canonicalization of resource names in getResource
- Adds .mxkeep file to create the necessary jar entry - Bumps requires mx version to work with .mxkeep
1 parent aadd2fd commit dfa1ec9

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pylint: disable=line-too-long
22
suite = {
3-
"mxversion": "5.316.15",
3+
"mxversion": "5.319.0",
44
"name": "substratevm",
55
"version" : "22.1.0",
66
"release" : False,

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/NativeImageResourceFileSystemProviderTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
8585
// Remove leading / for the resource patterns
8686
registry.addResources(ConfigurationCondition.alwaysTrue(), RESOURCE_FILE_1.substring(1));
8787
registry.addResources(ConfigurationCondition.alwaysTrue(), RESOURCE_FILE_2.substring(1));
88+
registry.addResources(ConfigurationCondition.alwaysTrue(), RESOURCE_DIR.substring(1));
8889

8990
/** Needed for {@link #testURLExternalFormEquivalence()} */
9091
for (Module module : ModuleLayer.boot().modules()) {
@@ -631,4 +632,22 @@ public void testURLExternalFormEquivalence() {
631632
Assert.fail("Contents of original URL and one created from originals ExternalForm must be the same: " + e);
632633
}
633634
}
635+
636+
@Test
637+
public void noCanonicalizationInGetResource() {
638+
Class<?> klass = NativeImageResourceFileSystemProviderTest.class;
639+
URL url = klass.getResource(RESOURCE_DIR + "/");
640+
Assert.assertNotNull(url);
641+
Assert.assertTrue(url.toString().endsWith("/"));
642+
url = klass.getResource(RESOURCE_DIR);
643+
Assert.assertNotNull(url);
644+
Assert.assertFalse(url.toString().endsWith("/"));
645+
url = klass.getResource(RESOURCE_DIR + "/./");
646+
Assert.assertNull(url);
647+
url = klass.getResource(RESOURCE_FILE_1);
648+
Assert.assertNotNull(url);
649+
url = klass.getResource(RESOURCE_FILE_1 + "/");
650+
Assert.assertNull(url);
651+
}
652+
634653
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file instructs mx to create a jar entry for the parent directory

0 commit comments

Comments
 (0)