Changeset 1994
- Timestamp:
- 07/09/15 13:50:59 (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/SOAPUtils.java
r1993 r1994 94 94 newSequence.add(new Event(new SimpleSOAPEventType(eventType 95 95 .getCalledMethod(), eventType.getServiceName(), eventType 96 .getClientName(), eventType.getSoapRequestBody(), equalSOAPDataMap))); 96 .getClientName(), eventType.getSoapRequestBody(), equalSOAPDataMap, 97 CallType.REQUEST))); 97 98 } 98 99 else { … … 222 223 */ 223 224 public static Element getSoapBodyFromEvent(Event event) { 224 return getSoapBodyFromEvent(event, false );225 } 226 227 /** 228 * <p> 229 * Helper function to get the body of a SOAP request.225 return getSoapBodyFromEvent(event, false, CallType.REQUEST); 226 } 227 228 /** 229 * <p> 230 * Helper function to get the body of a SOAP message. 230 231 * </p> 231 232 * 232 233 * @param event 233 * event for which the SOAP request body is retrieved 234 * @param useRandomRequestBodies 235 * defines is random request bodies are used or the body of the associated event 234 * event for which the SOAP message body is retrieved 235 * @param useRandomBodies 236 * defines if random message bodies are used or the body of the associated event 237 * @param callType 238 * defines if the request or response of a message is retrieved 236 239 * @return body of the SOAP event 237 240 */ 238 public static Element getSoapBodyFromEvent(Event event, boolean useRandomRequestBodies) { 239 Element requestBody = null; 241 public static Element getSoapBodyFromEvent(Event event, 242 boolean useRandomBodies, 243 CallType callType) 244 { 240 245 if (event.getType() instanceof SOAPEventType) { 241 requestBody = ((SOAPEventType) event.getType()).getSoapRequestBody(); 246 switch (callType) 247 { 248 case REQUEST: 249 return ((SOAPEventType) event.getType()).getSoapRequestBody(); 250 case RESPONSE: 251 return ((SOAPEventType) event.getType()).getSoapResponseBody(); 252 default: 253 throw new RuntimeException("unsupported call type: " + callType); 254 } 242 255 } 243 256 else if (event.getType() instanceof SimpleSOAPEventType) { 244 if (useRandomRequestBodies) { 245 requestBody = ((SimpleSOAPEventType) event.getType()).getRandomSoapMsgBody(); 246 } 247 else { 248 requestBody = ((SimpleSOAPEventType) event.getType()).getSoapMsgBody(); 249 } 250 } 251 return requestBody; 257 switch (callType) 258 { 259 case REQUEST: 260 if (((SimpleSOAPEventType) event.getType()).getCallType() == CallType.REQUEST) { 261 if (useRandomBodies) { 262 return ((SimpleSOAPEventType) event.getType()).getRandomSoapMsgBody(); 263 } 264 else { 265 return ((SimpleSOAPEventType) event.getType()).getSoapMsgBody(); 266 } 267 } 268 else { 269 throw new RuntimeException( 270 "cannot retrieve request body, is of CallType: " + 271 ((SimpleSOAPEventType) event.getType()) 272 .getCallType()); 273 } 274 case RESPONSE: 275 if (((SimpleSOAPEventType) event.getType()).getCallType() == CallType.RESPONSE) 276 { 277 if (useRandomBodies) { 278 return ((SimpleSOAPEventType) event.getType()).getRandomSoapMsgBody(); 279 } 280 else { 281 return ((SimpleSOAPEventType) event.getType()).getSoapMsgBody(); 282 } 283 } 284 else { 285 throw new RuntimeException( 286 "cannot retrieve response body, is of CallType: " + 287 ((SimpleSOAPEventType) event.getType()) 288 .getCallType()); 289 } 290 default: 291 throw new RuntimeException("unsupported call type: " + callType); 292 } 293 } 294 else { 295 throw new RuntimeException( 296 "unsupported event type; must be SOAPEventType or SimpleSOAPEventType but is: " + 297 event.getType().getClass().getName()); 298 } 299 } 300 301 /** 302 * <p> 303 * Checks if an event is a SOAP request 304 * </p> 305 * 306 * @param event 307 * event that is checked 308 * @return true if SOAP request; false otherwise 309 */ 310 public static boolean isSOAPRequest(Event event) { 311 if (event.getType() instanceof SOAPEventType) { 312 return true; 313 } 314 else if (event.getType() instanceof SimpleSOAPEventType) { 315 return ((SimpleSOAPEventType) event.getType()).getCallType() == CallType.REQUEST; 316 } 317 else { 318 throw new RuntimeException( 319 "unsupported event type; must be SOAPEventType or SimpleSOAPEventType but is: " + 320 event.getType().getClass().getName()); 321 } 322 } 323 324 /** 325 * <p> 326 * Checks if an event is a SOAP response 327 * </p> 328 * 329 * @param event 330 * event that is checked 331 * @return true if SOAP response; false otherwise 332 */ 333 public static boolean isSOAPResponse(Event event) { 334 if (event.getType() instanceof SOAPEventType) { 335 return true; 336 } 337 else if (event.getType() instanceof SimpleSOAPEventType) { 338 return ((SimpleSOAPEventType) event.getType()).getCallType() == CallType.RESPONSE; 339 } 340 else { 341 throw new RuntimeException( 342 "unsupported event type; must be SOAPEventType or SimpleSOAPEventType but is: " + 343 event.getType().getClass().getName()); 344 } 252 345 } 253 346 … … 384 477 eventType.getClientName(), 385 478 eventType.getSoapMsgBody(), 386 eventType.getEqualSOAPDataMap()), 479 eventType.getEqualSOAPDataMap(), 480 eventType.getCallType()), 387 481 event.getTarget()); 388 482 } … … 497 591 long responseOrderId = 498 592 soapEventType.getExchange().getResponse().getOrderingId(); 593 // System.out.println(requestOrderId + " / " + responseOrderId); 499 594 500 595 if (requestOrderId > lastOrderId && requestOrderId < selectedOrderId) { … … 532 627 lastOrderId = selectedOrderId; 533 628 } 534 535 } while(selectedEvent!=null); 629 630 } 631 while (selectedEvent != null); 536 632 sortedSequences.add(sortedSequence); 537 633 } -
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java
r1993 r1994 17 17 import java.io.ByteArrayInputStream; 18 18 import java.io.IOException; 19 import java.io.InvalidObjectException; 20 import java.io.ObjectInputStream; 21 import java.io.ObjectOutputStream; 19 22 20 23 import javax.xml.parsers.DocumentBuilderFactory; … … 91 94 * reference to the {@link EqualSOAPDataMap} associated with the sequence this event belongs to. 92 95 */ 93 private final EqualSOAPDataMap equalBodyMap; 94 95 /** 96 * <p> 97 * Constructor. Creates a new SimpleSOAPEventType. 98 * </p> 99 * 100 */ 101 public SimpleSOAPEventType(String calledMethod, 102 String serviceName, 103 String clientName, 104 Element soapMsgBody) 105 { 106 this(calledMethod, serviceName, clientName, soapMsgBody, null, CallType.REQUEST); 107 } 108 109 /** 110 * <p> 111 * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. 112 * </p> 113 * 114 */ 115 public SimpleSOAPEventType(String calledMethod, 116 String serviceName, 117 String clientName, 118 Element soapMsgBody, 119 EqualSOAPDataMap equalRequestsMap) 120 { 121 this(calledMethod, serviceName, clientName, soapMsgBody, equalRequestsMap, 122 CallType.REQUEST); 123 } 124 125 /** 126 * <p> 127 * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. 96 private transient EqualSOAPDataMap equalBodyMap; 97 98 /** 99 * <p> 100 * Constructor. Creates a new SimpleSOAPEventType with a EqualSOAPDATAMap. Should always call 101 * initEqualBodyMap afterwards. 128 102 * </p> 129 103 * … … 151 125 this.soapMsgBody = SOAPUtils.getSerialization(soapMsgBody); 152 126 this.callType = callType; 153 154 // this must be the last part of the constructor and only be called after all variables are 155 // initialized 156 if (equalRequestsMap != null) { 157 equalRequestsMap.add(this, this.soapMsgBody); 127 128 if (equalBodyMap != null) { 129 equalBodyMap.add(this, this.soapMsgBody); 158 130 } 159 131 } … … 256 228 } 257 229 else if (obj instanceof SimpleSOAPEventType) { 258 return callType.equals(((SimpleSOAPEventType) obj).callType) && 230 boolean callTypesEqual = true; 231 if (callType == null) { 232 if (((SimpleSOAPEventType) obj).callType == null) { 233 callTypesEqual = true; 234 } 235 else { 236 callTypesEqual = false; 237 } 238 } 239 else { 240 callTypesEqual = callType.equals(((SimpleSOAPEventType) obj).callType); 241 } 242 return callTypesEqual && 259 243 HTTPUtils.equals(calledMethod, ((SimpleSOAPEventType) obj).calledMethod) && 260 244 HTTPUtils.equals(serviceName, ((SimpleSOAPEventType) obj).serviceName) && … … 273 257 @Override 274 258 public int hashCode() { 275 return callType.hashCode() + calledMethod.hashCode() + serviceName.hashCode() + 276 clientName.hashCode(); 259 int hashCode = 13; 260 if (callType != null) { 261 hashCode += callType.hashCode(); 262 } 263 if (calledMethod == null || serviceName == null || clientName == null) { 264 System.out.print("fu!"); 265 } 266 return hashCode + calledMethod.hashCode() + serviceName.hashCode() + clientName.hashCode(); 277 267 } 278 268 … … 296 286 } 297 287 } 288 289 private void writeObject(ObjectOutputStream out) throws IOException { 290 out.defaultWriteObject(); 291 out.writeObject(equalBodyMap); 292 } 293 294 private void readObject(ObjectInputStream in) 295 throws ClassNotFoundException, IOException 296 { 297 in.defaultReadObject(); 298 equalBodyMap = (EqualSOAPDataMap) in.readObject(); 299 if ( equalBodyMap == null) { 300 throw new InvalidObjectException("null"); 301 } 302 } 298 303 } -
trunk/autoquest-plugin-uml-test/src/test/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtilsTest.java
r1993 r1994 19 19 import java.io.FileOutputStream; 20 20 import java.util.Collection; 21 import java.util.HashSet;22 import java.util.Iterator;23 21 import java.util.LinkedList; 24 22 import java.util.List; 25 23 import java.util.Properties; 26 24 import java.util.Random; 27 import java.util.Set;28 25 import java.util.logging.Level; 29 26 … … 42 39 import de.ugoe.cs.autoquest.plugin.http.HTTPLogParser; 43 40 import de.ugoe.cs.autoquest.plugin.http.SOAPUtils; 44 import de.ugoe.cs.autoquest.plugin.http.SOAPUtils.SequenceOrder;45 41 import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType; 46 42 import de.ugoe.cs.autoquest.testgeneration.RandomWalkGenerator; … … 173 169 .add(new Event(new SimpleSOAPEventType("transportInstructionRequest", 174 170 "TransportService", "Logistics_Environment", 175 null )));171 null, null, null))); 176 172 manuallyCreatedSequence 177 173 .add(new Event(new SimpleSOAPEventType("transportInstructionConfirmationRequest", 178 174 "materialSupplierService", 179 "Logistics_Environment", null )));175 "Logistics_Environment", null, null, null))); 180 176 181 177 // TODO make test case run … … 271 267 public void testValidateModelWithLog_ITA_1() throws Exception { 272 268 validateModelWithLogWorkflow(ita_1); 269 } 270 271 @Test 272 public void testSerialization_ITA_1() throws Exception { 273 TestData testdata = ita_1; 274 Properties properties = loadProperties(testdata); 275 Collection<List<Event>> sequences = loadAndPreprocessUsageJournal(testdata, properties); 276 IStochasticProcess model = createUsageProfile(testdata, sequences); 277 byte[] serialized = SerializationUtils.serialize(model); 278 SerializationUtils.deserialize(serialized); 273 279 } 274 280
Note: See TracChangeset
for help on using the changeset viewer.