Package org.apache.jasper.el

Examples of org.apache.jasper.el.ELContextImpl


     * Test using list directly as variable.
     */
    @Test
    public void testBug51544Direct() throws Exception {
        ExpressionFactory factory = ExpressionFactory.newInstance();
        ELContext context = new ELContextImpl();

        List<?> list = Collections.emptyList();

        ValueExpression var =
            factory.createValueExpression(list, List.class);
        context.getVariableMapper().setVariable("list", var);

        ValueExpression ve = factory.createValueExpression(
                context, "${list.size()}", Integer.class);

        Integer result = (Integer) ve.getValue(context);
View Full Code Here


    private ELContext context;

    @Before
    public void setUp() {
        factory = ExpressionFactory.newInstance();
        context = new ELContextImpl();

        TesterBeanA beanA = new TesterBeanA();
        beanA.setName("A");
        context.getVariableMapper().setVariable("beanA",
                factory.createValueExpression(beanA, TesterBeanA.class));
View Full Code Here

        // Don't try and evaluate expressions that depend on variables or functions
        if (expected != null) {
            try {
                ExpressionFactory factory = ExpressionFactory.newInstance();
                ELContext context = new ELContextImpl();
                ValueExpression ve = factory.createValueExpression(context, input, String.class);
                elResult = ve.getValue(context).toString();
                Assert.assertEquals(expected, elResult);
            } catch (ELException ele) {
                elException = ele;
View Full Code Here

    }

    // ************************************************************************

    private String evaluateExpression(String expression) {
        ELContextImpl ctx = new ELContextImpl();
        ctx.setFunctionMapper(new FMapper());
        ExpressionFactoryImpl exprFactory = new ExpressionFactoryImpl();
        ValueExpression ve = exprFactory.createValueExpression(ctx, expression,
                String.class);
        return (String) ve.getValue(ctx);
    }
View Full Code Here

                    result = new Node.JspAttribute(tai, qName, uri, localName,
                            value, false, el, dynamic);

                    if (el != null) {
                        ELContextImpl ctx = new ELContextImpl();
                        ctx.setFunctionMapper(getFunctionMapper(el));

                        try {
                            result.validateEL(this.pageInfo
                                    .getExpressionFactory(), ctx);
                        } catch (ELException e) {
View Full Code Here

        private void prepareExpression(ELNode.Nodes el, Node n, String expr)
                throws JasperException {
            validateFunctions(el, n);

            // test it out
            ELContextImpl ctx = new ELContextImpl();
            ctx.setFunctionMapper(this.getFunctionMapper(el));
            ExpressionFactory ef = this.pageInfo.getExpressionFactory();
            try {
                ef.createValueExpression(ctx, expr, Object.class);
            } catch (ELException e) {
View Full Code Here

     * Tests that a valid property is resolved.
     */
    @Test
    public void testGetType03() {
        ArrayELResolver resolver = new ArrayELResolver();
        ELContext context = new ELContextImpl();

        String[] base = new String[] { "element" };
        Class<?> result = resolver.getType(context, base, new Integer(0));

        Assert.assertEquals(base.getClass().getComponentType(), result);
        Assert.assertTrue(context.isPropertyResolved());
    }
View Full Code Here

     * Tests that the key is out of bounds and exception will be thrown.
     */
    @Test(expected = PropertyNotFoundException.class)
    public void testGetType04() {
        ArrayELResolver resolver = new ArrayELResolver();
        ELContext context = new ELContextImpl();

        String[] base = new String[] { "element" };
        resolver.getType(context, base, new Integer(1));
    }
View Full Code Here

     * Tests that a result is returned even when a coercion cannot be performed.
     */
    @Test
    public void testGetType05() {
        ArrayELResolver resolver = new ArrayELResolver();
        ELContext context = new ELContextImpl();

        String[] base = new String[] { "element" };
        Class<?> result = resolver.getType(context, base, "index");

        Assert.assertEquals(base.getClass().getComponentType(), result);
        Assert.assertTrue(context.isPropertyResolved());
    }
View Full Code Here

     * Tests that a valid property is resolved.
     */
    @Test
    public void testGetValue03() {
        ArrayELResolver resolver = new ArrayELResolver();
        ELContext context = new ELContextImpl();

        String[] base = new String[] { "element" };
        Object result = resolver.getValue(context, base, new Integer(0));

        Assert.assertEquals("element", result);
        Assert.assertTrue(context.isPropertyResolved());
    }
View Full Code Here

TOP

Related Classes of org.apache.jasper.el.ELContextImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.