HTTP_URI_Parser extends URI_Parser { public static HTTP_URI_Parser buildParser(final String uri) throws NoSuchAuthorityCodeException { String uriText = uri.trim(); int length = BASE_URI.length(); if (uriText.regionMatches(true, 0, BASE_URI, 0, length)) { String[] segments = uriText.substring(length).split(SEPARATOR); if (segments.length == 4 && !segments[0].isEmpty()) { URI_Type uriType = URI_Type.get(segments[0]); if (uriType != null && !segments[1].isEmpty() && !segments[2].isEmpty() && !segments[3].isEmpty()) { String uriAuthority = segments[1]; Version uriVersion = segments[2].equals(UNVERSIONED) ? null : new Version( segments[2]); String uriCode = segments[3]; return new HTTP_URI_Parser(uriText, uriType, uriAuthority, uriVersion, uriCode); } } } throw new NoSuchAuthorityCodeException( Errors.format(ErrorKeys.ILLEGAL_ARGUMENT_$1, uriText), AUTHORITY, uriText); } protected  HTTP_URI_Parser(String uri, URI_Type type, String authority, Version version,
            String code); static HTTP_URI_Parser buildParser(final String uri);  }
@Test public void testParseUnversioned() throws NoSuchAuthorityCodeException { URI_Parser parser = HTTP_URI_Parser .buildParser("http: assertEquals("crs", parser.type.name); assertEquals("EPSG", parser.authority); assertNull(parser.version); assertEquals("4326", parser.code); assertEquals("EPSG:4326", parser.getAuthorityCode()); }
@Test public void testParseVersioned() throws NoSuchAuthorityCodeException { URI_Parser parser = HTTP_URI_Parser .buildParser("http: 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()); }
@Test public void testParseMissingVersion() { String uri = "http: try { HTTP_URI_Parser.buildParser(uri); fail(); } catch (NoSuchAuthorityCodeException e) { assertEquals(uri, e.getAuthorityCode()); } }
@Test public void testParseInvalidType() { String uri = "http: try { HTTP_URI_Parser.buildParser(uri); fail(); } catch (NoSuchAuthorityCodeException e) { assertEquals(uri, e.getAuthorityCode()); } }