|
| 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 jakarta.el.ExpressionFactory; |
| 22 | +import jakarta.el.ValueExpression; |
| 23 | + |
| 24 | +import org.apache.myfaces.test.base.junit.AbstractFacesConfigurableMockTestCase; |
| 25 | +import org.junit.jupiter.api.Assertions; |
| 26 | +import org.junit.jupiter.api.Disabled; |
| 27 | +import org.junit.jupiter.api.Test; |
| 28 | + |
| 29 | +/** |
| 30 | + * Unit coverage for MYFACES-4589 at {@link TaglibAttributeVariableMapper} level: a taglib short name |
| 31 | + * bound to a composite pass-through ({@code #{cc.attrs.*}}) must not be returned from |
| 32 | + * {@link jakarta.el.VariableMapper#resolveVariable}, so {@code #{color.blue}} can resolve a same-named |
| 33 | + * managed bean via {@link jakarta.el.ELResolver} at render time. |
| 34 | + */ |
| 35 | +@Disabled |
| 36 | +public class TaglibAttributeVariableMapper4589Test extends AbstractFacesConfigurableMockTestCase |
| 37 | +{ |
| 38 | + |
| 39 | + @Test |
| 40 | + public void testCcAttrsPassThroughBindingMustNotResolveOnVariableMapper4589() |
| 41 | + { |
| 42 | + ExpressionFactory ef = application.getExpressionFactory(); |
| 43 | + ValueExpression ccAttrsColorVe = ef.createValueExpression( |
| 44 | + facesContext.getELContext(), "#{cc.attrs.color}", Object.class); |
| 45 | + |
| 46 | + DefaultVariableMapper delegate = new DefaultVariableMapper(); |
| 47 | + TaglibAttributeVariableMapper mapper = new TaglibAttributeVariableMapper(delegate); |
| 48 | + mapper.setVariable("color", ccAttrsColorVe); |
| 49 | + |
| 50 | + Assertions.assertNull(mapper.resolveVariable("color"), |
| 51 | + "Expected null so AstIdentifier falls through to ELResolver for a CDI bean named 'color'"); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void testNonCcAttrsTaglibBindingStillResolvesOnVariableMapper4585() |
| 56 | + { |
| 57 | + ExpressionFactory ef = application.getExpressionFactory(); |
| 58 | + ValueExpression converterVe = ef.createValueExpression( |
| 59 | + facesContext.getELContext(), "#{requestScope.user4585Bean.converter}", Object.class); |
| 60 | + |
| 61 | + DefaultVariableMapper delegate = new DefaultVariableMapper(); |
| 62 | + TaglibAttributeVariableMapper mapper = new TaglibAttributeVariableMapper(delegate); |
| 63 | + mapper.setVariable("converter", converterVe); |
| 64 | + |
| 65 | + ValueExpression resolved = mapper.resolveVariable("converter"); |
| 66 | + Assertions.assertNotNull(resolved); |
| 67 | + Assertions.assertTrue(resolved.getExpressionString().contains("user4585Bean"), |
| 68 | + "MYFACES-4585: ordinary taglib bindings must remain on VariableMapper"); |
| 69 | + } |
| 70 | +} |
0 commit comments