Package org.ajax4jsf.tests

Examples of org.ajax4jsf.tests.MockComponentState


    * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createComponentState()
    */
    protected DataComponentState createComponentState() {

        // TODO Auto-generated method stub
        return new MockComponentState();
    }
View Full Code Here


     * Test method for {@link org.ajax4jsf.component.UIDataAdaptor#iterate(javax.faces.context.FacesContext, org.ajax4jsf.ajax.repeat.RepeaterInvoker)}.
     */
    public void testProcess() {
        createTree();

        MockComponentState mockState = (MockComponentState) adaptor.getComponentState();

        mockState.setCount(4);
        adaptor.processDecodes(facesContext);
        assertEquals(childInvoked, 4);
        assertEquals(facetInvoked, 1);
    }
View Full Code Here

     * Test method for {@link org.ajax4jsf.component.UIDataAdaptor#iterate(javax.faces.context.FacesContext, org.ajax4jsf.ajax.repeat.RepeaterInvoker)}.
     */
    public void testProcessMore() {
        createTree();

        MockComponentState mockState = (MockComponentState) adaptor.getComponentState();

        mockState.setCount(Integer.MAX_VALUE);
        adaptor.processDecodes(facesContext);
        assertEquals(childInvoked, MockDataModel.ROWS);
        assertEquals(facetInvoked, 1);
    }
View Full Code Here

     * @throws InstantiationException
     */
    public void testRestoreStateFacesContextObject() throws Exception {
        createTree();

        MockComponentState mockState = (MockComponentState) adaptor.getComponentState();

        mockState.setCount(123);
        adaptor.encodeBegin(facesContext);

        UIViewRoot viewRoot = facesContext.getViewRoot();
        Object treeState = viewRoot.processSaveState(facesContext);
        UIViewRoot root = (UIViewRoot) viewRoot.getClass().newInstance();
        UIDataAdaptor restoredAdaptor = new MockDataAdaptor();

        root.getChildren().add(restoredAdaptor);
        root.processRestoreState(facesContext, treeState);
        mockState = (MockComponentState) restoredAdaptor.getComponentState();
        assertEquals(mockState.getCount(), 123);
    }
View Full Code Here

     */
    public void testSaveStateFacesContext() throws Exception {
        createDataTree();
        data.setRowIndex(0);

        MockComponentState mockState = (MockComponentState) adaptor.getComponentState();

        mockState.setCount(123);
        adaptor.encodeBegin(facesContext);
        data.setRowIndex(1);
        mockState = (MockComponentState) adaptor.getComponentState();
        mockState.setCount(321);
        adaptor.encodeBegin(facesContext);

        UIViewRoot viewRoot = facesContext.getViewRoot();
        Object treeState = viewRoot.processSaveState(facesContext);
        UIViewRoot root = (UIViewRoot) viewRoot.getClass().newInstance();
        UIData restoredData = new UIData();
        UIDataAdaptor restoredAdaptor = new MockDataAdaptor();

        root.getChildren().add(restoredData);

        UIColumn column = new UIColumn();

        restoredData.getChildren().add(column);
        column.getChildren().add(restoredAdaptor);
        root.processRestoreState(facesContext, treeState);
        restoredData.setRowIndex(0);
        mockState = (MockComponentState) restoredAdaptor.getComponentState();
        assertEquals(123, mockState.getCount());
        restoredData.setRowIndex(1);
        mockState = (MockComponentState) restoredAdaptor.getComponentState();
        assertEquals(321, mockState.getCount());
    }
View Full Code Here

  /**
   * Test method for {@link org.ajax4jsf.component.UIDataAdaptor#iterate(javax.faces.context.FacesContext, org.ajax4jsf.ajax.repeat.RepeaterInvoker)}.
   */
  public void testProcess() {
    createTree();
    MockComponentState mockState = (MockComponentState) adaptor.getComponentState();
    mockState.setCount(4);
    adaptor.processDecodes(facesContext);
    assertEquals(childInvoked, 4);
    assertEquals(facetInvoked, 1);
  }
View Full Code Here

  /**
   * Test method for {@link org.ajax4jsf.component.UIDataAdaptor#iterate(javax.faces.context.FacesContext, org.ajax4jsf.ajax.repeat.RepeaterInvoker)}.
   */
  public void testProcessMore() {
    createTree();
    MockComponentState mockState = (MockComponentState) adaptor.getComponentState();
    mockState.setCount(Integer.MAX_VALUE);
    adaptor.processDecodes(facesContext);
    assertEquals(childInvoked, MockDataModel.ROWS);
    assertEquals(facetInvoked, 1);
  }
View Full Code Here

   * @throws IllegalAccessException
   * @throws InstantiationException
   */
  public void testRestoreStateFacesContextObject() throws Exception {
    createTree();
    MockComponentState mockState = (MockComponentState) adaptor.getComponentState();
    mockState.setCount(123);
    adaptor.encodeBegin(facesContext);
    UIViewRoot viewRoot = facesContext.getViewRoot();
    Object treeState = viewRoot.processSaveState(facesContext);
    UIViewRoot root = (UIViewRoot) viewRoot.getClass().newInstance();
    UIDataAdaptor restoredAdaptor = new MockDataAdaptor();
    root.getChildren().add(restoredAdaptor);
    root.processRestoreState(facesContext, treeState);
    mockState = (MockComponentState) restoredAdaptor.getComponentState();
    assertEquals(mockState.getCount(), 123);
  }
View Full Code Here

   * Test method for {@link org.ajax4jsf.component.UIDataAdaptor#saveState(javax.faces.context.FacesContext)}.
   */
  public void testSaveStateFacesContext() throws Exception {
    createDataTree();
    data.setRowIndex(0);
    MockComponentState mockState = (MockComponentState) adaptor.getComponentState();
    mockState.setCount(123);
    adaptor.encodeBegin(facesContext);
    data.setRowIndex(1);
    mockState = (MockComponentState) adaptor.getComponentState();
    mockState.setCount(321);
    adaptor.encodeBegin(facesContext);
    UIViewRoot viewRoot = facesContext.getViewRoot();
    Object treeState = viewRoot.processSaveState(facesContext);
    UIViewRoot root = (UIViewRoot) viewRoot.getClass().newInstance();
    UIData restoredData = new UIData();
    UIDataAdaptor restoredAdaptor = new MockDataAdaptor();
    root.getChildren().add(restoredData);
    UIColumn column = new UIColumn();
    restoredData.getChildren().add(column);
    column.getChildren().add(restoredAdaptor);
    root.processRestoreState(facesContext, treeState);
    restoredData.setRowIndex(0);
    mockState = (MockComponentState) restoredAdaptor.getComponentState();
    assertEquals(123,mockState.getCount());
    restoredData.setRowIndex(1);
    mockState = (MockComponentState) restoredAdaptor.getComponentState();
    assertEquals(321,mockState.getCount());
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.ajax4jsf.ajax.repeat.UIDataAdaptor#createComponentState()
   */
  protected DataComponentState createComponentState() {
    // TODO Auto-generated method stub
    return new MockComponentState();
  }
View Full Code Here

TOP

Related Classes of org.ajax4jsf.tests.MockComponentState

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.