use of org.apache.jasper.el.ELContextImpl in project tomcat70 by apache.
the class TestResourceBundleELResolver method testGetFeatureDescriptors02.
/**
* Tests that a valid FeatureDescriptors are returned.
*/
@Test
public void testGetFeatureDescriptors02() {
ResourceBundleELResolver resolver = new ResourceBundleELResolver();
ELContext context = new ELContextImpl();
ResourceBundle resourceBundle = new TesterResourceBundle(new Object[][] { { "key", "value" } });
@SuppressWarnings("unchecked") Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(context, resourceBundle);
while (result.hasNext()) {
FeatureDescriptor featureDescriptor = result.next();
Assert.assertEquals("key", featureDescriptor.getDisplayName());
Assert.assertEquals("key", featureDescriptor.getName());
Assert.assertEquals("", featureDescriptor.getShortDescription());
Assert.assertFalse(featureDescriptor.isExpert());
Assert.assertFalse(featureDescriptor.isHidden());
Assert.assertTrue(featureDescriptor.isPreferred());
Assert.assertEquals(String.class, featureDescriptor.getValue(ELResolver.TYPE));
Assert.assertEquals(Boolean.TRUE, featureDescriptor.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
}
}
use of org.apache.jasper.el.ELContextImpl in project tomcat by apache.
the class TestMethodExpressionImpl method setUp.
@Before
public void setUp() {
factory = ExpressionFactory.newInstance();
context = new ELContextImpl(factory);
TesterBeanA beanA = new TesterBeanA();
beanA.setName("A");
context.getVariableMapper().setVariable("beanA", factory.createValueExpression(beanA, TesterBeanA.class));
TesterBeanAA beanAA = new TesterBeanAA();
beanAA.setName("AA");
context.getVariableMapper().setVariable("beanAA", factory.createValueExpression(beanAA, TesterBeanAA.class));
TesterBeanAAA beanAAA = new TesterBeanAAA();
beanAAA.setName("AAA");
context.getVariableMapper().setVariable("beanAAA", factory.createValueExpression(beanAAA, TesterBeanAAA.class));
beanB = new TesterBeanB();
beanB.setName("B");
context.getVariableMapper().setVariable("beanB", factory.createValueExpression(beanB, TesterBeanB.class));
TesterBeanBB beanBB = new TesterBeanBB();
beanBB.setName("BB");
context.getVariableMapper().setVariable("beanBB", factory.createValueExpression(beanBB, TesterBeanBB.class));
TesterBeanBBB beanBBB = new TesterBeanBBB();
beanBBB.setName("BBB");
context.getVariableMapper().setVariable("beanBBB", factory.createValueExpression(beanBBB, TesterBeanBBB.class));
TesterBeanC beanC = new TesterBeanC();
context.getVariableMapper().setVariable("beanC", factory.createValueExpression(beanC, TesterBeanC.class));
TesterBeanEnum beanEnum = new TesterBeanEnum();
context.getVariableMapper().setVariable("beanEnum", factory.createValueExpression(beanEnum, TesterBeanEnum.class));
}
use of org.apache.jasper.el.ELContextImpl in project tomcat by apache.
the class TestValueExpressionImpl method testBug56522SetNullValue.
@Test
public void testBug56522SetNullValue() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
ValueExpression var = factory.createValueExpression(beanB, TesterBeanB.class);
context.getVariableMapper().setVariable("beanB", var);
ValueExpression ve = factory.createValueExpression(context, "${beanB.name}", String.class);
// First check the basics work
String result = (String) ve.getValue(context);
Assert.assertEquals("Tomcat", result);
// Now set the value to null
ve.setValue(context, null);
Assert.assertEquals("", beanB.getName());
}
use of org.apache.jasper.el.ELContextImpl in project tomcat by apache.
the class TestValueExpressionImpl method testBug51544Bean.
/*
* Test returning an empty list as a bean property.
*/
@Test
public void testBug51544Bean() throws Exception {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanA beanA = new TesterBeanA();
beanA.setValList(Collections.emptyList());
ValueExpression var = factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("beanA", var);
ValueExpression ve = factory.createValueExpression(context, "${beanA.valList.size()}", Integer.class);
Integer result = (Integer) ve.getValue(context);
Assert.assertEquals(Integer.valueOf(0), result);
}
use of org.apache.jasper.el.ELContextImpl in project tomcat by apache.
the class TestValueExpressionImpl method testGetValueReferenceVariable.
@Test
public void testGetValueReferenceVariable() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl(factory);
TesterBeanB beanB = new TesterBeanB();
beanB.setName("Tomcat");
ValueExpression var = factory.createValueExpression(beanB, TesterBeanB.class);
context.getVariableMapper().setVariable("beanB", var);
ValueExpression var2 = factory.createValueExpression(context, "${beanB.name}", String.class);
context.getVariableMapper().setVariable("foo", var2);
ValueExpression ve = factory.createValueExpression(context, "${foo}", ValueExpression.class);
// Now check the value reference
ValueReference vr = ve.getValueReference(context);
Assert.assertNotNull(vr);
Assert.assertEquals(beanB, vr.getBase());
Assert.assertEquals("name", vr.getProperty());
}
Aggregations