@Test void getResourceWhenServletContextNotSet() { Throwable exception = assertThrows(RuntimeException.class, () -> { this.environment.getResource("/whatever"); }); assertEquals("The Servlet Environment has not been properly initialized (The Servlet Context is not set)", exception.getMessage()); }
@Override public URL getResource(String resourceName) { URL url; try { url = getServletContext().getResource(resourceName); } catch (MalformedURLException e) { url = null; this.logger.warn("Error getting resource [{}] because of invalid path format. Reason: [{}]", resourceName, e.getMessage()); } return url; }
ServletEnvironment extends AbstractEnvironment { @Override public URL getResource(String resourceName) { URL url; try { url = getServletContext().getResource(resourceName); } catch (MalformedURLException e) { url = null; this.logger.warn("Error getting resource [{}] because of invalid path format. Reason: [{}]", resourceName, e.getMessage()); } return url; } }
ServletEnvironment extends AbstractEnvironment { @Override public URL getResource(String resourceName) { URL url; try { url = getServletContext().getResource(resourceName); } catch (MalformedURLException e) { url = null; this.logger.warn("Error getting resource [{}] because of invalid path format. Reason: [{}]", resourceName, e.getMessage()); } return url; }  }
ServletEnvironment extends AbstractEnvironment { @Override public URL getResource(String resourceName) { URL url; try { url = getServletContext().getResource(resourceName); } catch (MalformedURLException e) { url = null; this.logger.warn("Error getting resource [{}] because of invalid path format. Reason: [{}]", resourceName, e.getMessage()); } return url; }  void setServletContext(ServletContext servletContext); ServletContext getServletContext(); @Override InputStream getResourceAsStream(String resourceName); @Override URL getResource(String resourceName); }
ServletEnvironment extends AbstractEnvironment { @Override public URL getResource(String resourceName) { URL url; try { url = getServletContext().getResource(resourceName); } catch (MalformedURLException e) { url = null; this.logger.warn("Error getting resource [{}] because of invalid path format. Reason: [{}]", resourceName, e.getMessage()); } return url; }  void setServletContext(ServletContext servletContext); ServletContext getServletContext(); @Override InputStream getResourceAsStream(String resourceName); @Override URL getResource(String resourceName);  }