1
2
3
4 package com.eviware.soapui.impl.wsdl;
5
6 import java.util.HashSet;
7 import java.util.Set;
8
9 import javax.swing.ImageIcon;
10
11 import com.eviware.soapui.config.TestStepConfig;
12 import com.eviware.soapui.impl.wsdl.actions.teststep.DeleteTestStepAction;
13 import com.eviware.soapui.impl.wsdl.actions.teststep.RenameTestStepAction;
14 import com.eviware.soapui.model.support.AbstractModelItem;
15 import com.eviware.soapui.model.testsuite.TestCase;
16 import com.eviware.soapui.model.testsuite.TestRunner;
17 import com.eviware.soapui.model.testsuite.TestStep;
18 import com.eviware.soapui.model.tree.SoapUITreeNode;
19 import com.eviware.soapui.model.tree.nodes.TestStepTreeNode;
20
21 /***
22 * Base class for WSDL project test steps.
23 *
24 * @author Ole.Matzura
25 */
26
27 abstract public class WsdlTestStep extends AbstractModelItem implements TestStep
28 {
29 private final WsdlTestCase testCase;
30 private TestStepConfig config;
31
32 private final Set<TestStepListener> listeners = new HashSet<TestStepListener>();
33
34 protected WsdlTestStep( WsdlTestCase testCase, TestStepConfig config )
35 {
36 this.testCase = testCase;
37 this.config = config;
38
39 addAction( new DeleteTestStepAction( this ) );
40 addAction( new RenameTestStepAction( this ) );
41 }
42
43 public TestCase getTestCase()
44 {
45 return testCase;
46 }
47
48 public String getName()
49 {
50 try
51 {
52 return config.getName();
53 }
54 catch (Exception e)
55 {
56 return null;
57 }
58 }
59
60 public TestStepConfig getConfig()
61 {
62 return config;
63 }
64
65 /***
66 * Called from WsdlTestCase when moving a teststep due to no move functionality
67 * in xmlbeans generated arrays.
68 *
69 * @param config the new config to use, will be a copy of the existing one. The current
70 * will be invalid
71 */
72
73 protected void resetConfigOnMove( TestStepConfig config )
74 {
75 this.config = config;
76 }
77
78 public void setName(String name)
79 {
80 String old = getName();
81 config.setName( name );
82 notifyPropertyChanged( NAME_PROPERTY, old, name );
83 }
84
85 protected SoapUITreeNode createTreeNode()
86 {
87 return new TestStepTreeNode( this );
88 }
89
90 public void addTestStepListener( TestStepListener listener )
91 {
92 listeners.add( listener );
93 }
94
95 public void removeTestStepListener( TestStepListener listener )
96 {
97 listeners.remove( listener );
98 }
99
100 public void fireBeforeRun()
101 {
102 TestStepListener [] listeners = this.listeners.toArray( new TestStepListener[this.listeners.size()]);
103
104 for (int i = 0; i < listeners.length; i++)
105 {
106 TestStepListener listener = listeners[i];
107 listener.beforeRun( this );
108 }
109 }
110
111 public void fireAfterRun()
112 {
113 TestStepListener [] listeners = this.listeners.toArray( new TestStepListener[this.listeners.size()]);
114
115 for (int i = 0; i < listeners.length; i++)
116 {
117 TestStepListener listener = listeners[i];
118 listener.afterRun( this );
119 }
120 }
121
122 public void prepare(TestRunner testRunner)
123 {
124 }
125
126 public ImageIcon getIcon()
127 {
128 return null;
129 }
130 }