ServletApplicationContext implements ApplicationContext { public ApplicationResource getResource(String localePath) { try { URL url = servletContext.getResource(localePath); if (url != null) { return new URLApplicationResource(localePath, url); } else { return null; } } catch (MalformedURLException e) { return null; } } ServletApplicationContext(ServletContext servletContext); Object getContext(); Map<String, Object> getApplicationScope(); Map<String, String> getInitParams(); ApplicationResource getResource(String localePath); ApplicationResource getResource(ApplicationResource base, Locale locale); Collection<ApplicationResource> getResources(String path);  }
@Test public void testGetResource() throws IOException { URL url = new URL("file: URL urlFr = new URL("file: expect(servletContext.getResource("/my/path.html")).andReturn(url); expect(servletContext.getResource("/my/path_fr.html")).andReturn(urlFr); expect(servletContext.getResource("/null/path.html")).andReturn(null); replay(servletContext); ApplicationResource resource = context.getResource("/my/path.html"); assertNotNull(resource); assertEquals(resource.getLocalePath(), "/my/path.html"); assertEquals(resource.getPath(), "/my/path.html"); assertEquals(Locale.ROOT, resource.getLocale()); ApplicationResource resourceFr = context.getResource(resource, Locale.FRENCH); assertNotNull(resourceFr); assertEquals("/my/path_fr.html", resourceFr.getLocalePath()); assertEquals("/my/path.html", resourceFr.getPath()); assertEquals(Locale.FRENCH, resourceFr.getLocale()); ApplicationResource nullResource = context.getResource("/null/path.html"); assertNull(nullResource); verify(servletContext); }