You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2008/07/02 02:03:08 UTC

svn commit: r673235 - in /ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding: ArithmeticsJettyWrapper.java HttpBindingTest.java JettyWrapper.java

Author: midon
Date: Tue Jul  1 17:03:07 2008
New Revision: 673235

URL: http://svn.apache.org/viewvc?rev=673235&view=rev
Log:
prepare the field for more services

Added:
    ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java
      - copied, changed from r673234, ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java
Removed:
    ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java
Modified:
    ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java

Modified: ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java?rev=673235&r1=673234&r2=673235&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java (original)
+++ ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java Tue Jul  1 17:03:07 2008
@@ -18,14 +18,14 @@
  * @author <a href="mailto:midon@intalio.com">Alexis Midon</a>
  */
 public class HttpBindingTest extends Axis2TestBase {
-    protected ArithmeticsJettyWrapper jettyWrapper;
+    protected JettyWrapper jettyWrapper;
 
     CountDownLatch latch;
 
     protected void setUp() throws Exception {
         super.setUp();
         latch = new CountDownLatch(1);
-        jettyWrapper = new ArithmeticsJettyWrapper(7070);
+        jettyWrapper = new JettyWrapper(7070);
         new Thread("HttpBindingJetty") {
             public void run() {
                 try {

Copied: ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java (from r673234, ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java)
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java?p2=ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java&p1=ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java&r1=673234&r2=673235&rev=673235&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java (original)
+++ ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java Tue Jul  1 17:03:07 2008
@@ -35,34 +35,49 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.ServletException;
 import javax.servlet.ServletInputStream;
+import javax.xml.namespace.QName;
 import java.io.IOException;
 
 /**
  * @author <a href="mailto:midon@intalio.com">Alexis Midon</a>
  */
-public class ArithmeticsJettyWrapper {
+public class JettyWrapper {
 
     protected Server server;
     private ContextHandlerCollection handlerColl;
 
-    public ArithmeticsJettyWrapper() throws Exception {
+    public JettyWrapper() throws Exception {
         this(7070);
     }
 
-    public ArithmeticsJettyWrapper(int port) throws Exception {
+    public JettyWrapper(int port) throws Exception {
         server = new Server(port);
-        // Adding the buildr handler to control our server lifecycle
-        ContextHandler context = new ContextHandler();
-        context.setContextPath("/HttpBindingTest/ArithmeticsService");
-        Handler handler = new ArithmeticsServiceHandler();
-        context.setHandler(handler);
+
+        // Arithmetics Service
+        ContextHandler arithmeticsContext = new ContextHandler();
+        arithmeticsContext.setContextPath("/HttpBindingTest/ArithmeticsService");
+        arithmeticsContext.setHandler(new ArithmeticsServiceHandler());
 
         handlerColl = new ContextHandlerCollection();
-        handlerColl.setHandlers(new Handler[]{context});
+        handlerColl.setHandlers(new Handler[]{arithmeticsContext});
 
         server.addHandler(handlerColl);
     }
 
+
+    private Document parseBody(ServletInputStream bodyStream, HttpServletResponse response) throws IOException {
+        if (bodyStream == null) {
+            response.sendError(400, "Missing body!");
+        } else {
+            try {
+                return DOMUtils.parse(bodyStream);
+            } catch (SAXException e) {
+                response.sendError(400, "Failed to parse body! " + e.getMessage());
+            }
+        }
+        return null;
+    }
+
     private class ArithmeticsServiceHandler extends AbstractHandler {
         /*
         8 urls to handle:
@@ -173,7 +188,7 @@
                                     Element secondElement = DOMUtils.getNextSiblingElement(firstOperand);
                                     String left = DOMUtils.getTextContent(firstOperand);
                                     String right = DOMUtils.getTextContent(secondElement);
-                                    Element res = bodyDoc.createElementNS("http://ode/bpel/arithmetics", "theresult");
+                                    Element res = bodyDoc.createElementNS("http://ode/bpel/test/arithmetics", "theresult");
                                     res.setTextContent(String.valueOf(Integer.valueOf(left) + Integer.valueOf(right)));
                                     response.getOutputStream().print(DOMUtils.domToString(res));
                                     response.setStatus(200);
@@ -188,14 +203,14 @@
                                 int left = Integer.valueOf(DOMUtils.getTextContent(firstOperand));
                                 int right = Integer.valueOf(DOMUtils.getTextContent(secondElement));
 
-                                int min = Math.min(left,right);
-                                int max = Math.max(left,right);
+                                int min = Math.min(left, right);
+                                int max = Math.max(left, right);
 //                                Element arrayElt = bodyDoc.createElement("sumOfInteger");
-                                Element anElt = bodyDoc.createElementNS("http://ode/bpel/arithmetics", "sumOfInteger");
+                                Element anElt = bodyDoc.createElementNS("http://ode/bpel/test/arithmetics", "sumOfInteger");
                                 Element msg = bodyDoc.createElement("msg");
                                 Element resultIs = bodyDoc.createElement("resultIs");
                                 msg.setTextContent("A dummy message we don't care about. Only purpose is to have a complex type");
-                                resultIs.setTextContent(String.valueOf((max*(max+1)-min*(min+1))/2));
+                                resultIs.setTextContent(String.valueOf((max * (max + 1) - min * (min + 1)) / 2));
 
                                 anElt.appendChild(msg);
                                 anElt.appendChild(resultIs);
@@ -214,23 +229,12 @@
             }
         }
 
-        private Document parseBody(ServletInputStream bodyStream, HttpServletResponse response) throws IOException {
-            if (bodyStream == null) {
-                response.sendError(400, "Missing body!");
-            } else {
-                try {
-                    return DOMUtils.parse(bodyStream);
-                } catch (SAXException e) {
-                    response.sendError(400, "Failed to parse body! " + e.getMessage());
-                }
-            }
-            return null;
-        }
     }
 
+
     public static void main(String[] args) {
         try {
-            new ArithmeticsJettyWrapper();
+            new JettyWrapper().server.start();
         } catch (Exception e) {
             e.printStackTrace();
         }