cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lgaw...@apache.org
Subject svn commit: r325988 - in /cocoon/blocks/template/trunk: WEB-INF/xconf/ test/org/apache/cocoon/components/expression/javascript/ test/org/apache/cocoon/template/jxtg/
Date Mon, 17 Oct 2005 21:39:28 GMT
Author: lgawron
Date: Mon Oct 17 14:38:35 2005
New Revision: 325988

URL: http://svn.apache.org/viewcvs?rev=325988&view=rev
Log:
jxtg javascript support test cases 
some missing configuration

Added:
    cocoon/blocks/template/trunk/test/org/apache/cocoon/components/expression/javascript/
    cocoon/blocks/template/trunk/test/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
  (with props)
Modified:
    cocoon/blocks/template/trunk/WEB-INF/xconf/cocoon-template-expression.xconf
    cocoon/blocks/template/trunk/test/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.xtest

Modified: cocoon/blocks/template/trunk/WEB-INF/xconf/cocoon-template-expression.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/WEB-INF/xconf/cocoon-template-expression.xconf?rev=325988&r1=325987&r2=325988&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/WEB-INF/xconf/cocoon-template-expression.xconf (original)
+++ cocoon/blocks/template/trunk/WEB-INF/xconf/cocoon-template-expression.xconf Mon Oct 17
14:38:35 2005
@@ -28,5 +28,10 @@
     <component-instance class="org.apache.cocoon.components.expression.jxpath.JXPathCompiler"
name="default"/>
     <component-instance class="org.apache.cocoon.components.expression.jexl.JexlCompiler"
name="jexl"/>
     <component-instance class="org.apache.cocoon.components.expression.jxpath.JXPathCompiler"
name="jxpath"/>
+    <component-instance class="org.apache.cocoon.components.expression.javascript.JavaScriptCompiler"
name="js"/>
   </expression-compilers>
+  <string-template-parsers>
+    <component-instance class="org.apache.cocoon.template.expression.JXTGStringTemplateParser"
name="jxtg"/>
+    <component-instance class="org.apache.cocoon.template.expression.DefaultStringTemplateParser"
name="default"/>
+  </string-template-parsers>
 </components>

Added: cocoon/blocks/template/trunk/test/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/test/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java?rev=325988&view=auto
==============================================================================
--- cocoon/blocks/template/trunk/test/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
(added)
+++ cocoon/blocks/template/trunk/test/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
Mon Oct 17 14:38:35 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.expression.javascript;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.cocoon.components.expression.Expression;
+import org.apache.cocoon.components.expression.ExpressionCompiler;
+import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.components.expression.ExpressionException;
+
+/**
+ * @version $Id$
+ */
+public class JavaScriptTestCase extends TestCase {
+
+    public void testExpression() throws ExpressionException {
+        ExpressionCompiler compiler = new JavaScriptCompiler();
+        Expression expression = compiler.compile("js", "1+2");
+        Object result = expression.evaluate(new ExpressionContext());
+        assertEquals(new Integer(3), result);
+    }
+
+    public void testContextExpression() throws ExpressionException {
+        ExpressionCompiler compiler = new JavaScriptCompiler();
+        ExpressionContext context = new ExpressionContext();
+        context.put("a", new Long(1));
+        context.put("b", new Long(2));
+        Expression expression = compiler.compile("js", "a+b");
+        Object result = expression.evaluate(context);
+        assertEquals(new Double(3), result);
+    }
+
+    public void testIterator() throws ExpressionException {
+        ExpressionCompiler compiler = new JavaScriptCompiler();
+        ExpressionContext context = new ExpressionContext();
+        String[] arr = { "foo" };
+        context.put("arr", arr);
+        Expression expression = compiler.compile("jexl", "arr");
+        Iterator iter = expression.iterate(context);
+        assertTrue("hasNext", iter.hasNext());
+        assertEquals("foo", iter.next());
+        assertFalse("hasNext", iter.hasNext());
+    }
+}

Propchange: cocoon/blocks/template/trunk/test/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/template/trunk/test/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/template/trunk/test/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/test/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.xtest?rev=325988&r1=325987&r2=325988&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/test/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.xtest
(original)
+++ cocoon/blocks/template/trunk/test/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.xtest
Mon Oct 17 14:38:35 2005
@@ -22,7 +22,8 @@
         <role name="org.apache.excalibur.source.SourceFactorySelector" shorthand="source-factories"
default-class="org.apache.cocoon.components.ExtendedComponentSelector"/>
         <role name="org.apache.excalibur.source.SourceResolver" shorthand="source-resolver"
default-class="org.apache.excalibur.source.impl.SourceResolverImpl"/>
         <role name="org.apache.cocoon.components.expression.ExpressionCompilerSelector"
shorthand="expression-compilers" default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
-        <role name="org.apache.cocoon.components.expression.ExpressionFactory" shorthand="expression-factory"
default-class="org.apache.cocoon.components.expression.ExpressionFactory"/>
+    	  <role name="org.apache.cocoon.components.expression.ExpressionFactory" shorthand="expression-factory"
default-class="org.apache.cocoon.components.expression.ExpressionFactory"/>
+        <role name="org.apache.cocoon.template.expression.StringTemplateParserSelector"
shorthand="string-template-parsers" default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
     </roles>
     <components>
         <xml-parser class="org.apache.excalibur.xml.impl.JaxpParser">
@@ -38,8 +39,11 @@
         <store logger="test"/>
         <component role="org.apache.cocoon.template.script.ScriptManager" class="org.apache.cocoon.template.script.DefaultScriptManager"/>
         <component role="org.apache.cocoon.template.script.InstructionFactory" class="org.apache.cocoon.template.script.DefaultInstructionFactory"/>
-        <component role="org.apache.cocoon.template.expression.StringTemplateParser" class="org.apache.cocoon.template.expression.JXTGStringTemplateParser"/>
         <expression-factory/>
+        <string-template-parsers>
+        	<component-instance class="org.apache.cocoon.template.expression.JXTGStringTemplateParser"
name="jxtg"/>
+        	<component-instance class="org.apache.cocoon.template.expression.DefaultStringTemplateParser"
name="default"/>
+        </string-template-parsers>
         <expression-compilers>
             <component-instance class="org.apache.cocoon.components.expression.jxpath.JXPathCompiler"
name="default"/>
             <component-instance class="org.apache.cocoon.components.expression.jexl.JexlCompiler"
name="jexl"/>



Mime
View raw message