### Question:
UrlPropertyConverter extends AbstractPropertyConverter { @Override public Object convert(String value, Context context) throws IllegalArgumentException { if (value.startsWith(CLASSPATH_SCHEME)) { value = value.substring(CLASSPATH_SCHEME.length()); while (value.startsWith("/")) { value = value.substring(1); } ClassLoader classLoader = (Thread.currentThread().getContextClassLoader() != null) ? Thread.currentThread().getContextClassLoader() : getClass().getClassLoader(); URL url = classLoader.getResource(value); if (url == null) { throw new IllegalArgumentException( "no such resource on classpath: " + value); } return url; } try { return new URL(value); } catch (MalformedURLException ex) { throw new IllegalArgumentException(ex); } }  @Override boolean supports(Class<?> type); @Override Object convert(String value, Context context);  }### Answer:
@Test public void testFileUrl() throws Exception { URL url = new URL("file:/path"); assertThat((URL) converter.convert(url.toString(), null), is(equalTo(url))); }
@Test public void testHttpUrl() throws Exception { URL url = new URL("http: assertThat((URL) converter.convert(url.toString(), null), is(equalTo(url))); }
@Test(expected = IllegalArgumentException.class) public void testMalformedUrl() throws Exception { converter.convert("not a URL", null); }
@Test public void testClasspathUrl() throws Exception { assertThat(converter.convert( "classpath:META-INF/beans.properties", null), is(not(nullValue()))); }
@Test public void testClasspathUrlWithLeadingSlash() throws Exception { assertThat(converter.convert( "classpath:/META-INF/beans.properties", null), is(not(nullValue()))); }
@Test(expected = IllegalArgumentException.class) public void testClasspathUrlWhenResourceNotFound() throws Exception { converter.convert("classpath:DOES_NOT_EXIST", null); }