- Timestamp:
- 06/11/14 10:09:21 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitoringProxyTest.java
r1561 r1563 443 443 assertNotNull(exchange.getResponse().getContent().getData()); 444 444 } 445 446 @Test 447 public void test_LargeRequest_Local() throws Exception { 448 proxy = new HttpMonitoringProxy 449 (new String[] { LOG_FILE_DIR, PROXY_PORT + "", "localhost:" + DUMMY_SERVER_PORT, 450 "local" }); 451 452 proxy.init(); 453 proxy.start(); 454 455 StringBuffer message = new StringBuffer(); 456 StringBuffer expectedResponse = new StringBuffer(); 457 458 for (int i = 0; i < 1000; i++) { 459 message.append(" # " + i + " test request data"); 460 expectedResponse.append(" # " + i + " test response data"); 461 } 462 463 String response = sendDummyMessage("POST", message.toString(), expectedResponse.toString()); 464 465 assertEquals(expectedResponse.toString(), response); 466 467 proxy.stop(); 468 proxy = null; 469 470 File logFile = new File(LOG_FILE_DIR + File.separator + "httpmonitor_000.log"); 471 472 assertTrue(logFile.exists()); 473 474 HTTPLogParser parser = new HTTPLogParser(); 475 476 parser.parseFile(logFile); 477 478 // check the sequences 479 Collection<List<Event>> sequences = parser.getSequences(); 480 481 assertNotNull(sequences); 482 483 Iterator<List<Event>> iterator = sequences.iterator(); 484 assertTrue(iterator.hasNext()); 485 486 List<Event> sequence = iterator.next(); 487 assertFalse(iterator.hasNext()); 488 489 assertNotNull(sequence); 490 assertEquals(1, sequence.size()); 491 492 assertEvent(sequence.get(0), "POST", message.toString(), expectedResponse.toString()); 493 } 494 495 @Test 496 public void test_LargeRequest_Remote() throws Exception { 497 proxy = new HttpMonitoringProxy 498 (new String[] { LOG_FILE_DIR, PROXY_PORT + "", 499 "localhost:" + DUMMY_SERVER_PORT, "localhost:" + MONITOR_PORT }); 500 501 proxy.init(); 502 proxy.start(); 503 504 505 StringBuffer message = new StringBuffer(); 506 StringBuffer expectedResponse = new StringBuffer(); 507 508 for (int i = 0; i < 1000; i++) { 509 message.append(" # " + i + " test request data"); 510 expectedResponse.append(" # " + i + " test response data"); 511 } 512 513 String response = sendDummyMessage("POST", message.toString(), expectedResponse.toString()); 514 515 assertEquals(expectedResponse.toString(), response); 516 517 // give the proxy some time to send the copy of the message 518 while(messages.size() < 1) { 519 Thread.sleep(1000); 520 } 521 522 assertEquals(1, messages.size()); 523 524 JAXBContext jaxbContext = JAXBContext.newInstance(HttpExchange.class.getPackage().getName()); 525 Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 526 527 @SuppressWarnings("unchecked") 528 JAXBElement<HttpExchange> jaxObject = 529 (JAXBElement<HttpExchange>) unmarshaller.unmarshal(new StringReader(messages.get(0))); 530 531 HttpExchange exchange = jaxObject.getValue(); 532 533 assertEquals(message.toString(), exchange.getRequest().getContent().getData()); 534 assertEquals(response.toString(), exchange.getResponse().getContent().getData()); 535 } 445 536 446 537 /**
Note: See TracChangeset
for help on using the changeset viewer.