1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package jtr.runners; |
8 |
| |
9 |
| import java.util.concurrent.Future; |
10 |
| |
11 |
| import jtr.config.RegisteredFactories; |
12 |
| import jtr.config.ws.Binding; |
13 |
| import jtr.config.ws.WebServiceConfig; |
14 |
| import jtr.ws.IWsHelper; |
15 |
| import jtr.ws.IWsHelperFactory; |
16 |
| import jtr.ws.IWsResponse; |
17 |
| import jtr.ws.IWsResponseListener; |
18 |
| import jtr.ws.WsMsgType; |
19 |
| import jtr.ws.WsProviderException; |
20 |
| import org.apache.log4j.Logger; |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| public abstract class AbstractWsRunner extends AbstractRunnerAncestor implements IRunnerWs { |
33 |
| |
34 |
| |
35 |
| |
36 |
34
| public AbstractWsRunner() {
|
37 |
34
| wsHelper = ((IWsHelperFactory) RegisteredFactories.getFactory(RegisteredFactories.IWSHELPER_FACTORY)).getInstance();
|
38 |
| } |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
0
| public WebServiceConfig getWsConfig() {
|
44 |
0
| return wsConfig;
|
45 |
| } |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
6014
| public void setWsConfig(WebServiceConfig wsConfig) {
|
51 |
6014
| this.wsConfig = wsConfig;
|
52 |
| } |
53 |
| |
54 |
| |
55 |
| |
56 |
| |
57 |
| |
58 |
| |
59 |
0
| @Deprecated
|
60 |
| protected void setMessageObjectPart(Binding binding, String partName, Object part, WsMsgType msgType) throws WsProviderException { |
61 |
0
| wsHelper.setMessageObjectPart(binding, partName, part, msgType);
|
62 |
| } |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
0
| @Deprecated
|
69 |
| protected void setMessageIntPart(Binding binding, String partName, int part, WsMsgType msgType) { |
70 |
0
| wsHelper.setMessageIntPart(binding, partName, part, msgType);
|
71 |
| } |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
| |
77 |
0
| @Deprecated
|
78 |
| protected void setMessageBooleanPart(Binding binding, String partName, boolean part, WsMsgType msgType) { |
79 |
0
| wsHelper.setMessageBooleanPart(binding, partName, part, msgType);
|
80 |
| } |
81 |
| |
82 |
| |
83 |
| |
84 |
| |
85 |
| |
86 |
0
| @Deprecated
|
87 |
| protected void setMessageBytePart(Binding binding, String partName, byte part, WsMsgType msgType) { |
88 |
0
| wsHelper.setMessageBytePart(binding, partName, part, msgType);
|
89 |
| } |
90 |
| |
91 |
| |
92 |
| |
93 |
| |
94 |
| |
95 |
0
| @Deprecated
|
96 |
| protected void setMessageCharPart(Binding binding, String partName, char part, WsMsgType msgType) { |
97 |
0
| wsHelper.setMessageCharPart(binding, partName, part, msgType);
|
98 |
| } |
99 |
| |
100 |
| |
101 |
| |
102 |
| |
103 |
| |
104 |
0
| @Deprecated
|
105 |
| protected void setMessageDoublePart(Binding binding, String partName, double part, WsMsgType msgType) { |
106 |
0
| wsHelper.setMessageDoublePart(binding, partName, part, msgType);
|
107 |
| } |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| |
113 |
0
| @Deprecated
|
114 |
| protected void setMessageFloatPart(Binding binding, String partName, float part, WsMsgType msgType) { |
115 |
0
| wsHelper.setMessageFloatPart(binding, partName, part, msgType);
|
116 |
| } |
117 |
| |
118 |
| |
119 |
| |
120 |
| |
121 |
| |
122 |
0
| @Deprecated
|
123 |
| protected void setMessageLongPart(Binding binding, String partName, long part, WsMsgType msgType) { |
124 |
0
| wsHelper.setMessageLongPart(binding, partName, part, msgType);
|
125 |
| } |
126 |
| |
127 |
| |
128 |
| |
129 |
| |
130 |
| |
131 |
| |
132 |
0
| @Deprecated
|
133 |
| protected Object getMessageObjectPart(Binding binding, String partName, WsMsgType msgType) throws WsProviderException { |
134 |
0
| return wsHelper.getMessageObjectPart(binding, partName, msgType);
|
135 |
| } |
136 |
| |
137 |
| |
138 |
| |
139 |
| |
140 |
| |
141 |
| |
142 |
0
| @Deprecated
|
143 |
| protected int getMessageIntPart(Binding binding, String partName, WsMsgType msgType) throws WsProviderException { |
144 |
0
| return wsHelper.getMessageIntPart(binding, partName, msgType);
|
145 |
| } |
146 |
| |
147 |
| |
148 |
| |
149 |
| |
150 |
| |
151 |
| |
152 |
0
| @Deprecated
|
153 |
| protected boolean getMessageBooleanPart(Binding binding, String partName, WsMsgType msgType) throws WsProviderException { |
154 |
0
| return wsHelper.getMessageBooleanPart(binding, partName, msgType);
|
155 |
| } |
156 |
| |
157 |
| |
158 |
| |
159 |
| |
160 |
| |
161 |
| |
162 |
0
| @Deprecated
|
163 |
| protected byte getMessageBytePart(Binding binding, String partName, WsMsgType msgType) throws WsProviderException { |
164 |
0
| return wsHelper.getMessageBytePart(binding, partName, msgType);
|
165 |
| } |
166 |
| |
167 |
| |
168 |
| |
169 |
| |
170 |
| |
171 |
| |
172 |
0
| @Deprecated
|
173 |
| protected char getMessageCharPart(Binding binding, String partName, WsMsgType msgType) throws WsProviderException { |
174 |
0
| return wsHelper.getMessageCharPart(binding, partName, msgType);
|
175 |
| } |
176 |
| |
177 |
| |
178 |
| |
179 |
| |
180 |
| |
181 |
| |
182 |
0
| @Deprecated
|
183 |
| protected double getMessageDoublePart(Binding binding, String partName, WsMsgType msgType) throws WsProviderException { |
184 |
0
| return wsHelper.getMessageDoublePart(binding, partName, msgType);
|
185 |
| } |
186 |
| |
187 |
| |
188 |
| |
189 |
| |
190 |
| |
191 |
| |
192 |
0
| @Deprecated
|
193 |
| protected float getMessageFloatPart(Binding binding, String partName, WsMsgType msgType) throws WsProviderException { |
194 |
0
| return wsHelper.getMessageFloatPart(binding, partName, msgType);
|
195 |
| } |
196 |
| |
197 |
| |
198 |
| |
199 |
| |
200 |
| |
201 |
| |
202 |
0
| @Deprecated
|
203 |
| protected long getMessageLongPart(Binding binding, String partName, WsMsgType msgType) throws WsProviderException { |
204 |
0
| return wsHelper.getMessageLongPart(binding, partName, msgType);
|
205 |
| } |
206 |
| |
207 |
| |
208 |
| |
209 |
| |
210 |
| |
211 |
0
| @Deprecated
|
212 |
| protected String getFaultMessageAsString(Binding binding) { |
213 |
0
| return wsHelper.getFaultMessageAsString(binding);
|
214 |
| } |
215 |
| |
216 |
| |
217 |
| |
218 |
| |
219 |
| |
220 |
0
| @Deprecated
|
221 |
| protected Throwable getFaultCause(Binding binding) { |
222 |
0
| return wsHelper.getFaultCause(binding);
|
223 |
| } |
224 |
| |
225 |
| |
226 |
| |
227 |
| |
228 |
| |
229 |
| |
230 |
| |
231 |
| |
232 |
| |
233 |
0
| @Deprecated
|
234 |
| protected boolean synchronousInvoke(Binding binding) throws Throwable { |
235 |
0
| boolean res = false;
|
236 |
0
| res = wsHelper.synchronousInvoke(binding);
|
237 |
0
| if(!res) {
|
238 |
0
| String faultMsg = getFaultMessageAsString(binding);
|
239 |
0
| logger.error("The synchronous invocation of "+binding.getNameSpace()+"-"+binding.getName()+"-"+binding.getPortName()+"-"+binding.getOperationName()+" returned the following fault message: \n"+faultMsg);
|
240 |
0
| logger.error("Follows the cause: ",getFaultCause(binding));
|
241 |
| } |
242 |
0
| return res;
|
243 |
| } |
244 |
| |
245 |
| |
246 |
| |
247 |
| |
248 |
| |
249 |
| |
250 |
| |
251 |
0
| @Deprecated
|
252 |
| public void asynchronousInputOnlyInvoke(Binding binding) throws Throwable { |
253 |
0
| wsHelper.asynchronousInputOnlyInvoke(binding);
|
254 |
| } |
255 |
| |
256 |
| |
257 |
| |
258 |
| |
259 |
| |
260 |
6014
| public void setBinding(Binding binding) {
|
261 |
6014
| this.binding = binding;
|
262 |
| } |
263 |
| |
264 |
| |
265 |
| |
266 |
| |
267 |
| |
268 |
36995
| public Binding getBinding() {
|
269 |
36997
| return binding;
|
270 |
| } |
271 |
| |
272 |
0
| @Deprecated
|
273 |
| public String[] getMessageParts(Binding binding, WsMsgType msgType) { |
274 |
0
| return wsHelper.getMessageParts(binding, msgType);
|
275 |
| } |
276 |
| |
277 |
| |
278 |
| |
279 |
| |
280 |
| |
281 |
| |
282 |
| |
283 |
| |
284 |
| |
285 |
| |
286 |
| |
287 |
| |
288 |
| |
289 |
1700
| public final void run() {
|
290 |
1700
| logger = Logger.getLogger(this.getClass().getName());
|
291 |
1700
| logger.debug("Running client thread...");
|
292 |
1700
| for (currentRun = 0; currentRun < getRuns(); currentRun++) {
|
293 |
| |
294 |
9499
| try {
|
295 |
9500
| logger.debug("Starting run " + currentRun + " in epoch " + epoch);
|
296 |
9498
| if (epoch == 0 && currentRun == 0 || paramsAssigner.requiresReinitialization()) {
|
297 |
6014
| logger.debug("Generating WS runtime configuration...");
|
298 |
6014
| wsHelper.generateRuntimeConfig(wsConfig);
|
299 |
| } |
300 |
9500
| doRunTest();
|
301 |
| } catch (Throwable t) { |
302 |
2000
| handleFailure(currentRun, t);
|
303 |
| } |
304 |
| |
305 |
9500
| try {
|
306 |
9500
| if (currentRun < getRuns() - 1) {
|
307 |
7800
| logger.debug("Completed, going to bed for a while... [" + getSleepTime() + " mSecs.]");
|
308 |
7799
| Thread.sleep(getSleepTime());
|
309 |
7798
| logger.debug("Awaken");
|
310 |
| |
311 |
7797
| logger.debug("Check for reinitialization");
|
312 |
7798
| if (paramsAssigner.requiresReinitialization()) {
|
313 |
| |
314 |
5000
| logger.debug("Reinitialization required...");
|
315 |
5000
| paramsAssigner.reAssign(clean());
|
316 |
5000
| logger.debug("... reinitialized");
|
317 |
| } else { |
318 |
| |
319 |
2799
| logger.debug("Reinitialization not required");
|
320 |
| } |
321 |
| } |
322 |
| } catch (InterruptedException e) { |
323 |
0
| String msg = "The current test-thread " + Thread.currentThread().getName() + " received an interrupt while sleeping";
|
324 |
0
| logger.warn(msg, e);
|
325 |
| } |
326 |
| } |
327 |
| |
328 |
1700
| logger.debug("Completed all the runs [" + getRuns() + "], going back into the pool");
|
329 |
1700
| logger.debug("Getting IPoolManager instance...");
|
330 |
1700
| pool.getPoolManager().backIntoPool(this);
|
331 |
| } |
332 |
| |
333 |
7494
| public Object invoke(Binding binding, Object input) throws WsProviderException {
|
334 |
7500
| return wsHelper.invoke(this, binding, input);
|
335 |
| } |
336 |
| |
337 |
4000
| public void invokeOneWay(Binding binding, Object input) throws WsProviderException {
|
338 |
4000
| wsHelper.invokeOneWay(this, binding, input);
|
339 |
| } |
340 |
| |
341 |
2000
| public Future<?> invokeAsync(Binding binding, Object input, IWsResponseListener rl) throws WsProviderException {
|
342 |
2000
| return wsHelper.invokeAsync(this, binding, input, rl);
|
343 |
| } |
344 |
| |
345 |
2000
| public IWsResponse invokeAsync(Binding binding, Object input) throws WsProviderException {
|
346 |
2000
| return wsHelper.invokeAsync(this, binding, input);
|
347 |
| } |
348 |
| |
349 |
| |
350 |
| |
351 |
| |
352 |
| |
353 |
| |
354 |
9500
| public int getCurrentRun() {
|
355 |
9500
| return currentRun;
|
356 |
| } |
357 |
| |
358 |
| private int currentRun; |
359 |
| private WebServiceConfig wsConfig; |
360 |
| private Binding binding; |
361 |
| private IWsHelper wsHelper; |
362 |
| } |