Author: mriou
Date: Fri Oct 31 17:35:15 2008
New Revision: 709617

URL: http://svn.apache.org/viewvc?rev=709617&view=rev
Log:
Testing that the location is set on new instance post response.

Modified:
    
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/expr/E4XExprRuntime.java
    
ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/RestfulSimPELTest.java

Modified: 
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/expr/E4XExprRuntime.java
URL: 
http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/expr/E4XExprRuntime.java?rev=709617&r1=709616&r2=709617&view=diff
==============================================================================
--- 
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/expr/E4XExprRuntime.java 
(original)
+++ 
ode/sandbox/simpel/src/main/java/org/apache/ode/simpel/expr/E4XExprRuntime.java 
Fri Oct 31 17:35:15 2008
@@ -35,8 +35,19 @@
     public void initialize(Map map) throws ConfigurationException {
     }
 
-    public String evaluateAsString(OExpression oExpression, EvaluationContext 
evaluationContext) throws FaultException {
-        return null;
+    public String evaluateAsString(OExpression oexpr, EvaluationContext 
evaluationContext) throws FaultException {
+        Context cx = ContextFactory.getGlobal().enterContext();
+        cx.setOptimizationLevel(-1);
+
+        Scriptable parentScope = getScope(cx, oexpr);
+        ODEDelegator scope = new ODEDelegator(parentScope, evaluationContext, 
(SimPELExpr)oexpr, cx);
+
+        // First evaluating the assignment
+        SimPELExpr expr = (SimPELExpr) oexpr;
+        Object res = cx.evaluateString(scope, expr.getExpr(), "<expr>", 0, 
null);
+        if (res instanceof String) return (String) res;
+        else throw new FaultException(new QName("e4xEvalFailure"), "Failed to 
evaluate "
+                + expr.getExpr() + " as a string value");
     }
 
     public boolean evaluateAsBoolean(OExpression oexpr, EvaluationContext 
evaluationContext) throws FaultException {

Modified: 
ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/RestfulSimPELTest.java
URL: 
http://svn.apache.org/viewvc/ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/RestfulSimPELTest.java?rev=709617&r1=709616&r2=709617&view=diff
==============================================================================
--- 
ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/RestfulSimPELTest.java 
(original)
+++ 
ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/RestfulSimPELTest.java 
Fri Oct 31 17:35:15 2008
@@ -9,6 +9,7 @@
 import com.sun.jersey.api.client.ClientResponse;
 
 import javax.ws.rs.core.Response;
+import java.util.regex.Pattern;
 
 public class RestfulSimPELTest extends TestCase {
 
@@ -33,7 +34,10 @@
         WebResource wr = c.resource("http://localhost:3033/hello";);
         ClientResponse resp = 
wr.path("/").accept("application/xml").type("application/xml")
                 .post(ClientResponse.class, "<simpelWrapper 
xmlns=\"http://ode.apache.org/simpel/1.0/definition/HelloWorld\";>foo</simpelWrapper>");
-        System.out.println("=> " + resp.getEntity(String.class));
+        String response = resp.getEntity(String.class);
+        System.out.println("=> " + response);
+        assertTrue(response.indexOf("Hello foo") > 0);
+        
assertTrue(resp.getMetadata().get("Location").get(0).matches("/hello/[0-9]*"));
         System.out.println("loc " + resp.getMetadata().get("Location"));
     }
 }


Reply via email to