Changeset 1392 for trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe
- Timestamp:
- 02/21/14 19:27:26 (11 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
r1390 r1392 15 15 package de.ugoe.cs.autoquest.httpmonitor; 16 16 17 import static org.junit.Assert.assertEquals; 18 import static org.junit.Assert.assertNotNull; 19 import static org.junit.Assert.assertTrue; 20 17 21 import java.io.BufferedReader; 18 22 import java.io.File; … … 35 39 import org.junit.Before; 36 40 41 import de.ugoe.cs.autoquest.eventcore.Event; 42 import de.ugoe.cs.autoquest.httpmonitor.exchange.HttpExchange; 43 import de.ugoe.cs.autoquest.httpmonitor.exchange.Method; 44 import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPEventType; 45 import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPTarget; 37 46 import de.ugoe.cs.util.console.TextConsole; 38 47 … … 208 217 return message.toString(); 209 218 } 219 220 /** 221 * 222 */ 223 protected void assertEvent(Event event, String method, String message, String response) { 224 assertNotNull(event); 225 assertNotNull(event.getType()); 226 assertNotNull(event.getTarget()); 227 228 assertTrue(event.getType() instanceof HTTPEventType); 229 assertTrue(event.getTarget() instanceof HTTPTarget); 230 231 HttpExchange exchange = ((HTTPEventType) event.getType()).getExchange(); 232 233 assertEquals(Method.fromValue(method), exchange.getRequest().getMethod()); 234 235 if (message != null) { 236 assertEquals(message, exchange.getRequest().getContent().getData()); 237 } 238 else if (exchange.getRequest().getContent() != null) { 239 System.err.println(exchange.getRequest().getContent().getData()); 240 } 241 242 if (response != null) { 243 assertEquals(response, exchange.getResponse().getContent().getData()); 244 } 245 else if (exchange.getResponse().getContent() != null) { 246 System.err.println(exchange.getResponse().getContent().getData()); 247 } 248 } 210 249 211 250 /** -
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorTest.java
r1390 r1392 22 22 import java.io.File; 23 23 import java.io.StringWriter; 24 import java.net.URL; 24 25 import java.util.Collection; 25 26 import java.util.Iterator; … … 28 29 import javax.xml.bind.JAXBContext; 29 30 import javax.xml.bind.Marshaller; 31 import javax.xml.namespace.QName; 30 32 31 33 import org.apache.http.HttpEntity; … … 46 48 import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPEventType; 47 49 import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPTarget; 50 import dummyservice.DummyService; 51 import dummyservice.DummyServicePortType; 52 import dummyservice.VerifyUserInMsgType; 53 import dummyservice.VerifyUserOutMsgType; 48 54 49 55 /** … … 201 207 assertEquals(1, sequence.size()); 202 208 203 assertNotNull(sequence.get(0)); 204 assertNotNull(sequence.get(0).getType()); 205 assertTrue(sequence.get(0).getType() instanceof HTTPEventType); 206 207 assertNotNull(sequence.get(0).getTarget()); 208 assertTrue(sequence.get(0).getTarget() instanceof HTTPTarget); 209 210 HttpExchange exchange = ((HTTPEventType) sequence.get(0).getType()).getExchange(); 211 212 assertEquals(message, exchange.getRequest().getContent().getData()); 213 assertEquals(response, exchange.getResponse().getContent().getData()); 209 assertEvent(sequence.get(0), "POST", message, response); 214 210 } 215 211 … … 295 291 assertEquals(1, sequence.size()); 296 292 297 assertNotNull(sequence.get(0)); 298 assertNotNull(sequence.get(0).getType()); 299 assertTrue(sequence.get(0).getType() instanceof HTTPEventType); 300 301 assertNotNull(sequence.get(0).getTarget()); 302 assertTrue(sequence.get(0).getTarget() instanceof HTTPTarget); 303 304 HttpExchange exchange = ((HTTPEventType) sequence.get(0).getType()).getExchange(); 305 306 assertEquals(message, exchange.getRequest().getContent().getData()); 307 assertEquals(response, exchange.getResponse().getContent().getData()); 293 assertEvent(sequence.get(0), "POST", message, response); 294 } 295 296 @Test 297 public void test_SOAP_ProxyAndMonitor() throws Exception { 298 monitor = new HttpMonitor(new String[] { LOG_FILE_DIR, MONITOR_PORT + "" }); 299 300 monitor.init(); 301 monitor.start(); 302 303 proxy = new HttpMonitoringProxy 304 (new String[] { LOG_FILE_DIR, PROXY_PORT + "", 305 "localhost:" + DUMMY_SERVER_PORT, "localhost:" + MONITOR_PORT }); 306 307 proxy.init(); 308 proxy.start(); 309 310 DummyService service = new DummyService 311 (new URL("http://localhost:" + PROXY_PORT + "/dummyWebapp/DummyServiceSOAPPort?wsdl"), 312 new QName("DummyService", "DummyService")); 313 314 DummyServicePortType dummyService = service.getDummyServiceSOAPPort(); 315 316 dummyservice.ObjectFactory factory = new dummyservice.ObjectFactory(); 317 VerifyUserInMsgType request = factory.createVerifyUserInMsgType(); 318 VerifyUserOutMsgType response = dummyService.verifyUser(request); 319 320 assertNotNull(response); 321 322 // the monitor needs some time to receive the exchange --> give it 323 Thread.sleep(1000); 324 325 monitor.stop(); 326 monitor = null; 327 328 File logFile = new File(LOG_FILE_DIR + File.separator + "httpmonitor_000.log"); 329 330 assertTrue(logFile.exists()); 331 332 HTTPLogParser parser = new HTTPLogParser(); 333 334 parser.parseFile(logFile); 335 336 // check the sequences 337 Collection<List<Event>> sequences = parser.getSequences(); 338 339 assertNotNull(sequences); 340 341 Iterator<List<Event>> iterator = sequences.iterator(); 342 assertTrue(iterator.hasNext()); 343 344 List<Event> sequence = iterator.next(); 345 assertFalse(iterator.hasNext()); 346 347 assertNotNull(sequence); 348 assertEquals(2, sequence.size()); 349 350 assertEvent(sequence.get(0), "GET", null, null); // get WSDL 351 assertEvent(sequence.get(1), "POST", null, null); // send request 308 352 } 309 353 -
trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitoringProxyTest.java
r1390 r1392 49 49 import de.ugoe.cs.autoquest.httpmonitor.proxy.HttpMonitoringProxy; 50 50 import de.ugoe.cs.autoquest.plugin.http.HTTPLogParser; 51 import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPEventType;52 import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPTarget;53 51 import dummyservice.DummyService; 54 52 import dummyservice.DummyServicePortType; … … 445 443 assertNotNull(exchange.getResponse().getContent().getData()); 446 444 } 447 448 /**449 *450 */451 private void assertEvent(Event event, String method, String message, String response) {452 assertNotNull(event);453 assertNotNull(event.getType());454 assertNotNull(event.getTarget());455 456 assertTrue(event.getType() instanceof HTTPEventType);457 assertTrue(event.getTarget() instanceof HTTPTarget);458 459 HttpExchange exchange = ((HTTPEventType) event.getType()).getExchange();460 461 assertEquals(Method.fromValue(method), exchange.getRequest().getMethod());462 463 if (message != null) {464 assertEquals(message, exchange.getRequest().getContent().getData());465 }466 else if (exchange.getRequest().getContent() != null) {467 System.err.println(exchange.getRequest().getContent().getData());468 }469 470 if (response != null) {471 assertEquals(response, exchange.getResponse().getContent().getData());472 }473 else if (exchange.getResponse().getContent() != null) {474 System.err.println(exchange.getResponse().getContent().getData());475 }476 }477 445 478 446 /**
Note: See TracChangeset
for help on using the changeset viewer.