Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.ExpressionEvaluator


    public void testWriteFail()
    {
        Fixture f = new Fixture();

        ExpressionEvaluator ee = create();

        try
        {
            ee.write(f, "class", "Foo");
            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertExceptionSubstring(ex, "Unable to update OGNL expression");
View Full Code Here


        return spec;
    }

    public void testIsConstantFail()
    {
        ExpressionEvaluator ee = create();

        try
        {
            ee.isConstant("@foo@BAR");
            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertExceptionSubstring(ex, "Error evaluating OGNL expression");
View Full Code Here

public class TestExpressionBinding extends BindingTestCase
{

    public void test_Invariant()
    {
        ExpressionEvaluator ev = newMock(ExpressionEvaluator.class);
        ExpressionCache ec = newMock(ExpressionCache.class);
        IComponent component = newMock(IComponent.class);
        Location l = fabricateLocation(1);

        Node compiled = newMock(Node.class);
        //ExpressionAccessor accessor = newMock(ExpressionAccessor.class);

        Object expressionValue = "EXPRESSION-VALUE";

        ValueConverter vc = newValueConverter();

        expect(ec.getCompiledExpression("exp")).andReturn(compiled);

        expect(compiled.getAccessor()).andReturn(null);

        expect(ev.isConstant("exp")).andReturn(true);

        expect(ec.getCompiledExpression(component, "exp")).andReturn(compiled);

        expect(ev.readCompiled(component, compiled)).andReturn(expressionValue);

        expect(component.getExtendedId()).andReturn("Foo/bar");

        replay();
View Full Code Here

        verify();
    }

    public void test_Variant()
    {
        ExpressionEvaluator ev = newMock(ExpressionEvaluator.class);
        ExpressionCache ec = newMock(ExpressionCache.class);
        Location l = fabricateLocation(1);

        IComponent component = newComponent();
        Node compiled = newMock(Node.class);
        ExpressionAccessor accessor = newMock(ExpressionAccessor.class);

        Object expressionValue1 = new Object();
        Object expressionValue2 = new Object();

        ValueConverter vc = newValueConverter();

        expect(ec.getCompiledExpression("exp")).andReturn(compiled);

        expect(ev.isConstant("exp")).andReturn(false);

        expect(ec.getCompiledExpression(component, "exp")).andReturn(compiled);

        expect(compiled.getAccessor()).andReturn(accessor);

        expect(ev.read(component, accessor)).andReturn(expressionValue1);
        expect(ev.read(component, accessor)).andReturn(expressionValue2);

        replay();

        ExpressionBinding b = new ExpressionBinding("param", l, vc, component,
                                                    "exp", ev, ec);
View Full Code Here

        verify();
    }

    public void test_Set_Object()
    {
        ExpressionEvaluator ev = newMock(ExpressionEvaluator.class);
        ExpressionCache ec = newMock(ExpressionCache.class);
        Location l = fabricateLocation(1);

        IComponent component = newComponent();
        Node compiled = newMock(Node.class);
        ValueConverter vc = newValueConverter();

        expect(ec.getCompiledExpression("exp")).andReturn(compiled);

        expect(ev.isConstant("exp")).andReturn(false);

        Object newValue = new Object();

        ev.writeCompiled(component, compiled, newValue);

        expect(ec.getCompiledExpression(component, "exp")).andReturn(compiled);
        expect(compiled.getAccessor()).andReturn(null);

        replay();
View Full Code Here

        verify();
    }

    public void test_Set_Object_Invariant()
    {
        ExpressionEvaluator ev = newMock(ExpressionEvaluator.class);
        ExpressionCache ec = newMock(ExpressionCache.class);
        Location l = fabricateLocation(1);

        IComponent component = newComponent();
        Node compiled = newMock(Node.class);

        ValueConverter vc = newValueConverter();

        expect(ec.getCompiledExpression("exp")).andReturn(compiled);
        expect(ev.isConstant("exp")).andReturn(true);

        expect(component.getExtendedId()).andReturn("Foo/bar.baz");

        replay();
View Full Code Here

        verify();
    }

    public void test_Set_Object_Failure()
    {
        ExpressionEvaluator ev = newMock(ExpressionEvaluator.class);
        ExpressionCache ec = newMock(ExpressionCache.class);
        Location l = fabricateLocation(1);

        IComponent component = newComponent();
        Node compiled = newMock(Node.class);

        ValueConverter vc = newValueConverter();

        expect(ec.getCompiledExpression("exp")).andReturn(compiled);

        expect(ev.isConstant("exp")).andReturn(false);

        Object newValue = new Object();

        RuntimeException innerException = new RuntimeException("Failure");

        ev.writeCompiled(component, compiled, newValue);
        expectLastCall().andThrow(innerException);

        replay();

        ExpressionBinding b = new ExpressionBinding("param", l, vc, component,
View Full Code Here

        verify();
    }

    public void test_Compile_Expression_Failure()
    {
        ExpressionEvaluator ev = newMock(ExpressionEvaluator.class);
        ExpressionCache ec = newMock(ExpressionCache.class);
        Location l = fabricateLocation(1);

        IComponent component = newComponent();
        ValueConverter vc = newValueConverter();
View Full Code Here

        verify();
    }

    public void test_Resolve_Expression_Failure()
    {
        ExpressionEvaluator ev = newMock(ExpressionEvaluator.class);
        ExpressionCache ec = newMock(ExpressionCache.class);
        Location l = fabricateLocation(1);

        IComponent component = newComponent();
        Node compiled = newMock(Node.class);
        ValueConverter vc = newValueConverter();

        expect(ec.getCompiledExpression("exp")).andReturn(compiled);

        expect(ev.isConstant("exp")).andReturn(false);

        Throwable innerException = new RuntimeException("Failure");

        ec.getCompiledExpression(component, "exp");
        expectLastCall().andThrow(innerException);
View Full Code Here

    public void test_Read()
    {
        Fixture f = new Fixture("Foo");

        ExpressionEvaluator ee = create();
        trainIntialize(ee);

        assertEquals("Foo", ee.read(f, "value"));
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.services.ExpressionEvaluator

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.