### Question:
URLPatternParser { public boolean matches(final URL target) { if (elPattern) { return urlElPattern.matcher(target.toURL()).matches(); } else { return urlPattern.toURL().equals(target.toURL()); } } URLPatternParser(final String pattern); boolean matches(final URL target); @Deprecated boolean matches(final String target); List<PathParameter> getPathParameters(); List<PathParameter> parse(final URL url); URL getMappedURL(final Object... params); int getParameterCount(); Object getPattern(); boolean isElPattern();  }### Answer:
@Test public void testMatches() { URLPatternParser parser = new URLPatternParser( "/project/#{paramsBean.project}/#{paramsBean.iteration}/#{paramsBean.story}"); assertTrue(parser.matches(new URL("/project/starfish1/starfish2/story1"))); assertFalse(parser.matches(new URL("project/starfish1/starfish2/story1"))); assertFalse(parser.matches(new URL("/project/starfish1/starfish2/story1/"))); assertFalse(parser.matches(new URL("project/starfish1/starfish2/story1/test"))); assertFalse(parser.matches(new URL("project/starfish2/story1"))); assertFalse(parser.matches(new URL("project/starfish1/starfish2"))); assertFalse(parser.matches(new URL("project/starfish1/starfish2/"))); }
@Test public void testMatchesPrefixedSegmentExpressionInjected() { URLPatternParser parser = new URLPatternParser("/project/#{paramsBean.project}/story-#{paramsBean.story}/"); assertTrue(parser.matches(new URL("/project/starfish/story-1/"))); assertFalse(parser.matches(new URL("/project/starfish/story-1/-"))); assertFalse(parser.matches(new URL("/project/starfish/story-/"))); assertFalse(parser.matches(new URL("project/starfish/story-23/"))); }
@Test public void testMatchesPrefixedSegmentExpressionNamed() { URLPatternParser parser = new URLPatternParser("/project/#{paramsBean.project}/story-#{story}/"); assertTrue(parser.matches(new URL("/project/starfish/story-1/"))); }
@Test public void testMatchesMultipleExpressionNamedSegment() { URLPatternParser parser = new URLPatternParser("/project/#{paramsBean.project}/story-#{story}-#{comment}"); assertTrue(parser.matches(new URL("/project/starfish/story-1-23"))); assertFalse(parser.matches(new URL("/project/starfish/story-1-23/"))); }
@Test public void testMatchesPrefixedSegmentExpressionNamedInjected() { URLPatternParser parser = new URLPatternParser("/project/#{paramsBean.project}/story-#{story:paramsBean.story}/"); assertTrue(parser.matches(new URL("/project/starfish/story-1/"))); }