Package cambridge.runtime

Examples of cambridge.runtime.ExpressionContext


   @Test
   public void testThird() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(IfElseTest.class.getResourceAsStream("ifelse.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();
         context.put("var3", true);

         TemplateDocument t = parser.parse();
         assertNotNull(t);
         FragmentList fragments = t.normalize();
View Full Code Here


   @Test
   public void testFinal() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(IfElseTest.class.getResourceAsStream("ifelse.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();

         TemplateDocument t = parser.parse();
         assertNotNull(t);
         FragmentList fragments = t.normalize();
View Full Code Here

   @Test
   public void test() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ConditionalAttributeBehaviorTest.class.getResourceAsStream("conditionalattribute.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();
         context.put("condition", true);

         TemplateDocument t = parser.parse();
         assertNotNull(t);
         FragmentList fragments = t.normalize();
View Full Code Here

    }

    @Test
    public void testSimple() throws ExpressionEvaluationException
    {
        ExpressionContext context = expressionLanguage.createNewContext();
        Expression expression = expressionLanguage.parse("5 + 8", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing simple arithmetic", 13, result);
    }
View Full Code Here

    }

    @Test
    public void testComplexArithmetic() throws ExpressionEvaluationException
    {
        ExpressionContext context = expressionLanguage.createNewContext();
        assertEquals("Testing simple arithmetic", 20494, expressionLanguage.parse("(891 * 23 + 12 / 8)", 1, 1).eval(context));
        assertEquals("Testing simple arithmetic", 20494.5, expressionLanguage.parse("(891 * 23 + 12.0 / 8)", 1, 1).eval(context));
        assertEquals("Testing simple arithmetic", 4.5, expressionLanguage.parse("(891 * 23 + 12.0 / 8) % 10", 1, 1).eval(context));
    }
View Full Code Here

    }

    @Test
    public void testVariableAccess() throws Exception
    {
        ExpressionContext context = expressionLanguage.createNewContext();
        context.put("name", "Cambridge");
        Expression expression = expressionLanguage.parse("name", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing variable access", "Cambridge", result);
    }
View Full Code Here

    }

    @Test
    public void testBean() throws Exception
    {
        ExpressionContext context = expressionLanguage.createNewContext();
        context.put("sample", sample);
        Expression expression = expressionLanguage.parse("sample", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing variable access", sample, result);
        assertTrue("Testing variable access", sample == result);
View Full Code Here

    @Test
    public void testBoolean() throws Exception
    {
        String expression = "true || false";
        ExpressionContext context = expressionLanguage.createNewContext();
        Expression e = expressionLanguage.parse(expression, 0, 0);
        //assertEquals("Testing type", CambridgeExpression.Type.Boolean, e.getType(bindings));
        assertTrue(e.asBoolean(context));
    }
View Full Code Here

    @Test
    public void testList() throws Exception
    {
        String expression = "['a', 'b', 213, aa]";
        ExpressionContext context = expressionLanguage.createNewContext();
        Expression e = expressionLanguage.parse(expression, 0, 0);
        assertTrue(e.eval(context) instanceof List);
        List<?> l = (List<?>) e.eval(context);
        assertEquals("a", l.get(0));
        assertEquals("b", l.get(1));
View Full Code Here

   public void testBasic() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("basic.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);

         ExpressionContext context = new MapExpressionContext();
         context.put("class", "test");
         TemplateDocument t = parser.parse();

         assertNotNull(t);

         Attribute a = t.locateTag("/div").getAttribute("class");
View Full Code Here

TOP

Related Classes of cambridge.runtime.ExpressionContext

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.