Changeset 1994 for trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/SOAPUtils.java
- Timestamp:
- 07/09/15 13:50:59 (9 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.