Ignore:
Timestamp:
07/14/15 10:57:19 (9 years ago)
Author:
sherbold
Message:
  • extended SOAP utils with function that removes all invalid request/response pairs from a sequence of SimpleSOAPEvents
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-http-test/src/test/java/de/ugoe/cs/autoquest/http/SOAPUtilsTest.java

    r1988 r2003  
    2020import java.util.Collection; 
    2121import java.util.Iterator; 
     22import java.util.LinkedList; 
    2223import java.util.List; 
    23  
     24import java.util.logging.Level; 
     25 
     26import org.junit.BeforeClass; 
    2427import org.junit.Test; 
    2528 
    2629import de.ugoe.cs.autoquest.eventcore.Event; 
     30import de.ugoe.cs.autoquest.eventcore.EventUtils; 
    2731import de.ugoe.cs.autoquest.plugin.http.HTTPLogParser; 
    2832import de.ugoe.cs.autoquest.plugin.http.SOAPUtils; 
    2933import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType; 
    3034import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType; 
     35import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType.CallType; 
     36import de.ugoe.cs.util.console.Console; 
     37import de.ugoe.cs.util.console.TextConsole; 
    3138 
    3239/** 
     
    3845 */ 
    3946public class SOAPUtilsTest { 
     47     
     48    @BeforeClass 
     49    public static void setupBeforeClass() { 
     50        new TextConsole(Level.FINEST); 
     51    } 
    4052 
    4153    @Test 
     
    8294            } 
    8395        } 
    84  
    85     } 
    86  
     96    } 
     97     
     98    @Test 
     99    public void testDropInvalidResponseRequestPairs_1() throws Exception { 
     100        List<Event> sequence = new LinkedList<Event>(); 
     101        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     102        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     103        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     104        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.REQUEST))); 
     105        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.RESPONSE))); 
     106        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     107         
     108        List<Event> expectedSequence = new LinkedList<>(sequence); 
     109         
     110        List<Event> originalSequence = new LinkedList<>(sequence); 
     111         
     112        List<Event> validSequence = SOAPUtils.dropInvalidResponseRequestPairs(sequence); 
     113        Console.traceln(Level.INFO, getCurrentMethodName()); 
     114        EventUtils.traceSequence(Level.INFO, validSequence); 
     115         
     116        assertEquals(expectedSequence, validSequence); 
     117        assertEquals(originalSequence, sequence); 
     118    } 
     119     
     120    @Test 
     121    public void testDropInvalidResponseRequestPairs_2() throws Exception { 
     122        List<Event> sequence = new LinkedList<Event>(); 
     123        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     124        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     125        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     126        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.REQUEST))); 
     127        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     128        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.RESPONSE))); 
     129         
     130        List<Event> expectedSequence = new LinkedList<Event>(); 
     131        expectedSequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     132        expectedSequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     133         
     134        List<Event> originalSequence = new LinkedList<>(sequence); 
     135         
     136        List<Event> validSequence = SOAPUtils.dropInvalidResponseRequestPairs(sequence); 
     137        Console.traceln(Level.INFO, getCurrentMethodName()); 
     138        EventUtils.traceSequence(Level.INFO, validSequence); 
     139         
     140        assertEquals(expectedSequence, validSequence); 
     141        assertEquals(originalSequence, sequence); 
     142    } 
     143     
     144    @Test 
     145    public void testDropInvalidResponseRequestPairs_3() throws Exception { 
     146        List<Event> sequence = new LinkedList<Event>(); 
     147        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     148        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     149        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     150        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.REQUEST))); 
     151        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.RESPONSE))); 
     152         
     153        List<Event> expectedSequence = new LinkedList<Event>(); 
     154        expectedSequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     155        expectedSequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     156         
     157        List<Event> originalSequence = new LinkedList<>(sequence); 
     158         
     159        List<Event> validSequence = SOAPUtils.dropInvalidResponseRequestPairs(sequence); 
     160        Console.traceln(Level.INFO, getCurrentMethodName()); 
     161        EventUtils.traceSequence(Level.INFO, validSequence); 
     162         
     163        assertEquals(expectedSequence, validSequence); 
     164        assertEquals(originalSequence, sequence); 
     165    } 
     166     
     167    @Test 
     168    public void testDropInvalidResponseRequestPairs_4() throws Exception { 
     169        List<Event> sequence = new LinkedList<Event>(); 
     170        sequence.add(Event.STARTEVENT); 
     171        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     172        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     173        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     174        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.REQUEST))); 
     175        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.RESPONSE))); 
     176        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     177        sequence.add(Event.ENDEVENT); 
     178         
     179        List<Event> expectedSequence = new LinkedList<>(sequence); 
     180         
     181        List<Event> originalSequence = new LinkedList<>(sequence); 
     182         
     183        List<Event> validSequence = SOAPUtils.dropInvalidResponseRequestPairs(sequence); 
     184        Console.traceln(Level.INFO, getCurrentMethodName()); 
     185        EventUtils.traceSequence(Level.INFO, validSequence); 
     186         
     187        assertEquals(expectedSequence, validSequence); 
     188        assertEquals(originalSequence, sequence); 
     189    } 
     190     
     191    @Test 
     192    public void testDropInvalidResponseRequestPairs_5() throws Exception { 
     193        List<Event> sequence = new LinkedList<Event>(); 
     194        sequence.add(Event.STARTEVENT); 
     195        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     196        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     197        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     198        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.REQUEST))); 
     199        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     200        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.RESPONSE))); 
     201        sequence.add(Event.ENDEVENT); 
     202         
     203        List<Event> expectedSequence = new LinkedList<Event>(); 
     204        expectedSequence.add(Event.STARTEVENT); 
     205        expectedSequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     206        expectedSequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     207        expectedSequence.add(Event.ENDEVENT); 
     208         
     209        List<Event> originalSequence = new LinkedList<>(sequence); 
     210         
     211        List<Event> validSequence = SOAPUtils.dropInvalidResponseRequestPairs(sequence); 
     212        Console.traceln(Level.INFO, getCurrentMethodName() ); 
     213        EventUtils.traceSequence(Level.INFO, validSequence); 
     214         
     215        assertEquals(expectedSequence, validSequence); 
     216        assertEquals(originalSequence, sequence); 
     217    } 
     218     
     219    @Test 
     220    public void testDropInvalidResponseRequestPairs_6() throws Exception { 
     221        List<Event> sequence = new LinkedList<Event>(); 
     222        sequence.add(Event.STARTEVENT); 
     223        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     224        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     225        sequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     226        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.REQUEST))); 
     227        sequence.add(new Event(new SimpleSOAPEventType("op2", "foo", "bar", null, null, CallType.RESPONSE))); 
     228        sequence.add(Event.ENDEVENT); 
     229         
     230        List<Event> expectedSequence = new LinkedList<Event>(); 
     231        expectedSequence.add(Event.STARTEVENT); 
     232        expectedSequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.REQUEST))); 
     233        expectedSequence.add(new Event(new SimpleSOAPEventType("op1", "foo", "bar", null, null, CallType.RESPONSE))); 
     234        expectedSequence.add(Event.ENDEVENT); 
     235         
     236        List<Event> originalSequence = new LinkedList<>(sequence); 
     237         
     238        List<Event> validSequence = SOAPUtils.dropInvalidResponseRequestPairs(sequence); 
     239        Console.traceln(Level.INFO, getCurrentMethodName()); 
     240        EventUtils.traceSequence(Level.INFO, validSequence); 
     241         
     242        assertEquals(expectedSequence, validSequence); 
     243        assertEquals(originalSequence, sequence); 
     244    } 
     245 
     246    private  String getCurrentMethodName() { 
     247         StackTraceElement stackTraceElements[] = (new Throwable()).getStackTrace(); 
     248         return stackTraceElements[1].toString(); 
     249    } 
     250     
    87251} 
Note: See TracChangeset for help on using the changeset viewer.