/** * {@inheritDoc} */ @Override public void init(final ServletConfig servletConfig) throws ServletException { this.servletConfig = servletConfig; init(); }
@Test public void shouldProvideContextAfterInitialization() throws ServletException { HttpServlet httpServlet = new SampleServlet(); ServletContext servletContext = mock(ServletContext.class); ServletConfig servletConfig = new ServletConfigImpl(servletContext); httpServlet.init(servletConfig); assertThat(httpServlet.getServletInfo(), is("")); assertThat(httpServlet.getServletContext(), is(equalTo(servletContext))); httpServlet.destroy(); }
@Test public void shouldProvideDefaultValues() { HttpServlet httpServlet = new SampleServlet(); assertThat(httpServlet.getServletInfo(), is("")); assertThat(httpServlet.getServletContext(), is(nullValue())); httpServlet.destroy(); }
@Override public void destroy() { super.destroy(); destroyedCounter++; }
@Override public void init() throws ServletException { super.init(); initializedCounter++; }