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