@Test public void ignore_null_from_get_resource_paths() throws Exception { ServletContext servletContext = newServletContext(); expect(servletContext.getResourcePaths("/foo")).andReturn(null); replay(); List<String> actual = new ContextImpl(servletContext).getResourcePaths("/foo"); assertTrue(actual.isEmpty()); verify(); }
@SuppressWarnings("unchecked") public List<String> getResourcePaths(String path) { List<String> result = CollectionFactory.newList(); Stack<String> queue = CollectionFactory.newStack(); queue.push(path); while (!queue.isEmpty()) { String current = queue.pop(); Set<String> matches = servletContext.getResourcePaths(current); if (matches == null) continue; for (String match : matches) { if (match.endsWith("/")) queue.push(match); else result.add(match); } } Collections.sort(result); return result; }
ContextImpl implements Context { @SuppressWarnings("unchecked") public List<String> getResourcePaths(String path) { List<String> result = CollectionFactory.newList(); Stack<String> queue = CollectionFactory.newStack(); queue.push(path); while (!queue.isEmpty()) { String current = queue.pop(); Set<String> matches = servletContext.getResourcePaths(current); if (matches == null) continue; for (String match : matches) { if (match.endsWith("/")) queue.push(match); else result.add(match); } } Collections.sort(result); return result; } }
ContextImpl implements Context { @SuppressWarnings("unchecked") public List<String> getResourcePaths(String path) { List<String> result = CollectionFactory.newList(); Stack<String> queue = CollectionFactory.newStack(); queue.push(path); while (!queue.isEmpty()) { String current = queue.pop(); Set<String> matches = servletContext.getResourcePaths(current); if (matches == null) continue; for (String match : matches) { if (match.endsWith("/")) queue.push(match); else result.add(match); } } Collections.sort(result); return result; } ContextImpl(ServletContext servletContext); }
ContextImpl implements Context { @SuppressWarnings("unchecked") public List<String> getResourcePaths(String path) { List<String> result = CollectionFactory.newList(); Stack<String> queue = CollectionFactory.newStack(); queue.push(path); while (!queue.isEmpty()) { String current = queue.pop(); Set<String> matches = servletContext.getResourcePaths(current); if (matches == null) continue; for (String match : matches) { if (match.endsWith("/")) queue.push(match); else result.add(match); } } Collections.sort(result); return result; } ContextImpl(ServletContext servletContext); URL getResource(String path); File getRealFile(String path); String getInitParameter(String name); @SuppressWarnings("unchecked") List<String> getResourcePaths(String path); Object getAttribute(String name); List<String> getAttributeNames(); String getMimeType(String file); }
ContextImpl implements Context { @SuppressWarnings("unchecked") public List<String> getResourcePaths(String path) { List<String> result = CollectionFactory.newList(); Stack<String> queue = CollectionFactory.newStack(); queue.push(path); while (!queue.isEmpty()) { String current = queue.pop(); Set<String> matches = servletContext.getResourcePaths(current); if (matches == null) continue; for (String match : matches) { if (match.endsWith("/")) queue.push(match); else result.add(match); } } Collections.sort(result); return result; } ContextImpl(ServletContext servletContext); URL getResource(String path); File getRealFile(String path); String getInitParameter(String name); @SuppressWarnings("unchecked") List<String> getResourcePaths(String path); Object getAttribute(String name); List<String> getAttributeNames(); String getMimeType(String file);  }