Ignore:
Timestamp:
07/08/15 09:03:46 (9 years ago)
Author:
pharms
Message:
  • added ordering id for requests and responses
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorTest.java

    r1614 r1991  
    3232 
    3333import org.apache.http.HttpEntity; 
     34import org.apache.http.HttpResponse; 
     35import org.apache.http.client.methods.HttpGet; 
    3436import org.apache.http.client.methods.HttpPost; 
    3537import org.apache.http.entity.ContentType; 
     
    102104     */ 
    103105    @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 
    104129    public void test_SimulatedSession_MonitorOnly() throws Exception { 
    105130        monitor = new HttpMonitor(new String[] { LOG_FILE_DIR, MONITOR_PORT + "" }); 
     
    138163        System.out.println("{"); 
    139164        System.out.println("  {"); 
     165        long prevId = 0; 
     166         
    140167        for (int j = 0; j < sequence.size(); j++) { 
    141168            System.out.print("    "); 
     
    150177            assertTrue(sequence.get(j).getTarget() instanceof HTTPTarget); 
    151178 
     179            HTTPEventType eventType = (HTTPEventType) sequence.get(j).getType(); 
     180             
    152181            HTTPTestUtils.assertExchangeEquals 
    153                 (simulatedSession.getHttpExchange().get(j), 
    154                  ((HTTPEventType) sequence.get(j).getType()).getExchange()); 
     182                (simulatedSession.getHttpExchange().get(j), eventType.getExchange()); 
    155183 
    156184            assertEquals(HTTPUtils.toString(simulatedSession.getHttpExchange().get(j).getReceiver()), 
    157185                         ((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(); 
    158194        } 
    159195        System.out.println("  }"); 
     
    510546    } 
    511547 
     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 
    512565} 
Note: See TracChangeset for help on using the changeset viewer.