camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r673619 - in /activemq/camel/trunk/components/camel-script: ./ src/main/java/org/apache/camel/builder/script/ src/test/java/org/apache/camel/builder/script/ src/test/java/org/apache/camel/language/script/ src/test/resources/
Date Thu, 03 Jul 2008 08:40:59 GMT
Author: ningjiang
Date: Thu Jul  3 01:40:58 2008
New Revision: 673619

URL: http://svn.apache.org/viewvc?rev=673619&view=rev
Log:
CAMEL-655 got camel-script work again

Modified:
    activemq/camel/trunk/components/camel-script/pom.xml
    activemq/camel/trunk/components/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java
    activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java
    activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java
    activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/JavaScriptLanguageTest.java
    activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/PythonLanguageTest.java
    activemq/camel/trunk/components/camel-script/src/test/resources/log4j.properties

Modified: activemq/camel/trunk/components/camel-script/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/pom.xml?rev=673619&r1=673618&r2=673619&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/pom.xml (original)
+++ activemq/camel/trunk/components/camel-script/pom.xml Thu Jul  3 01:40:58 2008
@@ -135,11 +135,12 @@
       <optional>true</optional>
       <scope>test</scope>
     </dependency>
-      
+
     <dependency>
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-spring</artifactId>
       <scope>test</scope>
+      <optional>true</optional>
     </dependency>
 
     <dependency>
@@ -208,20 +209,12 @@
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
+          <forkMode>pertest</forkMode>
           <childDelegation>false</childDelegation>
           <useFile>true</useFile>
           <includes>
-            <!--<include>**/*Test.*</include>-->
+            <include>**/*Test.*</include>
           </includes>
-          <excludes>
-            <!-- These tests fail/error; I haven't investigated yet.
-                 The PythonExpressionTest also fails but that is demonstrating a problem
that should be fixed.
-                 Same with JavaScriptExpressionTest.
-                 Same with RubyExpressionTest -->
-            <exclude>**/PythonLanguageTest.*</exclude>
-            <exclude>**/JavaScriptLanguageTest.*</exclude>
-            <exclude>**/GroovyFilterTest.*</exclude>
-          </excludes>
         </configuration>
       </plugin>
     </plugins>

Modified: activemq/camel/trunk/components/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java?rev=673619&r1=673618&r2=673619&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java
(original)
+++ activemq/camel/trunk/components/camel-script/src/main/java/org/apache/camel/builder/script/ScriptBuilder.java
Thu Jul  3 01:40:58 2008
@@ -482,7 +482,11 @@
         try {
             getScriptContext();
             populateBindings(getEngine(), exchange);
-            return runScript();
+            Object result = runScript();
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("the script result is " + result);
+            }
+            return result;
         } catch (ScriptException e) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Script evaluation failed: " + e, e);
@@ -495,15 +499,23 @@
 
     protected Object runScript() throws ScriptException, IOException {
         checkInitialised();
+        Object result = null;
         if (compiledScript != null) {
-            return compiledScript.eval();
+            result = compiledScript.eval();
+            if (scriptEngineName.equals("python") || scriptEngineName.equals("jython")) {
+                result = compiledScript.getEngine().get("result");
+            }
         } else {
             if (scriptText != null) {
-                return getEngine().eval(scriptText);
+                result = getEngine().eval(scriptText);
             } else {
-                return getEngine().eval(createScriptReader());
+                result = getEngine().eval(createScriptReader());
+            }
+            if (scriptEngineName.equals("python") || scriptEngineName.equals("jython")) {
+                result = getEngine().get("result");
             }
         }
+        return result;
     }
 
     protected void populateBindings(ScriptEngine engine, Exchange exchange) {

Modified: activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java?rev=673619&r1=673618&r2=673619&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java
(original)
+++ activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java
Thu Jul  3 01:40:58 2008
@@ -57,7 +57,7 @@
                 from("direct:start").choice().
                         // The following java script expression should return a boolean
                         // but it seems to always return false -- what's up with that?
-                        when().javaScript("request.headers['foo'] == 'bar'").to("mock:result")
+                        when().javaScript("request.headers.get('foo') == 'bar'").to("mock:result")
                         .otherwise().to("mock:unmatched");
             }
         };

Modified: activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java?rev=673619&r1=673618&r2=673619&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java
(original)
+++ activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/PythonExpressionTest.java
Thu Jul  3 01:40:58 2008
@@ -58,7 +58,7 @@
                 from("direct:start").choice().
                         // The following python expression should return a boolean
                         // but it seems to return null instead -- what's up with that?
-                        when().python("request.headers['foo'] == 'bar'").to("mock:result")
+                        when().python("result = request.headers['foo']=='bar'").to("mock:result")
                         .otherwise().to("mock:unmatched");
             }
         };

Modified: activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/JavaScriptLanguageTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/JavaScriptLanguageTest.java?rev=673619&r1=673618&r2=673619&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/JavaScriptLanguageTest.java
(original)
+++ activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/JavaScriptLanguageTest.java
Thu Jul  3 01:40:58 2008
@@ -23,9 +23,10 @@
  */
 public class JavaScriptLanguageTest extends LanguageTestSupport {
     public void testLanguageExpressions() throws Exception {
-        assertExpression("exchange.in.headers.foo", "abc");
-        assertExpression("request.headers.foo", "abc");
-        //assertExpression("headers.foo", "abc");
+        assertExpression("exchange.getIn()", "Message: <hello id='m123'>world!</hello>");
+        assertExpression("exchange.getIn().body", "<hello id='m123'>world!</hello>");
+        assertExpression("request.headers.get('foo')", "abc");
+
     }
 
     protected String getLanguageName() {

Modified: activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/PythonLanguageTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/PythonLanguageTest.java?rev=673619&r1=673618&r2=673619&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/PythonLanguageTest.java
(original)
+++ activemq/camel/trunk/components/camel-script/src/test/java/org/apache/camel/language/script/PythonLanguageTest.java
Thu Jul  3 01:40:58 2008
@@ -23,11 +23,10 @@
  */
 public class PythonLanguageTest extends LanguageTestSupport {
     public void testLanguageExpressions() throws Exception {
-        assertExpression("exchange", "abc");
-        assertExpression("exchange.in", "abc");
-        assertExpression("exchange.in.headers[\"foo\"]", "abc");
-        assertExpression("request.headers[\"foo\"]", "abc");
-        //assertExpression("headers.foo", "abc");
+        assertExpression("result=exchange.in.headers", "{foo=abc, bar=123}");
+        assertExpression("result=exchange.in", "Message: <hello id='m123'>world!</hello>");
+        assertExpression("result=exchange.in.headers.get('foo')", "abc");
+        assertExpression("result=request.headers.get('foo')", "abc");
     }
 
     protected String getLanguageName() {

Modified: activemq/camel/trunk/components/camel-script/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-script/src/test/resources/log4j.properties?rev=673619&r1=673618&r2=673619&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-script/src/test/resources/log4j.properties (original)
+++ activemq/camel/trunk/components/camel-script/src/test/resources/log4j.properties Thu Jul
 3 01:40:58 2008
@@ -20,7 +20,7 @@
 #
 log4j.rootLogger=INFO, out
 
-#log4j.logger.org.apache.camel=DEBUG
+log4j.logger.org.apache.camel=DEBUG
 log4j.logger.org.springframework=WARN
 
 # CONSOLE appender not used by default



Mime
View raw message