You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2007/02/10 23:21:31 UTC

svn commit: r505778 - in /webservices/axis/trunk/c/tests/utils/monitor/org/apache/test: MockServer.java MockServerThread.java Response.java

Author: nadiramra
Date: Sat Feb 10 14:21:31 2007
New Revision: 505778

URL: http://svn.apache.org/viewvc?view=rev&rev=505778
Log:
Mock server was not actually updating the content-length correctly.

Modified:
    webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServer.java
    webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServerThread.java
    webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/Response.java

Modified: webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServer.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServer.java?view=diff&rev=505778&r1=505777&r2=505778
==============================================================================
--- webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServer.java (original)
+++ webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServer.java Sat Feb 10 14:21:31 2007
@@ -179,7 +179,6 @@
     private MockServer( String responseFileName, int port, boolean loopOnResponses) throws IOException
     {
         this(responseFileName, loopOnResponses);
-        System.out.println( "MockServer(responseFile, port)");
         this.port =port;
         // no point in going on if we can;'t create a server socket
         //serverSocket = TCPMonitor.getServerSocket(port);
@@ -200,7 +199,7 @@
         // check the responsefile is there
         if (!this.responseFile.canRead( ))
             throw new IOException("Can't read the response file <" +responseFile+">");
-        System.out.println( "2MockServer will loop on responses? " + loopOnResponses);
+
         cacheResponseFile();
         // now deal with the port and threads
     }
@@ -210,7 +209,6 @@
      */
     protected void cacheResponseFile( )throws IOException
     {
-        System.out.println( "1MockServer will loop on responses? " + loopOnResponses);       
         // cache the response file (this is a necessary optimisation - if the file is big then the connection blows)
         MockServerThread.cacheResponseFile(responseFile, loopOnResponses);
     }

Modified: webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServerThread.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServerThread.java?view=diff&rev=505778&r1=505777&r2=505778
==============================================================================
--- webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServerThread.java (original)
+++ webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/MockServerThread.java Sat Feb 10 14:21:31 2007
@@ -294,7 +294,6 @@
             // Recalculate time for local offset
             Calendar calendar = format.getCalendar();
             Date date = calendar.getTime();
-//            date.setTime(date.getTime() - calendar.getTimeZone().getRawOffset());
             date.setTime(date.getTime() - calendar.getTimeZone().getOffset(date.getTime()));
 
             // Create new string to be placed in response
@@ -319,9 +318,13 @@
         {
             String orgResponse = "HTTP" + responseStrings[i];
             String hash = "###";
-            
-            int hashPos = orgResponse.indexOf( hash);
             String newResponse = orgResponse;
+            
+            int hashPos = -1;
+            
+            // The content length will be modified later, so skip if not chunked.
+            if (newResponse.indexOf("Content-Length:")==-1)
+                hashPos = orgResponse.indexOf( hash);
             
             if( hashPos != -1)
             {

Modified: webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/Response.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/Response.java?view=diff&rev=505778&r1=505777&r2=505778
==============================================================================
--- webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/Response.java (original)
+++ webservices/axis/trunk/c/tests/utils/monitor/org/apache/test/Response.java Sat Feb 10 14:21:31 2007
@@ -79,7 +79,8 @@
             hasCloseConnectionHeader=true;
        
         // Find out if the message is chunked
-        deriveIsChunked( );
+        // simply look for the content length string
+        chunked= message.indexOf(CONTENT_LENGTH)==-1;
         
         // emulate None OS machines when you want to test out the CRLF method
         //emulateNoneWinmachines();
@@ -103,12 +104,6 @@
         message = msgString.toCharArray();
     }
 
-    private void deriveIsChunked( )
-    {
-        // simply look for the content length string
-        chunked=new String(message).indexOf(CONTENT_LENGTH)==-1;
-    }
-
     public char[] getMessage( )
     {
         return message;
@@ -131,7 +126,7 @@
         String modifiedResponse="";
         if (chunked)
         {
-            System.out.println("Information - Response file is chunked.");
+            System.out.println("Information - Response is chunked.");
             
             String messageString= new String(getMessage());
             modifiedResponse = correctHTTPHeaderSection(messageString);
@@ -140,6 +135,8 @@
         }
         else
         {
+            System.out.println("Information - Response is NOT chunked.");    
+            
             if (System.getProperty("os.name").toLowerCase( ).startsWith("windows"))
                 System.out.println("Windows operating system - not converting crlf's");
             else
@@ -311,67 +308,6 @@
     return theCorrectedResponse.toString();
 }
 
-//    /**
-//     * This method looks through a chunked data section and ensures that the
-//     * chunksizes are correct. *
-//     * 
-//     * @param message
-//     * @return the message - corrected if necessary
-//     */
-//    private boolean checkBlocks(String message)
-//    {
-//        boolean sizesCorrect=true;
-//        boolean reachedEndOfAllChunks=false;
-//        int indexOfEndOfChunkSize=0;
-//        while (!reachedEndOfAllChunks&&sizesCorrect)
-//        {
-//            // Find this chunk_size value.
-//            indexOfEndOfChunkSize=message.indexOf(CRLF);
-//            System.out.println("indexOfChunkSize = "+indexOfEndOfChunkSize);
-//            //                System.out.println( "Message ="+message);
-//            System.out.println("Message.length() = "+message.length( ));
-//
-//            String chunkSizeString=message.substring(0, indexOfEndOfChunkSize)
-//                    .trim( );
-//
-//            int chunkSize=Integer.parseInt(chunkSizeString, 16);
-//            System.out.println("chunkSize="+chunkSize);
-//            if (chunkSize!=8192)
-//            {
-//                System.out.println("DEBUGGIN");
-//                ;
-//            }
-//            if (chunkSize==0)
-//            {
-//                reachedEndOfAllChunks=true;
-//            }
-//            else
-//            {
-//                // move the message past the size of Chunk
-//                message=message.substring(chunkSizeString.length( )
-//                        +CRLF.length( ));
-//
-//                // check that the last two chars are CRLF
-//                String lastTwoChars=message.substring(chunkSize, chunkSize+2);
-//                if (!lastTwoChars.equals(CRLF))
-//                {
-//                    System.err
-//                            .println("WARNING: Actual chunksize != declared chunksize: "
-//                                    +chunkSize);
-//                    sizesCorrect=false;
-//                }
-//                else
-//                {
-//                    // 	move the message on to the end of this chunk
-//                    message=message.substring(chunkSize+CRLF.length( ));
-//                }
-//            }
-//
-//        }
-//        return sizesCorrect;
-//
-//    }
-
     /**
      * @param sResponse
      * @param iIndex
@@ -421,7 +357,7 @@
             // the Content-Length value needs to be set to the size
             // of the body of the http response 
             String returnedHttpBody = response.substring(iIndex);
-            returnedResponse.replaceFirst("###", new Integer(returnedHttpBody.length()).toString());
+            returnedResponse = returnedResponse.replaceFirst("###", Integer.toString(returnedHttpBody.length()));
             return returnedResponse + returnedHttpBody;
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org