URLApplicationResource extends PostfixedApplicationResource { @Override public InputStream getInputStream() throws IOException { if (file != null) { return new FileInputStream(file); } else { return openConnection().getInputStream(); } } URLApplicationResource(String localePath, URL url);  URLApplicationResource(String path, Locale locale, URL url); @Override InputStream getInputStream(); @Override long getLastModified(); @Override String toString();  }
@Test public void testGetInputStream() throws IOException { URL url = getClass().getClassLoader().getResource("org/apache/tiles/request/test/locale/resource.txt"); URLApplicationResource resource = new URLApplicationResource("org/apache/tiles/request/test/locale/resource.txt", url); InputStream is = resource.getInputStream(); assertNotNull(is); is.close(); }
@Test public void testGetInputStreamWithSpace() throws IOException { URL url = getClass().getClassLoader().getResource("org/apache/tiles/request/test/locale/resource with space.txt"); URLApplicationResource resource = new URLApplicationResource("org/apache/tiles/request/test/locale/resource with space.txt", url); InputStream is = resource.getInputStream(); assertNotNull(is); is.close(); }
@Test(expected = FileNotFoundException.class) public void testLocalProtocol() throws IOException { URL url = new URL("test1: URLApplicationResource resource = new URLApplicationResource("org/apache/tiles/request/test/locale/resource.txt", url); resource.getInputStream(); }