1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.teststeps;
14
15 import com.eviware.soapui.config.*;
16 import com.eviware.soapui.impl.wsdl.*;
17 import com.eviware.soapui.impl.wsdl.mock.*;
18 import com.eviware.soapui.impl.wsdl.panels.mockoperation.WsdlMockResultMessageExchange;
19 import com.eviware.soapui.impl.wsdl.support.assertions.AssertableConfig;
20 import com.eviware.soapui.impl.wsdl.support.assertions.AssertedXPathsContainer;
21 import com.eviware.soapui.impl.wsdl.support.assertions.AssertionsSupport;
22 import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
23 import com.eviware.soapui.impl.wsdl.teststeps.assertions.TestAssertionRegistry;
24 import com.eviware.soapui.model.ModelItem;
25 import com.eviware.soapui.model.iface.Interface;
26 import com.eviware.soapui.model.iface.Operation;
27 import com.eviware.soapui.model.iface.SubmitContext;
28 import com.eviware.soapui.model.mock.MockResult;
29 import com.eviware.soapui.model.propertyexpansion.PropertyExpansion;
30 import com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils;
31 import com.eviware.soapui.model.support.*;
32 import com.eviware.soapui.model.testsuite.*;
33 import com.eviware.soapui.model.testsuite.AssertionError;
34 import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus;
35 import com.eviware.soapui.support.UISupport;
36 import com.eviware.soapui.support.types.StringToStringMap;
37 import org.apache.log4j.Logger;
38
39 import javax.swing.*;
40 import java.beans.PropertyChangeEvent;
41 import java.beans.PropertyChangeListener;
42 import java.util.*;
43
44
45 public class WsdlAsyncResponseTestStep extends WsdlTestStepWithProperties implements PropertyChangeListener, Assertable
46 {
47 private static final Logger log = Logger.getLogger(WsdlAsyncResponseTestStep.class);
48
49 public static final String STATUS_PROPERTY = WsdlAsyncResponseTestStep.class.getName() + "@status";
50 public static final String TIMEOUT_PROPERTY = WsdlAsyncResponseTestStep.class.getName() + "@timeout";
51 public static final String MATCHING_VALUE_PROPERTY = WsdlAsyncResponseTestStep.class.getName() + "@matchingValue";
52
53 private AsyncResponseStepConfig testStepConfig;
54 private MockResponseConfig mockResponseConfig;
55 private WsdlMockOperation mockOperation;
56 private WsdlMockService mockService;
57 private WsdlMockResponse mockResponse;
58
59 private AssertionsSupport assertionsSupport;
60 private InternalMockRunListener listener;
61
62 private final InternalProjectListener projectListener = new InternalProjectListener();
63 private final InternalInterfaceListener interfaceListener = new InternalInterfaceListener();
64 private WsdlInterface iface;
65 private AssertionStatus oldStatus;
66
67 /***
68 * Constructor
69 *
70 * @param testCase
71 * @param testStepConfig
72 * @param forLoadTest
73 */
74 public WsdlAsyncResponseTestStep(WsdlTestCase testCase, TestStepConfig config, boolean forLoadTest)
75 {
76 super(testCase, config, true, forLoadTest);
77
78 if (config.getConfig() != null)
79 {
80 testStepConfig = (AsyncResponseStepConfig) config.getConfig().changeType(AsyncResponseStepConfig.type);
81 mockResponseConfig = testStepConfig.getResponse();
82 }
83 else
84 {
85 testStepConfig = (AsyncResponseStepConfig) config.addNewConfig().changeType(AsyncResponseStepConfig.type);
86 mockResponseConfig = testStepConfig.addNewResponse();
87 }
88
89 assertionsSupport = new AssertionsSupport(this, new AssertableConfig()
90 {
91
92 public TestAssertionConfig addNewAssertion()
93 {
94 return testStepConfig.addNewAssertion();
95 }
96
97 public List<TestAssertionConfig> getAssertionList()
98 {
99 return testStepConfig.getAssertionList();
100 }
101
102 public void removeAssertion(int ix)
103 {
104 testStepConfig.removeAssertion(ix);
105 }
106 });
107
108 createMockService();
109
110 if (!forLoadTest)
111 {
112 setIcon(UISupport.createImageIcon("/asyncResponseStep.gif"));
113 if (iface != null)
114 {
115 iface.getProject().addProjectListener(projectListener);
116 iface.addInterfaceListener(interfaceListener);
117 }
118 }
119
120 addProperty(new TestStepBeanProperty("Response", false, mockResponse, "responseContent", this));
121 addProperty(new DefaultTestStepProperty("Request", true, new DefaultTestStepProperty.PropertyHandlerAdapter()
122 {
123 public String getValue(DefaultTestStepProperty property)
124 {
125 WsdlMockResult mockResult = getMockResponse().getMockResult();
126 if (mockResult == null)
127 {
128 return null;
129 }
130 else
131 {
132 return mockResult.getMockRequest().getRequestContent();
133 }
134 }
135 }, this));
136
137 addProperty(new TestStepBeanProperty("Matching Value", false, this, "matchingValue", this));
138 }
139
140 public void resetConfigOnMove(TestStepConfig config)
141 {
142 super.resetConfigOnMove(config);
143
144 testStepConfig = (AsyncResponseStepConfig) config.getConfig().changeType(AsyncResponseStepConfig.type);
145 mockResponseConfig = this.testStepConfig.getResponse();
146 mockResponse.setConfig(mockResponseConfig);
147
148 assertionsSupport.refresh();
149 }
150
151 public boolean cancel()
152 {
153 if (listener != null)
154 {
155 listener.cancel();
156 }
157
158 return true;
159 }
160
161 public void createMockService()
162 {
163 WsdlProject project = getTestCase().getTestSuite().getProject();
164 MockRunnerManager manager = MockRunnerManagerImpl.getInstance(getTestCase());
165
166 mockService = manager.getMockService(getPort(), getPath());
167
168 iface = (WsdlInterface) project.getInterfaceByName(testStepConfig.getInterface());
169 iface.addInterfaceListener(interfaceListener);
170
171 WsdlOperation operation = iface.getOperationByName(testStepConfig.getOperation());
172 mockOperation = mockService.getMockOperation(operation);
173 if (mockOperation == null)
174 mockOperation = mockService.addNewMockOperation(operation);
175 mockOperation.setDispatchStyle(DispatchStyleConfig.QUERY_MATCH);
176 mockResponse = mockOperation.addNewMockResponse(mockResponseConfig);
177 mockResponse.addPropertyChangeListener(this);
178
179 listener = new InternalMockRunListener();
180 mockService.addMockRunListener(listener);
181 }
182
183 public TestStepResult run(TestRunner testRunner, TestRunContext context)
184 {
185 WsdlMockResponse oldResponse = getMockResponse();
186 mockResponse = mockOperation.addNewMockResponse(getRequestQuery(), getMatchingValue());
187 mockResponse.setConfig(oldResponse.getConfig());
188
189 WsdlSingleMessageExchangeTestStepResult result = new WsdlSingleMessageExchangeTestStepResult(this);
190
191 result.startTimer();
192 long timeout = getTimeout();
193
194 synchronized (listener)
195 {
196 long start = System.currentTimeMillis();
197 do
198 {
199 try
200 {
201 listener.wait(timeout);
202 }
203 catch (InterruptedException e)
204 {
205
206 }
207
208 timeout -= (System.currentTimeMillis() - start);
209 }
210 while (timeout > 0);
211 }
212
213 if (listener.getResult() != null)
214 {
215 AssertedWsdlMockResultMessageExchange messageExchange = new AssertedWsdlMockResultMessageExchange(listener
216 .getResult());
217
218 result.setMessageExchange(messageExchange);
219
220 context.setProperty(AssertedXPathsContainer.ASSERTEDXPATHSCONTAINER_PROPERTY, messageExchange);
221 updateAssertionStatus(listener.getResult(), ((context)));
222 }
223
224 result.stopTimer();
225
226 if (listener.getResult() == null)
227 {
228 if (listener.isCanceled())
229 {
230 result.setStatus(TestStepStatus.CANCELED);
231 }
232 else
233 {
234 result.setStatus(TestStepStatus.FAILED);
235 result.addMessage((new StringBuilder()).append("Timeout occured after ").append(timeout).append(
236 " milliseconds").toString());
237 }
238 }
239 else if (getAssertionStatus() == AssertionStatus.FAILED)
240 {
241 result.setStatus(TestStepStatus.FAILED);
242 if (getAssertionCount() == 0)
243 {
244 result.addMessage("Invalid/empty request");
245 }
246 else
247 {
248 for (int i = 0; i < getAssertionCount(); i++)
249 {
250 AssertionError assertionErrors[] = getAssertionAt(i).getErrors();
251 if (assertionErrors != null)
252 {
253 for (int j = 0; j < assertionErrors.length; j++)
254 {
255 AssertionError assertionError = assertionErrors[j];
256 result.addMessage(assertionError.getMessage());
257 }
258 }
259 }
260 }
261 }
262 else
263 {
264 result.setStatus(TestStepStatus.OK);
265 }
266
267 return result;
268 }
269
270 private void updateAssertionStatus(WsdlMockResult mockResult, SubmitContext submitContext)
271 {
272 if (oldStatus == null)
273 {
274 oldStatus = getAssertionStatus();
275 }
276
277 for (int i = 0; i < getAssertionCount(); i++)
278 {
279 WsdlMessageAssertion assertion = getAssertionAt(i);
280 if (!assertion.isDisabled())
281 assertion.assertRequest(new WsdlMockResultMessageExchange(mockResult, getMockResponse()), submitContext);
282 }
283
284 AssertionStatus newAssertionStatus = getAssertionStatus();
285 if (newAssertionStatus != oldStatus)
286 {
287 notifyPropertyChanged(STATUS_PROPERTY, oldStatus, newAssertionStatus);
288 oldStatus = newAssertionStatus;
289 }
290 }
291
292 public void finish(TestRunner testrunner, TestRunContext testruncontext)
293 {
294 }
295
296 public WsdlMockResponse getMockResponse()
297 {
298 return mockResponse;
299 }
300
301 public void setPort(int port)
302 {
303 mockService.setPort(port);
304 testStepConfig.setPort(port);
305 }
306
307 public int getPort()
308 {
309 return testStepConfig.getPort();
310 }
311
312 public void setPath(String path)
313 {
314 mockService.setPath(path);
315 testStepConfig.setPath(path);
316 }
317
318 public String getPath()
319 {
320 return testStepConfig.getPath();
321 }
322
323 public void setRequestQuery(String query)
324 {
325 testStepConfig.setRequestQuery(query);
326 }
327
328 public String getRequestQuery()
329 {
330 return testStepConfig.getRequestQuery();
331 }
332
333 public void setMatchingValue(String value)
334 {
335
336 if (value == null)
337 {
338 value = "";
339 }
340
341 String oldValue = testStepConfig.getMatchingValue();
342
343 if (!value.equals(oldValue))
344 {
345 testStepConfig.setMatchingValue(value);
346 notifyPropertyChanged(MATCHING_VALUE_PROPERTY, oldValue, value);
347 }
348 }
349
350 public String getMatchingValue()
351 {
352 return testStepConfig.getMatchingValue();
353 }
354
355 public long getContentLength()
356 {
357 if (mockResponse == null)
358 {
359 return 0;
360 }
361 else
362 {
363 return mockResponse.getContentLength();
364 }
365 }
366
367 public String getEncoding()
368 {
369 return mockResponse.getEncoding();
370 }
371
372 public void setEncoding(String encoding)
373 {
374 mockResponse.setEncoding(encoding);
375 }
376
377 public boolean isMtomEnabled()
378 {
379 return mockResponse.isMtomEnabled();
380 }
381
382 public void setMtomEnabled(boolean mtomEnabled)
383 {
384 mockResponse.setMtomEnabled(mtomEnabled);
385 }
386
387 public String getOutgoingWss()
388 {
389 return mockResponse.getOutgoingWss();
390 }
391
392 public void setOutgoingWss(String outgoingWss)
393 {
394 mockResponse.setOutgoingWss(outgoingWss);
395 }
396
397 public boolean isForceMtom()
398 {
399 return mockResponse.isForceMtom();
400 }
401
402 public void setForceMtom(boolean forceMtom)
403 {
404 mockResponse.setForceMtom(forceMtom);
405 }
406
407 public boolean isInlineFilesEnabled()
408 {
409 return mockResponse.isInlineFilesEnabled();
410 }
411
412 public void setInlineFilesEnabled(boolean inlineFilesEnabled)
413 {
414 mockResponse.setInlineFilesEnabled(inlineFilesEnabled);
415 }
416
417 public boolean isMultipartEnabled()
418 {
419 return mockResponse.isMultipartEnabled();
420 }
421
422 public void setMultipartEnabled(boolean multipartEnabled)
423 {
424 mockResponse.setMultipartEnabled(multipartEnabled);
425 }
426
427 public long getResponseDelay()
428 {
429 return mockResponse.getResponseDelay();
430 }
431
432 public void setResponseDelay(long delay)
433 {
434 mockResponse.setResponseDelay(delay);
435 }
436
437 public String getResponseHttpStatus()
438 {
439 return mockResponse.getResponseHttpStatus();
440 }
441
442 public void setResponseHttpStatus(String status)
443 {
444 mockResponse.setResponseHttpStatus(status);
445 }
446
447 public boolean isEncodeAttachments()
448 {
449 return mockResponse.isEncodeAttachments();
450 }
451
452 public boolean isRemoveEmptyContent()
453 {
454 return mockResponse.isRemoveEmptyContent();
455 }
456
457 public boolean isStripWhitespaces()
458 {
459 return mockResponse.isStripWhitespaces();
460 }
461
462 public void setEncodeAttachments(boolean encodeAttachments)
463 {
464 mockResponse.setEncodeAttachments(encodeAttachments);
465 }
466
467 public void setRemoveEmptyContent(boolean removeEmptyContent)
468 {
469 mockResponse.setRemoveEmptyContent(removeEmptyContent);
470 }
471
472 public void setStripWhitespaces(boolean stripWhitespaces)
473 {
474 mockResponse.setStripWhitespaces(stripWhitespaces);
475 }
476
477 public void propertyChange(PropertyChangeEvent event)
478 {
479 if (event.getSource() == mockResponse)
480 {
481 mockResponseConfig.set(mockResponse.getConfig());
482
483 notifyPropertyChanged(event.getPropertyName(), event.getOldValue(), event.getNewValue());
484 }
485
486
487
488
489
490
491
492 }
493
494 public WsdlMessageAssertion addAssertion(String assertion)
495 {
496 PropertyChangeNotifier notifier = new PropertyChangeNotifier();
497
498 TestAssertionConfig assertionConfig = testStepConfig.addNewAssertion();
499 assertionConfig.setType(TestAssertionRegistry.getInstance().getAssertionTypeForName(assertion));
500
501 WsdlMessageAssertion messageAssertion = assertionsSupport.addWsdlAssertion(assertionConfig);
502
503 assertionsSupport.fireAssertionAdded(messageAssertion);
504
505 if (getMockResponse().getMockResult() != null)
506 {
507 messageAssertion.assertRequest(new WsdlMockResultMessageExchange(getMockResponse().getMockResult(),
508 getMockResponse()), new WsdlSubmitContext(this));
509 notifier.notifyChange();
510 }
511
512 return messageAssertion;
513 }
514
515 public void addAssertionsListener(AssertionsListener listener)
516 {
517 assertionsSupport.addAssertionsListener(listener);
518 }
519
520 public WsdlMessageAssertion getAssertionAt(int i)
521 {
522 return assertionsSupport.getAssertionAt(i);
523 }
524
525 public int getAssertionCount()
526 {
527 return assertionsSupport.getAssertionCount();
528 }
529
530 public void removeAssertionsListener(AssertionsListener listener)
531 {
532 assertionsSupport.removeAssertionsListener(listener);
533 }
534
535 public AssertionStatus getAssertionStatus()
536 {
537 AssertionStatus currentStatus = AssertionStatus.UNKNOWN;
538 int i = getAssertionCount();
539 if (i == 0)
540 {
541 return currentStatus;
542 }
543
544 int j = 0;
545 do
546 {
547 if (j >= i)
548 {
549 break;
550 }
551
552 WsdlMessageAssertion assertion = getAssertionAt(j);
553 if (!assertion.isDisabled() && assertion.getStatus() == AssertionStatus.FAILED)
554 {
555 currentStatus = AssertionStatus.FAILED;
556 break;
557 }
558
559 j++;
560 }
561 while (true);
562
563 if (currentStatus == AssertionStatus.UNKNOWN)
564 {
565 currentStatus = AssertionStatus.VALID;
566 }
567
568 return currentStatus;
569 }
570
571 public void removeAssertion(TestAssertion assertion)
572 {
573 PropertyChangeNotifier notifier = new PropertyChangeNotifier();
574
575 assertionsSupport.removeAssertion((WsdlMessageAssertion) assertion);
576
577 notifier.notifyChange();
578 }
579
580 public String getAssertableContent()
581 {
582 WsdlMockResult result = getMockResponse().getMockResult();
583
584 if (result == null)
585 {
586 return null;
587 }
588 else
589 {
590 return result.getMockRequest().getRequestContent();
591 }
592 }
593
594 public TestStep getTestStep()
595 {
596 return this;
597 }
598
599 public void setName(String name)
600 {
601 super.setName(name);
602
603 if (mockService != null)
604 {
605 mockService.setName(getName());
606 }
607 }
608
609 public WsdlInterface getInterface()
610 {
611 return getOperation().getInterface();
612 }
613
614 public WsdlOperation getOperation()
615 {
616 return getMockResponse().getMockOperation().getOperation();
617 }
618
619 public void setInterface(String interfaceName)
620 {
621 WsdlInterface wsdlInterface = (WsdlInterface) getTestCase().getTestSuite().getProject().getInterfaceByName(
622 interfaceName);
623
624 if (wsdlInterface != null)
625 {
626 testStepConfig.setInterface(wsdlInterface.getName());
627 WsdlOperation wsdloperation = wsdlInterface.getOperationAt(0);
628 testStepConfig.setOperation(wsdloperation.getName());
629 mockOperation.setOperation(wsdloperation);
630 }
631 }
632
633 public void setOperation(String operationName)
634 {
635 WsdlOperation wsdlOperation = getInterface().getOperationByName(operationName);
636 if (wsdlOperation != null)
637 {
638 testStepConfig.setOperation(operationName);
639 mockOperation.setOperation(wsdlOperation);
640 }
641 }
642
643 public void release()
644 {
645 super.release();
646
647 assertionsSupport.release();
648
649 if (mockResponse != null)
650 {
651 mockResponse.removePropertyChangeListener(this);
652 }
653
654 if (mockService != null)
655 {
656 mockService.release();
657 }
658
659 if (iface != null)
660 {
661 iface.getProject().removeProjectListener(projectListener);
662 iface.removeInterfaceListener(interfaceListener);
663 }
664 }
665
666 public TestAssertionRegistry.AssertableType getAssertableType()
667 {
668 return TestAssertionRegistry.AssertableType.REQUEST;
669 }
670
671 public Collection<WsdlInterface> getRequiredInterfaces()
672 {
673 ArrayList<WsdlInterface> interfaces = new ArrayList<WsdlInterface>();
674 interfaces.add(getInterface());
675
676 return interfaces;
677 }
678
679 public String getDefaultSourcePropertyName()
680 {
681 return "Response";
682 }
683
684 public String getDefaultTargetPropertyName()
685 {
686 return "Resource";
687 }
688
689 public void beforeSave()
690 {
691 super.beforeSave();
692
693 if (mockResponse != null)
694 {
695 mockResponse.beforeSave();
696 mockResponseConfig.set(mockResponse.getConfig());
697 }
698 }
699
700 public long getTimeout()
701 {
702 return testStepConfig.getTimeout();
703 }
704
705 public void setTimeout(long newTimeout)
706 {
707 long oldTimeout = getTimeout();
708 testStepConfig.setTimeout(newTimeout);
709 notifyPropertyChanged(TIMEOUT_PROPERTY, Long.valueOf(oldTimeout), Long.valueOf(newTimeout));
710 }
711
712 public boolean dependsOn(AbstractWsdlModelItem<?> modelItem)
713 {
714 return modelItem == getOperation().getInterface();
715 }
716
717 public WsdlMessageAssertion cloneAssertion(TestAssertion testAssertion, String s)
718 {
719 TestAssertionConfig assertionConfig = testStepConfig.addNewAssertion();
720 assertionConfig.set(((WsdlMessageAssertion) testAssertion).getConfig());
721 assertionConfig.setName(s);
722 WsdlMessageAssertion messageAssertion = assertionsSupport.addWsdlAssertion(assertionConfig);
723
724 assertionsSupport.fireAssertionAdded(messageAssertion);
725 return messageAssertion;
726 }
727
728 public List<TestAssertion> getAssertionList()
729 {
730 return new ArrayList<TestAssertion>(assertionsSupport.getAssertionList());
731 }
732
733 public List<WsdlMessageAssertion> getChildren()
734 {
735 return assertionsSupport.getAssertionList();
736 }
737
738 public PropertyExpansion[] getPropertyExpansions()
739 {
740 ArrayList<PropertyExpansion> expansions = new ArrayList<PropertyExpansion>();
741 expansions.addAll(PropertyExpansionUtils.extractPropertyExpansions(this, mockResponse, "responseContent"));
742
743 StringToStringMap headers = mockResponse.getResponseHeaders();
744 String s;
745 for (Iterator<?> iterator = headers.keySet().iterator(); iterator.hasNext(); PropertyExpansionUtils
746 .extractPropertyExpansions(this, new ResponseHeaderHolder(headers, s), "value"))
747 s = (String) iterator.next();
748
749 return (PropertyExpansion[]) expansions.toArray(new PropertyExpansion[expansions.size()]);
750 }
751
752 public WsdlMessageAssertion getAssertionByName(String s)
753 {
754 return assertionsSupport.getAssertionByName(s);
755 }
756
757 public Map<String, TestAssertion> getAssertions()
758 {
759 HashMap<String, TestAssertion> hashmap = new HashMap<String, TestAssertion>();
760 TestAssertion testassertion;
761 for (Iterator<?> iterator = getAssertionList().iterator(); iterator.hasNext(); hashmap.put(testassertion
762 .getName(), testassertion))
763 testassertion = (TestAssertion) iterator.next();
764
765 return hashmap;
766 }
767
768 public String toString()
769 {
770 return WsdlAsyncResponseTestStep.class.getName() + " [port= " + this.getPort() + ", path= " + this.getPath()
771 + ", query=" + this.getRequestQuery() + ", value=" + this.getMatchingValue() + ", interface="
772 + this.getInterface().getName() + ", operation=" + this.getOperation().getName() + "]";
773 }
774
775 public String getDefaultAssertableContent()
776 {
777 return getOperation().createResponse(true);
778 }
779
780 private class AssertedWsdlMockResultMessageExchange extends WsdlMockResultMessageExchange implements
781 RequestAssertedMessageExchange, AssertedXPathsContainer
782 {
783 private List<AssertedXPath> list;
784
785 public AssertedWsdlMockResultMessageExchange(WsdlMockResult result)
786 {
787 super(result, result.getMockResponse());
788 }
789
790 public AssertedXPath[] getAssertedXPathsForRequest()
791 {
792 return (list == null ? new AssertedXPath[0] : list.toArray(new AssertedXPath[list.size()]));
793 }
794
795 public void addAssertedXPath(AssertedXPath assertedXPath)
796 {
797 if (list == null)
798 {
799 list = new ArrayList<AssertedXPath>();
800 }
801
802 list.add(assertedXPath);
803 }
804 }
805
806 private class ResponseHeaderHolder
807 {
808 private final StringToStringMap headers;
809 private final String header;
810
811 public String getValue()
812 {
813 return headers.get(header);
814 }
815
816 public void setValue(String value)
817 {
818 headers.put(header, value);
819 getMockResponse().setResponseHeaders(headers);
820 }
821
822 public ResponseHeaderHolder(StringToStringMap headers, String header)
823 {
824 this.headers = headers;
825 this.header = header;
826 }
827 }
828
829 private class InternalInterfaceListener extends InterfaceListenerAdapter
830 {
831 public void operationRemoved(Operation operation)
832 {
833 if (operation == getOperation())
834 {
835 log.debug("Removing test step due to removed operation");
836 getTestCase().removeTestStep(WsdlAsyncResponseTestStep.this);
837 }
838 }
839
840 public void operationUpdated(Operation operation)
841 {
842 if (operation == getOperation())
843 {
844 setOperation(operation.getName());
845 }
846 }
847 }
848
849 private class InternalProjectListener extends ProjectListenerAdapter
850 {
851 public void interfaceRemoved(Interface iface)
852 {
853 if (getOperation() != null && getOperation().getInterface().equals(iface))
854 {
855 log.debug("Removing test step due to removed interface");
856 getTestCase().removeTestStep(WsdlAsyncResponseTestStep.this);
857 }
858 }
859 }
860
861 private class PropertyChangeNotifier
862 {
863 private AssertionStatus status;
864 private ImageIcon icon;
865
866 public PropertyChangeNotifier()
867 {
868 status = getAssertionStatus();
869 icon = getIcon();
870 }
871
872 public void notifyChange()
873 {
874 AssertionStatus newStatus = getAssertionStatus();
875 ImageIcon newIcon = getIcon();
876
877 if (this.status != newStatus)
878 {
879 notifyPropertyChanged(WsdlAsyncResponseTestStep.STATUS_PROPERTY, this.status, newStatus);
880 }
881
882 if (this.icon != newIcon)
883 {
884 notifyPropertyChanged(ModelItem.ICON_PROPERTY, this.icon, newIcon);
885 }
886 }
887 }
888
889 private class InternalMockRunListener extends MockRunListenerAdapter
890 {
891 private WsdlMockResult result;
892 private boolean canceled;
893
894 public void onMockResult(MockResult mockResult)
895 {
896 result = (WsdlMockResult) mockResult;
897
898
899 if (result == null || (result != null && result.getMockResponse() == mockResponse))
900 {
901 synchronized (this)
902 {
903 notifyAll();
904 }
905 }
906 }
907
908 public void cancel()
909 {
910 canceled = true;
911 listener.onMockResult(null);
912 }
913
914 public WsdlMockResult getResult()
915 {
916 return result;
917 }
918
919 public boolean isCanceled()
920 {
921 return canceled;
922 }
923 }
924
925 }