View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces;
20  
21  import javax.el.ELContext;
22  import javax.faces.application.Application;
23  import javax.faces.context.ExternalContext;
24  import javax.faces.context.FacesContext;
25  
26  import junit.framework.TestCase;
27  
28  import org.apache.myfaces.test.mock.MockFacesContext12;
29  import org.easymock.classextension.EasyMock;
30  import org.easymock.classextension.IMocksControl;
31  
32  /**
33   * @author Mathias Broekelmann (latest modification by $Author: lu4242 $)
34   * @version $Revision: 883907 $ $Date: 2009-11-24 17:37:53 -0500 (Tue, 24 Nov 2009) $
35   */
36  public abstract class FacesTestCase extends TestCase
37  {
38      protected FacesContext _facesContext;
39      protected IMocksControl _mocksControl;
40      protected ExternalContext _externalContext;
41      protected Application _application;
42      protected ELContext _elContext;
43  
44      protected void setUp() throws Exception
45      {
46          _mocksControl = EasyMock.createControl();
47          _externalContext = _mocksControl.createMock(ExternalContext.class);
48          _facesContext = _mocksControl.createMock(FacesContext.class);
49          MockFacesContext12.setCurrentInstance(_facesContext);
50          _application = _mocksControl.createMock(Application.class);
51          _elContext = _mocksControl.createMock(ELContext.class);        
52      }
53      
54      @Override
55      protected void tearDown() throws Exception
56      {
57          MockFacesContext12.setCurrentInstance(null);
58      }
59  }