/** * @see * org.geotools.referencing.factory.Abstract_URI_AuthorityFactory#buildParser(java.lang.String) */ @Override protected URI_Parser buildParser(String code) throws NoSuchAuthorityCodeException { return HTTP_URI_Parser.buildParser(code); } }
segments[2].equals(UNVERSIONED) ? null : new Version(segments[2]); String uriCode = segments[3]; return new HTTP_URI_Parser(uriText, uriType, uriAuthority, uriVersion, uriCode);
/** Test that an HTTP URI with missing version results in the expected exception. */ @Test public void testParseMissingVersion() { String uri = "http://www.opengis.net/def/crs/EPSG/4326"; try { HTTP_URI_Parser.buildParser(uri); fail(); } catch (NoSuchAuthorityCodeException e) { assertEquals(uri, e.getAuthorityCode()); } }
/** Test that an HTTP URI with an invalid type results in the expected exception. */ @Test public void testParseInvalidType() { String uri = "http://www.opengis.net/def/does-not-exist/EPSG/0/4326"; try { HTTP_URI_Parser.buildParser(uri); fail(); } catch (NoSuchAuthorityCodeException e) { assertEquals(uri, e.getAuthorityCode()); } } }
/** Test that an unversioned HTTP URI can be parsed. */ @Test public void testParseUnversioned() throws NoSuchAuthorityCodeException { URI_Parser parser = HTTP_URI_Parser.buildParser("http://www.opengis.net/def/crs/EPSG/0/4326"); assertEquals("crs", parser.type.name); assertEquals("EPSG", parser.authority); assertNull(parser.version); assertEquals("4326", parser.code); assertEquals("EPSG:4326", parser.getAuthorityCode()); }
/** Test that an versioned HTTP URI can be parsed. */ @Test public void testParseVersioned() throws NoSuchAuthorityCodeException { URI_Parser parser = HTTP_URI_Parser.buildParser("http://www.opengis.net/def/crs/EPSG/6.11.2/4326"); assertEquals("crs", parser.type.name); assertEquals("EPSG", parser.authority); assertEquals("6.11.2", parser.version.toString()); assertEquals("4326", parser.code); assertEquals("EPSG:4326", parser.getAuthorityCode()); }