Changeset 1614 for trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorTest.java
- Timestamp:
- 07/15/14 13:45:31 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorTest.java
r1561 r1614 98 98 } 99 99 100 /** 101 * 102 */ 100 103 @Test 101 104 public void test_SimulatedSession_MonitorOnly() throws Exception { … … 158 161 System.out.println("\n\n"); 159 162 } 160 163 164 /** 165 * 166 */ 161 167 @Test 162 168 public void test_SimpleText_ProxyAndMonitor() throws Exception { … … 175 181 String message = "dummy message"; 176 182 String expectedResponse = "response content"; 177 String response = sendDummyMessage("POST", message, expectedResponse);183 String response = sendDummyMessage("POST", null, message, expectedResponse); 178 184 179 185 assertEquals(expectedResponse, response); … … 207 213 assertEquals(1, sequence.size()); 208 214 209 assertEvent(sequence.get(0), "POST", message, response); 210 } 211 215 assertEvent(sequence.get(0), "POST", null, message, response); 216 } 217 218 /** 219 * 220 */ 212 221 @Test 213 222 public void test_XMLMessage_ProxyAndMonitor() throws Exception { … … 259 268 "</httpEvent>"; 260 269 261 String response = sendDummyMessage("POST", message, expectedResponse);270 String response = sendDummyMessage("POST", null, message, expectedResponse); 262 271 263 272 assertEquals(expectedResponse, response); … … 291 300 assertEquals(1, sequence.size()); 292 301 293 assertEvent(sequence.get(0), "POST", message, response); 294 } 295 302 assertEvent(sequence.get(0), "POST", null, message, response); 303 } 304 305 /** 306 * 307 */ 296 308 @Test 297 309 public void test_SOAP_ProxyAndMonitor() throws Exception { … … 348 360 assertEquals(2, sequence.size()); 349 361 350 assertEvent(sequence.get(0), "GET", null, null); // get WSDL 351 assertEvent(sequence.get(1), "POST", null, null); // send request 352 } 353 362 assertEvent(sequence.get(0), "GET", "wsdl", null, null); // get WSDL 363 assertEvent(sequence.get(1), "POST", null, null, null); // send request 364 } 365 366 /** 367 * 368 */ 369 @Test 370 public void test_LargeRequest_ProxyAndMonitor() throws Exception { 371 monitor = new HttpMonitor(new String[] { LOG_FILE_DIR, MONITOR_PORT + "" }); 372 373 monitor.init(); 374 monitor.start(); 375 376 proxy = new HttpMonitoringProxy 377 (new String[] { LOG_FILE_DIR, PROXY_PORT + "", 378 "localhost:" + DUMMY_SERVER_PORT, "localhost:" + MONITOR_PORT }); 379 380 proxy.init(); 381 proxy.start(); 382 383 StringBuffer message = new StringBuffer(); 384 StringBuffer expectedResponse = new StringBuffer(); 385 386 for (int i = 0; i < 1000; i++) { 387 message.append(" # " + i + " test request data"); 388 expectedResponse.append(" # " + i + " test response data"); 389 } 390 391 String response = 392 sendDummyMessage("POST", null, message.toString(), expectedResponse.toString()); 393 394 assertEquals(expectedResponse.toString(), response); 395 396 // the monitor needs some time to receive the exchange --> give it 397 Thread.sleep(1000); 398 399 monitor.stop(); 400 monitor = null; 401 402 File logFile = new File(LOG_FILE_DIR + File.separator + "httpmonitor_000.log"); 403 404 assertTrue(logFile.exists()); 405 406 HTTPLogParser parser = new HTTPLogParser(); 407 408 parser.parseFile(logFile); 409 410 // check the sequences 411 Collection<List<Event>> sequences = parser.getSequences(); 412 413 assertNotNull(sequences); 414 415 Iterator<List<Event>> iterator = sequences.iterator(); 416 assertTrue(iterator.hasNext()); 417 418 List<Event> sequence = iterator.next(); 419 assertFalse(iterator.hasNext()); 420 421 assertNotNull(sequence); 422 assertEquals(1, sequence.size()); 423 424 assertEvent(sequence.get(0), "POST", null, message.toString(), response); 425 } 426 427 /** 428 * 429 */ 430 @Test 431 public void test_Query_ProxyAndMonitor() throws Exception { 432 monitor = new HttpMonitor(new String[] { LOG_FILE_DIR, MONITOR_PORT + "" }); 433 434 monitor.init(); 435 monitor.start(); 436 437 proxy = new HttpMonitoringProxy 438 (new String[] { LOG_FILE_DIR, PROXY_PORT + "", 439 "localhost:" + DUMMY_SERVER_PORT, "localhost:" + MONITOR_PORT }); 440 441 proxy.init(); 442 proxy.start(); 443 444 String message = "dummy message"; 445 String query = "key=value&key2=value2&key3=%3E%3CXXX"; 446 String expectedResponse = "response content"; 447 String response = sendDummyMessage("POST", query, message, expectedResponse); 448 449 assertEquals(expectedResponse, response); 450 451 // the monitor needs some time to receive the exchange --> give it 452 Thread.sleep(1000); 453 454 monitor.stop(); 455 monitor = null; 456 457 File logFile = new File(LOG_FILE_DIR + File.separator + "httpmonitor_000.log"); 458 459 assertTrue(logFile.exists()); 460 461 HTTPLogParser parser = new HTTPLogParser(); 462 463 parser.parseFile(logFile); 464 465 // check the sequences 466 Collection<List<Event>> sequences = parser.getSequences(); 467 468 assertNotNull(sequences); 469 470 Iterator<List<Event>> iterator = sequences.iterator(); 471 assertTrue(iterator.hasNext()); 472 473 List<Event> sequence = iterator.next(); 474 assertFalse(iterator.hasNext()); 475 476 assertNotNull(sequence); 477 assertEquals(1, sequence.size()); 478 479 assertEvent(sequence.get(0), "POST", query, message, response); 480 } 481 354 482 /** 355 483 *
Note: See TracChangeset
for help on using the changeset viewer.