001package de.cuioss.test.jsf.mocks; 002 003import javax.faces.component.UIComponent; 004import javax.faces.context.FacesContext; 005import javax.faces.view.ViewDeclarationLanguage; 006 007import org.apache.myfaces.test.mock.MockViewHandler20; 008import org.easymock.EasyMock; 009 010/** 011 * In addition to {@link MockViewHandler20} this extension provides a mocked 012 * {@link #getViewDeclarationLanguage(FacesContext, String)} using 013 * {@link EasyMock} and a method for dynamically adding Composite-Component: 014 * {@link #registerCompositeComponent(String, String, UIComponent)} Technically 015 * they have not other use but being defined. 016 * 017 * @author Oliver Wolff 018 * 019 */ 020public class CuiMockViewHandler extends MockViewHandler20 { 021 022 final ViewDeclarationLanguage mock = EasyMock.niceMock(ViewDeclarationLanguage.class); 023 024 @Override 025 public ViewDeclarationLanguage getViewDeclarationLanguage(FacesContext context, String viewId) { 026 return mock; 027 } 028 029 /** 030 * @param libraryName must not be null 031 * @param tagName must not be null 032 * @param uiComponent must not be null 033 */ 034 public void registerCompositeComponent(String libraryName, String tagName, UIComponent uiComponent) { 035 EasyMock.expect(mock.createComponent(EasyMock.anyObject(), EasyMock.eq(libraryName), EasyMock.eq(tagName), 036 EasyMock.anyObject())).andReturn(uiComponent).anyTimes(); 037 EasyMock.replay(mock); 038 } 039}