Ignore:
Timestamp:
06/13/14 16:57:43 (10 years ago)
Author:
pharms
Message:
  • next solved issue with reused buffers
Location:
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/AbstractTC.java

    r1561 r1567  
    8383    /** */ 
    8484    private static Tomcat tomcat = new Tomcat(); 
     85     
     86    /** 
     87     *  
     88     */ 
     89    static String readStreamContentToString(InputStream stream) throws IOException { 
     90        return readToString(new BufferedReader(new InputStreamReader(stream))); 
     91    } 
     92     
     93    /** 
     94     *  
     95     */ 
     96    static String readToString(BufferedReader reader) throws IOException { 
     97        StringBuffer message = new StringBuffer(); 
     98         
     99        String line = reader.readLine(); 
     100        while (line != null) { 
     101            System.err.println(line); 
     102            if (message.length() > 0) { 
     103                message.append('\n'); 
     104            } 
     105            message.append(line); 
     106            line = reader.readLine(); 
     107        } 
     108         
     109        return message.toString(); 
     110    } 
    85111 
    86112    /** 
     
    182208        try { 
    183209            HttpResponse response = httpclient.execute(httpRequest); 
     210             
     211            assertEquals(message, dummyServlet.getRequest()); 
    184212            System.err.println(response.getStatusLine()); 
    185213            String responseStr = readStreamContentToString(response.getEntity().getContent()); 
     
    190218            httpRequest.releaseConnection(); 
    191219        } 
    192     } 
    193      
    194     /** 
    195      *  
    196      */ 
    197     protected String readStreamContentToString(InputStream stream) throws IOException { 
    198         return readToString(new BufferedReader(new InputStreamReader(stream))); 
    199     } 
    200      
    201     /** 
    202      *  
    203      */ 
    204     protected String readToString(BufferedReader reader) throws IOException { 
    205         StringBuffer message = new StringBuffer(); 
    206          
    207         String line = reader.readLine(); 
    208         while (line != null) { 
    209             System.err.println(line); 
    210             if (message.length() > 0) { 
    211                 message.append('\n'); 
    212             } 
    213             message.append(line); 
    214             line = reader.readLine(); 
    215         } 
    216          
    217         return message.toString(); 
    218220    } 
    219221     
  • trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/DummyServlet.java

    r1376 r1567  
    3131     
    3232    /** */ 
     33    private String requestMessage; 
     34     
     35    /** */ 
    3336    private String responseMessage; 
    3437 
     
    4043        throws ServletException, IOException 
    4144    { 
     45        requestMessage = AbstractTC.readStreamContentToString(request.getInputStream()); 
     46         
    4247        System.err.println("responding on get with:   " + responseMessage); 
    4348        response.getOutputStream().write(responseMessage.getBytes()); 
     
    5156        throws ServletException, IOException 
    5257    { 
     58        requestMessage = AbstractTC.readStreamContentToString(request.getInputStream()); 
     59         
    5360        System.err.println("responding on post with:  " + responseMessage); 
    5461        response.getOutputStream().write(responseMessage.getBytes()); 
     
    5966     */ 
    6067    @Override 
    61     protected void doTrace(HttpServletRequest req, HttpServletResponse response) 
     68    protected void doTrace(HttpServletRequest request, HttpServletResponse response) 
    6269        throws ServletException, IOException 
    6370    { 
     71        requestMessage = AbstractTC.readStreamContentToString(request.getInputStream()); 
     72         
    6473        System.err.println("responding on trace with: " + responseMessage); 
    6574        response.getOutputStream().write(responseMessage.getBytes()); 
     
    7281        this.responseMessage = responseMessage; 
    7382    } 
     83 
     84    /** 
     85     *  
     86     */ 
     87    String getRequest() { 
     88        return this.requestMessage; 
     89    } 
    7490} 
Note: See TracChangeset for help on using the changeset viewer.