You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2009/01/14 23:14:20 UTC

svn commit: r734532 - in /ode/sandbox/simpel/src: main/antlr/org/apache/ode/simpel/antlr/SimPEL.g test/java/org/apache/ode/simpel/RestfulSimPELTest.java

Author: mriou
Date: Wed Jan 14 14:14:20 2009
New Revision: 734532

URL: http://svn.apache.org/viewvc?rev=734532&view=rev
Log:
RESTful tests.

Modified:
    ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g
    ode/sandbox/simpel/src/test/java/org/apache/ode/simpel/RestfulSimPELTest.java

Modified: ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g
URL: http://svn.apache.org/viewvc/ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g?rev=734532&r1=734531&r2=734532&view=diff
==============================================================================
--- ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g (original)
+++ ode/sandbox/simpel/src/main/antlr/org/apache/ode/simpel/antlr/SimPEL.g Wed Jan 14 14:14:20 2009
@@ -64,18 +64,18 @@
     }
     
     public void displayRecognitionError(String[] tokenNames, RecognitionException e) {
-    	el.reportRecognitionError(tokenNames, e.line, getErrorMessage(e, tokenNames), e);
+    	  el.reportRecognitionError(tokenNames, e.line, getErrorMessage(e, tokenNames), e);
     }
     
     public String getErrorMessage(RecognitionException e, String[] tokenNames) {
-	List stack = getRuleInvocationStack(e, this.getClass().getName());
-    	String msg = null;
-    	if ( e instanceof NoViableAltException ) {
+	      List stack = getRuleInvocationStack(e, this.getClass().getName());
+    	  String msg = null;
+    	  if ( e instanceof NoViableAltException ) {
        	    NoViableAltException nvae = (NoViableAltException)e;
        	    msg = " no viable alt; token="+e.token+" (decision="+nvae.decisionNumber+" state "+nvae.stateNumber+")"+
                   " decision=<<"+nvae.grammarDecisionDescription+">>";
         } else {
-           msg = super.getErrorMessage(e, tokenNames);
+            msg = super.getErrorMessage(e, tokenNames);
         }
         return stack+" "+msg;
     }

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=734532&r1=734531&r2=734532&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 Wed Jan 14 14:14:20 2009
@@ -44,34 +44,6 @@
         server.stop();
     }
 
-    public static final String CALLING_GET =
-            "var feedBUrl = \"http://feeds.feedburner.com/\"; " +
-            "process CallingGet {\n" +
-            "   receive(self) { |query|\n" +
-            "       feed = request(feedBUrl + query);\n" +
-            "       title = feed.channel.title;\n" +
-            "       reply(title);\n" +
-            "   }\n" +
-            "}";
-
-    public void testCallingGet() throws Exception {
-        EmbeddedServer server = new EmbeddedServer();
-        server.start();
-        Descriptor desc = new Descriptor();
-        desc.setAddress("/feedget");
-        server.deploy(CALLING_GET, desc);
-
-        ClientConfig cc = new DefaultClientConfig();
-        Client c = Client.create(cc);
-
-        WebResource wr = c.resource("http://localhost:3434/feedget");
-        ClientResponse resp = wr.path("/").accept("application/xml").type("application/xml")
-                .post(ClientResponse.class, "<simpelWrapper xmlns=\"http://ode.apache.org/simpel/1.0/definition/CallingGet\">OffTheLip</simpelWrapper>");
-        String response = resp.getEntity(String.class);
-        System.out.println("=> " + response);
-        assertTrue(response.indexOf("Off The Lip") > 0);
-    }
-
     private static final String COUNTER =
             "process Counter {\n" +
             "   counter = receive(self); \n" +
@@ -166,23 +138,65 @@
         Thread.sleep(1500);
         queryResponse = instance.path("/").type("application/xml").get(ClientResponse.class);
         assertTrue(queryResponse.getStatus() == 410);
-//        response = queryResponse.getEntity(String.class);
-//        System.out.println("=> " + response);
-//        System.out.println("=> " + queryResponse.getStatus());
-
-
-        // Decrementing counter
-//        ClientResponse decResponse = instance.path("/dec").type("application/xml").post(ClientResponse.class);
-//        response = decResponse.getEntity(String.class);
-//        assertTrue(valueResponse.getStatus() == 200);
-//        assertTrue(response.indexOf("4") > 0);
-//
-//        // Incrementing counter
-//        ClientResponse incResponse = instance.path("/inc").type("application/xml").post(ClientResponse.class);
-//        response = incResponse.getEntity(String.class);
-//        assertTrue(valueResponse.getStatus() == 200);
-//        assertTrue(response.indexOf("5") > 0);
 
         server.stop();
     }
+    
+    public static final String CALLING_GET =
+            "var feedBUrl = \"http://feeds.feedburner.com/\"; " +
+            "process CallingGet {\n" +
+            "   receive(self) { |query|\n" +
+            "       feed = request(feedBUrl + query);\n" +
+            "       title = feed.channel.title;\n" +
+            "       reply(title);\n" +
+            "   }\n" +
+            "}";
+
+    public void testCallingGet() throws Exception {
+        EmbeddedServer server = new EmbeddedServer();
+        server.start();
+        Descriptor desc = new Descriptor();
+        desc.setAddress("/feedget");
+        server.deploy(CALLING_GET, desc);
+
+        ClientConfig cc = new DefaultClientConfig();
+        Client c = Client.create(cc);
+
+        WebResource wr = c.resource("http://localhost:3434/feedget");
+        ClientResponse resp = wr.path("/").accept("application/xml").type("application/xml")
+                .post(ClientResponse.class, "<simpelWrapper xmlns=\"http://ode.apache.org/simpel/1.0/definition/CallingGet\">OffTheLip</simpelWrapper>");
+        String response = resp.getEntity(String.class);
+        System.out.println("=> " + response);
+        assertTrue(response.indexOf("Off The Lip") > 0);
+    }
+
+    public static final String GET_PUT_POST_DELETE =
+            "var testRoot = \"http://localhost:3434/test/gppd/\"; " +
+            "process AllMethods {\n" +
+            "   receive(self) { |query|\n" +
+            "       getRes = request(testRoot);\n" +
+            "       res = getRes.text();\n" +
+            "       postMsg = <foo>foo</foo>;\n" +
+            "       postRes = request(testRoot, \"post\", postMsg);\n" +
+            "       res = res + postRes.text();\n" +
+            "       reply(res);\n" +
+            "   }\n" +
+            "}";
+
+    public void testAllMethods() throws Exception {
+        EmbeddedServer server = new EmbeddedServer();
+        server.start();
+        Descriptor desc = new Descriptor();
+        desc.setAddress("/gppd");
+        server.deploy(GET_PUT_POST_DELETE, desc);
+
+        ClientConfig cc = new DefaultClientConfig();
+        Client c = Client.create(cc);
+
+        WebResource wr = c.resource("http://localhost:3434/gppd");
+        ClientResponse resp = wr.path("/").accept("application/xml").type("application/xml")
+                .post(ClientResponse.class, "<simpelWrapper xmlns=\"http://ode.apache.org/simpel/1.0/definition/AllMethods\"></simpelWrapper>");
+        String response = resp.getEntity(String.class);
+        System.out.println("=> " + response);
+    }
 }