Package org.springframework.boot.context.embedded

Examples of org.springframework.boot.context.embedded.ErrorPage


    @Configuration
    public static class ErrorConfig implements EmbeddedServletContainerCustomizer {

        @Override
        public void customize(ConfigurableEmbeddedServletContainer factory) {
            factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/404"));
            factory.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500"));
        }
View Full Code Here


    assertThat(this.response.getForwardedUrl(), is(nullValue()));
  }

  @Test
  public void unauthorizedWithErrorPath() throws Exception {
    this.filter.addErrorPages(new ErrorPage("/error"));
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
        ((HttpServletResponse) response).sendError(401, "UNAUTHORIZED");
View Full Code Here

    assertThat(this.response.getForwardedUrl(), equalTo("/error"));
  }

  @Test
  public void responseCommitted() throws Exception {
    this.filter.addErrorPages(new ErrorPage("/error"));
    this.response.setCommitted(true);
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
View Full Code Here

    this.filter.doFilter(this.request, this.response, this.chain);
  }

  @Test
  public void globalError() throws Exception {
    this.filter.addErrorPages(new ErrorPage("/error"));
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
        ((HttpServletResponse) response).sendError(400, "BAD");
View Full Code Here

    assertThat(this.response.getForwardedUrl(), equalTo("/error"));
  }

  @Test
  public void statusError() throws Exception {
    this.filter.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400"));
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
        ((HttpServletResponse) response).sendError(400, "BAD");
View Full Code Here

    assertThat(this.response.getForwardedUrl(), equalTo("/400"));
  }

  @Test
  public void statusErrorWithCommittedResponse() throws Exception {
    this.filter.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400"));
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
        ((HttpServletResponse) response).sendError(400, "BAD");
View Full Code Here

    assertThat(this.response.getForwardedUrl(), is(nullValue()));
  }

  @Test
  public void exceptionError() throws Exception {
    this.filter.addErrorPages(new ErrorPage(RuntimeException.class, "/500"));
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
        super.doFilter(request, response);
View Full Code Here

    assertThat(this.response.getForwardedUrl(), equalTo("/500"));
  }

  @Test
  public void exceptionErrorWithCommittedResponse() throws Exception {
    this.filter.addErrorPages(new ErrorPage(RuntimeException.class, "/500"));
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
        super.doFilter(request, response);
View Full Code Here

        equalTo(200));
  }

  @Test
  public void subClassExceptionError() throws Exception {
    this.filter.addErrorPages(new ErrorPage(RuntimeException.class, "/500"));
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
        super.doFilter(request, response);
View Full Code Here

  }

  @Test
  public void responseIsCommitedWhenRequestIsAsyncAndExceptionIsThrown()
      throws Exception {
    this.filter.addErrorPages(new ErrorPage("/error"));
    this.request.setAsyncStarted(true);
    this.chain = new MockFilterChain() {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response)
          throws IOException, ServletException {
View Full Code Here

TOP

Related Classes of org.springframework.boot.context.embedded.ErrorPage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.