### Question:
ValidationRulesServlet extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); Options options = loadOptions(); invalidConfigurationMessage = validate(options); correctlyConfigured = StringUtils.isEmpty(invalidConfigurationMessage); corsAllowOriginPattern = options.getCorsAllowOriginPattern(); parser = new ConstraintParser(options); logConfigurationStatus(); logCorsStatus(); }  @Override void init(ServletConfig config);  }### Answer:
@Test public void shouldThrowExceptionIfNoConfigFileExists() throws ServletException { given(servletConfig.getInitParameter("configFile")).willReturn(""); try { servlet.init(servletConfig); fail("Should throw IllegalArgumentException if no config file exists."); } catch (IllegalArgumentException e) { } }
@Test public void shouldUseCustomConfigFileIfProvided() throws IOException, ServletException { givenThisConfiguration("{\n" + " \"modelPackages\": [\"com.github.valdr.model.b\"],\n" + " \"corsAllowOriginPattern\": \"abc.com\"\n" + "}"); servlet.init(servletConfig); assertThat(ReflectionTestUtils.getField(servlet, "correctlyConfigured").toString(), is("true")); assertThat(ReflectionTestUtils.getField(servlet, "corsAllowOriginPattern").toString(), is("abc.com")); }