Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.ExpressionEvaluator


    }

    public void testCompileExpressionFailure()
    {
        MockControl evc = newControl(ExpressionEvaluator.class);
        ExpressionEvaluator ev = (ExpressionEvaluator) evc.getMock();

        MockControl ecc = newControl(ExpressionCache.class);
        ExpressionCache ec = (ExpressionCache) ecc.getMock();

        IComponent component = newComponent();
View Full Code Here


    }

    public void testResolveExpressionFailure()
    {
        MockControl evc = newControl(ExpressionEvaluator.class);
        ExpressionEvaluator ev = (ExpressionEvaluator) evc.getMock();

        MockControl ecc = newControl(ExpressionCache.class);
        ExpressionCache ec = (ExpressionCache) ecc.getMock();

        IComponent component = newComponent();
        Object compiled = new Object();

        ValueConverter vc = newValueConverter();

        ec.getCompiledExpression("exp");
        ecc.setReturnValue(compiled);

        ev.isConstant("exp");
        evc.setReturnValue(false);

        Throwable innerException = new RuntimeException("Failure");

        ev.readCompiled(component, compiled);
        evc.setThrowable(innerException);

        replayControls();

        ExpressionBinding b = new ExpressionBinding("param", fabricateLocation(1), vc, component,
View Full Code Here

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

        ExpressionEvaluator ee = create();

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

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

        ExpressionEvaluator ee = create();

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

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

        ExpressionEvaluator ee = create();

        ee.write(f, "value", "Bar");

        assertEquals("Bar", f.getValue());
    }
View Full Code Here

    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

        }
    }

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

        assertEquals(true, ee.isConstant("true"));
        assertEquals(true, ee.isConstant("'OGNL'"));
        assertEquals(false, ee.isConstant("foo.bar"));
        assertEquals(false, ee.isConstant("bar()"));
        assertEquals(true, ee.isConstant("@org.apache.tapestry.Tapestry@HOME_SERVICE"));
    }
View Full Code Here

        assertEquals(true, ee.isConstant("@org.apache.tapestry.Tapestry@HOME_SERVICE"));
    }

    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

      if (fullSource == null)
        fullSource = getSource();
      if (fullSource == null)
        return primaryKeys;
     
      ExpressionEvaluator evaluator = getExpressionEvaluator();
     
      Iterator iteratorSource = (Iterator) getValueConverter().coerceValue(fullSource, Iterator.class);
      while (iteratorSource.hasNext()) {
        Object value = iteratorSource.next();
          Object primaryKey = evaluator.read(value, keyExpression);
          if (primaryKey != null)
            primaryKeys.put(primaryKey, value);
      }
     
      setPrimaryKeyMap(primaryKeys);
View Full Code Here

        return value;
    }

    private Object findPrimaryKeyMatch(Object primaryKey, String parameter)
    {
        ExpressionEvaluator evaluator = getExpressionEvaluator();
        String keyExpression = getKeyExpression();

        Map primaryKeys = getPrimaryKeyMap();
        if (primaryKeys == null)
            primaryKeys = new HashMap();

        Map sourceIteratorMap = getSourceIteratorMap();
        if (sourceIteratorMap == null)
            sourceIteratorMap = new HashMap();

        Iterator it = (Iterator) sourceIteratorMap.get(parameter);
        if (it == null)
        {
            it = getSource(parameter);
            if (it == null)
                it = Collections.EMPTY_LIST.iterator();
        }

        try
        {
            while (it.hasNext())
            {
                Object sourceValue = it.next();
                Object sourcePrimaryKey = evaluator.read(sourceValue, keyExpression);
                if (sourcePrimaryKey != null)
                    primaryKeys.put(sourcePrimaryKey, sourceValue);

                if (primaryKey.equals(sourcePrimaryKey))
                {
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.