Changeset 1229 for trunk/autoquest-htmlmonitor-test/src/test/java/de
- Timestamp:
- 06/26/13 15:31:42 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-htmlmonitor-test/src/test/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorTest.java
r1078 r1229 146 146 htmlMonitor = null; 147 147 148 File logFile = new File(LOG_FILE_DIR + File.separator + clientId+ File.separator +149 "htmlmonitor_" + clientId + "_000.log");148 File logFile = new File(LOG_FILE_DIR + File.separator + "host" + File.separator + 149 clientId + File.separator + "htmlmonitor_" + clientId + "_000.log"); 150 150 151 151 assertTrue(logFile.exists()); … … 362 362 htmlMonitor = null; 363 363 364 File logFile = new File(LOG_FILE_DIR + File.separator + clientId+ File.separator +365 "htmlmonitor_" + clientId + "_000.log");364 File logFile = new File(LOG_FILE_DIR + File.separator + "host" + File.separator + 365 clientId + File.separator + "htmlmonitor_" + clientId + "_000.log"); 366 366 367 367 assertTrue(logFile.exists()); … … 527 527 // assert 9 already rotated log files 528 528 for (int i = 0; i < numberOfSessions; i++) { 529 File logFile = new File(LOG_FILE_DIR + File.separator + clientId + File.separator + 530 "htmlmonitor_" + clientId + "_00" + i + ".log"); 529 File logFile = new File(LOG_FILE_DIR + File.separator + "host" + File.separator + 530 clientId + File.separator + "htmlmonitor_" + clientId + "_00" + 531 i + ".log"); 531 532 532 533 assertTrue(logFile.exists()); … … 603 604 assertEvent(sequence.get(0), 12345, MouseClick.class, node, 194, 7); 604 605 } 606 } 607 608 /** 609 * 610 */ 611 @Test 612 public void testRevertOfOldFiles() throws Exception { 613 String clientId = "123"; 614 615 String message = 616 "{" + 617 " \"message\": {" + 618 " \"clientInfos\": {" + 619 " \"clientId\":\"" + clientId + "\"," + 620 " \"userAgent\":\"Agent\"," + 621 " \"title\":\"Title\"," + 622 " \"url\":\"http://host/path\"" + 623 " }," + 624 " \"guiModel\": {" + 625 " \"tagName\":\"html\"," + 626 " \"index\":\"0\"," + 627 " \"children\":" + 628 " [ {" + 629 " \"tagName\":\"head\"," + 630 " \"index\":\"0\"," + 631 " }," + 632 " {" + 633 " \"tagName\":\"body\"," + 634 " \"htmlId\":\"gsr\"," + 635 " }" + 636 " ]" + 637 " }," + 638 " \"events\":" + 639 " [ {" + 640 " \"time\":\"12345\"," + 641 " \"path\":\"/html[0]/body(htmlId=gsr)\"," + 642 " \"eventType\":\"onclick\"" + 643 " \"coordinates\": [\"194\", \"7\"]" + 644 " }" + 645 " ]" + 646 " }" + 647 "}"; 648 649 sendMessageAndAssertResponse(message); 650 651 htmlMonitor.stop(); 652 htmlMonitor = null; 653 654 File logFile1 = new File(LOG_FILE_DIR + File.separator + "host" + File.separator + 655 clientId + File.separator + "htmlmonitor_" + clientId + "_000.log"); 656 657 assertTrue(logFile1.exists()); 658 659 // Move file to a the directory in which it would resist in the old structure and then 660 // restart the server, resend the message and ensure two separate log files in the new 661 // structure 662 File oldLogFile = new File(LOG_FILE_DIR + File.separator + clientId + File.separator + 663 "htmlmonitor_" + clientId + "_000.log"); 664 665 assertTrue(oldLogFile.getParentFile().mkdirs()); 666 assertTrue(logFile1.renameTo(oldLogFile)); 667 668 htmlMonitor = new HtmlMonitor(new String[] { LOG_FILE_DIR, Integer.toString(PORT) }); 669 htmlMonitor.init(); 670 htmlMonitor.start(); 671 672 sendMessageAndAssertResponse(message); 673 674 htmlMonitor.stop(); 675 htmlMonitor = null; 676 677 assertTrue(logFile1.exists()); 678 679 File logFile2 = new File(LOG_FILE_DIR + File.separator + "host" + File.separator + 680 clientId + File.separator + "htmlmonitor_" + clientId + "_001.log"); 681 682 assertTrue(logFile2.exists()); 683 684 HTMLLogParser parser = new HTMLLogParser(); 685 686 parser.parseFile(logFile1); 687 parser.parseFile(logFile2); 688 689 // check the GUI model 690 GUIModel guiModel = parser.getGuiModel(); 691 assertNotNull(guiModel); 692 693 List<IGUIElement> nodes = guiModel.getRootElements(); 694 assertNotNull(nodes); 695 assertEquals(1, nodes.size()); 696 697 // get server node 698 IGUIElement node = nodes.get(0); 699 assertNotNull(node); 700 assertTrue(node instanceof HTMLServer); 701 assertEquals("HTML", node.getPlatform()); 702 assertFalse(node.isUsed()); 703 704 nodes = guiModel.getChildren(node); 705 assertNotNull(nodes); 706 assertEquals(1, nodes.size()); 707 708 // get document node 709 node = nodes.get(0); 710 assertNotNull(node); 711 assertTrue(node instanceof HTMLDocument); 712 assertEquals("HTML", node.getPlatform()); 713 assertFalse(node.isUsed()); 714 715 nodes = guiModel.getChildren(node); 716 assertNotNull(nodes); 717 assertEquals(1, nodes.size()); 718 719 // get html node 720 node = nodes.get(0); 721 assertNotNull(node); 722 assertTrue(node instanceof HTMLPageElement); 723 assertEquals("HTML", node.getPlatform()); 724 assertFalse(node.isUsed()); 725 726 nodes = guiModel.getChildren(node); 727 assertNotNull(nodes); 728 assertEquals(1, nodes.size()); // only one child as the head tag should have been ignored 729 730 // get body node 731 node = nodes.get(0); 732 assertNotNull(node); 733 assertTrue(node instanceof HTMLPageElement); 734 assertEquals("HTML", node.getPlatform()); 735 assertTrue(node.isUsed()); 736 737 nodes = guiModel.getChildren(node); 738 assertNotNull(nodes); 739 assertEquals(0, nodes.size()); 740 741 // check the sequences 742 Collection<List<Event>> sequences = parser.getSequences(); 743 744 assertNotNull(sequences); 745 746 Iterator<List<Event>> iterator = sequences.iterator(); 747 assertTrue(iterator.hasNext()); 748 749 List<Event> sequence = iterator.next(); 750 751 assertNotNull(sequence); 752 assertEquals(1, sequence.size()); 753 754 assertEvent(sequence.get(0), 12345, MouseClick.class, node, 194, 7); 755 756 assertTrue(iterator.hasNext()); 757 758 sequence = iterator.next(); 759 assertFalse(iterator.hasNext()); 760 761 assertNotNull(sequence); 762 assertEquals(1, sequence.size()); 763 764 assertEvent(sequence.get(0), 12345, MouseClick.class, node, 194, 7); 605 765 } 606 766
Note: See TracChangeset
for help on using the changeset viewer.