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.el;
20  
21  import javax.faces.el.PropertyResolver;
22  
23  import junit.framework.Test;
24  import junit.framework.TestSuite;
25  
26  import org.apache.myfaces.el.data.B;
27  import org.apache.shale.test.base.AbstractJsfTestCase;
28  
29  public class PropertyResolverTestCase extends AbstractJsfTestCase
30  {
31  
32    public PropertyResolverTestCase(String arg0) {
33      super(arg0);
34    }
35  
36    public void setUp() 
37    {
38      super.setUp();
39      PropertyResolver pr = new PropertyResolverImpl();
40      facesContext.getApplication().setPropertyResolver(pr);
41    }
42  
43    public void tearDown() 
44    {
45      // TODO Auto-generated method stub
46      super.tearDown();
47    }
48    
49    public static Test suite()
50    {
51      return new TestSuite(PropertyResolverTestCase.class);
52    }
53    
54    public void testComplexBean() throws Exception
55    {
56      B b = new B();
57      facesContext.getExternalContext().getSessionMap().put("b", b);
58      B o = (B) facesContext.getApplication().getVariableResolver().resolveVariable(facesContext, "b");
59      assertEquals(o.getFirst(), "First");
60      facesContext.getApplication().getPropertyResolver().setValue(b, "first", "LALA");
61      o = (B) facesContext.getApplication().getVariableResolver().resolveVariable(facesContext, "b");
62      assertEquals(o.getFirst(), "LALA");
63      
64    }
65  }