axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/test build_functional_tests.xml
Date Sun, 16 Sep 2001 19:58:46 GMT
gdaniels    01/09/16 12:58:46

  Modified:    java/samples/transport/tcp TCPTransport.java
               java/src/org/apache/axis Message.java
               java/src/org/apache/axis/client ServiceClient.java
                        Transport.java
               java/src/org/apache/axis/providers/java RPCProvider.java
               java/src/org/apache/axis/security/simple
                        SimpleSecurityProvider.java
               java/src/org/apache/axis/transport/http AxisServlet.java
                        HTTPTransport.java
               java/src/org/apache/axis/transport/local LocalSender.java
               java/test build_functional_tests.xml
  Log:
  Fix a bunch of bugs/issues that have been hanging around:
  
  * MessageContext now gets reset() each time invoke() in the ServiceClient
    is called.  This makes sure to clear out transient properties -
    MessageContext is per message, not per session/connection.  In concert
    with this, we now keep a hash of properties in the ServiceClient which
    are copied into the freshly reset MessageContext on each request, which is
    how we persist things.  Timeout and maintainSession have been moved up
    into the ServiceClient as members, and are set accordingly.
  
  * We needed a way to retrieve transport-specific things such as cookie
    headers from a returned MessageContext.  The Transport class now has a
    processReturnedMessageContext() method, defined as a no-op in the base
    class.  If you override it, you can get access to the MessageContext
    which comes back just like setupMessageContext() can get to the one
    that's about to go out.  See HTTPTransport for an example of how to
    use this - this is how we get back the session cookies and store them
    so they get set next time through setupMessageContext().
  
  * Add a little more debugging stuff to RPCProvider
  
  * Remove erroneous setting of HTTP transport from within LocalSender
  
  * Copy users.lst into build dir so that functional stock test works
  
  * Add the beginnings of HTTP GET functionality (i.e. use a browser
    to access http://localhost/axis/Calculator.jws?method=add&arg0=1&arg1=23
    and get back the result).  This is not clean / finished yet.
  
  Revision  Changes    Path
  1.9       +4 -4      xml-axis/java/samples/transport/tcp/TCPTransport.java
  
  Index: TCPTransport.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/transport/tcp/TCPTransport.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TCPTransport.java	2001/09/05 17:22:58	1.8
  +++ TCPTransport.java	2001/09/16 19:58:45	1.9
  @@ -110,15 +110,15 @@
             String urlString = mc.getStrProp(MessageContext.TRANS_URL);
             if (urlString != null) {
               URL url = new URL(urlString);
  -            mc.setProperty(HOST, url.getHost());
  -            mc.setProperty(PORT, new Integer(url.getPort()).toString());
  +            host = url.getHost();
  +            port = new Integer(url.getPort()).toString();
             }
           } catch (java.net.MalformedURLException e) {
             // Do nothing here?
           }
   
  -        if (host != null) serv.set(HOST, host);
  -        if (port != null) serv.set(PORT, port);
  +        if (host != null) mc.setProperty(HOST, host);
  +        if (port != null) mc.setProperty(PORT, port);
   
           category.debug( "Port = " + mc.getStrProp(PORT));
           category.debug( "Host = " + mc.getStrProp(HOST));
  
  
  
  1.45      +1 -0      xml-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Message.java	2001/09/05 17:22:59	1.44
  +++ Message.java	2001/09/16 19:58:45	1.45
  @@ -188,6 +188,7 @@
               try {
                   getAsSOAPEnvelope();
               } catch (Exception e) {
  +                category.fatal("Couldn't make envelope", e);
                   return null;
               }
           }
  
  
  
  1.51      +35 -6     xml-axis/java/src/org/apache/axis/client/ServiceClient.java
  
  Index: ServiceClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/ServiceClient.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- ServiceClient.java	2001/09/05 17:22:59	1.50
  +++ ServiceClient.java	2001/09/16 19:58:45	1.51
  @@ -184,6 +184,13 @@
       // The message context we use across invocations
       private MessageContext msgContext;
   
  +    // Collection of properties to store and put in MessageContext at
  +    // invoke() time
  +    private Hashtable myProperties = null;
  +
  +    private int timeout;
  +    private boolean maintainSession;
  +
       // Our Transport, if any
       private Transport transport;
       private String    transportName;
  @@ -320,7 +327,12 @@
        * @param value the value of the property.
        */
       public void set (String name, Object value) {
  -        msgContext.setProperty(name, value);
  +        if (name == null || value == null)
  +            return;
  +        if (myProperties == null) {
  +            myProperties = new Hashtable();
  +        }
  +        myProperties.put(name, value);
       }
   
       /**
  @@ -330,7 +342,8 @@
        * @return the property's value.
        */
       public Object get (String name) {
  -        return msgContext.getProperty(name);
  +        return (name == null || myProperties == null) ? null :
  +                                                        myProperties.get(name);
       }
   
       /**
  @@ -339,7 +352,7 @@
        * @param value the maximum amount of time, in milliseconds
        */
       public void setTimeout (int value) {
  -        msgContext.setTimeout(value);
  +        timeout = value;
       }
   
       /**
  @@ -348,7 +361,7 @@
        * @return value the maximum amount of time, in milliseconds
        */
       public int getTimeout () {
  -        return msgContext.getTimeout();
  +        return timeout;
       }
   
       /**
  @@ -381,7 +394,7 @@
        * @param yesno true if session state is desired, false if not.
        */
       public void setMaintainSession (boolean yesno) {
  -        msgContext.setMaintainSession(yesno);
  +        maintainSession = yesno;
       }
   
       /**
  @@ -525,7 +538,6 @@
   
           msgContext.setRequestMessage(reqMsg);
           msgContext.setResponseMessage(resMsg);
  -        msgContext.setServiceDescription(this.serviceDesc);
   
           reqEnv.addBodyElement(body);
           reqEnv.setMessageType(ServiceDescription.REQUEST);
  @@ -618,7 +630,21 @@
       public void invoke() throws AxisFault {
           category.debug("Enter: Service::invoke()" );
   
  +        msgContext.reset();
  +
  +        msgContext.setTimeout(timeout);
  +
  +        if (myProperties != null) {
  +            Enumeration enum = myProperties.keys();
  +            while (enum.hasMoreElements()) {
  +                String name = (String) enum.nextElement();
  +                Object value = myProperties.get(name);
  +                msgContext.setProperty(name, value);
  +            }
  +        }
  +
           msgContext.setServiceDescription(serviceDesc);
  +        msgContext.setMaintainSession(maintainSession);
   
           // set up message context if there is a transport
           if (transport != null) {
  @@ -629,6 +655,9 @@
   
           try {
               engine.invoke( msgContext );
  +
  +            if (transport != null)
  +                transport.processReturnedMessageContext(msgContext);
           }
           catch( AxisFault fault ) {
               category.error( fault );
  
  
  
  1.10      +9 -0      xml-axis/java/src/org/apache/axis/client/Transport.java
  
  Index: Transport.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Transport.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Transport.java	2001/08/31 18:40:14	1.9
  +++ Transport.java	2001/09/16 19:58:45	1.10
  @@ -118,6 +118,15 @@
       }
   
       /**
  +     * Allow the transport to grab any transport-specific stuff it might
  +     * want from a returned MessageContext
  +     */
  +    public void processReturnedMessageContext(MessageContext context)
  +    {
  +        // Default impl does nothing
  +    }
  +
  +    /**
        * Sets the transport chain name - to override the default.
        * @param name the name of the transport chain to use
        */
  
  
  
  1.19      +8 -4      xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
  
  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- RPCProvider.java	2001/09/06 20:18:09	1.18
  +++ RPCProvider.java	2001/09/16 19:58:46	1.19
  @@ -63,6 +63,7 @@
   import org.apache.axis.message.* ;
   import org.apache.axis.server.ParamList;
   import org.apache.log4j.Category;
  +import org.apache.log4j.Priority;
   
   /**
    * Implement message processing by walking over RPCElements of the
  @@ -85,8 +86,11 @@
                                   Object obj)
           throws Exception
       {
  +        category.debug("Enter::RPCProvider.processMessage()");
           Vector          bodies = reqEnv.getBodyElements();
  -        
  +        category.debug("There are " + bodies.size() + " body elements.");
  +        category.debug("body is " + bodies.get(0));
  +
           /* Loop over each entry in the SOAPBody - each one is a different */
           /* RPC call.                                                      */
           /******************************************************************/
  @@ -106,9 +110,7 @@
                   for ( int i = 0 ; i < args.size() ; i++ ) {
                       argValues[i]  = ((RPCParam)args.get(i)).getValue() ;
                       
  -                    if (DEBUG_LOG) {
  -                        System.out.println("  value: " + argValues[i] );
  -                    }
  +                    category.debug("  value: " + argValues[i] );
                   }
               }
   
  @@ -218,6 +220,8 @@
                   objRes = method.invoke( obj, argValues );
                 }
               }
  +
  +            category.debug("Got result: " + objRes);
   
               /* Now put the result in the result SOAPEnvelope */
               /*************************************************/
  
  
  
  1.4       +0 -1      xml-axis/java/src/org/apache/axis/security/simple/SimpleSecurityProvider.java
  
  Index: SimpleSecurityProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/security/simple/SimpleSecurityProvider.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SimpleSecurityProvider.java	2001/09/12 18:15:23	1.3
  +++ SimpleSecurityProvider.java	2001/09/16 19:58:46	1.4
  @@ -81,7 +81,6 @@
   
       // load the users list
       static {
  -        category.setPriority(Priority.DEBUG);
           File userFile = new File("users.lst");
           if (userFile.exists()) {
               users = new HashMap();
  
  
  
  1.47      +45 -2     xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
  
  Index: AxisServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- AxisServlet.java	2001/09/12 18:54:55	1.46
  +++ AxisServlet.java	2001/09/16 19:58:46	1.47
  @@ -73,8 +73,7 @@
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
  -import java.io.IOException;
  -import java.io.InputStream;
  +import java.io.*;
   import java.util.Enumeration;
   
   /**
  @@ -175,6 +174,50 @@
                           XMLUtils.DocumentToWriter(doc, res.getWriter());
                           res.getWriter().close();
                       }
  +                } else if (req.getParameterNames().hasMoreElements()) {
  +                    Enumeration enum = req.getParameterNames();
  +                    PrintWriter writer = res.getWriter();
  +                    String method = null;
  +                    String args = "";
  +                    while (enum.hasMoreElements()) {
  +                        String param = (String) enum.nextElement();
  +                        if (param.equalsIgnoreCase("method")) {
  +                            method = req.getParameter(param);
  +                        } else {
  +                            args += "<" + param + ">" +
  +                                    req.getParameter(param) +
  +                                    "</" + param + ">";
  +                        }
  +                    }
  +                    if (method == null) {
  +                        writer.println("<p>No method!</p>");
  +                        writer.close();
  +                        return;
  +                    }
  +                    String body = "<" + method + ">" + args +
  +                                  "</" + method + ">";
  +                    String msgtxt = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+
  +                                 "<SOAP-ENV:Body>" + body + "</SOAP-ENV:Body>"
+
  +                                 "</SOAP-ENV:Envelope>";
  +                    ByteArrayInputStream istream = new ByteArrayInputStream(
  +                        msgtxt.getBytes());
  +                    Message msg = new Message(istream, false);
  +                    msgContext.setRequestMessage(msg);
  +//                    if (msg != null) {
  +//                        writer.println(msg.getAsString());
  +//                        return;
  +//                    }
  +                    engine.invoke(msgContext);
  +                    Message respMsg = msgContext.getResponseMessage();
  +                    if (respMsg != null) {
  +                        writer.println("<p>Got response message:</p>");
  +                        writer.println(respMsg.getAsString());
  +                        writer.close();
  +                    } else {
  +                        writer.println("<p>No response message!</p>");
  +                        writer.close();
  +                    }
  +                    return;
                   } else {
                       res.setContentType("text/html");
                       res.getWriter().println("<h1>" + req.getRequestURI() +
  
  
  
  1.7       +15 -2     xml-axis/java/src/org/apache/axis/transport/http/HTTPTransport.java
  
  Index: HTTPTransport.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTTPTransport.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HTTPTransport.java	2001/09/05 17:23:00	1.6
  +++ HTTPTransport.java	2001/09/16 19:58:46	1.7
  @@ -81,7 +81,9 @@
        */
       static public String URL = MessageContext.TRANS_URL;
       static public String ACTION = HTTPConstants.MC_HTTP_SOAPACTION;
  -    
  +
  +    private String cookie;
  +    private String cookie2;
       private String action;
       
       public HTTPTransport () {
  @@ -111,12 +113,23 @@
           throws AxisFault
       {
           if (action != null) mc.setProperty(ACTION, action);
  -        
  +
  +        // Set up any cookies we know about
  +        if (cookie != null)
  +            mc.setProperty(HTTPConstants.HEADER_COOKIE, cookie);
  +        if (cookie2 != null)
  +            mc.setProperty(HTTPConstants.HEADER_COOKIE, cookie2);
  +
           // Allow the SOAPAction to determine the service, if the service
           // (a) has not already been determined, and (b) if a service matching
           // the soap action has been deployed.
           if (mc.getServiceHandler() == null) {
               mc.setTargetService( (String)mc.getProperty(ACTION) );
           }
  +    }
  +
  +    public void processReturnedMessageContext(MessageContext context) {
  +        cookie = context.getStrProp(HTTPConstants.HEADER_COOKIE);
  +        cookie2 = context.getStrProp(HTTPConstants.HEADER_COOKIE2);
       }
   }
  
  
  
  1.12      +0 -7      xml-axis/java/src/org/apache/axis/transport/local/LocalSender.java
  
  Index: LocalSender.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/local/LocalSender.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LocalSender.java	2001/09/10 19:56:29	1.11
  +++ LocalSender.java	2001/09/16 19:58:46	1.12
  @@ -114,13 +114,6 @@
           serverContext.setRequestMessage(new Message(msgStr));
           serverContext.setTransportName("local");
   
  -        // copy soap action if it is present
  -        String action = clientContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
  -        if (action != null) {
  -            serverContext.setProperty(HTTPConstants.MC_HTTP_SOAPACTION, action);
  -            serverContext.setTransportName("http");
  -        }
  -
           // Also copy authentication info if present
           String user = clientContext.getStrProp(MessageContext.USERID);
           if (user != null) {
  
  
  
  1.9       +10 -7     xml-axis/java/test/build_functional_tests.xml
  
  Index: build_functional_tests.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/build_functional_tests.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- build_functional_tests.xml	2001/07/10 22:53:15	1.8
  +++ build_functional_tests.xml	2001/09/16 19:58:46	1.9
  @@ -11,7 +11,7 @@
   Prerequisites:
   
      a successful Axis build configuration
  -   
  +
   Author:
     Rob Jellinghaus <robj@unrealities.com>
   
  @@ -54,17 +54,20 @@
         <classpath refid="test-classpath" />
       </java>
     </target>
  -  
  +
     <!-- =================================================================== -->
     <!-- Runs the JUnit functional test -->
     <!-- =================================================================== -->
     <target name="junit-functional" if="junit.present">
  -  
  +
       <!-- first, put the JWS where the functional test can see it -->
       <mkdir dir="build/jws" />
       <copy file="samples/stock/StockQuoteService.jws" todir="build/jws" />
       <copy file="test/functional/AltStockQuoteService.jws" todir="build/jws" />
  -    
  +
  +    <!--...not to mention the sample user list -->
  +    <copy file="samples/stock/users.lst" todir="build"/>
  +
       <!-- now, run the actual test -->
       <junit dir="." printsummary="yes" haltonfailure="yes" fork="yes">
         <classpath refid="test-classpath" />
  @@ -78,7 +81,7 @@
         </batchtest>
       </junit>
     </target>
  -  
  +
     <!-- =================================================================== -->
     <!-- Stops the functional test HTTP server -->
     <!-- =================================================================== -->
  @@ -89,7 +92,7 @@
         <arg line="quit"/>
       </java>
     </target>
  -  
  +
     <!-- =================================================================== -->
     <!-- Run functional tests                                                -->
     <!-- =================================================================== -->
  @@ -103,7 +106,7 @@
         testTarget="junit-functional"
         stopTarget="stop-functional-test-http-server" />
     </target>
  -  
  +
     <!-- =================================================================== -->
     <!-- Runs the JUnit functional test, with special class parameter.       -->
     <!-- This is because RobJ's IDE can't build into multiple directories;   -->
  
  
  

Mime
View raw message