Package org.springframework.springfaces.mvc.render

Examples of org.springframework.springfaces.mvc.render.ViewArtifact


  }

  @Test
  public void shouldGetHandlerWhenHasState() throws Exception {
    setupFacesHandlerInterceptor();
    ViewArtifact viewArtifact = new ViewArtifact("artifact");
    given(this.stateHandler.read(this.request)).willReturn(viewArtifact);
    HandlerExecutionChain handler = this.postbackHandler.getHandler(this.request);
    Postback postback = (Postback) handler.getHandler();
    assertThat(postback, is(not(nullValue())));
    assertThat(postback.getHandler(), is(this.originalHandler));
View Full Code Here


  }

  @Test
  @SuppressWarnings("unchecked")
  public void shouldRenderOnHandle() throws Exception {
    ViewArtifact viewArtifact = new ViewArtifact("artifact");
    Postback handler = new Postback(viewArtifact, this.originalHandler);
    HttpServletResponse response = mock(HttpServletResponse.class);
    ModelAndView result = this.postbackHandler.handle(this.request, response, handler);
    verify(this.springFacesContext).render(this.viewCaptor.capture(), (Map<String, Object>) isNull());
    assertThat(((FacesView) this.viewCaptor.getValue()).getViewArtifact(), is(viewArtifact));
View Full Code Here

  @Test
  public void shouldGetBeanFactoryFromSpringFacesContext() throws Exception {
    SpringFacesContextSetter.setCurrentInstance(this.springFacesContext);
    try {
      ViewArtifact viewArtifact = new ViewArtifact("artifact");
      ModelAndViewArtifact rendering = new ModelAndViewArtifact(viewArtifact, null);
      given(this.springFacesContext.getRendering()).willReturn(rendering);
      WebApplicationContext applicationContext = mock(WebApplicationContext.class);
      given(this.springFacesContext.getWebApplicationContext()).willReturn(applicationContext);
      assertThat(this.resolver.getBeanFactory(this.elContext), is(sameInstance((Object) applicationContext)));
View Full Code Here

  }

  @Test
  public void shouldCallStateHandler() throws Exception {
    SpringFacesContextSetter.setCurrentInstance(this.springFacesContext);
    ViewArtifact viewArtifact = new ViewArtifact("page.xhtml");
    ModelAndViewArtifact rendering = new ModelAndViewArtifact(viewArtifact, null);
    given(this.springFacesContext.getRendering()).willReturn(rendering);
    this.stateManager.setRenderKitId("HTML_BASIC");
    this.stateManager.writeState(this.context, this.state);
    verify(this.stateHandler).write(this.context, viewArtifact);
View Full Code Here

  @Override
  public void writeState(FacesContext context, Object state) throws IOException {
    if (SpringFacesContext.getCurrentInstance() != null
        && SpringFacesContext.getCurrentInstance().getRendering() != null
        && RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(this.renderKitId)) {
      ViewArtifact viewArtifact = SpringFacesContext.getCurrentInstance().getRendering().getViewArtifact();
      this.stateHandler.write(context, viewArtifact);
    }
    super.writeState(context, state);
  }
View Full Code Here

    assertThat(this.initializedSpringFacesContextHandler, is(sameInstance(this.handler)));
  }

  @Test
  public void shouldPreHandlePostback() throws Exception {
    ViewArtifact viewArtifact = new ViewArtifact("test");
    Postback postback = new Postback(viewArtifact, this.handler);
    boolean proceed = this.interceptor.preHandle(this.request, this.response, postback);
    assertThat(proceed, is(true));
    assertThat(this.initializedSpringFacesContextHandler, is(sameInstance(this.handler)));
  }
View Full Code Here

  }

  @Test
  public void shouldCreateWithViewArtifact() throws Exception {
    String artifact = "/WEB-INF/pages/page.xhtml";
    ViewArtifact viewArtifact = new ViewArtifact(artifact);
    FacesView view = new FacesView(viewArtifact);
    assertThat(view.getUrl(), is(artifact));
  }
View Full Code Here

  @Test
  public void shouldGetViewArtifactFromUrl() throws Exception {
    FacesView view = new FacesView();
    view.setUrl("artifact");
    assertThat(view.getViewArtifact(), is(equalTo(new ViewArtifact("artifact"))));
  }
View Full Code Here

  }

  @Test
  public void shouldRenderFacesView() throws Exception {
    FacesView view = mock(FacesView.class);
    given(view.getViewArtifact()).willReturn(new ViewArtifact("artifact"));
    Map<String, Object> model = new HashMap<String, Object>();
    Lifecycle lifecycle = mock(Lifecycle.class);
    given(this.lifecycleAccessor.getLifecycle()).willReturn(lifecycle);
    this.springFacesContext.render(view, model);
    verify(lifecycle).execute(this.facesContextCaptor.capture());
View Full Code Here

  }

  @Test
  public void shouldHaveRenderingWhenRendering() throws Exception {
    FacesView view = mock(FacesView.class);
    given(view.getViewArtifact()).willReturn(new ViewArtifact("artifact"));
    Map<String, Object> model = new HashMap<String, Object>();
    final ModelAndViewArtifact modelAndViewArtifact = new ModelAndViewArtifact("artifact", model);
    Lifecycle lifecycle = mock(Lifecycle.class);
    given(this.lifecycleAccessor.getLifecycle()).willReturn(lifecycle);
    willAnswer(new Answer<Object>() {
View Full Code Here

TOP

Related Classes of org.springframework.springfaces.mvc.render.ViewArtifact

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.