@@ -215,94 +215,101 @@ void convertPath2FileURITest() throws URISyntaxException {
215215 class normalize {
216216 @ Test
217217 void throwsOnNull () {
218- assertThrows (IllegalArgumentException .class , () -> normalize (null ));
218+ assertThrows (IllegalArgumentException .class , () -> getNormalizedAbsolutePathOrUri (null ));
219219 }
220220
221+
221222 @ Test
222223 void throwsOnEmpty () {
223- assertThrows (IllegalArgumentException .class , () -> normalize ("" ));
224+ assertThrows (IllegalArgumentException .class , () -> getNormalizedAbsolutePathOrUri ("" ));
224225 }
225226
226227 @ Test
227228 void normalizesRelativeFilesystemPath () {
228229 var input = "foo/../bar/test.txt" ;
229230 var expected = Path .of (input ).toAbsolutePath ().normalize ().toString ();
230- assertEquals (expected , normalize (input ));
231+ assertEquals (expected , getNormalizedAbsolutePathOrUri (input ));
231232 }
232233
233234 @ Test
234235 void normalizesAbsoluteFilesystemPath () {
235236 var input = Path .of ("foo" , ".." , "bar" ).toAbsolutePath ().toString ();
236237 var expected = Path .of (input ).toAbsolutePath ().normalize ().toString ();
237- assertEquals (expected , normalize (input ));
238+ assertEquals (expected , getNormalizedAbsolutePathOrUri (input ));
238239 }
239240
240241 @ Test
241242 void normalizesFileUri () {
242- assertEquals ("file:/test.xml" , normalize ("file:///tmp/../test.xml" ));
243+ assertEquals ("file:/test.xml" , getNormalizedAbsolutePathOrUri ("file:///tmp/../test.xml" ));
243244 }
244245
245246 @ Test
246247 void normalizesHttpUri () {
247- assertEquals ("http://example.com/b/wsdl.xsd" , normalize ("http://example.com/a/../b/wsdl.xsd" ));
248+ assertEquals ("http://example.com/b/wsdl.xsd" , getNormalizedAbsolutePathOrUri ("http://example.com/a/../b/wsdl.xsd" ));
248249 }
249250
251+ @ Test
252+ void normalizesHttpUriWithQuery () {
253+ assertEquals ("http://example.com/b/wsdl.xsd?a=a/../b" , getNormalizedAbsolutePathOrUri ("http://example.com/a/../b/wsdl.xsd?a=a/../b" ));
254+ }
255+
256+
250257 @ Test
251258 void classpathUri () {
252259 // The '..' within the path portion normalizes correctly.
253- assertEquals ("classpath://authority/xsd/test.xsd" , normalize ("classpath://authority/schema/../xsd/test.xsd" ));
260+ assertEquals ("classpath://authority/xsd/test.xsd" , getNormalizedAbsolutePathOrUri ("classpath://authority/schema/../xsd/test.xsd" ));
254261 }
255262
256263 @ Test
257264 void keepsClasspathUri () {
258265 // The '..' at the start of the path (after authority) cannot traverse above the authority, so it's preserved.
259- assertEquals ("classpath://authority/../xsd/test.xsd" , normalize ("classpath://authority/../xsd/test.xsd" ));
266+ assertEquals ("classpath://authority/../xsd/test.xsd" , getNormalizedAbsolutePathOrUri ("classpath://authority/../xsd/test.xsd" ));
260267 }
261268
262269 @ Test
263270 void normalizesUnixLikePath () {
264271 var input = "/tmp/../var/data.xsd" ;
265272 var expected = Path .of (input ).toAbsolutePath ().normalize ().toString ();
266- assertEquals (expected , normalize (input ));
273+ assertEquals (expected , getNormalizedAbsolutePathOrUri (input ));
267274 }
268275
269276 @ Test
270277 @ EnabledOnOs (WINDOWS )
271278 void handlesWindowsDriveLetterPath () {
272279 var input = "C:\\ temp\\ ..\\ data\\ test.xsd" ;
273280 var expected = Path .of (input ).toAbsolutePath ().normalize ().toString ();
274- assertEquals (expected , normalize (input ));
281+ assertEquals (expected , getNormalizedAbsolutePathOrUri (input ));
275282 }
276283
277284 @ Test
278285 @ EnabledOnOs (WINDOWS )
279286 void handlesWindowsDriveRelativePath () {
280287 var input = "C:temp\\ ..\\ data\\ test.xsd" ;
281288 var expected = Path .of (input ).toAbsolutePath ().normalize ().toString ();
282- assertEquals (expected , normalize (input ));
289+ assertEquals (expected , getNormalizedAbsolutePathOrUri (input ));
283290 }
284291
285292 @ Test
286293 void keepsRelativeUriWithQuery () {
287- assertEquals ("schema.xsd?version=1" , normalize ("schema.xsd?version=1" )
294+ assertEquals ("schema.xsd?version=1" , getNormalizedAbsolutePathOrUri ("schema.xsd?version=1" )
288295 );
289296 }
290297
291298 @ Test
292299 void keepsRelativeUriWithFragment () {
293- assertEquals ("../types.xsd#frag" , normalize ("../types.xsd#frag" )
300+ assertEquals ("../types.xsd#frag" , getNormalizedAbsolutePathOrUri ("../types.xsd#frag" )
294301 );
295302 }
296303
297304 @ Test
298305 void keepsRelativeUriWithQueryAndFragment () {
299- assertEquals ("../types.xsd?version=1#frag" , normalize ("../types.xsd?version=1#frag" )
306+ assertEquals ("../types.xsd?version=1#frag" , getNormalizedAbsolutePathOrUri ("../types.xsd?version=1#frag" )
300307 );
301308 }
302309
303310 @ Test
304311 void keepsSchemeRelativeReference () {
305- assertEquals ("//example.com/schema.xsd?version=1" , normalize ("//example.com/schema.xsd?version=1" ));
312+ assertEquals ("//example.com/schema.xsd?version=1" , getNormalizedAbsolutePathOrUri ("//example.com/schema.xsd?version=1" ));
306313 }
307314 }
308315}
0 commit comments