001/*
002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Anahide Tchertchian
016 */
017package org.nuxeo.ecm.platform.ui.web.jsf;
018
019import java.util.Collection;
020import java.util.Iterator;
021import java.util.Locale;
022
023import javax.el.ELException;
024import javax.el.ExpressionFactory;
025import javax.faces.FacesException;
026import javax.faces.application.Application;
027import javax.faces.application.NavigationHandler;
028import javax.faces.application.StateManager;
029import javax.faces.application.ViewHandler;
030import javax.faces.component.UIComponent;
031import javax.faces.context.ExternalContext;
032import javax.faces.context.FacesContext;
033import javax.faces.convert.Converter;
034import javax.faces.el.MethodBinding;
035import javax.faces.el.PropertyResolver;
036import javax.faces.el.ReferenceSyntaxException;
037import javax.faces.el.ValueBinding;
038import javax.faces.el.VariableResolver;
039import javax.faces.event.ActionListener;
040import javax.faces.validator.Validator;
041
042import org.jboss.el.ExpressionFactoryImpl;
043
044/**
045 * Mock application, providing expressions resolutions using the {@link MockFacesContext}, and providing an
046 * {@link ExternalContext} implemented by {@link MockExternalContext}
047 *
048 * @since 5.7.3
049 */
050public class MockApplication extends Application {
051
052    @Override
053    public Object evaluateExpressionGet(FacesContext context, String expression, Class expectedType) throws ELException {
054        return ((MockFacesContext) context).evaluateExpressionGet(context, expression, expectedType);
055    }
056
057    @Override
058    public void addComponent(String componentType, String componentClass) {
059    }
060
061    @Override
062    public void addConverter(Class targetClass, String converterClass) {
063    }
064
065    @Override
066    public void addConverter(String converterId, String converterClass) {
067    }
068
069    @Override
070    public void addValidator(String validatorId, String validatorClass) {
071    }
072
073    @Override
074    public UIComponent createComponent(String componentType) throws FacesException {
075        return null;
076    }
077
078    @Override
079    public UIComponent createComponent(ValueBinding componentBinding, FacesContext context, String componentType)
080            throws FacesException {
081        return null;
082    }
083
084    @Override
085    public Converter createConverter(Class targetClass) {
086        return null;
087    }
088
089    @Override
090    public Converter createConverter(String converterId) {
091        return null;
092    }
093
094    @Override
095    public MethodBinding createMethodBinding(String ref, Class[] params) throws ReferenceSyntaxException {
096        return null;
097    }
098
099    @Override
100    public Validator createValidator(String validatorId) throws FacesException {
101        return null;
102    }
103
104    @Override
105    public ValueBinding createValueBinding(String ref) throws ReferenceSyntaxException {
106        return null;
107    }
108
109    @Override
110    public ActionListener getActionListener() {
111        return null;
112    }
113
114    @Override
115    public Iterator<String> getComponentTypes() {
116        return null;
117    }
118
119    @Override
120    public Iterator<String> getConverterIds() {
121        return null;
122    }
123
124    @Override
125    public Iterator<Class<?>> getConverterTypes() {
126        return null;
127    }
128
129    @Override
130    public Locale getDefaultLocale() {
131        return null;
132    }
133
134    @Override
135    public String getDefaultRenderKitId() {
136        return null;
137    }
138
139    @Override
140    public String getMessageBundle() {
141        return null;
142    }
143
144    @Override
145    public NavigationHandler getNavigationHandler() {
146        return null;
147    }
148
149    @Override
150    public PropertyResolver getPropertyResolver() {
151        return null;
152    }
153
154    @Override
155    public StateManager getStateManager() {
156        return null;
157    }
158
159    @Override
160    public Iterator<Locale> getSupportedLocales() {
161        return null;
162    }
163
164    @Override
165    public Iterator<String> getValidatorIds() {
166        return null;
167    }
168
169    @Override
170    public VariableResolver getVariableResolver() {
171        return null;
172    }
173
174    @Override
175    public ViewHandler getViewHandler() {
176        return null;
177    }
178
179    @Override
180    public void setActionListener(ActionListener listener) {
181    }
182
183    @Override
184    public void setDefaultLocale(Locale locale) {
185    }
186
187    @Override
188    public void setDefaultRenderKitId(String renderKitId) {
189    }
190
191    @Override
192    public void setMessageBundle(String bundle) {
193    }
194
195    @Override
196    public void setNavigationHandler(NavigationHandler handler) {
197    }
198
199    @Override
200    public void setPropertyResolver(PropertyResolver resolver) {
201    }
202
203    @Override
204    public void setStateManager(StateManager manager) {
205    }
206
207    @Override
208    public void setSupportedLocales(Collection<Locale> locales) {
209    }
210
211    @Override
212    public void setVariableResolver(VariableResolver resolver) {
213    }
214
215    @Override
216    public void setViewHandler(ViewHandler handler) {
217    }
218
219    @Override
220    public ExpressionFactory getExpressionFactory() {
221        return new ExpressionFactoryImpl();
222    }
223}