Ignore:
Timestamp:
07/31/14 16:44:36 (10 years ago)
Author:
sherbold
Message:
  • fixed SOAP event types hashCode and equals method to account for the serviceName
  • added SimpleSOAPEventType that contains only the name of the called method and of the called service
  • added convertToSimpleSOAPEvent method to HTTPUtils
  • added tests for convertToSimpleSOAPEvent
Location:
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http
Files:
1 added
2 edited

Legend:

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

    r1561 r1635  
    1515package de.ugoe.cs.autoquest.plugin.http; 
    1616 
     17import java.util.LinkedList; 
     18import java.util.List; 
     19 
     20import de.ugoe.cs.autoquest.eventcore.Event; 
     21import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType; 
     22import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType; 
    1723import de.ugoe.cs.autoquest.plugin.http.logdata.Address; 
    1824 
     
    2834    /** 
    2935     * <p> 
    30      * converts an address to a simple string containing either host or ip and the port number 
    31      * if any. 
     36     * converts an address to a simple string containing either host or ip and the port number if 
     37     * any. 
    3238     * </p> 
    3339     *  
    34      * @param address the address to convert 
     40     * @param address 
     41     *            the address to convert 
    3542     *  
    3643     * @return either "host:port" or "ip:port" or "host" or "ip" or "port" or null 
     
    6572    /** 
    6673     * <p> 
    67      * compares two addresses and returns true, if they are equal and false else. The addresses 
    68      * are equal, if either the ip-addresses and the ports match or the host names and the 
    69      * ports match. 
     74     * compares two addresses and returns true, if they are equal and false else. The addresses are 
     75     * equal, if either the ip-addresses and the ports match or the host names and the ports match. 
    7076     * </p> 
    71      * 
    72      * @param address1 the first address to compare 
    73      * @param address2 the second address to compare 
     77     *  
     78     * @param address1 
     79     *            the first address to compare 
     80     * @param address2 
     81     *            the second address to compare 
    7482     *  
    7583     * @return as described 
     
    8290            return false; 
    8391        } 
    84          
     92 
    8593        if (!equals(address1.getPort(), address2.getPort())) { 
    8694            return false; 
    8795        } 
    88          
     96 
    8997        if (address1.getIp() != null) { 
    9098            return equals(address1.getIp(), address2.getIp()); 
     
    94102        } 
    95103    } 
    96      
     104 
    97105    /** 
    98106     * <p> 
    99      * convenience method to compare to objects. They are considered equal if they both are null, 
    100      * or if their equals method returns true. 
     107     * convenience method to compare to objects. They are considered equal if they both are null, or 
     108     * if their equals method returns true. 
    101109     * </p> 
    102      * 
    103      * @param object1 the first object to compare 
    104      * @param object2 the second object to compare 
     110     *  
     111     * @param object1 
     112     *            the first object to compare 
     113     * @param object2 
     114     *            the second object to compare 
    105115     *  
    106116     * @return as described 
    107117     */ 
    108118    public static <T> boolean equals(T object1, T object2) { 
    109         if (object1 == null)  { 
     119        if (object1 == null) { 
    110120            return object2 == null; 
    111121        } 
     
    117127    /** 
    118128     * <p> 
     129     * Replaces events with a {@link SOAPEventType} with new events of {@link SimpleSOAPEventType} 
     130     * and no target. 
     131     * </p> 
     132     *  
     133     * @param sequence 
     134     *            sequence where the events are replaced 
     135     * @return sequence with {@link SimpleSOAPEventType}s instead of {@link SOAPEventType}s 
     136     */ 
     137    public static List<Event> convertToSimpleSOAPEvent(List<Event> sequence) { 
     138        List<Event> newSequence = null; 
     139        if (sequence != null) { 
     140            newSequence = new LinkedList<>(); 
     141            for (Event event : sequence) { 
     142                if (event.getType() instanceof SOAPEventType) { 
     143                    SOAPEventType eventType = (SOAPEventType) event.getType(); 
     144                    newSequence.add(new Event(new SimpleSOAPEventType(eventType.getCalledMethod(), 
     145                                                                      eventType.getServiceName()))); 
     146                } 
     147                else { 
     148                    newSequence.add(event); 
     149                } 
     150            } 
     151        } 
     152        return newSequence; 
     153    } 
     154 
     155    /** 
     156     * <p> 
    119157     * prevent instantiation 
    120158     * </p> 
    121159     */ 
    122     private HTTPUtils() { } 
    123      
     160    private HTTPUtils() {} 
     161 
    124162} 
  • trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SOAPEventType.java

    r1622 r1635  
    4747     * </p> 
    4848     */ 
    49     transient private SOAPMessage soapRequest; 
     49    transient private final SOAPMessage soapRequest; 
    5050     
    5151    /** 
     
    5454     * </p> 
    5555     */ 
    56     transient private SOAPMessage soapResponse; 
     56    transient private final SOAPMessage soapResponse; 
    5757     
    5858    /** 
     
    6161     * </p> 
    6262     */ 
    63     private String calledMethod; 
     63    private final String calledMethod; 
    6464     
    6565    /** 
    6666     * <p> 
    6767     * the name of the service; this is either the path or, if a path map is available 
    68      */ 
    69     private String serviceName; 
     68     * </p> 
     69     */ 
     70    private final String serviceName; 
    7071     
    7172    /** 
     
    7475     * </p> 
    7576     */ 
    76     private String name; 
     77    private final String name; 
    7778 
    7879    /** 
     
    227228            return 
    228229                super.equals(obj) && 
    229                 HTTPUtils.equals(calledMethod, ((SOAPEventType) obj).calledMethod); 
     230                HTTPUtils.equals(calledMethod, ((SOAPEventType) obj).calledMethod) && 
     231                HTTPUtils.equals(serviceName, ((SOAPEventType) obj).serviceName); 
    230232        } 
    231233        else { 
     
    239241    @Override 
    240242    public int hashCode() { 
     243        int hashCode = super.hashCode(); 
    241244        if (calledMethod != null) { 
    242             return super.hashCode() + calledMethod.hashCode(); 
    243         } 
    244         else { 
    245             return super.hashCode(); 
    246         } 
     245            hashCode += calledMethod.hashCode(); 
     246        } 
     247        if( serviceName != null ) { 
     248            hashCode += serviceName.hashCode(); 
     249        } 
     250        return hashCode; 
    247251    } 
    248252 
Note: See TracChangeset for help on using the changeset viewer.