@Test public void resource() throws MalformedURLException { MockServletContext context = new MockServletContext(new File("src/java/test/unit/org/jcatapult/mock/servlet")); URL url = context.getResource("/MockServletContextTest.java"); assertNotNull(url); assertEquals( new File("src/java/test/unit/org/jcatapult/mock/servlet/MockServletContextTest.java") .toURI() .toURL(), url); }
@Test public void resourcePath() throws MalformedURLException { MockServletContext context = new MockServletContext(new File("src/java/test/unit/org/jcatapult/mock/servlet")); Set<String> urls = context.getResourcePaths("/WEB-INF/lib"); assertNotNull(urls); assertTrue(urls.size() > 1); boolean found = false; for (String url : urls) { System.out.println("Checking URL " + url); found |= url.contains("commons-io"); assertTrue(url.startsWith("/WEB-INF/lib")); assertNotNull(context.getResource(url)); assertNotNull(context.getResourceAsStream(url)); } assertTrue(found); }