Ignore:
Timestamp:
02/21/14 19:27:26 (11 years ago)
Author:
pharms
Message:
  • correct 2 bugs: one an implementation bug in encoding queries in the Jetty HTML client and another one when proxying CXF SOAP exchanges where the server is deployed in a tomcat.
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  
    1515package de.ugoe.cs.autoquest.httpmonitor; 
    1616 
     17import static org.junit.Assert.assertEquals; 
     18import static org.junit.Assert.assertNotNull; 
     19import static org.junit.Assert.assertTrue; 
     20 
    1721import java.io.BufferedReader; 
    1822import java.io.File; 
     
    3539import org.junit.Before; 
    3640 
     41import de.ugoe.cs.autoquest.eventcore.Event; 
     42import de.ugoe.cs.autoquest.httpmonitor.exchange.HttpExchange; 
     43import de.ugoe.cs.autoquest.httpmonitor.exchange.Method; 
     44import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPEventType; 
     45import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPTarget; 
    3746import de.ugoe.cs.util.console.TextConsole; 
    3847 
     
    208217        return message.toString(); 
    209218    } 
     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    } 
    210249 
    211250    /** 
  • trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorTest.java

    r1390 r1392  
    2222import java.io.File; 
    2323import java.io.StringWriter; 
     24import java.net.URL; 
    2425import java.util.Collection; 
    2526import java.util.Iterator; 
     
    2829import javax.xml.bind.JAXBContext; 
    2930import javax.xml.bind.Marshaller; 
     31import javax.xml.namespace.QName; 
    3032 
    3133import org.apache.http.HttpEntity; 
     
    4648import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPEventType; 
    4749import de.ugoe.cs.autoquest.plugin.http.eventcore.HTTPTarget; 
     50import dummyservice.DummyService; 
     51import dummyservice.DummyServicePortType; 
     52import dummyservice.VerifyUserInMsgType; 
     53import dummyservice.VerifyUserOutMsgType; 
    4854 
    4955/** 
     
    201207        assertEquals(1, sequence.size()); 
    202208 
    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); 
    214210    } 
    215211 
     
    295291        assertEquals(1, sequence.size()); 
    296292 
    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 
    308352    } 
    309353     
  • trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitoringProxyTest.java

    r1390 r1392  
    4949import de.ugoe.cs.autoquest.httpmonitor.proxy.HttpMonitoringProxy; 
    5050import 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; 
    5351import dummyservice.DummyService; 
    5452import dummyservice.DummyServicePortType; 
     
    445443        assertNotNull(exchange.getResponse().getContent().getData()); 
    446444    } 
    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     } 
    477445 
    478446    /** 
Note: See TracChangeset for help on using the changeset viewer.