/** Test that a query is ignored */ @Test public void queryIgnored() { String path = AppSchemaResolver.getSimpleHttpResourcePath( "http://schemas.example.org/exampleml/exml.xsd?q=ignored"); Assert.assertEquals("/org/example/schemas/exampleml/exml.xsd", path); }
/** Test GeoSciML 2.0 canonical URL is correctly converted into a classpath URL. */ @Test public void geosciml20() { String path = AppSchemaResolver.getSimpleHttpResourcePath( "http://www.geosciml.org/geosciml/2.0/xsd/geosciml.xsd"); Assert.assertEquals(path, "/org/geosciml/www/geosciml/2.0/xsd/geosciml.xsd"); String classpathPath = AppSchemaResolver.class.getResource(path).toExternalForm(); Assert.assertTrue(classpathPath.startsWith("jar:file:/")); Assert.assertTrue(classpathPath.endsWith("!/org/geosciml/www/geosciml/2.0/xsd/geosciml.xsd")); }
/** Test that a URL not http/https return null. */ @Test public void badlyFormattedUrlReturnsNull() { Assert.assertNull( AppSchemaResolver.getSimpleHttpResourcePath( "http://schemas.example.org/" + "exampleml/with spaces/exml.xsd")); }
/** Test that a jar URL (not http/https) returns null. */ @Test public void jarReturnsNull() { Assert.assertNull( AppSchemaResolver.getSimpleHttpResourcePath( "jar:file:example.jar" + "!/org/example/schemas/exampleml/exml.xsd")); }
/** Test that an ftp URL (not http/https) returns null. */ @Test public void ftpReturnsNull() { Assert.assertNull( AppSchemaResolver.getSimpleHttpResourcePath( "ftp://schemas.example.org/exampleml/exml.xsd")); }