### Question:
MavenUrl { public static MavenUrl parse( String url, TextDecoder decoder ) { if (decoder == null) decoder = new UrlEncoder(); Pattern urlPattern = Pattern.compile("jcr:( Matcher matcher = urlPattern.matcher(url); MavenUrl result = null; if (matcher.find()) { result = new MavenUrl(); result.setHostname(matcher.group(3)); String portStr = matcher.group(5); if (portStr != null && portStr.trim().length() != 0) { result.setPort(Integer.parseInt(portStr)); } String workspaceName = decoder.decode(matcher.group(6)); String path = decoder.decode(matcher.group(7)); result.setWorkspaceName(workspaceName); result.setPath(path); } return result; }  String getHostname(); void setHostname( String hostname ); int getPort(); void setPort( int port ); String getHostnameAndPort(); String getWorkspaceName(); void setWorkspaceName( String workspaceName ); String getPath(); void setPath( String path ); URL getUrl( URLStreamHandler handler,
                       TextEncoder encoder ); @Override String toString(); static MavenUrl parse( String url,
                                  TextDecoder decoder ); static MavenUrl parse( URL url,
                                  TextDecoder decoder ); static final int NO_PORT; static final String JCR_PROTOCOL; }### Answer:
@Test public void shouldParseUrlsWithValidFormat() throws Exception { parse("jcr: parse("jcr: parse("jcr: parse("jcr: parse("jcr: parse("jcr: parse("jcr: parse("jcr: parse("jcr: parse("jcr:/workspaceName/path/to/node/x", "", MavenUrl.NO_PORT, "workspaceName", "/path/to/node/x", "jcr:/workspaceName/path/to/node/x"); parse("jcr: }
@Test public void shouldNotParseUrlsWithInvalidFormat() { assertThat(MavenUrl.parse("http: }