Changeset 1991 for trunk/autoquest-httpmonitor-test/src/test/java/de
- Timestamp:
- 07/08/15 09:03:46 (9 years ago)
- Location:
- trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/AbstractTC.java
r1614 r1991 280 280 System.err.println(exchange.getResponse().getContent().getData()); 281 281 } 282 283 assertNotNull(exchange.getRequest().getOrderingId()); 284 assertNotNull(exchange.getResponse().getOrderingId()); 285 assertTrue(exchange.getRequest().getOrderingId() < exchange.getResponse().getOrderingId()); 282 286 } 283 287 -
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorTest.java
r1614 r1991 32 32 33 33 import org.apache.http.HttpEntity; 34 import org.apache.http.HttpResponse; 35 import org.apache.http.client.methods.HttpGet; 34 36 import org.apache.http.client.methods.HttpPost; 35 37 import org.apache.http.entity.ContentType; … … 102 104 */ 103 105 @Test 106 public void test_RetrievalOfId_MonitorOnly() throws Exception { 107 monitor = new HttpMonitor(new String[] { LOG_FILE_DIR, MONITOR_PORT + "" }); 108 109 monitor.init(); 110 monitor.start(); 111 112 long id = getId(); 113 assertTrue(id > 0); 114 115 for (int i = 0; i < 300; i++) { 116 long prevId = id; 117 id = getId(); 118 assertTrue(id > prevId); 119 } 120 121 monitor.stop(); 122 monitor = null; 123 } 124 125 /** 126 * 127 */ 128 @Test 104 129 public void test_SimulatedSession_MonitorOnly() throws Exception { 105 130 monitor = new HttpMonitor(new String[] { LOG_FILE_DIR, MONITOR_PORT + "" }); … … 138 163 System.out.println("{"); 139 164 System.out.println(" {"); 165 long prevId = 0; 166 140 167 for (int j = 0; j < sequence.size(); j++) { 141 168 System.out.print(" "); … … 150 177 assertTrue(sequence.get(j).getTarget() instanceof HTTPTarget); 151 178 179 HTTPEventType eventType = (HTTPEventType) sequence.get(j).getType(); 180 152 181 HTTPTestUtils.assertExchangeEquals 153 (simulatedSession.getHttpExchange().get(j), 154 ((HTTPEventType) sequence.get(j).getType()).getExchange()); 182 (simulatedSession.getHttpExchange().get(j), eventType.getExchange()); 155 183 156 184 assertEquals(HTTPUtils.toString(simulatedSession.getHttpExchange().get(j).getReceiver()), 157 185 ((HTTPTarget) sequence.get(j).getTarget()).getStringIdentifier()); 186 187 assertNotNull(eventType.getExchange().getRequest().getOrderingId()); 188 assertTrue(prevId < eventType.getExchange().getRequest().getOrderingId()); 189 prevId = eventType.getExchange().getRequest().getOrderingId(); 190 191 assertNotNull(eventType.getExchange().getResponse().getOrderingId()); 192 assertTrue(prevId < eventType.getExchange().getResponse().getOrderingId()); 193 prevId = eventType.getExchange().getResponse().getOrderingId(); 158 194 } 159 195 System.out.println(" }"); … … 510 546 } 511 547 548 /** 549 * 550 */ 551 private long getId() throws Exception { 552 DefaultHttpClient httpclient = new DefaultHttpClient(); 553 554 HttpGet httpRequest = new HttpGet("http://localhost:" + MONITOR_PORT + "/"); 555 556 try { 557 HttpResponse response = httpclient.execute(httpRequest); 558 return Long.parseLong(response.getFirstHeader("X-AutoQUEST-OrderingId").getValue()); 559 } 560 finally { 561 httpRequest.releaseConnection(); 562 } 563 } 564 512 565 } -
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitoringProxyTest.java
r1614 r1991 65 65 */ 66 66 private Server dummyMonitor; 67 68 /** 69 * the id generator used by the dummy 70 */ 71 private IdGenerator idGenerator; 67 72 68 73 /** … … 77 82 // setup a simple HTTP server 78 83 messages = new LinkedList<String>(); 84 85 idGenerator = new SimpleIdGenerator(); 86 idGenerator.init(); 87 idGenerator.start(); 79 88 80 89 dummyMonitor = new Server(MONITOR_PORT); … … 99 108 } 100 109 } 110 101 111 if (dummyMonitor != null) { 102 112 try { … … 105 115 finally { 106 116 dummyMonitor = null; 117 } 118 } 119 120 if (idGenerator != null) { 121 try { 122 idGenerator.stop(); 123 } 124 finally { 125 idGenerator = null; 107 126 } 108 127 } … … 642 661 643 662 /* (non-Javadoc) 644 * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)663 * @see HttpServlet#service(HttpServletRequest, HttpServletResponse) 645 664 */ 646 665 @Override … … 653 672 System.out.println("send ok response"); 654 673 } 674 675 /* (non-Javadoc) 676 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 677 */ 678 @Override 679 protected void doGet(HttpServletRequest req, HttpServletResponse resp) 680 throws ServletException, IOException 681 { 682 resp.setHeader("X-AutoQUEST-OrderingId", Long.toString(idGenerator.getNextId())); 683 } 655 684 656 685
Note: See TracChangeset
for help on using the changeset viewer.