Changeset 1567 for trunk


Ignore:
Timestamp:
06/13/14 16:57:43 (10 years ago)
Author:
pharms
Message:
  • next solved issue with reused buffers
Location:
trunk
Files:
3 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} 
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxyServlet.java

    r1563 r1567  
    258258            ByteBuffer next = delegate.next(); 
    259259             
    260             ByteBuffer clone = ByteBuffer.allocate(next.capacity()); 
     260            ByteBuffer clone1 = ByteBuffer.allocate(next.capacity()); 
     261            ByteBuffer clone2 = ByteBuffer.allocate(next.capacity()); 
     262             
    261263            next.rewind(); 
    262             clone.put(next); 
     264            clone1.put(next); 
    263265            next.rewind(); 
    264             clone.flip(); 
     266            clone2.put(next); 
     267            next.rewind(); 
     268             
     269            clone1.flip(); 
     270            clone2.flip(); 
    265271              
    266             exchangeListenerManager.onRequestContent(request, clone); 
     272            exchangeListenerManager.onRequestContent(request, clone1); 
    267273             
    268             return next; 
     274            return clone2; 
    269275        } 
    270276 
Note: See TracChangeset for help on using the changeset viewer.