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.view.facelets.el;
20  
21  import javax.el.ExpressionFactory;
22  import org.apache.myfaces.view.facelets.FaceletTestCase;
23  import org.junit.Assert;
24  import org.junit.Test;
25  
26  /**
27   *
28   * @author Leonardo Uribe
29   */
30  public class CompositeComponentELUtilsTestCase extends FaceletTestCase
31  {
32      
33      @Override
34      protected ExpressionFactory createExpressionFactory()
35      {
36          return new org.apache.el.ExpressionFactoryImpl();
37      }
38      
39      @Test
40      public void test_cc_attrs_method_expression1() throws Exception
41      {
42          Assert.assertTrue(
43              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
44              "#{cc.attrs.someProp}"));
45          Assert.assertTrue(
46              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
47              "#{ cc.attrs.someProp}"));
48          Assert.assertFalse(
49              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
50              "#{cc.attrs.someProp.someKey}"));
51          Assert.assertFalse(
52              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
53              "#{xy:call(cc.attrs.someProp)}"));
54          Assert.assertFalse(
55              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
56              "#{xy:call( cc.attrs.someProp)}"));
57          Assert.assertFalse(
58              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
59              "#{xy:call(zz, cc.attrs.someProp)}"));        
60          Assert.assertFalse(
61              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
62              "#{xy:call(zz,cc.attrs.someProp)}"));
63          Assert.assertTrue(
64              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
65              "#{cc.attrs.method(someProp)}"));
66          Assert.assertTrue(
67              CompositeComponentELUtils.isCompositeComponentAttrsMethodExpression(
68              "#{cc.attrs.method( someProp, someAttr )}"));
69      }
70  }