List of usage examples for java.net URL sameFile
public boolean sameFile(URL other)
Returns true if this URL and the other argument are equal without taking the fragment component into consideration.
From source file:org.n52.youngs.test.DirectorySourceTestDisabled.java
@Test public void fileUrl() throws MalformedURLException { DirectorySource source = new DirectorySource(baseDirectory.resolve("csw")); URL endpoint = source.getEndpoint(); // probably everything is already good at this point assertThat("beginning of url is file:/", endpoint.toExternalForm(), startsWith("file:/")); assertThat("end of url is directories", endpoint.getPath(), endsWith("records/csw/")); assertThat("file is correct", endpoint.sameFile(baseDirectory.resolve("csw").toFile().toURI().toURL()), is(true));//from ww w .j a v a2 s. c om }
From source file:org.webical.test.plugin.classloading.PluginClassLoaderTest.java
/** * Tests resource loading from the classpath */// w w w . java2s. co m public void testResourceLoading() { File resourceFile = new File(getClass().getResource("test-resource.txt").getFile()); log.info("testResourceLoading:File " + resourceFile.toString()); try { classLoader.addClassPathResourceRegistration( ClassUtils.fileToClassPathResourceIdentifier(resourceFile.getParentFile(), resourceFile), resourceFile); } catch (DuplicateClassPathEntryException e) { fail("What is it with those duplicates..."); } URL resourceUrl = classLoader.findResource("test-resource.txt"); log.info("testResourceLoading:URL " + resourceUrl.toString()); try { if (resourceUrl == null || !resourceUrl.sameFile(resourceFile.toURI().toURL())) { fail("Could not successfully load the resource"); } } catch (MalformedURLException e) { fail("Malformed url registered used"); } }