use of org.apache.jasper.el.ELContextImpl in project tomcat70 by apache.
the class TestELParser method testJavaKeyWordSuffix.
@Test
public void testJavaKeyWordSuffix() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
TesterBeanA beanA = new TesterBeanA();
beanA.setInt("five");
ValueExpression var = factory.createValueExpression(beanA, TesterBeanA.class);
context.getVariableMapper().setVariable("beanA", var);
// Should fail
Exception e = null;
try {
factory.createValueExpression(context, "${beanA.int}", String.class);
} catch (ELException ele) {
e = ele;
}
Assert.assertNotNull(e);
}
use of org.apache.jasper.el.ELContextImpl in project tomcat70 by apache.
the class TestELParser method testExpression.
private void testExpression(String expression, String expected) {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
ValueExpression ve = factory.createValueExpression(context, expression, String.class);
String result = (String) ve.getValue(context);
Assert.assertEquals(expected, result);
}
use of org.apache.jasper.el.ELContextImpl in project tomcat70 by apache.
the class TestMapELResolver method testGetFeatureDescriptors02.
/**
* Tests that a valid FeatureDescriptors are returned.
*/
@Test
public void testGetFeatureDescriptors02() {
MapELResolver mapELResolver = new MapELResolver();
ELContext context = new ELContextImpl();
Map<String, String> map = new HashMap<String, String>();
map.put("key", "value");
Iterator<FeatureDescriptor> result = mapELResolver.getFeatureDescriptors(context, map);
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("key".getClass(), featureDescriptor.getValue(ELResolver.TYPE));
Assert.assertEquals(Boolean.TRUE, featureDescriptor.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
}
}
use of org.apache.jasper.el.ELContextImpl in project tomcat70 by apache.
the class TestResourceBundleELResolver method bug53001.
@Test
public void bug53001() {
ExpressionFactory factory = ExpressionFactory.newInstance();
ELContext context = new ELContextImpl();
ResourceBundle rb = new TesterResourceBundle();
ValueExpression var = factory.createValueExpression(rb, ResourceBundle.class);
context.getVariableMapper().setVariable("rb", var);
ValueExpression ve = factory.createValueExpression(context, "${rb.keys}", String.class);
MethodExpression me = factory.createMethodExpression(context, "${rb.getKeys()}", Enumeration.class, null);
// Ensure we are specification compliant
String result1 = (String) ve.getValue(context);
Assert.assertEquals("???keys???", result1);
// Check that the method expression does return the keys
Object result2 = me.invoke(context, null);
Assert.assertTrue(result2 instanceof Enumeration);
@SuppressWarnings("unchecked") Enumeration<String> e = (Enumeration<String>) result2;
Assert.assertTrue(e.hasMoreElements());
String element = e.nextElement();
if ("key1".equals(element)) {
Assert.assertEquals("key1", element);
Assert.assertTrue(e.hasMoreElements());
Assert.assertEquals("key2", e.nextElement());
Assert.assertFalse(e.hasMoreElements());
} else {
Assert.assertEquals("key2", element);
Assert.assertTrue(e.hasMoreElements());
Assert.assertEquals("key1", e.nextElement());
Assert.assertFalse(e.hasMoreElements());
}
}
use of org.apache.jasper.el.ELContextImpl in project tomcat70 by apache.
the class TestResourceBundleELResolver method testGetType03.
/**
* Tests that null will be returned when base is ResourceBundle. Checks that
* the propertyResolved is true.
*/
@Test
public void testGetType03() {
ResourceBundleELResolver resolver = new ResourceBundleELResolver();
ELContext context = new ELContextImpl();
ResourceBundle resourceBundle = new TesterResourceBundle();
Class<?> result = resolver.getType(context, resourceBundle, "key1");
Assert.assertNull(result);
Assert.assertTrue(context.isPropertyResolved());
}
Aggregations