Changeset 1567 for trunk/autoquest-httpmonitor-test/src/test/java
- Timestamp:
- 06/13/14 16:57:43 (11 years ago)
- 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 83 83 /** */ 84 84 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 } 85 111 86 112 /** … … 182 208 try { 183 209 HttpResponse response = httpclient.execute(httpRequest); 210 211 assertEquals(message, dummyServlet.getRequest()); 184 212 System.err.println(response.getStatusLine()); 185 213 String responseStr = readStreamContentToString(response.getEntity().getContent()); … … 190 218 httpRequest.releaseConnection(); 191 219 } 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();218 220 } 219 221 -
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/DummyServlet.java
r1376 r1567 31 31 32 32 /** */ 33 private String requestMessage; 34 35 /** */ 33 36 private String responseMessage; 34 37 … … 40 43 throws ServletException, IOException 41 44 { 45 requestMessage = AbstractTC.readStreamContentToString(request.getInputStream()); 46 42 47 System.err.println("responding on get with: " + responseMessage); 43 48 response.getOutputStream().write(responseMessage.getBytes()); … … 51 56 throws ServletException, IOException 52 57 { 58 requestMessage = AbstractTC.readStreamContentToString(request.getInputStream()); 59 53 60 System.err.println("responding on post with: " + responseMessage); 54 61 response.getOutputStream().write(responseMessage.getBytes()); … … 59 66 */ 60 67 @Override 61 protected void doTrace(HttpServletRequest req , HttpServletResponse response)68 protected void doTrace(HttpServletRequest request, HttpServletResponse response) 62 69 throws ServletException, IOException 63 70 { 71 requestMessage = AbstractTC.readStreamContentToString(request.getInputStream()); 72 64 73 System.err.println("responding on trace with: " + responseMessage); 65 74 response.getOutputStream().write(responseMessage.getBytes()); … … 72 81 this.responseMessage = responseMessage; 73 82 } 83 84 /** 85 * 86 */ 87 String getRequest() { 88 return this.requestMessage; 89 } 74 90 }
Note: See TracChangeset
for help on using the changeset viewer.