use of jakarta.faces.webapp.FacesServlet in project mojarra by eclipse-ee4j.
the class FacesServletTestCase method testNegativeInitWithContextParamsOfWildcardHttpMethods.
public void testNegativeInitWithContextParamsOfWildcardHttpMethods() throws Exception {
FacesServlet me = new FacesServlet();
servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "* * * *");
me.init(config);
this.sendRequest(me, "OPTIONS");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "GET");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "HEAD");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "POST");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "PUT");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "DELETE");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "TRACE");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "CONNECT");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "BOO_YA");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}
use of jakarta.faces.webapp.FacesServlet in project mojarra by eclipse-ee4j.
the class FacesInitializer method handleMappingConcerns.
private static void handleMappingConcerns(ServletContext servletContext) throws ServletException {
ServletRegistration existingFacesServletRegistration = getExistingFacesServletRegistration(servletContext);
if (existingFacesServletRegistration != null) {
// FacesServlet has already been defined, so we're not going to add additional mappings.
servletContext.setAttribute(FACES_SERVLET_REGISTRATION, existingFacesServletRegistration);
return;
}
ServletRegistration newFacesServletRegistration = servletContext.addServlet(FacesServlet.class.getSimpleName(), FACES_SERVLET_CLASS_NAME);
if (parseBoolean(servletContext.getInitParameter(FacesServlet.DISABLE_FACESSERVLET_TO_XHTML_PARAM_NAME))) {
newFacesServletRegistration.addMapping(FACES_SERVLET_MAPPINGS_WITHOUT_XHTML);
} else {
newFacesServletRegistration.addMapping(FACES_SERVLET_MAPPINGS_WITH_XHTML);
}
servletContext.setAttribute(FACES_SERVLET_MAPPINGS, newFacesServletRegistration.getMappings());
servletContext.setAttribute(FACES_SERVLET_REGISTRATION, newFacesServletRegistration);
}
use of jakarta.faces.webapp.FacesServlet in project mojarra by eclipse-ee4j.
the class FacesServletTestCase method testPositiveInitWithContextParamsOfKnownHttpMethods.
public void testPositiveInitWithContextParamsOfKnownHttpMethods() throws Exception {
FacesServlet me = new FacesServlet();
servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "GET POST");
me.init(config);
this.sendRequest(me, "OPTIONS");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "GET");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "HEAD");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "POST");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "PUT");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "DELETE");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "TRACE");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
this.sendRequest(me, "CONNECT");
assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
}
use of jakarta.faces.webapp.FacesServlet in project mojarra by eclipse-ee4j.
the class FacesServletTestCase method testPositiveInitWithContextParamsOfWildcardHttpMethods.
public void testPositiveInitWithContextParamsOfWildcardHttpMethods() throws Exception {
FacesServlet me = new FacesServlet();
servletContext.addInitParameter(ALLOWED_HTTP_METHODS_ATTR_COPY, "*");
me.init(config);
this.sendRequest(me, "OPTIONS");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "GET");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "HEAD");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "POST");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "PUT");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "DELETE");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "TRACE");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "CONNECT");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
this.sendRequest(me, "BOO_YA");
assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}
Aggregations