File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed
substratevm/src/com.oracle.svm.test/src Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 2626package com .oracle .svm .test ;
2727
2828import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_DIR ;
29+ import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_DIR_WITH_SPACE ;
2930import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_EMPTY_DIR ;
3031import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_FILE_1 ;
3132import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_FILE_2 ;
@@ -231,6 +232,20 @@ public void queryEmptyDir() {
231232 }
232233 }
233234
235+ /**
236+ * Query a directory with spaces in its name
237+ */
238+ @ Test
239+ public void queryDirWithSpaces () {
240+ Path dirWithSpaces = fileSystem .getPath (RESOURCE_DIR_WITH_SPACE );
241+ try (Stream <Path > stream = Files .walk (dirWithSpaces )) {
242+ Assert .assertEquals (1 , stream .count ());
243+ } catch (IOException e ) {
244+ e .printStackTrace ();
245+ Assert .fail ("IOException occurred during file system walk, starting from the root." );
246+ }
247+ }
248+
234249 /**
235250 * Reading from file using {@link java.nio.channels.ByteChannel}.
236251 */
Original file line number Diff line number Diff line change 2626package com .oracle .svm .test ;
2727
2828import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_DIR ;
29+ import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_DIR_WITH_SPACE ;
2930import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_FILE_1 ;
3031import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_FILE_2 ;
3132import static com .oracle .svm .test .NativeImageResourceUtils .RESOURCE_FILE_3 ;
@@ -131,6 +132,19 @@ public void classGetDirectoryResource() {
131132 resourceNameToURL (nonCanonicalResourceDirectoryName , false );
132133 }
133134
135+ @ Test
136+ public void classGetDirectoryWithSpaceResource () {
137+ URL url1 = resourceNameToURL (RESOURCE_DIR_WITH_SPACE + "/" , true );
138+ Assert .assertTrue ("The URL should end with slash!" , url1 .toString ().endsWith ("/" ));
139+
140+ URL url2 = resourceNameToURL (RESOURCE_DIR_WITH_SPACE , true );
141+ Assert .assertFalse ("The URL should not end with slash!" , url2 .toString ().endsWith ("/" ));
142+ Assert .assertTrue ("Two URLs must be the same!" , compareTwoURLs (url1 , url2 ));
143+
144+ String nonCanonicalResourceDirectoryName = RESOURCE_DIR_WITH_SPACE + "/./" ;
145+ resourceNameToURL (nonCanonicalResourceDirectoryName , false );
146+ }
147+
134148 @ Test
135149 public void registeredResourceDirectoryHasContent () throws IOException {
136150 URL directory = NativeImageResourceUtils .class .getResource (SIMPLE_RESOURCE_DIR );
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ public class NativeImageResourceUtils {
4444 public static final String RESOURCE_DIR = "/resources" ;
4545 public static final String SIMPLE_RESOURCE_DIR = "/simpleDir" ;
4646 public static final String RESOURCE_EMPTY_DIR = RESOURCE_DIR + "/empty" ;
47+ public static final String RESOURCE_DIR_WITH_SPACE = RESOURCE_DIR + "/dir with space" ;
4748 public static final String RESOURCE_FILE_1 = RESOURCE_DIR + "/resource-test1.txt" ;
4849 public static final String RESOURCE_FILE_2 = RESOURCE_DIR + "/resource-test2.txt" ;
4950 public static final String RESOURCE_FILE_3 = RESOURCE_DIR + "/resource-test3.html" ;
@@ -58,6 +59,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
5859 RuntimeResourceAccess .addResource (resourceModule , RESOURCE_DIR .substring (1 ));
5960 RuntimeResourceAccess .addResource (resourceModule , SIMPLE_RESOURCE_DIR .substring (1 ));
6061 RuntimeResourceAccess .addResource (resourceModule , RESOURCE_EMPTY_DIR .substring (1 ));
62+ RuntimeResourceAccess .addResource (resourceModule , RESOURCE_DIR_WITH_SPACE .substring (1 ));
6163 RuntimeResourceAccess .addResource (resourceModule , RESOURCE_FILE_1 .substring (1 ));
6264 RuntimeResourceAccess .addResource (resourceModule , RESOURCE_FILE_2 .substring (1 ));
6365 RuntimeResourceAccess .addResource (resourceModule , RESOURCE_FILE_3 .substring (1 ));
Original file line number Diff line number Diff line change 1+ This file instructs mx to create a jar entry for the parent directory
You can’t perform that action at this time.
0 commit comments