cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r565521 - in /cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src: main/resources/META-INF/cocoon/spring/DefaultExpressionFactory.xml test/java/org/apache/cocoon/components/expression/ExpressionTestCase.java
Date Mon, 13 Aug 2007 21:06:37 GMT
Author: gkossakowski
Date: Mon Aug 13 14:06:37 2007
New Revision: 565521

URL: http://svn.apache.org/viewvc?view=rev&rev=565521
Log:
Remove dependency on CocoonTestCase by setting up all necessary beans by hand in setUp() method.

Removed:
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/DefaultExpressionFactory.xml
Modified:
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/ExpressionTestCase.java

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/ExpressionTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/ExpressionTestCase.java?view=diff&rev=565521&r1=565520&r2=565521
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/ExpressionTestCase.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/ExpressionTestCase.java
Mon Aug 13 14:06:37 2007
@@ -16,10 +16,19 @@
  */
 package org.apache.cocoon.components.expression;
 
-import org.apache.cocoon.CocoonTestCase;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.cocoon.components.expression.javascript.JavaScriptCompiler;
+import org.apache.cocoon.components.expression.jexl.JexlCompiler;
+import org.apache.cocoon.components.expression.jxpath.JXPathCompiler;
 import org.apache.cocoon.objectmodel.ObjectModelImpl;
 
-public class ExpressionTestCase extends CocoonTestCase {
+public class ExpressionTestCase extends TestCase {
+    
+    private DefaultExpressionFactory expressionFactory;
 
     /*public void testContext() {
         ObjectModel parentContext = new ObjectModelImpl();
@@ -45,40 +54,49 @@
         assertEquals("foo", parentContext.getContextBean());
         assertEquals("bar", objectModel.getContextBean());
     }*/
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        expressionFactory = new DefaultExpressionFactory();
+        Map expressionCompilers = new HashMap();
+        expressionCompilers.put("js", new JavaScriptCompiler());
+        expressionCompilers.put("jexl", new JexlCompiler());
+        JXPathCompiler jXPathCompiler = new JXPathCompiler();
+        expressionCompilers.put("jxpath", jXPathCompiler);
+        expressionCompilers.put("default", jXPathCompiler);
+        expressionFactory.setExpressionCompilers(expressionCompilers);
+    }
 
     public void testFactoryJexl() throws ExpressionException {
-        ExpressionFactory factory = (ExpressionFactory) this.getBeanFactory().getBean(ExpressionFactory.ROLE);
-        assertNotNull("Test lookup of expression factory", factory);
+        assertNotNull("Test lookup of expression factory", expressionFactory);
 
-        Expression expression = factory.getExpression("jexl", "1+2");
+        Expression expression = expressionFactory.getExpression("jexl", "1+2");
         assertNotNull("Test expression compilation", expression);
 
         assertEquals(new Long(3), expression.evaluate(new ObjectModelImpl()));
     }
 
     public void testFactoryJXPath() throws ExpressionException {
-        ExpressionFactory factory = (ExpressionFactory) this.getBeanFactory().getBean(ExpressionFactory.ROLE);
-        assertNotNull("Test lookup of expression factory", factory);
+        assertNotNull("Test lookup of expression expressionFactory", expressionFactory);
 
-        Expression expression = factory.getExpression("jxpath", "1+2");
+        Expression expression = expressionFactory.getExpression("jxpath", "1+2");
         assertNotNull("Test expression compilation", expression);
 
         assertEquals(new Double(3), expression.evaluate(new ObjectModelImpl()));
     }
 
     public void testFactoryPluggable() throws ExpressionException {
-        ExpressionFactory factory = (ExpressionFactory) this.getBeanFactory().getBean(ExpressionFactory.ROLE);
-        assertNotNull("Test lookup of expression factory", factory);
+        assertNotNull("Test lookup of expression expressionFactory", expressionFactory);
 
-        Expression expression = factory.getExpression("1+2");
+        Expression expression = expressionFactory.getExpression("1+2");
         assertNotNull("Test expression compilation", expression);
         assertEquals(new Double(3), expression.evaluate(new ObjectModelImpl()));
 
-        expression = factory.getExpression("jexl:1+2");
+        expression = expressionFactory.getExpression("jexl:1+2");
         assertNotNull("Test expression compilation", expression);
         assertEquals(new Long(3), expression.evaluate(new ObjectModelImpl()));
 
-        expression = factory.getExpression("jxpath:1+2");
+        expression = expressionFactory.getExpression("jxpath:1+2");
         assertNotNull("Test expression compilation", expression);
         assertEquals(new Double(3), expression.evaluate(new ObjectModelImpl()));
     }



Mime
View raw message