Example #1
0
  public String getReleaseResult2() {
    try {
      FacesContext currentContext = FacesContext.getCurrentInstance();
      ExternalContextImpl externalContext =
          new ExternalContextImpl(
              (ServletContext) currentContext.getExternalContext().getContext(),
              (HttpServletRequest) currentContext.getExternalContext().getRequest(),
              (HttpServletResponse) currentContext.getExternalContext().getResponse());
      LifecycleImpl lifecycle = new LifecycleImpl();

      FacesContextImpl context = new FacesContextImpl(externalContext, lifecycle);

      context.release();
      boolean exceptionThrown = false;
      try {
        context.getViewRoot();
      } catch (IllegalStateException ise) {
        exceptionThrown = true;
      }
      assertTrue(exceptionThrown);

      exceptionThrown = false;
      try {
        context.getResponseStream();
      } catch (IllegalStateException ise) {
        exceptionThrown = true;
      }

      exceptionThrown = false;
      try {
        context.getResponseWriter();
      } catch (IllegalStateException ise) {
        exceptionThrown = true;
      }
      assertTrue(exceptionThrown);

    } catch (NullPointerException exception) {
      exception.printStackTrace();
      fail();
    }

    return "PASSED";
  }