|
Lines 1-1362
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* $Id: AutoGUIRunner.java,v 1.25 2008/07/14 19:18:57 paules Exp $ |
7 |
* $Id: AutoGUIRunner.java,v 1.25 2008/07/14 19:18:57 paules Exp $ |
| 8 |
* |
8 |
* |
| 9 |
* Contributors: |
9 |
* Contributors: |
| 10 |
* IBM Corporation - initial API and implementation |
10 |
* IBM Corporation - initial API and implementation |
| 11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
| 12 |
package org.eclipse.tptp.test.auto.gui.internal.runner; |
12 |
package org.eclipse.tptp.test.auto.gui.internal.runner; |
| 13 |
|
13 |
|
| 14 |
import java.io.ByteArrayInputStream; |
14 |
import java.io.ByteArrayInputStream; |
| 15 |
import java.io.PrintStream; |
15 |
import java.io.PrintStream; |
| 16 |
import java.io.UnsupportedEncodingException; |
16 |
import java.io.UnsupportedEncodingException; |
| 17 |
import java.util.ArrayList; |
17 |
import java.util.ArrayList; |
| 18 |
import java.util.Hashtable; |
18 |
import java.util.Hashtable; |
| 19 |
import java.util.Iterator; |
19 |
import java.util.Iterator; |
| 20 |
import java.util.List; |
20 |
import java.util.List; |
| 21 |
import java.util.Map; |
21 |
import java.util.Map; |
| 22 |
import java.util.Stack; |
22 |
import java.util.Stack; |
| 23 |
import java.util.Vector; |
23 |
import java.util.Vector; |
| 24 |
|
24 |
|
| 25 |
import junit.framework.AssertionFailedError; |
25 |
import junit.framework.AssertionFailedError; |
| 26 |
import junit.framework.Test; |
26 |
import junit.framework.Test; |
| 27 |
import junit.framework.TestResult; |
27 |
import junit.framework.TestResult; |
| 28 |
|
28 |
|
| 29 |
import org.eclipse.core.runtime.CoreException; |
29 |
import org.eclipse.core.runtime.CoreException; |
| 30 |
import org.eclipse.hyades.execution.core.IControlMessage; |
30 |
import org.eclipse.hyades.execution.core.IControlMessage; |
| 31 |
import org.eclipse.hyades.internal.execution.local.common.CustomCommand; |
31 |
import org.eclipse.hyades.internal.execution.local.common.CustomCommand; |
| 32 |
import org.eclipse.hyades.internal.execution.remote.CustomCommandHandler; |
32 |
import org.eclipse.hyades.internal.execution.remote.CustomCommandHandler; |
| 33 |
import org.eclipse.hyades.internal.execution.remote.RemoteComponentSkeleton; |
33 |
import org.eclipse.hyades.internal.execution.remote.RemoteComponentSkeleton; |
| 34 |
import org.eclipse.hyades.models.common.facades.behavioral.ITestSuite; |
34 |
import org.eclipse.hyades.models.common.facades.behavioral.ITestSuite; |
| 35 |
import org.eclipse.hyades.models.common.facades.behavioral.impl.HyadesUtil; |
35 |
import org.eclipse.hyades.models.common.facades.behavioral.impl.HyadesUtil; |
| 36 |
import org.eclipse.hyades.test.common.event.ExecutionEvent; |
36 |
import org.eclipse.hyades.test.common.event.ExecutionEvent; |
| 37 |
import org.eclipse.hyades.test.common.event.InvocationEvent; |
37 |
import org.eclipse.hyades.test.common.event.InvocationEvent; |
| 38 |
import org.eclipse.hyades.test.common.event.LoopEvent; |
38 |
import org.eclipse.hyades.test.common.event.LoopEvent; |
| 39 |
import org.eclipse.hyades.test.common.event.MessageEvent; |
39 |
import org.eclipse.hyades.test.common.event.MessageEvent; |
| 40 |
import org.eclipse.hyades.test.common.event.TypedEvent; |
40 |
import org.eclipse.hyades.test.common.event.TypedEvent; |
| 41 |
import org.eclipse.hyades.test.common.event.VerdictEvent; |
41 |
import org.eclipse.hyades.test.common.event.VerdictEvent; |
| 42 |
import org.eclipse.hyades.test.common.junit.IHyadesTest; |
42 |
import org.eclipse.hyades.test.common.junit.IHyadesTest; |
| 43 |
import org.eclipse.hyades.test.common.runner.internal.util.AgentConsoleStream; |
43 |
import org.eclipse.hyades.test.common.runner.internal.util.AgentConsoleStream; |
| 44 |
import org.eclipse.hyades.test.common.runner.model.Action; |
44 |
import org.eclipse.hyades.test.common.runner.model.Action; |
| 45 |
import org.eclipse.hyades.test.common.runner.model.IActionOwner; |
45 |
import org.eclipse.hyades.test.common.runner.model.IActionOwner; |
| 46 |
import org.eclipse.hyades.test.common.runner.model.Loop; |
46 |
import org.eclipse.hyades.test.common.runner.model.Loop; |
| 47 |
import org.eclipse.hyades.test.common.runner.model.NamedElement; |
47 |
import org.eclipse.hyades.test.common.runner.model.NamedElement; |
| 48 |
import org.eclipse.hyades.test.common.runner.model.TestInvocation; |
48 |
import org.eclipse.hyades.test.common.runner.model.TestInvocation; |
| 49 |
import org.eclipse.hyades.test.common.runner.model.TestSuite; |
49 |
import org.eclipse.hyades.test.common.runner.model.TestSuite; |
| 50 |
import org.eclipse.hyades.test.common.runner.model.util.EventLogger; |
50 |
import org.eclipse.hyades.test.common.runner.model.util.EventLogger; |
| 51 |
import org.eclipse.hyades.test.common.runner.model.util.ModelUtil; |
51 |
import org.eclipse.hyades.test.common.runner.model.util.ModelUtil; |
| 52 |
import org.eclipse.hyades.test.common.util.BaseString; |
52 |
import org.eclipse.hyades.test.common.util.BaseString; |
| 53 |
import org.eclipse.hyades.test.java.runner.HyadesJUnitRunner; |
53 |
import org.eclipse.hyades.test.java.runner.HyadesJUnitRunner; |
| 54 |
import org.eclipse.jface.dialogs.MessageDialog; |
54 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 55 |
import org.eclipse.osgi.util.NLS; |
55 |
import org.eclipse.osgi.util.NLS; |
| 56 |
import org.eclipse.swt.widgets.Display; |
56 |
import org.eclipse.swt.widgets.Display; |
| 57 |
import org.eclipse.swt.widgets.Shell; |
57 |
import org.eclipse.swt.widgets.Shell; |
| 58 |
import org.eclipse.tptp.test.auto.gui.internal.AutoGUIMessages; |
58 |
import org.eclipse.tptp.test.auto.gui.internal.AutoGUIMessages; |
| 59 |
import org.eclipse.tptp.test.auto.gui.internal.AutoGUIUtil; |
59 |
import org.eclipse.tptp.test.auto.gui.internal.AutoGUIUtil; |
| 60 |
import org.eclipse.tptp.test.auto.gui.internal.GlobalConstants; |
60 |
import org.eclipse.tptp.test.auto.gui.internal.GlobalConstants; |
| 61 |
import org.eclipse.tptp.test.auto.gui.internal.GuiPlugin; |
61 |
import org.eclipse.tptp.test.auto.gui.internal.GuiPlugin; |
| 62 |
import org.eclipse.tptp.test.auto.gui.internal.commands.ModifyCommand; |
62 |
import org.eclipse.tptp.test.auto.gui.internal.commands.ModifyCommand; |
| 63 |
import org.eclipse.tptp.test.auto.gui.internal.commands.WaitCommand; |
63 |
import org.eclipse.tptp.test.auto.gui.internal.commands.WaitCommand; |
| 64 |
import org.eclipse.tptp.test.auto.gui.internal.editor.AutoGUITestCasesForm.GUITestCaseProperties; |
64 |
import org.eclipse.tptp.test.auto.gui.internal.editor.AutoGUITestCasesForm.GUITestCaseProperties; |
| 65 |
import org.eclipse.tptp.test.auto.gui.internal.macro.MacroConstants; |
65 |
import org.eclipse.tptp.test.auto.gui.internal.macro.MacroConstants; |
| 66 |
import org.eclipse.tptp.test.auto.gui.internal.macro.MacroManager; |
66 |
import org.eclipse.tptp.test.auto.gui.internal.macro.MacroManager; |
| 67 |
import org.eclipse.tptp.test.auto.gui.internal.macro.MacroUtil; |
67 |
import org.eclipse.tptp.test.auto.gui.internal.macro.MacroUtil; |
| 68 |
import org.eclipse.tptp.test.auto.gui.internal.macro.XMLDefaultHandler; |
68 |
import org.eclipse.tptp.test.auto.gui.internal.runner.ExtendedScriptParser.ExtendedTestCase; |
| 69 |
import org.eclipse.tptp.test.auto.gui.internal.runner.ExtendedScriptParser.ExtendedTestCase; |
69 |
import org.eclipse.tptp.test.auto.gui.internal.runner.ExtendedScriptParser.ExtendedTestInvocation; |
| 70 |
import org.eclipse.tptp.test.auto.gui.internal.runner.ExtendedScriptParser.ExtendedTestInvocation; |
70 |
import org.eclipse.tptp.test.auto.gui.internal.runner.ExtendedScriptParser.ExtendedTestSuite; |
| 71 |
import org.eclipse.tptp.test.auto.gui.internal.runner.ExtendedScriptParser.ExtendedTestSuite; |
71 |
import org.eclipse.tptp.test.auto.gui.internal.runner.ExtendedScriptParser.GeneralPropertyRetriever; |
| 72 |
import org.eclipse.tptp.test.auto.gui.internal.runner.ExtendedScriptParser.GeneralPropertyRetriever; |
72 |
import org.eclipse.tptp.test.auto.gui.internal.runner.VariableSubstitution.Variable; |
| 73 |
import org.eclipse.tptp.test.auto.gui.internal.runner.VariableSubstitution.Variable; |
73 |
import org.eclipse.tptp.test.auto.gui.internal.util.XMLDefaultHandler; |
| 74 |
import org.eclipse.ui.IStartup; |
74 |
import org.eclipse.ui.IStartup; |
| 75 |
import org.eclipse.ui.IWorkbench; |
75 |
import org.eclipse.ui.IWorkbench; |
| 76 |
import org.eclipse.ui.IWorkbenchWindow; |
76 |
import org.eclipse.ui.IWorkbenchWindow; |
| 77 |
import org.eclipse.ui.PlatformUI; |
77 |
import org.eclipse.ui.PlatformUI; |
| 78 |
import org.eclipse.ui.WorkbenchException; |
78 |
import org.eclipse.ui.WorkbenchException; |
| 79 |
import org.w3c.dom.Element; |
79 |
import org.w3c.dom.Element; |
| 80 |
import org.w3c.dom.Node; |
80 |
import org.w3c.dom.Node; |
| 81 |
import org.w3c.dom.NodeList; |
81 |
import org.w3c.dom.NodeList; |
| 82 |
import org.w3c.dom.Text; |
82 |
import org.w3c.dom.Text; |
| 83 |
|
83 |
|
| 84 |
/** |
84 |
/** |
| 85 |
* This is the runner for the automated GUI test suite. It needs to be under this plug-in |
85 |
* This is the runner for the automated GUI test suite. It needs to be under this plug-in |
| 86 |
* as opposed to the tools.core plug-in because of the UI operations that it performs. |
86 |
* as opposed to the tools.core plug-in because of the UI operations that it performs. |
| 87 |
* <p/> |
87 |
* <p/> |
| 88 |
* |
88 |
* |
| 89 |
* |
89 |
* |
| 90 |
* @author Ali Mehregani |
90 |
* @author Ali Mehregani |
| 91 |
* @author Paul E. Slauenwhite |
91 |
* @author Paul E. Slauenwhite |
| 92 |
* @version July 14, 2008 |
92 |
* @version July 14, 2008 |
| 93 |
* @since August 18, 2005 |
93 |
* @since August 18, 2005 |
| 94 |
*/ |
94 |
*/ |
| 95 |
public class AutoGUIRunner extends HyadesJUnitRunner implements IStartup |
95 |
public class AutoGUIRunner extends HyadesJUnitRunner implements IStartup |
| 96 |
{ |
96 |
{ |
| 97 |
/* The modes that the test cases can run in */ |
97 |
/* The modes that the test cases can run in */ |
| 98 |
private final static byte QUICK_RUN_MODE = 0x01; |
98 |
private final static byte QUICK_RUN_MODE = 0x01; |
| 99 |
private final static byte EXECUTION_RUN_MODE = 0x02; |
99 |
private final static byte EXECUTION_RUN_MODE = 0x02; |
| 100 |
|
100 |
|
| 101 |
/* The test script */ |
101 |
/* The test script */ |
| 102 |
private String testScript; |
102 |
private String testScript; |
| 103 |
|
103 |
|
| 104 |
/* Static copy of the script -- lock it before using it*/ |
104 |
/* Static copy of the script -- lock it before using it*/ |
| 105 |
private static byte[] staticTestCase = new byte[0]; |
105 |
private static byte[] staticTestCase = new byte[0]; |
| 106 |
|
106 |
|
| 107 |
/* Set when there is an error in the process of test execution */ |
107 |
/* Set when there is an error in the process of test execution */ |
| 108 |
private boolean errorOccurred; |
108 |
private boolean errorOccurred; |
| 109 |
|
109 |
|
| 110 |
|
110 |
|
| 111 |
/* Holds the mode that we're running in */ |
111 |
/* Holds the mode that we're running in */ |
| 112 |
private byte runningMode; |
112 |
private byte runningMode; |
| 113 |
|
113 |
|
| 114 |
/* The test case index that we're currently at when executing in quick mode */ |
114 |
/* The test case index that we're currently at when executing in quick mode */ |
| 115 |
private int currentTestCaseInx; |
115 |
private int currentTestCaseInx; |
| 116 |
|
116 |
|
| 117 |
/* The last test invocation that was detected is stored here */ |
117 |
/* The last test invocation that was detected is stored here */ |
| 118 |
private ExtendedTestInvocation lastAction; |
118 |
private ExtendedTestInvocation lastAction; |
| 119 |
|
119 |
|
| 120 |
/* Keeps track of the loops */ |
120 |
/* Keeps track of the loops */ |
| 121 |
private Stack loopStack; |
121 |
private Stack loopStack; |
| 122 |
|
122 |
|
| 123 |
/* Stores the number of loops and test invocations detected so far seen */ |
123 |
/* Stores the number of loops and test invocations detected so far seen */ |
| 124 |
private int loopNumbersDetected, invocationNumbersDetected; |
124 |
private int loopNumbersDetected, invocationNumbersDetected; |
| 125 |
|
125 |
|
| 126 |
/* Keeps a stack of the execution events. Elements must be of type ExecutionEvent */ |
126 |
/* Keeps a stack of the execution events. Elements must be of type ExecutionEvent */ |
| 127 |
private Stack executionEventStack; |
127 |
private Stack executionEventStack; |
| 128 |
|
128 |
|
| 129 |
/* A reference to the ITestSuite EMF object - Available only in quick mode */ |
129 |
/* A reference to the ITestSuite EMF object - Available only in quick mode */ |
| 130 |
private ITestSuite testSuiteEMF; |
130 |
private ITestSuite testSuiteEMF; |
| 131 |
|
131 |
|
| 132 |
/* Contains a stack of action iterators that need to be executed */ |
132 |
/* Contains a stack of action iterators that need to be executed */ |
| 133 |
private Stack actionIteratorStack; |
133 |
private Stack actionIteratorStack; |
| 134 |
|
134 |
|
| 135 |
/* Indicates if the action iterator stack is been initialized */ |
135 |
/* Indicates if the action iterator stack is been initialized */ |
| 136 |
private boolean isActionIteratorStackInitialized; |
136 |
private boolean isActionIteratorStackInitialized; |
| 137 |
|
137 |
|
| 138 |
/* The extended test suite */ |
138 |
/* The extended test suite */ |
| 139 |
private ExtendedTestSuite extendedTestSuite; |
139 |
private ExtendedTestSuite extendedTestSuite; |
| 140 |
|
140 |
|
| 141 |
|
141 |
|
| 142 |
/** |
142 |
/** |
| 143 |
* Default constructor. |
143 |
* Default constructor. |
| 144 |
*/ |
144 |
*/ |
| 145 |
public AutoGUIRunner() |
145 |
public AutoGUIRunner() |
| 146 |
{ |
146 |
{ |
| 147 |
super((RemoteComponentSkeleton)null); |
147 |
super((RemoteComponentSkeleton)null); |
| 148 |
init(); |
148 |
init(); |
| 149 |
} |
149 |
} |
| 150 |
|
150 |
|
| 151 |
/** |
151 |
/** |
| 152 |
* This constructor is used to create the appropriate agent. |
152 |
* This constructor is used to create the appropriate agent. |
| 153 |
* |
153 |
* |
| 154 |
* @param args The last statement is assumed to be the resource id. |
154 |
* @param args The last statement is assumed to be the resource id. |
| 155 |
* @param commandListeners The command listeners |
155 |
* @param commandListeners The command listeners |
| 156 |
*/ |
156 |
*/ |
| 157 |
public AutoGUIRunner(String[] args, Vector commandListeners) |
157 |
public AutoGUIRunner(String[] args, Vector commandListeners) |
| 158 |
{ |
158 |
{ |
| 159 |
super (args, commandListeners); |
159 |
super (args, commandListeners); |
| 160 |
init(); |
160 |
init(); |
| 161 |
} |
161 |
} |
| 162 |
|
162 |
|
| 163 |
|
163 |
|
| 164 |
private void init() |
164 |
private void init() |
| 165 |
{ |
165 |
{ |
| 166 |
/* Initialize the event logger here, eventhough nothing will be logged if this constructor is used. |
166 |
/* Initialize the event logger here, eventhough nothing will be logged if this constructor is used. |
| 167 |
* This is done to avoid an NPE when running in quick mode (all events will be ignored because there |
167 |
* This is done to avoid an NPE when running in quick mode (all events will be ignored because there |
| 168 |
* is no agent to send the events to) */ |
168 |
* is no agent to send the events to) */ |
| 169 |
ModelUtil.setEventLogger(new EventLogger () |
169 |
ModelUtil.setEventLogger(new EventLogger () |
| 170 |
{ |
170 |
{ |
| 171 |
public void log(ExecutionEvent executionEvent) |
171 |
public void log(ExecutionEvent executionEvent) |
| 172 |
{ |
172 |
{ |
| 173 |
writeEvent (executionEvent); |
173 |
writeEvent (executionEvent); |
| 174 |
}}); |
174 |
}}); |
| 175 |
|
175 |
|
| 176 |
loopNumbersDetected= 0; |
176 |
loopNumbersDetected= 0; |
| 177 |
executionEventStack = new Stack(); |
177 |
executionEventStack = new Stack(); |
| 178 |
loopStack = new Stack(); |
178 |
loopStack = new Stack(); |
| 179 |
actionIteratorStack = new Stack(); |
179 |
actionIteratorStack = new Stack(); |
| 180 |
isActionIteratorStackInitialized = false; |
180 |
isActionIteratorStackInitialized = false; |
| 181 |
} |
181 |
} |
| 182 |
|
182 |
|
| 183 |
|
183 |
|
| 184 |
/** |
184 |
/** |
| 185 |
* Invoked when the workbench starts |
185 |
* Invoked when the workbench starts |
| 186 |
*/ |
186 |
*/ |
| 187 |
public void earlyStartup() |
187 |
public void earlyStartup() |
| 188 |
{ |
188 |
{ |
| 189 |
String[] args = null; |
189 |
String[] args = null; |
| 190 |
long startTime = 0; |
190 |
long startTime = 0; |
| 191 |
AutoGUIRunner runner = null; |
191 |
AutoGUIRunner runner = null; |
| 192 |
|
192 |
|
| 193 |
try |
193 |
try |
| 194 |
{ |
194 |
{ |
| 195 |
/* These first few steps need to be quick and painless - they will impact the workbench |
195 |
/* These first few steps need to be quick and painless - they will impact the workbench |
| 196 |
* startup time */ |
196 |
* startup time */ |
| 197 |
final String isHeadlessModeOn = "tptp.automated.gui"; |
197 |
final String isHeadlessModeOn = "tptp.automated.gui"; |
| 198 |
if (System.getProperty(isHeadlessModeOn) == null) |
198 |
if (System.getProperty(isHeadlessModeOn) == null) |
| 199 |
return; |
199 |
return; |
| 200 |
|
200 |
|
| 201 |
/* We're in the headless mode. Get the resource id */ |
201 |
/* We're in the headless mode. Get the resource id */ |
| 202 |
final String executorProperty = "tptp.automated.gui.executor"; |
202 |
final String executorProperty = "tptp.automated.gui.executor"; |
| 203 |
final String executor = System.getProperty(executorProperty); |
203 |
final String executor = System.getProperty(executorProperty); |
| 204 |
|
204 |
|
| 205 |
if (executor == null) |
205 |
if (executor == null) |
| 206 |
AutoGUIUtil.showMessage ( |
206 |
AutoGUIUtil.showMessage ( |
| 207 |
AutoGUIMessages.AUTO_GUI_ERROR_PLAYBACK_PROP_T, |
207 |
AutoGUIMessages.AUTO_GUI_ERROR_PLAYBACK_PROP_T, |
| 208 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_PLAYBACK_PROP, executorProperty), |
208 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_PLAYBACK_PROP, executorProperty), |
| 209 |
MessageDialog.ERROR); |
209 |
MessageDialog.ERROR); |
| 210 |
|
210 |
|
| 211 |
/* Instantiate an instance of this class */ |
211 |
/* Instantiate an instance of this class */ |
| 212 |
args = new String[1]; |
212 |
args = new String[1]; |
| 213 |
args[0] = executor; |
213 |
args[0] = executor; |
| 214 |
Vector commandListeners = new Vector(); |
214 |
Vector commandListeners = new Vector(); |
| 215 |
commandListeners.add(new CustomCommandHandler() |
215 |
commandListeners.add(new CustomCommandHandler() |
| 216 |
{ |
216 |
{ |
| 217 |
/* Start listening for the script */ |
217 |
/* Start listening for the script */ |
| 218 |
public void handleCommand(CustomCommand command) |
218 |
public void handleCommand(CustomCommand command) |
| 219 |
{ |
219 |
{ |
| 220 |
if(command.getData().equals(IControlMessage.START)) |
220 |
if(command.getData().equals(IControlMessage.START)) |
| 221 |
{ |
221 |
{ |
| 222 |
/* Don't do anything */ |
222 |
/* Don't do anything */ |
| 223 |
} |
223 |
} |
| 224 |
else |
224 |
else |
| 225 |
{ |
225 |
{ |
| 226 |
synchronized(staticTestCase) |
226 |
synchronized(staticTestCase) |
| 227 |
{ |
227 |
{ |
| 228 |
staticTestCase = command.getDataBinary(); |
228 |
staticTestCase = command.getDataBinary(); |
| 229 |
} |
229 |
} |
| 230 |
} |
230 |
} |
| 231 |
} |
231 |
} |
| 232 |
} |
232 |
} |
| 233 |
); |
233 |
); |
| 234 |
|
234 |
|
| 235 |
runner = new AutoGUIRunner(args, commandListeners); |
235 |
runner = new AutoGUIRunner(args, commandListeners); |
| 236 |
|
236 |
|
| 237 |
/* Wait for the script. The wait is for a maximum of 2 minutes */ |
237 |
/* Wait for the script. The wait is for a maximum of 2 minutes */ |
| 238 |
synchronized (this) |
238 |
synchronized (this) |
| 239 |
{ |
239 |
{ |
| 240 |
try |
240 |
try |
| 241 |
{ |
241 |
{ |
| 242 |
/* Check every second, and wait for a maximum of 2 minutes */ |
242 |
/* Check every second, and wait for a maximum of 2 minutes */ |
| 243 |
synchronized (staticTestCase) |
243 |
synchronized (staticTestCase) |
| 244 |
{ |
244 |
{ |
| 245 |
int counter = 0; |
245 |
int counter = 0; |
| 246 |
while (staticTestCase.length <= 0 && counter < 120) |
246 |
while (staticTestCase.length <= 0 && counter < 120) |
| 247 |
{ |
247 |
{ |
| 248 |
counter++; |
248 |
counter++; |
| 249 |
wait (1000); |
249 |
wait (1000); |
| 250 |
} |
250 |
} |
| 251 |
|
251 |
|
| 252 |
/* Notify the agent that something went wrong, if we still haven't go the script */ |
252 |
/* Notify the agent that something went wrong, if we still haven't go the script */ |
| 253 |
if (staticTestCase.length <= 0) |
253 |
if (staticTestCase.length <= 0) |
| 254 |
{ |
254 |
{ |
| 255 |
/* Try and tell the client we are timing out */ |
255 |
/* Try and tell the client we are timing out */ |
| 256 |
agent.sendMessageToAttachedClient("The test script was not set after two minutes.", 0); |
256 |
agent.sendMessageToAttachedClient("The test script was not set after two minutes.", 0); |
| 257 |
|
257 |
|
| 258 |
/* We have timed out. exit */ |
258 |
/* We have timed out. exit */ |
| 259 |
System.exit(-1); |
259 |
System.exit(-1); |
| 260 |
} |
260 |
} |
| 261 |
else |
261 |
else |
| 262 |
{ |
262 |
{ |
| 263 |
runner.setTestScript(staticTestCase); |
263 |
runner.setTestScript(staticTestCase); |
| 264 |
} |
264 |
} |
| 265 |
} |
265 |
} |
| 266 |
} |
266 |
} |
| 267 |
catch (InterruptedException e) |
267 |
catch (InterruptedException e) |
| 268 |
{ |
268 |
{ |
| 269 |
|
269 |
|
| 270 |
} |
270 |
} |
| 271 |
} |
271 |
} |
| 272 |
|
272 |
|
| 273 |
|
273 |
|
| 274 |
|
274 |
|
| 275 |
|
275 |
|
| 276 |
/* Get the agent */ |
276 |
/* Get the agent */ |
| 277 |
RemoteComponentSkeleton agent = runner.getAgent(null); |
277 |
RemoteComponentSkeleton agent = runner.getAgent(null); |
| 278 |
|
278 |
|
| 279 |
/* Do the initializations */ |
279 |
/* Do the initializations */ |
| 280 |
runner.writeExecEvent("<EXECUTION>"); |
280 |
runner.writeExecEvent("<EXECUTION>"); |
| 281 |
TestSuite testSuiteObj = runner.parseTestScript(); |
281 |
TestSuite testSuiteObj = runner.parseTestScript(); |
| 282 |
|
282 |
|
| 283 |
/* Redirect std out and err */ |
283 |
/* Redirect std out and err */ |
| 284 |
System.setOut(new PrintStream(new AgentConsoleStream(agent, AgentConsoleStream.OUT, ModelUtil.getHierarchyId(testSuiteObj),_peekParentEventID()))); |
284 |
System.setOut(new PrintStream(new AgentConsoleStream(agent, AgentConsoleStream.OUT, ModelUtil.getHierarchyId(testSuiteObj),_peekParentEventID()))); |
| 285 |
System.setErr(new PrintStream(new AgentConsoleStream(agent, AgentConsoleStream.ERR, ModelUtil.getHierarchyId(testSuiteObj),_peekParentEventID()))); |
285 |
System.setErr(new PrintStream(new AgentConsoleStream(agent, AgentConsoleStream.ERR, ModelUtil.getHierarchyId(testSuiteObj),_peekParentEventID()))); |
| 286 |
|
286 |
|
| 287 |
/* Run the tests */ |
287 |
/* Run the tests */ |
| 288 |
startTime = getCurrentTime(); |
288 |
startTime = getCurrentTime(); |
| 289 |
|
289 |
|
| 290 |
runner.runTest (testSuiteObj, EXECUTION_RUN_MODE); |
290 |
runner.runTest (testSuiteObj, EXECUTION_RUN_MODE); |
| 291 |
} |
291 |
} |
| 292 |
catch(Throwable e) |
292 |
catch(Throwable e) |
| 293 |
{ |
293 |
{ |
| 294 |
/* We could not find the class (or something else, report the error) */ |
294 |
/* We could not find the class (or something else, report the error) */ |
| 295 |
try |
295 |
try |
| 296 |
{ |
296 |
{ |
| 297 |
MessageEvent messageEvent = new MessageEvent(); |
297 |
MessageEvent messageEvent = new MessageEvent(); |
| 298 |
messageEvent.setText(BaseString.getStackTrace(e)); |
298 |
messageEvent.setText(BaseString.getStackTrace(e)); |
| 299 |
messageEvent.setSeverity(MessageEvent.ERROR); |
299 |
messageEvent.setSeverity(MessageEvent.ERROR); |
| 300 |
messageEvent.setParentId("ROOT"); |
300 |
messageEvent.setParentId("ROOT"); |
| 301 |
ModelUtil.getEventLogger().log(messageEvent); |
301 |
ModelUtil.getEventLogger().log(messageEvent); |
| 302 |
} |
302 |
} |
| 303 |
catch (Throwable t) |
303 |
catch (Throwable t) |
| 304 |
{ |
304 |
{ |
| 305 |
/* We weren't able to report the error */ |
305 |
/* We weren't able to report the error */ |
| 306 |
} |
306 |
} |
| 307 |
|
307 |
|
| 308 |
} |
308 |
} |
| 309 |
|
309 |
|
| 310 |
/* Exit */ |
310 |
/* Exit */ |
| 311 |
try |
311 |
try |
| 312 |
{ |
312 |
{ |
| 313 |
long endTime = getCurrentTime(); |
313 |
long endTime = getCurrentTime(); |
| 314 |
runnerExit(true, (endTime - startTime)); |
314 |
runnerExit(true, (endTime - startTime)); |
| 315 |
runner.writeExecEvent("</EXECUTION>"); |
315 |
runner.writeExecEvent("</EXECUTION>"); |
| 316 |
} |
316 |
} |
| 317 |
catch (Throwable t) |
317 |
catch (Throwable t) |
| 318 |
{ |
318 |
{ |
| 319 |
/* Doesn't need to be handled */ |
319 |
/* Doesn't need to be handled */ |
| 320 |
} |
320 |
} |
| 321 |
|
321 |
|
| 322 |
/* Always make sure that the headless workbench quits (regardless of errors occurring while running the test runner */ |
322 |
/* Always make sure that the headless workbench quits (regardless of errors occurring while running the test runner */ |
| 323 |
System.exit(0); |
323 |
System.exit(0); |
| 324 |
|
324 |
|
| 325 |
} |
325 |
} |
| 326 |
|
326 |
|
| 327 |
/** |
327 |
/** |
| 328 |
* Runs the test cases of 'testSuite' using the current workbench as |
328 |
* Runs the test cases of 'testSuite' using the current workbench as |
| 329 |
* the context. |
329 |
* the context. |
| 330 |
* |
330 |
* |
| 331 |
* @param testSuite The testSuite to be tested. |
331 |
* @param testSuite The testSuite to be tested. |
| 332 |
*/ |
332 |
*/ |
| 333 |
public void runTestInCurrentContext(ITestSuite testSuiteEMF, final TestSuite testSuite, final ITestRunnerDelegator delegator) |
333 |
public void runTestInCurrentContext(ITestSuite testSuiteEMF, final TestSuite testSuite, final ITestRunnerDelegator delegator) |
| 334 |
{ |
334 |
{ |
| 335 |
new Thread (new Runnable(){ |
335 |
new Thread (new Runnable(){ |
| 336 |
|
336 |
|
| 337 |
public void run() |
337 |
public void run() |
| 338 |
{ |
338 |
{ |
| 339 |
runTest(testSuite, QUICK_RUN_MODE); |
339 |
runTest(testSuite, QUICK_RUN_MODE); |
| 340 |
delegator.finishedTestRun(); |
340 |
delegator.finishedTestRun(); |
| 341 |
} |
341 |
} |
| 342 |
|
342 |
|
| 343 |
}).start(); |
343 |
}).start(); |
| 344 |
|
344 |
|
| 345 |
this.testSuiteEMF = testSuiteEMF; |
345 |
this.testSuiteEMF = testSuiteEMF; |
| 346 |
} |
346 |
} |
| 347 |
|
347 |
|
| 348 |
|
348 |
|
| 349 |
/** |
349 |
/** |
| 350 |
* Runs the actual test script in the mode that it is given. |
350 |
* Runs the actual test script in the mode that it is given. |
| 351 |
* |
351 |
* |
| 352 |
* @param testSuite The test script |
352 |
* @param testSuite The test script |
| 353 |
* @param mode Can be QUICK_RUN_MODE (used when a quick run mode button of the test case form is |
353 |
* @param mode Can be QUICK_RUN_MODE (used when a quick run mode button of the test case form is |
| 354 |
* pressed) or EXECUTION_RUN_MODE (used when a proper launch configuration is used) |
354 |
* pressed) or EXECUTION_RUN_MODE (used when a proper launch configuration is used) |
| 355 |
*/ |
355 |
*/ |
| 356 |
private void runTest(TestSuite testSuite, final byte mode) |
356 |
private void runTest(TestSuite testSuite, final byte mode) |
| 357 |
{ |
357 |
{ |
| 358 |
runningMode = mode; |
358 |
runningMode = mode; |
| 359 |
currentTestCaseInx = 0; |
359 |
currentTestCaseInx = 0; |
| 360 |
|
360 |
|
| 361 |
if (!(testSuite instanceof ExtendedTestSuite)) |
361 |
if (!(testSuite instanceof ExtendedTestSuite)) |
| 362 |
return; |
362 |
return; |
| 363 |
|
363 |
|
| 364 |
extendedTestSuite = (ExtendedTestSuite)testSuite; |
364 |
extendedTestSuite = (ExtendedTestSuite)testSuite; |
| 365 |
/* Before running the test cases, set the dependencies of the test suite (if any exist) */ |
365 |
/* Before running the test cases, set the dependencies of the test suite (if any exist) */ |
| 366 |
if (extendedTestSuite.getDependencies() != null && extendedTestSuite.getDependencies().size() > 0) |
366 |
if (extendedTestSuite.getDependencies() != null && extendedTestSuite.getDependencies().size() > 0) |
| 367 |
MacroManager.getInstance().setDependecies(extendedTestSuite.getDependencies()); |
367 |
MacroManager.getInstance().setDependecies(extendedTestSuite.getDependencies()); |
| 368 |
|
368 |
|
| 369 |
/* Register this runner */ |
369 |
/* Register this runner */ |
| 370 |
MacroManager.getInstance().setRunner(this); |
370 |
MacroManager.getInstance().setRunner(this); |
| 371 |
|
371 |
|
| 372 |
if (mode == EXECUTION_RUN_MODE) |
372 |
if (mode == EXECUTION_RUN_MODE) |
| 373 |
/* Log the start of the test suite */ |
373 |
/* Log the start of the test suite */ |
| 374 |
sendTypeEvent(TypedEvent.START, null); |
374 |
sendTypeEvent(TypedEvent.START, null); |
| 375 |
|
375 |
|
| 376 |
|
376 |
|
| 377 |
/* Do all initializations required before the test run begins */ |
377 |
/* Do all initializations required before the test run begins */ |
| 378 |
Exception initializeState = null; |
378 |
Exception initializeState = null; |
| 379 |
try |
379 |
try |
| 380 |
{ |
380 |
{ |
| 381 |
initializeTestRun(mode); |
381 |
initializeTestRun(mode); |
| 382 |
} |
382 |
} |
| 383 |
catch (CoreException e) |
383 |
catch (CoreException e) |
| 384 |
{ |
384 |
{ |
| 385 |
initializeState = e; |
385 |
initializeState = e; |
| 386 |
|
386 |
|
| 387 |
} |
387 |
} |
| 388 |
|
388 |
|
| 389 |
/* Holds the next executable action that is to be executed */ |
389 |
/* Holds the next executable action that is to be executed */ |
| 390 |
Object nextExecution = null; |
390 |
Object nextExecution = null; |
| 391 |
/* Holds the test suite if we are executing a test suite reference, added for bugzilla_136186*/ |
391 |
/* Holds the test suite if we are executing a test suite reference, added for bugzilla_136186*/ |
| 392 |
TestSuite nestedSuite = new TestSuite(); |
392 |
TestSuite nestedSuite = new TestSuite(); |
| 393 |
/* To keep track of when we are in a reference to a test suite*/ |
393 |
/* To keep track of when we are in a reference to a test suite*/ |
| 394 |
boolean inTestSuite =false; |
394 |
boolean inTestSuite =false; |
| 395 |
/* To keep track of whether we are in a Loop inside of a test suite reference*/ |
395 |
/* To keep track of whether we are in a Loop inside of a test suite reference*/ |
| 396 |
boolean loopStarted = false; |
396 |
boolean loopStarted = false; |
| 397 |
/* The index of test cases in a references Loop or test suite*/ |
397 |
/* The index of test cases in a references Loop or test suite*/ |
| 398 |
int index=0; |
398 |
int index=0; |
| 399 |
|
399 |
|
| 400 |
/* Walk through every element that needs to be executed in our test suite */ |
400 |
/* Walk through every element that needs to be executed in our test suite */ |
| 401 |
if (initializeState == null) |
401 |
if (initializeState == null) |
| 402 |
{ |
402 |
{ |
| 403 |
|
403 |
|
| 404 |
while (((inTestSuite)|| (nextExecution =nextExecution(mode, testSuite))!=null)) |
404 |
while (((inTestSuite)|| (nextExecution =nextExecution(mode, testSuite))!=null)) |
| 405 |
{ |
405 |
{ |
| 406 |
// Added for bugzilla_136186 to add the ability to step through test |
406 |
// Added for bugzilla_136186 to add the ability to step through test |
| 407 |
//cases in a referenced test suite |
407 |
//cases in a referenced test suite |
| 408 |
// Liz D. |
408 |
// Liz D. |
| 409 |
if (inTestSuite) |
409 |
if (inTestSuite) |
| 410 |
{ |
410 |
{ |
| 411 |
nextExecution = nestedSuite.getActions().get(index); |
411 |
nextExecution = nestedSuite.getActions().get(index); |
| 412 |
|
412 |
|
| 413 |
if (nextExecution instanceof org.eclipse.hyades.test.common.runner.model.Loop) |
413 |
if (nextExecution instanceof org.eclipse.hyades.test.common.runner.model.Loop) |
| 414 |
{ |
414 |
{ |
| 415 |
if (loopStarted) |
415 |
if (loopStarted) |
| 416 |
{ |
416 |
{ |
| 417 |
nextExecution = ((Loop)nextExecution).getActions().get(index); |
417 |
nextExecution = ((Loop)nextExecution).getActions().get(index); |
| 418 |
loopStarted=false; |
418 |
loopStarted=false; |
| 419 |
} |
419 |
} |
| 420 |
else |
420 |
else |
| 421 |
loopStarted=true; |
421 |
loopStarted=true; |
| 422 |
} |
422 |
} |
| 423 |
|
423 |
|
| 424 |
} |
424 |
} |
| 425 |
|
425 |
|
| 426 |
try |
426 |
try |
| 427 |
{ |
427 |
{ |
| 428 |
errorOccurred = false; |
428 |
errorOccurred = false; |
| 429 |
Object testCaseObject = null; |
429 |
Object testCaseObject = null; |
| 430 |
lastAction = null; |
430 |
lastAction = null; |
| 431 |
|
431 |
|
| 432 |
/* Flush out the system output and error stream if in case the previous test case stored anything in the buffer */ |
432 |
/* Flush out the system output and error stream if in case the previous test case stored anything in the buffer */ |
| 433 |
System.out.flush(); |
433 |
System.out.flush(); |
| 434 |
System.err.flush(); |
434 |
System.err.flush(); |
| 435 |
|
435 |
|
| 436 |
/* Set the test case object of the item that is being executed next */ |
436 |
/* Set the test case object of the item that is being executed next */ |
| 437 |
if (mode == QUICK_RUN_MODE) |
437 |
if (mode == QUICK_RUN_MODE) |
| 438 |
testCaseObject = nextExecution; |
438 |
testCaseObject = nextExecution; |
| 439 |
else if (mode == EXECUTION_RUN_MODE) |
439 |
else if (mode == EXECUTION_RUN_MODE) |
| 440 |
{ |
440 |
{ |
| 441 |
/* End the last loop if the owner is either the root or from the parent of the last loop */ |
441 |
/* End the last loop if the owner is either the root or from the parent of the last loop */ |
| 442 |
Loop lastLoop = getLastLoop(); |
442 |
Loop lastLoop = getLastLoop(); |
| 443 |
if (lastLoop != null) |
443 |
if (lastLoop != null) |
| 444 |
{ |
444 |
{ |
| 445 |
IActionOwner parentOfLastLoop = lastLoop.getOwner(); |
445 |
IActionOwner parentOfLastLoop = lastLoop.getOwner(); |
| 446 |
String parentOfLastLoopId = getActionId(parentOfLastLoop); |
446 |
String parentOfLastLoopId = getActionId(parentOfLastLoop); |
| 447 |
String nextExecutionId = getActionId(nextExecution); |
447 |
String nextExecutionId = getActionId(nextExecution); |
| 448 |
|
448 |
|
| 449 |
/* Iterating through the same loop */ |
449 |
/* Iterating through the same loop */ |
| 450 |
if (lastLoop.getId().equals(nextExecutionId)) |
450 |
if (lastLoop.getId().equals(nextExecutionId)) |
| 451 |
{ |
451 |
{ |
| 452 |
continue; |
452 |
continue; |
| 453 |
} |
453 |
} |
| 454 |
|
454 |
|
| 455 |
/* End of the last loop */ |
455 |
/* End of the last loop */ |
| 456 |
else if (nextExecutionId.equals(parentOfLastLoopId)) |
456 |
else if (nextExecutionId.equals(parentOfLastLoopId)) |
| 457 |
{ |
457 |
{ |
| 458 |
sendLoopStop(); |
458 |
sendLoopStop(); |
| 459 |
continue; |
459 |
continue; |
| 460 |
} |
460 |
} |
| 461 |
|
461 |
|
| 462 |
else if (((Action)nextExecution).getOwner() instanceof TestSuite && !inTestSuite) |
462 |
else if (((Action)nextExecution).getOwner() instanceof TestSuite && !inTestSuite) |
| 463 |
{ |
463 |
{ |
| 464 |
sendAllLoopStop (); |
464 |
sendAllLoopStop (); |
| 465 |
|
465 |
|
| 466 |
} |
466 |
} |
| 467 |
} |
467 |
} |
| 468 |
|
468 |
|
| 469 |
/* If the action happens to be a loop, then simply send the loop start event */ |
469 |
/* If the action happens to be a loop, then simply send the loop start event */ |
| 470 |
if (nextExecution instanceof Loop) |
470 |
if (nextExecution instanceof Loop) |
| 471 |
{ |
471 |
{ |
| 472 |
sendLoopStart ((Loop)nextExecution); |
472 |
sendLoopStart ((Loop)nextExecution); |
| 473 |
continue; |
473 |
continue; |
| 474 |
|
474 |
|
| 475 |
} |
475 |
} |
| 476 |
|
476 |
|
| 477 |
/* If the action is a test invocation, then send the test invocation */ |
477 |
/* If the action is a test invocation, then send the test invocation */ |
| 478 |
if (nextExecution instanceof ExtendedTestInvocation ) |
478 |
if (nextExecution instanceof ExtendedTestInvocation ) |
| 479 |
{ |
479 |
{ |
| 480 |
lastAction = (ExtendedTestInvocation)nextExecution; |
480 |
lastAction = (ExtendedTestInvocation)nextExecution; |
| 481 |
testCaseObject = lastAction.getTest(); |
481 |
testCaseObject = lastAction.getTest(); |
| 482 |
sendTestInvocation(lastAction, InvocationEvent.STATUS_SUCCESSFUL, lastAction.getName()); |
482 |
sendTestInvocation(lastAction, InvocationEvent.STATUS_SUCCESSFUL, lastAction.getName()); |
| 483 |
|
483 |
|
| 484 |
if (testCaseObject instanceof TestSuite) |
484 |
if (testCaseObject instanceof TestSuite) |
| 485 |
{ |
485 |
{ |
| 486 |
nestedSuite = ((TestSuite)testCaseObject); |
486 |
nestedSuite = ((TestSuite)testCaseObject); |
| 487 |
inTestSuite=true; |
487 |
inTestSuite=true; |
| 488 |
index =0; |
488 |
index =0; |
| 489 |
continue; |
489 |
continue; |
| 490 |
} |
490 |
} |
| 491 |
} |
491 |
} |
| 492 |
|
492 |
|
| 493 |
/* Otherwise continue with the main loop */ |
493 |
/* Otherwise continue with the main loop */ |
| 494 |
else |
494 |
else |
| 495 |
{ |
495 |
{ |
| 496 |
continue; |
496 |
continue; |
| 497 |
} |
497 |
} |
| 498 |
} |
498 |
} |
| 499 |
if (!((testCaseObject instanceof ExtendedTestCase))) |
499 |
if (!((testCaseObject instanceof ExtendedTestCase))) |
| 500 |
continue; |
500 |
continue; |
| 501 |
|
501 |
|
| 502 |
/* Switch to the perspective representing our starting point */ |
502 |
/* Switch to the perspective representing our starting point */ |
| 503 |
final ExtendedTestCase testCase = (ExtendedTestCase)testCaseObject; |
503 |
final ExtendedTestCase testCase = (ExtendedTestCase)testCaseObject; |
| 504 |
|
504 |
|
| 505 |
final String startingPoint = testCase.getProperty(String.valueOf(GUITestCaseProperties.STARTING_PT)); |
505 |
final String startingPoint = testCase.getProperty(String.valueOf(GUITestCaseProperties.STARTING_PT)); |
| 506 |
|
506 |
|
| 507 |
|
507 |
|
| 508 |
/* This is a required field. In case it is not set, then mark the test case with |
508 |
/* This is a required field. In case it is not set, then mark the test case with |
| 509 |
* a verdict of error */ |
509 |
* a verdict of error */ |
| 510 |
if (startingPoint == null || startingPoint.length() <= 0) |
510 |
if (startingPoint == null || startingPoint.length() <= 0) |
| 511 |
{ |
511 |
{ |
| 512 |
/* Show an error if we're running in quick run mode */ |
512 |
/* Show an error if we're running in quick run mode */ |
| 513 |
if (mode == QUICK_RUN_MODE) |
513 |
if (mode == QUICK_RUN_MODE) |
| 514 |
{ |
514 |
{ |
| 515 |
AutoGUIUtil.showMessage( |
515 |
AutoGUIUtil.showMessage( |
| 516 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_MISS_SP_T, |
516 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_MISS_SP_T, |
| 517 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_MISS_SP, |
517 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_MISS_SP, |
| 518 |
MessageDialog.ERROR); |
518 |
MessageDialog.ERROR); |
| 519 |
} |
519 |
} |
| 520 |
else if (mode == EXECUTION_RUN_MODE) |
520 |
else if (mode == EXECUTION_RUN_MODE) |
| 521 |
{ |
521 |
{ |
| 522 |
sendVerdict(lastAction, VerdictEvent.VERDICT_ERROR, |
522 |
sendVerdict(lastAction, VerdictEvent.VERDICT_ERROR, |
| 523 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_MISS_SP_T); |
523 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_MISS_SP_T); |
| 524 |
} |
524 |
} |
| 525 |
|
525 |
|
| 526 |
continue; |
526 |
continue; |
| 527 |
} |
527 |
} |
| 528 |
|
528 |
|
| 529 |
final IWorkbench workbench = PlatformUI.getWorkbench(); |
529 |
final IWorkbench workbench = PlatformUI.getWorkbench(); |
| 530 |
final TestInvocation constantTestInvocation = lastAction; |
530 |
final TestInvocation constantTestInvocation = lastAction; |
| 531 |
workbench.getDisplay().syncExec(new Runnable() { |
531 |
workbench.getDisplay().syncExec(new Runnable() { |
| 532 |
public void run() |
532 |
public void run() |
| 533 |
{ |
533 |
{ |
| 534 |
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); |
534 |
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); |
| 535 |
if (window != null) |
535 |
if (window != null) |
| 536 |
{ |
536 |
{ |
| 537 |
try |
537 |
try |
| 538 |
{ |
538 |
{ |
| 539 |
/* If we are running in execution mode then we may need to close the welcome page and maximize the workbench*/ |
539 |
/* If we are running in execution mode then we may need to close the welcome page and maximize the workbench*/ |
| 540 |
if (mode == EXECUTION_RUN_MODE) |
540 |
if (mode == EXECUTION_RUN_MODE) |
| 541 |
{ |
541 |
{ |
| 542 |
MacroUtil.closeWelcomePage(); |
542 |
MacroUtil.closeWelcomePage(); |
| 543 |
MacroUtil.maximizeWorkbench(); |
543 |
MacroUtil.maximizeWorkbench(); |
| 544 |
} |
544 |
} |
| 545 |
|
545 |
|
| 546 |
|
546 |
|
| 547 |
workbench.showPerspective(startingPoint, window); |
547 |
workbench.showPerspective(startingPoint, window); |
| 548 |
} |
548 |
} |
| 549 |
|
549 |
|
| 550 |
catch (WorkbenchException e) |
550 |
catch (WorkbenchException e) |
| 551 |
{ |
551 |
{ |
| 552 |
errorOccurred = true; |
552 |
errorOccurred = true; |
| 553 |
/* If we are running in quick mode, then display the correct error message */ |
553 |
/* If we are running in quick mode, then display the correct error message */ |
| 554 |
if (mode == QUICK_RUN_MODE) |
554 |
if (mode == QUICK_RUN_MODE) |
| 555 |
{ |
555 |
{ |
| 556 |
AutoGUIUtil.showMessage( |
556 |
AutoGUIUtil.showMessage( |
| 557 |
AutoGUIMessages.AUTO_GUI_ERROR_PERS_SWITCH_TITLE, |
557 |
AutoGUIMessages.AUTO_GUI_ERROR_PERS_SWITCH_TITLE, |
| 558 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_PERS_SWITCH, new String[] {startingPoint, e.getLocalizedMessage()}), |
558 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_PERS_SWITCH, new String[] {startingPoint, e.getLocalizedMessage()}), |
| 559 |
MessageDialog.ERROR); |
559 |
MessageDialog.ERROR); |
| 560 |
} |
560 |
} |
| 561 |
else if (mode == EXECUTION_RUN_MODE) |
561 |
else if (mode == EXECUTION_RUN_MODE) |
| 562 |
{ |
562 |
{ |
| 563 |
sendVerdict(constantTestInvocation, VerdictEvent.VERDICT_ERROR, |
563 |
sendVerdict(constantTestInvocation, VerdictEvent.VERDICT_ERROR, |
| 564 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_PERS_SWITCH, new String[] {startingPoint, e.getLocalizedMessage()})); |
564 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_PERS_SWITCH, new String[] {startingPoint, e.getLocalizedMessage()})); |
| 565 |
} |
565 |
} |
| 566 |
} |
566 |
} |
| 567 |
} |
567 |
} |
| 568 |
} |
568 |
} |
| 569 |
}); |
569 |
}); |
| 570 |
|
570 |
|
| 571 |
if (errorOccurred) |
571 |
if (errorOccurred) |
| 572 |
continue; |
572 |
continue; |
| 573 |
|
573 |
|
| 574 |
|
574 |
|
| 575 |
/* Time to run the macro */ |
575 |
/* Time to run the macro */ |
| 576 |
final String macro = testCase.getProperty(String.valueOf(GUITestCaseProperties.MACRO_FRAGMENT)); |
576 |
final String macro = testCase.getProperty(String.valueOf(GUITestCaseProperties.MACRO_FRAGMENT)); |
| 577 |
|
577 |
|
| 578 |
class MacroPlayWrapper implements Runnable |
578 |
class MacroPlayWrapper implements Runnable |
| 579 |
{ |
579 |
{ |
| 580 |
private Object objectToNotify; |
580 |
private Object objectToNotify; |
| 581 |
private boolean isDone; |
581 |
private boolean isDone; |
| 582 |
|
582 |
|
| 583 |
public MacroPlayWrapper (Object objectToNotify) |
583 |
public MacroPlayWrapper (Object objectToNotify) |
| 584 |
{ |
584 |
{ |
| 585 |
this.objectToNotify = objectToNotify; |
585 |
this.objectToNotify = objectToNotify; |
| 586 |
isDone = false; |
586 |
isDone = false; |
| 587 |
} |
587 |
} |
| 588 |
|
588 |
|
| 589 |
|
589 |
|
| 590 |
public void run() |
590 |
public void run() |
| 591 |
{ |
591 |
{ |
| 592 |
try |
592 |
try |
| 593 |
{ |
593 |
{ |
| 594 |
/* Not interested if there is no macro */ |
594 |
/* Not interested if there is no macro */ |
| 595 |
if (macro == null || macro.length() <= 0) |
595 |
if (macro == null || macro.length() <= 0) |
| 596 |
return; |
596 |
return; |
| 597 |
|
597 |
|
| 598 |
XMLDefaultHandler handler = MacroManager.getInstance().createMacroDocument(new ByteArrayInputStream(macro.getBytes("UTF-8"))); |
598 |
XMLDefaultHandler handler = MacroManager.getInstance().createMacroDocument(new ByteArrayInputStream(macro.getBytes("UTF-8"))); |
| 599 |
int timeout = GlobalConstants.DEFAULT_COMMAND_TIME_OUT_PERIOD; |
599 |
int timeout = GlobalConstants.DEFAULT_COMMAND_TIME_OUT_PERIOD; |
| 600 |
if (mode == EXECUTION_RUN_MODE) |
600 |
if (mode == EXECUTION_RUN_MODE) |
| 601 |
{ |
601 |
{ |
| 602 |
linkUserInput(handler); |
602 |
linkUserInput(handler); |
| 603 |
String timeoutStr = lastAction.getProperty(GlobalConstants.COMMAND_TIMEOUT_THRESHOLD); |
603 |
String timeoutStr = lastAction.getProperty(GlobalConstants.COMMAND_TIMEOUT_THRESHOLD); |
| 604 |
if (timeoutStr != null) |
604 |
if (timeoutStr != null) |
| 605 |
{ |
605 |
{ |
| 606 |
try |
606 |
try |
| 607 |
{ |
607 |
{ |
| 608 |
timeout = Integer.parseInt(timeoutStr); |
608 |
timeout = Integer.parseInt(timeoutStr); |
| 609 |
} |
609 |
} |
| 610 |
catch (Exception e) |
610 |
catch (Exception e) |
| 611 |
{ |
611 |
{ |
| 612 |
/* Doesn't need to be handled -- timeout is already set to default */ |
612 |
/* Doesn't need to be handled -- timeout is already set to default */ |
| 613 |
} |
613 |
} |
| 614 |
} |
614 |
} |
| 615 |
} |
615 |
} |
| 616 |
/* We may need to do variable substitution if we're running in quick mode */ |
616 |
/* We may need to do variable substitution if we're running in quick mode */ |
| 617 |
else if (mode == QUICK_RUN_MODE) |
617 |
else if (mode == QUICK_RUN_MODE) |
| 618 |
{ |
618 |
{ |
| 619 |
doVariableSubstitution(handler); |
619 |
doVariableSubstitution(handler); |
| 620 |
} |
620 |
} |
| 621 |
|
621 |
|
| 622 |
MacroManager mng = MacroManager.getInstance(); |
622 |
MacroManager mng = MacroManager.getInstance(); |
| 623 |
mng.setCommandTimeoutThreshold(timeout); |
623 |
mng.setCommandTimeoutThreshold(timeout); |
| 624 |
mng.play(GuiPlugin.getDefault().getWorkbench().getDisplay(), null, testCase.getName(), handler, Boolean.TRUE); |
624 |
mng.play(GuiPlugin.getDefault().getWorkbench().getDisplay(), null, testCase.getName(), handler, Boolean.TRUE); |
| 625 |
handler = null; |
625 |
handler = null; |
| 626 |
|
626 |
|
| 627 |
if (objectToNotify != null) |
627 |
if (objectToNotify != null) |
| 628 |
{ |
628 |
{ |
| 629 |
synchronized (objectToNotify) |
629 |
synchronized (objectToNotify) |
| 630 |
{ |
630 |
{ |
| 631 |
objectToNotify.notify(); |
631 |
objectToNotify.notify(); |
| 632 |
} |
632 |
} |
| 633 |
} |
633 |
} |
| 634 |
|
634 |
|
| 635 |
isDone = true; |
635 |
isDone = true; |
| 636 |
} |
636 |
} |
| 637 |
catch (Throwable t) |
637 |
catch (Throwable t) |
| 638 |
{ |
638 |
{ |
| 639 |
/* If we are running in quick mode, then display the correct error message */ |
639 |
/* If we are running in quick mode, then display the correct error message */ |
| 640 |
if (mode == QUICK_RUN_MODE) |
640 |
if (mode == QUICK_RUN_MODE) |
| 641 |
{ |
641 |
{ |
| 642 |
AutoGUIUtil.openErrorWithDetail(AutoGUIMessages.AUTO_GUI_ERROR_MACRO_RUNNING_T, |
642 |
AutoGUIUtil.openErrorWithDetail(AutoGUIMessages.AUTO_GUI_ERROR_MACRO_RUNNING_T, |
| 643 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_MACRO_RUNNING, testCase.getName()), t); |
643 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_MACRO_RUNNING, testCase.getName()), t); |
| 644 |
|
644 |
|
| 645 |
} |
645 |
} |
| 646 |
else if (mode == EXECUTION_RUN_MODE) |
646 |
else if (mode == EXECUTION_RUN_MODE) |
| 647 |
{ |
647 |
{ |
| 648 |
sendVerdict(constantTestInvocation, VerdictEvent.VERDICT_FAIL, |
648 |
sendVerdict(constantTestInvocation, VerdictEvent.VERDICT_FAIL, |
| 649 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_MACRO_RUNNING, testCase.getName()) + ". " + AutoGUIUtil.getExceptionStackTrace(t)); |
649 |
NLS.bind(AutoGUIMessages.AUTO_GUI_ERROR_MACRO_RUNNING, testCase.getName()) + ". " + AutoGUIUtil.getExceptionStackTrace(t)); |
| 650 |
} |
650 |
} |
| 651 |
|
651 |
|
| 652 |
|
652 |
|
| 653 |
/* Give a chance for unfinished threads to exit */ |
653 |
/* Give a chance for unfinished threads to exit */ |
| 654 |
int outstandingShellCommandCount = MacroManager.getInstance().getOutstandShellCommands(); |
654 |
int outstandingShellCommandCount = MacroManager.getInstance().getOutstandShellCommands(); |
| 655 |
final int INCREMENT = 3000; |
655 |
final int INCREMENT = 3000; |
| 656 |
final int MAX_COUNT = 3; |
656 |
final int MAX_COUNT = 3; |
| 657 |
int count = 0; |
657 |
int count = 0; |
| 658 |
while (outstandingShellCommandCount > 0 && count < MAX_COUNT) |
658 |
while (outstandingShellCommandCount > 0 && count < MAX_COUNT) |
| 659 |
{ |
659 |
{ |
| 660 |
MacroUtil.closeSecondaryShells(GuiPlugin.getDefault().getWorkbench().getDisplay()); |
660 |
MacroUtil.closeSecondaryShells(GuiPlugin.getDefault().getWorkbench().getDisplay()); |
| 661 |
Thread.yield(); |
661 |
Thread.yield(); |
| 662 |
synchronized(this) |
662 |
synchronized(this) |
| 663 |
{ |
663 |
{ |
| 664 |
try |
664 |
try |
| 665 |
{ |
665 |
{ |
| 666 |
wait(INCREMENT); |
666 |
wait(INCREMENT); |
| 667 |
} |
667 |
} |
| 668 |
catch (Exception e) |
668 |
catch (Exception e) |
| 669 |
{ |
669 |
{ |
| 670 |
|
670 |
|
| 671 |
} |
671 |
} |
| 672 |
} |
672 |
} |
| 673 |
|
673 |
|
| 674 |
count++; |
674 |
count++; |
| 675 |
outstandingShellCommandCount = MacroManager.getInstance().getOutstandShellCommands(); |
675 |
outstandingShellCommandCount = MacroManager.getInstance().getOutstandShellCommands(); |
| 676 |
} |
676 |
} |
| 677 |
|
677 |
|
| 678 |
errorOccurred = true; |
678 |
errorOccurred = true; |
| 679 |
isDone = true; |
679 |
isDone = true; |
| 680 |
|
680 |
|
| 681 |
}// end whlie |
681 |
}// end whlie |
| 682 |
} |
682 |
} |
| 683 |
|
683 |
|
| 684 |
public boolean isDone() |
684 |
public boolean isDone() |
| 685 |
{ |
685 |
{ |
| 686 |
return isDone; |
686 |
return isDone; |
| 687 |
} |
687 |
} |
| 688 |
|
688 |
|
| 689 |
/** |
689 |
/** |
| 690 |
* Used to link the user input to datapools, custom inputs, etc... |
690 |
* Used to link the user input to datapools, custom inputs, etc... |
| 691 |
*/ |
691 |
*/ |
| 692 |
private void linkUserInput(XMLDefaultHandler handler) |
692 |
private void linkUserInput(XMLDefaultHandler handler) |
| 693 |
{ |
693 |
{ |
| 694 |
Map modifiableFields = new Hashtable(); |
694 |
Map modifiableFields = new Hashtable(); |
| 695 |
getModifiableFields(handler, modifiableFields, new ArrayList()); |
695 |
getModifiableFields(handler, modifiableFields, new ArrayList()); |
| 696 |
int modifyCounter = 0, waitCounter = 0; |
696 |
int modifyCounter = 0, waitCounter = 0; |
| 697 |
|
697 |
|
| 698 |
/* For every linkable command */ |
698 |
/* For every linkable command */ |
| 699 |
for (Iterator linkableCommands = modifiableFields.keySet().iterator(); linkableCommands.hasNext();) |
699 |
for (Iterator linkableCommands = modifiableFields.keySet().iterator(); linkableCommands.hasNext();) |
| 700 |
{ |
700 |
{ |
| 701 |
String currentCommandType = (String)linkableCommands.next(); |
701 |
String currentCommandType = (String)linkableCommands.next(); |
| 702 |
List commandList = (List)modifiableFields.get(currentCommandType); |
702 |
List commandList = (List)modifiableFields.get(currentCommandType); |
| 703 |
if (commandList == null) |
703 |
if (commandList == null) |
| 704 |
continue; |
704 |
continue; |
| 705 |
|
705 |
|
| 706 |
for (int i = 0, commandCount = commandList.size(); i < commandCount; i++) |
706 |
for (int i = 0, commandCount = commandList.size(); i < commandCount; i++) |
| 707 |
{ |
707 |
{ |
| 708 |
Element currentCommand = (Element)commandList.get(i); |
708 |
Element currentCommand = (Element)commandList.get(i); |
| 709 |
if (currentCommand == null) |
709 |
if (currentCommand == null) |
| 710 |
continue; |
710 |
continue; |
| 711 |
|
711 |
|
| 712 |
String propertySuffix = ""; |
712 |
String propertySuffix = ""; |
| 713 |
if (ModifyCommand.TYPE.equals(currentCommandType)) |
713 |
if (ModifyCommand.TYPE.equals(currentCommandType)) |
| 714 |
{ |
714 |
{ |
| 715 |
modifyCounter++; |
715 |
modifyCounter++; |
| 716 |
propertySuffix += modifyCounter; |
716 |
propertySuffix += modifyCounter; |
| 717 |
} |
717 |
} |
| 718 |
else if (WaitCommand.TYPE.equals(currentCommandType)) |
718 |
else if (WaitCommand.TYPE.equals(currentCommandType)) |
| 719 |
{ |
719 |
{ |
| 720 |
waitCounter++; |
720 |
waitCounter++; |
| 721 |
propertySuffix = currentCommandType + waitCounter; |
721 |
propertySuffix = currentCommandType + waitCounter; |
| 722 |
} |
722 |
} |
| 723 |
|
723 |
|
| 724 |
/* First attempt datapool link */ |
724 |
/* First attempt datapool link */ |
| 725 |
String property = lastAction.getProperty(GlobalConstants.DATAPOOL_LINK_PROPERTY_BASE + propertySuffix); |
725 |
String property = lastAction.getProperty(GlobalConstants.DATAPOOL_LINK_PROPERTY_BASE + propertySuffix); |
| 726 |
|
726 |
|
| 727 |
/* No datapool link present, give user input a try */ |
727 |
/* No datapool link present, give user input a try */ |
| 728 |
if (property == null) |
728 |
if (property == null) |
| 729 |
property = lastAction.getProperty(GlobalConstants.CUSTOM_INPUT_LINK_PROPERTY_BASE + propertySuffix); |
729 |
property = lastAction.getProperty(GlobalConstants.CUSTOM_INPUT_LINK_PROPERTY_BASE + propertySuffix); |
| 730 |
|
730 |
|
| 731 |
if (property != null) |
731 |
if (property != null) |
| 732 |
{ |
732 |
{ |
| 733 |
String subsProperty = VariableSubstitution.getInstance().doSubstitutions(property); |
733 |
String subsProperty = VariableSubstitution.getInstance().doSubstitutions(property); |
| 734 |
linkUserInput ((Element)currentCommand, subsProperty); |
734 |
linkUserInput ((Element)currentCommand, subsProperty); |
| 735 |
} |
735 |
} |
| 736 |
/* Otherwise we may need to do variable substitution */ |
736 |
/* Otherwise we may need to do variable substitution */ |
| 737 |
else |
737 |
else |
| 738 |
{ |
738 |
{ |
| 739 |
doVarSubstitutionForModifiedField (((Element)currentCommand).getChildNodes()); |
739 |
doVarSubstitutionForModifiedField (((Element)currentCommand).getChildNodes()); |
| 740 |
} |
740 |
} |
| 741 |
} |
741 |
} |
| 742 |
} |
742 |
} |
| 743 |
} |
743 |
} |
| 744 |
|
744 |
|
| 745 |
private void doVariableSubstitution (XMLDefaultHandler handler) |
745 |
private void doVariableSubstitution (XMLDefaultHandler handler) |
| 746 |
{ |
746 |
{ |
| 747 |
List modifiableFields = new ArrayList(5); |
747 |
List modifiableFields = new ArrayList(5); |
| 748 |
getModifiableFields(handler, new Hashtable(), modifiableFields); |
748 |
getModifiableFields(handler, new Hashtable(), modifiableFields); |
| 749 |
|
749 |
|
| 750 |
/* Replace values accordingly */ |
750 |
/* Replace values accordingly */ |
| 751 |
for (int i = 0, modifiableSize = modifiableFields.size(); i < modifiableSize; i++) |
751 |
for (int i = 0, modifiableSize = modifiableFields.size(); i < modifiableSize; i++) |
| 752 |
{ |
752 |
{ |
| 753 |
doVarSubstitutionForModifiedField (((Element)modifiableFields.get(i)).getChildNodes()); |
753 |
doVarSubstitutionForModifiedField (((Element)modifiableFields.get(i)).getChildNodes()); |
| 754 |
} |
754 |
} |
| 755 |
|
755 |
|
| 756 |
} |
756 |
} |
| 757 |
|
757 |
|
| 758 |
|
758 |
|
| 759 |
private void doVarSubstitutionForModifiedField (NodeList modifyChildren) |
759 |
private void doVarSubstitutionForModifiedField (NodeList modifyChildren) |
| 760 |
{ |
760 |
{ |
| 761 |
for (int j = 0, modifyChildCount = modifyChildren.getLength(); j < modifyChildCount; j++) |
761 |
for (int j = 0, modifyChildCount = modifyChildren.getLength(); j < modifyChildCount; j++) |
| 762 |
{ |
762 |
{ |
| 763 |
if (modifyChildren.item(j).getNodeType() == Node.TEXT_NODE) |
763 |
if (modifyChildren.item(j).getNodeType() == Node.TEXT_NODE) |
| 764 |
{ |
764 |
{ |
| 765 |
Text textModifyElement = (Text)modifyChildren.item(j); |
765 |
Text textModifyElement = (Text)modifyChildren.item(j); |
| 766 |
String modifyCommandText = textModifyElement.getData(); |
766 |
String modifyCommandText = textModifyElement.getData(); |
| 767 |
String modifyCommandTextSubs = VariableSubstitution.getInstance().doSubstitutions(modifyCommandText); |
767 |
String modifyCommandTextSubs = VariableSubstitution.getInstance().doSubstitutions(modifyCommandText); |
| 768 |
|
768 |
|
| 769 |
if (!(modifyCommandText.equals(modifyCommandTextSubs))) |
769 |
if (!(modifyCommandText.equals(modifyCommandTextSubs))) |
| 770 |
textModifyElement.setData(modifyCommandTextSubs); |
770 |
textModifyElement.setData(modifyCommandTextSubs); |
| 771 |
break; |
771 |
break; |
| 772 |
} |
772 |
} |
| 773 |
} |
773 |
} |
| 774 |
} |
774 |
} |
| 775 |
|
775 |
|
| 776 |
private void getModifiableFields (XMLDefaultHandler handler, Map modifiableFields, List orderedList) |
776 |
private void getModifiableFields (XMLDefaultHandler handler, Map modifiableFields, List orderedList) |
| 777 |
{ |
777 |
{ |
| 778 |
Node root = handler.getDocumentElement(); |
778 |
Node root = handler.getDocumentElement(); |
| 779 |
if (root == null) |
779 |
if (root == null) |
| 780 |
return; |
780 |
return; |
| 781 |
|
781 |
|
| 782 |
AutoGUIUtil.walkDomTree (root.getChildNodes(), modifiableFields, orderedList); |
782 |
AutoGUIUtil.walkDomTree (root.getChildNodes(), modifiableFields, orderedList); |
| 783 |
} |
783 |
} |
| 784 |
|
784 |
|
| 785 |
|
785 |
|
| 786 |
private void linkUserInput (Element element, String newModifiedField) |
786 |
private void linkUserInput (Element element, String newModifiedField) |
| 787 |
{ |
787 |
{ |
| 788 |
String elementType = element.getAttribute(MacroConstants.TYPE_ATTRIBUTE); |
788 |
String elementType = element.getAttribute(MacroConstants.TYPE_ATTRIBUTE); |
| 789 |
|
789 |
|
| 790 |
/* Is the element a modify command */ |
790 |
/* Is the element a modify command */ |
| 791 |
if (ModifyCommand.TYPE.equals(elementType)) |
791 |
if (ModifyCommand.TYPE.equals(elementType)) |
| 792 |
{ |
792 |
{ |
| 793 |
NodeList modifyChildren = element.getChildNodes(); |
793 |
NodeList modifyChildren = element.getChildNodes(); |
| 794 |
boolean childChanged = false; |
794 |
boolean childChanged = false; |
| 795 |
for (int j = 0, modifyChildCount = modifyChildren.getLength(); j < modifyChildCount; j++) |
795 |
for (int j = 0, modifyChildCount = modifyChildren.getLength(); j < modifyChildCount; j++) |
| 796 |
{ |
796 |
{ |
| 797 |
if (childChanged && modifyChildren.item(j) instanceof Text) |
797 |
if (childChanged && modifyChildren.item(j) instanceof Text) |
| 798 |
element.removeChild(modifyChildren.item(j)); |
798 |
element.removeChild(modifyChildren.item(j)); |
| 799 |
|
799 |
|
| 800 |
if (modifyChildren.item(j) instanceof Text) |
800 |
if (modifyChildren.item(j) instanceof Text) |
| 801 |
{ |
801 |
{ |
| 802 |
((Text)modifyChildren.item(j)).setData(newModifiedField); |
802 |
((Text)modifyChildren.item(j)).setData(newModifiedField); |
| 803 |
childChanged = true; |
803 |
childChanged = true; |
| 804 |
} |
804 |
} |
| 805 |
} |
805 |
} |
| 806 |
|
806 |
|
| 807 |
} |
807 |
} |
| 808 |
/* Is the element a wait command */ |
808 |
/* Is the element a wait command */ |
| 809 |
else if (WaitCommand.TYPE.equals(elementType)) |
809 |
else if (WaitCommand.TYPE.equals(elementType)) |
| 810 |
{ |
810 |
{ |
| 811 |
Node timeToWaitAttribute = element.getAttributeNode(MacroConstants.TIME_TO_WAIT_ATTRIBUTE); |
811 |
Node timeToWaitAttribute = element.getAttributeNode(MacroConstants.TIME_TO_WAIT_ATTRIBUTE); |
| 812 |
timeToWaitAttribute.setNodeValue(newModifiedField); |
812 |
timeToWaitAttribute.setNodeValue(newModifiedField); |
| 813 |
} |
813 |
} |
| 814 |
} |
814 |
} |
| 815 |
} |
815 |
} |
| 816 |
|
816 |
|
| 817 |
MacroPlayWrapper macroPlayWrapper = new MacroPlayWrapper (this.getClass()); |
817 |
MacroPlayWrapper macroPlayWrapper = new MacroPlayWrapper (this.getClass()); |
| 818 |
Thread macroPlayThread = new Thread(macroPlayWrapper); |
818 |
Thread macroPlayThread = new Thread(macroPlayWrapper); |
| 819 |
macroPlayThread.start(); |
819 |
macroPlayThread.start(); |
| 820 |
while (!macroPlayWrapper.isDone()) |
820 |
while (!macroPlayWrapper.isDone()) |
| 821 |
{ |
821 |
{ |
| 822 |
synchronized (this.getClass()) |
822 |
synchronized (this.getClass()) |
| 823 |
{ |
823 |
{ |
| 824 |
this.getClass().wait(500); |
824 |
this.getClass().wait(500); |
| 825 |
} |
825 |
} |
| 826 |
} |
826 |
} |
| 827 |
|
827 |
|
| 828 |
} |
828 |
} |
| 829 |
|
829 |
|
| 830 |
/* An error occurred while attempting to run this test case */ |
830 |
/* An error occurred while attempting to run this test case */ |
| 831 |
catch (Throwable t) |
831 |
catch (Throwable t) |
| 832 |
{ |
832 |
{ |
| 833 |
errorOccurred = true; |
833 |
errorOccurred = true; |
| 834 |
String messageWithOrigin = AutoGUIUtil.getOriginOfException(t); |
834 |
String messageWithOrigin = AutoGUIUtil.getOriginOfException(t); |
| 835 |
|
835 |
|
| 836 |
/* If we are running in quick mode, then display the correct error message */ |
836 |
/* If we are running in quick mode, then display the correct error message */ |
| 837 |
if (mode == QUICK_RUN_MODE) |
837 |
if (mode == QUICK_RUN_MODE) |
| 838 |
{ |
838 |
{ |
| 839 |
String stackTrace = AutoGUIUtil.getExceptionStackTrace(t); |
839 |
String stackTrace = AutoGUIUtil.getExceptionStackTrace(t); |
| 840 |
String cause = messageWithOrigin + "\n" + stackTrace; |
840 |
String cause = messageWithOrigin + "\n" + stackTrace; |
| 841 |
|
841 |
|
| 842 |
AutoGUIUtil.openErrorWithDetail( |
842 |
AutoGUIUtil.openErrorWithDetail( |
| 843 |
Display.getDefault().getActiveShell(), |
843 |
Display.getDefault().getActiveShell(), |
| 844 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_UNCAP_T, |
844 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_UNCAP_T, |
| 845 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_UNCAP, |
845 |
AutoGUIMessages.AUTO_GUI_ERROR_MACRO_UNCAP, |
| 846 |
cause); |
846 |
cause); |
| 847 |
} |
847 |
} |
| 848 |
else if (mode == EXECUTION_RUN_MODE) |
848 |
else if (mode == EXECUTION_RUN_MODE) |
| 849 |
sendVerdict (lastAction, VerdictEvent.VERDICT_ERROR, messageWithOrigin); |
849 |
sendVerdict (lastAction, VerdictEvent.VERDICT_ERROR, messageWithOrigin); |
| 850 |
|
850 |
|
| 851 |
} |
851 |
} |
| 852 |
|
852 |
|
| 853 |
|
853 |
|
| 854 |
/* If we got to this point without any errors, then pass the test case */ |
854 |
/* If we got to this point without any errors, then pass the test case */ |
| 855 |
if (!errorOccurred && lastAction != null) |
855 |
if (!errorOccurred && lastAction != null) |
| 856 |
sendVerdict(lastAction, VerdictEvent.VERDICT_PASS, null); |
856 |
sendVerdict(lastAction, VerdictEvent.VERDICT_PASS, null); |
| 857 |
|
857 |
|
| 858 |
/* Send out a stop event on the test case invocation */ |
858 |
/* Send out a stop event on the test case invocation */ |
| 859 |
if (mode == EXECUTION_RUN_MODE) |
859 |
if (mode == EXECUTION_RUN_MODE) |
| 860 |
sendTypeEvent(TypedEvent.STOP, null); |
860 |
sendTypeEvent(TypedEvent.STOP, null); |
| 861 |
index ++; |
861 |
index ++; |
| 862 |
if (index >= (nestedSuite.getActions().size()) && inTestSuite) |
862 |
if (index >= (nestedSuite.getActions().size()) && inTestSuite) |
| 863 |
{ |
863 |
{ |
| 864 |
sendSuiteStop(); |
864 |
sendSuiteStop(); |
| 865 |
inTestSuite=false; |
865 |
inTestSuite=false; |
| 866 |
} |
866 |
} |
| 867 |
|
867 |
|
| 868 |
}// end while |
868 |
}// end while |
| 869 |
}// end if |
869 |
}// end if |
| 870 |
|
870 |
|
| 871 |
if (mode == EXECUTION_RUN_MODE) |
871 |
if (mode == EXECUTION_RUN_MODE) |
| 872 |
{ |
872 |
{ |
| 873 |
System.out.flush(); |
873 |
System.out.flush(); |
| 874 |
System.err.flush(); |
874 |
System.err.flush(); |
| 875 |
|
875 |
|
| 876 |
/* Close loops if they have already not been done so */ |
876 |
/* Close loops if they have already not been done so */ |
| 877 |
while (loopStack.size() > 0) |
877 |
while (loopStack.size() > 0) |
| 878 |
{ |
878 |
{ |
| 879 |
sendTypeEvent(TypedEvent.STOP, null); |
879 |
sendTypeEvent(TypedEvent.STOP, null); |
| 880 |
loopStack.pop(); |
880 |
loopStack.pop(); |
| 881 |
} |
881 |
} |
| 882 |
|
882 |
|
| 883 |
/* Send the verdict of the test suite */ |
883 |
/* Send the verdict of the test suite */ |
| 884 |
if (initializeState != null) |
884 |
if (initializeState != null) |
| 885 |
{ |
885 |
{ |
| 886 |
initializeState.printStackTrace(); |
886 |
initializeState.printStackTrace(); |
| 887 |
} |
887 |
} |
| 888 |
|
888 |
|
| 889 |
VerdictEvent testSuiteVerdict = ModelUtil.DEFAULT_ARBITER.analyse(); |
889 |
VerdictEvent testSuiteVerdict = ModelUtil.DEFAULT_ARBITER.analyse(); |
| 890 |
testSuiteVerdict.setParentId("ROOT"); |
890 |
testSuiteVerdict.setParentId("ROOT"); |
| 891 |
ModelUtil.getEventLogger().log(testSuiteVerdict); |
891 |
ModelUtil.getEventLogger().log(testSuiteVerdict); |
| 892 |
|
892 |
|
| 893 |
sendTypeEvent(TypedEvent.STOP, null); |
893 |
sendTypeEvent(TypedEvent.STOP, null); |
| 894 |
} |
894 |
} |
| 895 |
else if (mode == QUICK_RUN_MODE && initializeState != null) |
895 |
else if (mode == QUICK_RUN_MODE && initializeState != null) |
| 896 |
{ |
896 |
{ |
| 897 |
AutoGUIUtil.openErrorWithDetail(AutoGUIMessages.AUTO_GUI_COMMON_ERROR, AutoGUIMessages.AUTO_GUI_ERROR_MACRO_INITIALIZE, initializeState); |
897 |
AutoGUIUtil.openErrorWithDetail(AutoGUIMessages.AUTO_GUI_COMMON_ERROR, AutoGUIMessages.AUTO_GUI_ERROR_MACRO_INITIALIZE, initializeState); |
| 898 |
} |
898 |
} |
| 899 |
} |
899 |
} |
| 900 |
|
900 |
|
| 901 |
|
901 |
|
| 902 |
private String getActionId(Object action) |
902 |
private String getActionId(Object action) |
| 903 |
{ |
903 |
{ |
| 904 |
if (action instanceof NamedElement) |
904 |
if (action instanceof NamedElement) |
| 905 |
return ((NamedElement)action).getId(); |
905 |
return ((NamedElement)action).getId(); |
| 906 |
|
906 |
|
| 907 |
return null; |
907 |
return null; |
| 908 |
} |
908 |
} |
| 909 |
|
909 |
|
| 910 |
private Loop getLastLoop() |
910 |
private Loop getLastLoop() |
| 911 |
{ |
911 |
{ |
| 912 |
if (loopStack.size() <= 0) |
912 |
if (loopStack.size() <= 0) |
| 913 |
return null; |
913 |
return null; |
| 914 |
|
914 |
|
| 915 |
return (Loop)loopStack.peek(); |
915 |
return (Loop)loopStack.peek(); |
| 916 |
} |
916 |
} |
| 917 |
|
917 |
|
| 918 |
|
918 |
|
| 919 |
/** |
919 |
/** |
| 920 |
* Used to do the required initialization prior to the beginning |
920 |
* Used to do the required initialization prior to the beginning |
| 921 |
* of a test run. |
921 |
* of a test run. |
| 922 |
* @throws CoreException |
922 |
* @throws CoreException |
| 923 |
*/ |
923 |
*/ |
| 924 |
private void initializeTestRun(byte mode) throws CoreException |
924 |
private void initializeTestRun(byte mode) throws CoreException |
| 925 |
{ |
925 |
{ |
| 926 |
/* A good time to initialize the variables declared in VariableSubstitution */ |
926 |
/* A good time to initialize the variables declared in VariableSubstitution */ |
| 927 |
initializeVariable(extendedTestSuite, mode); |
927 |
initializeVariable(extendedTestSuite, mode); |
| 928 |
|
928 |
|
| 929 |
/* Tag the existing shells so that they don't accidently get closed when the macro playback |
929 |
/* Tag the existing shells so that they don't accidently get closed when the macro playback |
| 930 |
* closes nested shells in the case of an error */ |
930 |
* closes nested shells in the case of an error */ |
| 931 |
final Display currentDisplay = GuiPlugin.getDefault().getWorkbench().getDisplay(); |
931 |
final Display currentDisplay = GuiPlugin.getDefault().getWorkbench().getDisplay(); |
| 932 |
currentDisplay.syncExec(new Runnable(){ |
932 |
currentDisplay.syncExec(new Runnable(){ |
| 933 |
|
933 |
|
| 934 |
public void run() |
934 |
public void run() |
| 935 |
{ |
935 |
{ |
| 936 |
Shell[] openedShells = currentDisplay.getShells(); |
936 |
Shell[] openedShells = currentDisplay.getShells(); |
| 937 |
for (int i = 0; i < openedShells.length; i++) |
937 |
for (int i = 0; i < openedShells.length; i++) |
| 938 |
{ |
938 |
{ |
| 939 |
openedShells[i].setData(GlobalConstants.OPENED_SHELL_INDICATOR, Boolean.TRUE); |
939 |
openedShells[i].setData(GlobalConstants.OPENED_SHELL_INDICATOR, Boolean.TRUE); |
| 940 |
} |
940 |
} |
| 941 |
|
941 |
|
| 942 |
}}); |
942 |
}}); |
| 943 |
|
943 |
|
| 944 |
/* Retrieve the object mine of the test suite */ |
944 |
/* Retrieve the object mine of the test suite */ |
| 945 |
String objectMineXML = null; |
945 |
String objectMineXML = null; |
| 946 |
if (mode == QUICK_RUN_MODE && testSuiteEMF != null) |
946 |
if (mode == QUICK_RUN_MODE && testSuiteEMF != null) |
| 947 |
{ |
947 |
{ |
| 948 |
objectMineXML = HyadesUtil.getTestSuiteVariable(testSuiteEMF, GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE); |
948 |
objectMineXML = HyadesUtil.getTestSuiteVariable(testSuiteEMF, GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE); |
| 949 |
} |
949 |
} |
| 950 |
else if (mode == EXECUTION_RUN_MODE) |
950 |
else if (mode == EXECUTION_RUN_MODE) |
| 951 |
{ |
951 |
{ |
| 952 |
GeneralPropertyRetriever properties = extendedTestSuite.getProperties(); |
952 |
GeneralPropertyRetriever properties = extendedTestSuite.getProperties(); |
| 953 |
objectMineXML = properties == null ? null : (String)properties.getProperty(GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE); |
953 |
objectMineXML = properties == null ? null : (String)properties.getProperty(GlobalConstants.TEST_SUITE_PROPERTY_OBJECT_MINE); |
| 954 |
} |
954 |
} |
| 955 |
|
955 |
|
| 956 |
if (objectMineXML != null) |
956 |
if (objectMineXML != null) |
| 957 |
{ |
957 |
{ |
| 958 |
MacroManager.getInstance().prepareForPlayBack(objectMineXML); |
958 |
MacroManager.getInstance().prepareForPlayBack(objectMineXML); |
| 959 |
} |
959 |
} |
| 960 |
|
960 |
|
| 961 |
} |
961 |
} |
| 962 |
/** |
962 |
/** |
| 963 |
* Initialize the variables decalred in VariableSubstitution |
963 |
* Initialize the variables decalred in VariableSubstitution |
| 964 |
*/ |
964 |
*/ |
| 965 |
private void initializeVariable(ExtendedTestSuite testSuite, byte mode) |
965 |
private void initializeVariable(ExtendedTestSuite testSuite, byte mode) |
| 966 |
{ |
966 |
{ |
| 967 |
Hashtable variableContainer = VariableSubstitution.getInstance().getVariableContainer(); |
967 |
Hashtable variableContainer = VariableSubstitution.getInstance().getVariableContainer(); |
| 968 |
Variable contextWorkbenchVar = (Variable)variableContainer.get(VariableSubstitution.VAR_CONTEXT_WORKSPACE); |
968 |
Variable contextWorkbenchVar = (Variable)variableContainer.get(VariableSubstitution.VAR_CONTEXT_WORKSPACE); |
| 969 |
contextWorkbenchVar.initialize(AutoGUIUtil.getWorkspaceLocation()); |
969 |
contextWorkbenchVar.initialize(AutoGUIUtil.getWorkspaceLocation()); |
| 970 |
|
970 |
|
| 971 |
Variable projectLocationVar = (Variable)variableContainer.get(VariableSubstitution.VAR_PROJECT_LOCATION); |
971 |
Variable projectLocationVar = (Variable)variableContainer.get(VariableSubstitution.VAR_PROJECT_LOCATION); |
| 972 |
|
972 |
|
| 973 |
/* If we're running in standard mode, then the value of this variable is expected to be defined as |
973 |
/* If we're running in standard mode, then the value of this variable is expected to be defined as |
| 974 |
* a property of our test suite */ |
974 |
* a property of our test suite */ |
| 975 |
String projectLocation = null; |
975 |
String projectLocation = null; |
| 976 |
if (mode == EXECUTION_RUN_MODE) |
976 |
if (mode == EXECUTION_RUN_MODE) |
| 977 |
{ |
977 |
{ |
| 978 |
GeneralPropertyRetriever properties = testSuite.getProperties(); |
978 |
GeneralPropertyRetriever properties = testSuite.getProperties(); |
| 979 |
projectLocation = (String)properties.getProperty(GlobalConstants.TEST_SUITE_PROPERTY_BASE + "0"); |
979 |
projectLocation = (String)properties.getProperty(GlobalConstants.TEST_SUITE_PROPERTY_BASE + "0"); |
| 980 |
} |
980 |
} |
| 981 |
/* In quick mode, we have to retrieve the value of the variable */ |
981 |
/* In quick mode, we have to retrieve the value of the variable */ |
| 982 |
else if (mode == QUICK_RUN_MODE && testSuiteEMF != null) |
982 |
else if (mode == QUICK_RUN_MODE && testSuiteEMF != null) |
| 983 |
{ |
983 |
{ |
| 984 |
projectLocation = AutoGUIUtil.getTestSuiteProjectLocation(testSuiteEMF); |
984 |
projectLocation = AutoGUIUtil.getTestSuiteProjectLocation(testSuiteEMF); |
| 985 |
} |
985 |
} |
| 986 |
|
986 |
|
| 987 |
if (projectLocation != null) |
987 |
if (projectLocation != null) |
| 988 |
projectLocationVar.initialize(projectLocation); |
988 |
projectLocationVar.initialize(projectLocation); |
| 989 |
} |
989 |
} |
| 990 |
|
990 |
|
| 991 |
|
991 |
|
| 992 |
/** |
992 |
/** |
| 993 |
* Returns the id of the last execution event detected |
993 |
* Returns the id of the last execution event detected |
| 994 |
*/ |
994 |
*/ |
| 995 |
private String lastExecutionEventId() |
995 |
private String lastExecutionEventId() |
| 996 |
{ |
996 |
{ |
| 997 |
if (executionEventStack.size() <= 0) |
997 |
if (executionEventStack.size() <= 0) |
| 998 |
return "ROOT"; |
998 |
return "ROOT"; |
| 999 |
return ((ExecutionEvent)executionEventStack.peek()).getId(); |
999 |
return ((ExecutionEvent)executionEventStack.peek()).getId(); |
| 1000 |
|
1000 |
|
| 1001 |
} |
1001 |
} |
| 1002 |
|
1002 |
|
| 1003 |
|
1003 |
|
| 1004 |
/** |
1004 |
/** |
| 1005 |
* Returns the last container id according to what is stored in the |
1005 |
* Returns the last container id according to what is stored in the |
| 1006 |
* execution event stack. A container is either a loop or the ROOT. It could also be a nested test suite invocation |
1006 |
* execution event stack. A container is either a loop or the ROOT. It could also be a nested test suite invocation |
| 1007 |
* |
1007 |
* |
| 1008 |
* @return The last container id. |
1008 |
* @return The last container id. |
| 1009 |
*/ |
1009 |
*/ |
| 1010 |
private String lastContainerId() |
1010 |
private String lastContainerId() |
| 1011 |
{ |
1011 |
{ |
| 1012 |
/* Walk through the stack and find the container */ |
1012 |
/* Walk through the stack and find the container */ |
| 1013 |
Object[] stackItems = executionEventStack.toArray(); |
1013 |
Object[] stackItems = executionEventStack.toArray(); |
| 1014 |
for (int i = stackItems.length - 1; i >= 0 ; i--) |
1014 |
for (int i = stackItems.length - 1; i >= 0 ; i--) |
| 1015 |
{ |
1015 |
{ |
| 1016 |
if (stackItems[i] instanceof LoopEvent) |
1016 |
if (stackItems[i] instanceof LoopEvent) |
| 1017 |
return ((LoopEvent)stackItems[i]).getId(); |
1017 |
return ((LoopEvent)stackItems[i]).getId(); |
| 1018 |
else if (stackItems[i] instanceof InvocationEvent){ |
1018 |
else if (stackItems[i] instanceof InvocationEvent){ |
| 1019 |
return ((InvocationEvent)stackItems[i]).getId(); |
1019 |
return ((InvocationEvent)stackItems[i]).getId(); |
| 1020 |
} |
1020 |
} |
| 1021 |
} |
1021 |
} |
| 1022 |
return "ROOT"; |
1022 |
return "ROOT"; |
| 1023 |
} |
1023 |
} |
| 1024 |
|
1024 |
|
| 1025 |
|
1025 |
|
| 1026 |
/** |
1026 |
/** |
| 1027 |
* Sends typed events representing start/stop events for the last event on |
1027 |
* Sends typed events representing start/stop events for the last event on |
| 1028 |
* the execution event stack. |
1028 |
* the execution event stack. |
| 1029 |
*/ |
1029 |
*/ |
| 1030 |
private void sendTypeEvent(int type, String text) |
1030 |
private void sendTypeEvent(int type, String text) |
| 1031 |
{ |
1031 |
{ |
| 1032 |
TypedEvent event = new TypedEvent(); |
1032 |
TypedEvent event = new TypedEvent(); |
| 1033 |
String parentId = lastExecutionEventId(); |
1033 |
String parentId = lastExecutionEventId(); |
| 1034 |
if (executionEventStack.size() > 0) |
1034 |
if (executionEventStack.size() > 0) |
| 1035 |
event.setOwnerId(((ExecutionEvent)executionEventStack.peek()).getOwnerId()); |
1035 |
event.setOwnerId(((ExecutionEvent)executionEventStack.peek()).getOwnerId()); |
| 1036 |
event.setParentId(parentId); |
1036 |
event.setParentId(parentId); |
| 1037 |
event.setType(type); |
1037 |
event.setType(type); |
| 1038 |
|
1038 |
|
| 1039 |
ModelUtil.getEventLogger().log(event); |
1039 |
ModelUtil.getEventLogger().log(event); |
| 1040 |
|
1040 |
|
| 1041 |
if (type == TypedEvent.STOP && executionEventStack.size() > 0) |
1041 |
if (type == TypedEvent.STOP && executionEventStack.size() > 0) |
| 1042 |
executionEventStack.pop(); |
1042 |
executionEventStack.pop(); |
| 1043 |
} |
1043 |
} |
| 1044 |
|
1044 |
|
| 1045 |
/** |
1045 |
/** |
| 1046 |
* Added for bugzilla_136186 in order to send an additional Stop event for a test suite |
1046 |
* Added for bugzilla_136186 in order to send an additional Stop event for a test suite |
| 1047 |
*/ |
1047 |
*/ |
| 1048 |
private void sendSuiteStop() |
1048 |
private void sendSuiteStop() |
| 1049 |
{ |
1049 |
{ |
| 1050 |
sendTypeEvent(TypedEvent.STOP, null); |
1050 |
sendTypeEvent(TypedEvent.STOP, null); |
| 1051 |
|
1051 |
|
| 1052 |
} |
1052 |
} |
| 1053 |
/** |
1053 |
/** |
| 1054 |
* Sends a loop event |
1054 |
* Sends a loop event |
| 1055 |
*/ |
1055 |
*/ |
| 1056 |
private void sendLoopStart (Loop loop) |
1056 |
private void sendLoopStart (Loop loop) |
| 1057 |
{ |
1057 |
{ |
| 1058 |
loopNumbersDetected++; |
1058 |
loopNumbersDetected++; |
| 1059 |
|
1059 |
|
| 1060 |
LoopEvent loopEvent = new LoopEvent(); |
1060 |
LoopEvent loopEvent = new LoopEvent(); |
| 1061 |
loopEvent.setIterations(loop.getIterations()); |
1061 |
loopEvent.setIterations(loop.getIterations()); |
| 1062 |
associateEventIds(loop, loopEvent); |
1062 |
associateEventIds(loop, loopEvent); |
| 1063 |
|
1063 |
|
| 1064 |
ModelUtil.getEventLogger().log(loopEvent); |
1064 |
ModelUtil.getEventLogger().log(loopEvent); |
| 1065 |
sendTypeEvent (TypedEvent.START, null); |
1065 |
sendTypeEvent (TypedEvent.START, null); |
| 1066 |
loopStack.push(loop); |
1066 |
loopStack.push(loop); |
| 1067 |
} |
1067 |
} |
| 1068 |
|
1068 |
|
| 1069 |
private void sendLoopStop () |
1069 |
private void sendLoopStop () |
| 1070 |
{ |
1070 |
{ |
| 1071 |
sendTypeEvent(TypedEvent.STOP, null); |
1071 |
sendTypeEvent(TypedEvent.STOP, null); |
| 1072 |
loopStack.pop(); |
1072 |
loopStack.pop(); |
| 1073 |
} |
1073 |
} |
| 1074 |
|
1074 |
|
| 1075 |
|
1075 |
|
| 1076 |
private void sendAllLoopStop () |
1076 |
private void sendAllLoopStop () |
| 1077 |
{ |
1077 |
{ |
| 1078 |
while (loopStack.size() > 0) |
1078 |
while (loopStack.size() > 0) |
| 1079 |
{ |
1079 |
{ |
| 1080 |
sendLoopStop(); |
1080 |
sendLoopStop(); |
| 1081 |
} |
1081 |
} |
| 1082 |
} |
1082 |
} |
| 1083 |
|
1083 |
|
| 1084 |
/** |
1084 |
/** |
| 1085 |
* Sends a test invocation event |
1085 |
* Sends a test invocation event |
| 1086 |
* |
1086 |
* |
| 1087 |
* @param testInvocation |
1087 |
* @param testInvocation |
| 1088 |
* @param status |
1088 |
* @param status |
| 1089 |
* @param text |
1089 |
* @param text |
| 1090 |
*/ |
1090 |
*/ |
| 1091 |
private void sendTestInvocation (TestInvocation testInvocation, int status, String text) |
1091 |
private void sendTestInvocation (TestInvocation testInvocation, int status, String text) |
| 1092 |
{ |
1092 |
{ |
| 1093 |
invocationNumbersDetected++; |
1093 |
invocationNumbersDetected++; |
| 1094 |
|
1094 |
|
| 1095 |
InvocationEvent event = new InvocationEvent(); |
1095 |
InvocationEvent event = new InvocationEvent(); |
| 1096 |
associateEventIds(testInvocation, event); |
1096 |
associateEventIds(testInvocation, event); |
| 1097 |
|
1097 |
|
| 1098 |
|
1098 |
|
| 1099 |
|
1099 |
|
| 1100 |
if(testInvocation.getTest() == null) |
1100 |
if(testInvocation.getTest() == null) |
| 1101 |
{ |
1101 |
{ |
| 1102 |
event.setStatus(InvocationEvent.STATUS_UNSUCCESSFUL); |
1102 |
event.setStatus(InvocationEvent.STATUS_UNSUCCESSFUL); |
| 1103 |
event.setReason(InvocationEvent.REASON_NO_BEHAVIOR); |
1103 |
event.setReason(InvocationEvent.REASON_NO_BEHAVIOR); |
| 1104 |
|
1104 |
|
| 1105 |
} |
1105 |
} |
| 1106 |
else |
1106 |
else |
| 1107 |
{ |
1107 |
{ |
| 1108 |
event.setInvokedId(ModelUtil.appendHierarchyId(testInvocation.getTest(), event.getOwnerId())); |
1108 |
event.setInvokedId(ModelUtil.appendHierarchyId(testInvocation.getTest(), event.getOwnerId())); |
| 1109 |
event.setStatus(status); |
1109 |
event.setStatus(status); |
| 1110 |
|
1110 |
|
| 1111 |
|
1111 |
|
| 1112 |
} |
1112 |
} |
| 1113 |
|
1113 |
|
| 1114 |
ModelUtil.getEventLogger().log(event); |
1114 |
ModelUtil.getEventLogger().log(event); |
| 1115 |
sendTypeEvent (TypedEvent.START, null); |
1115 |
sendTypeEvent (TypedEvent.START, null); |
| 1116 |
} |
1116 |
} |
| 1117 |
|
1117 |
|
| 1118 |
|
1118 |
|
| 1119 |
/** |
1119 |
/** |
| 1120 |
* Associates a verdict with a test test invocation. |
1120 |
* Associates a verdict with a test test invocation. |
| 1121 |
* |
1121 |
* |
| 1122 |
* @param testInvocation The test invocation |
1122 |
* @param testInvocation The test invocation |
| 1123 |
* @param verdict Can either be VerdictEvent.VERDICT_PASS, VerdictEvent.VERDICT_FAIL, |
1123 |
* @param verdict Can either be VerdictEvent.VERDICT_PASS, VerdictEvent.VERDICT_FAIL, |
| 1124 |
* VerdictEvent.VERDICT_ERROR |
1124 |
* VerdictEvent.VERDICT_ERROR |
| 1125 |
* @param reason The reason for the verdict. Can be null. |
1125 |
* @param reason The reason for the verdict. Can be null. |
| 1126 |
*/ |
1126 |
*/ |
| 1127 |
private void sendVerdict (TestInvocation testInvocation, int verdict, String reason) |
1127 |
private void sendVerdict (TestInvocation testInvocation, int verdict, String reason) |
| 1128 |
{ |
1128 |
{ |
| 1129 |
VerdictEvent verdictEvent = ModelUtil.createTestVerdictEvent(testInvocation); |
1129 |
VerdictEvent verdictEvent = ModelUtil.createTestVerdictEvent(testInvocation); |
| 1130 |
|
1130 |
|
| 1131 |
/* We're expected to have a test invocation on our stack */ |
1131 |
/* We're expected to have a test invocation on our stack */ |
| 1132 |
if (executionEventStack.size() <= 0 && !(executionEventStack.peek() instanceof InvocationEvent) && lastAction == null) |
1132 |
if (executionEventStack.size() <= 0 && !(executionEventStack.peek() instanceof InvocationEvent) && lastAction == null) |
| 1133 |
return; /* Should never happen */ |
1133 |
return; /* Should never happen */ |
| 1134 |
|
1134 |
|
| 1135 |
/* Determine the ids: |
1135 |
/* Determine the ids: |
| 1136 |
* - The id is the same as the invocation id appended with '_verdict' |
1136 |
* - The id is the same as the invocation id appended with '_verdict' |
| 1137 |
* - The owner id is the id of the test from the test invocation |
1137 |
* - The owner id is the id of the test from the test invocation |
| 1138 |
* - The parent id is the id of the test invocation |
1138 |
* - The parent id is the id of the test invocation |
| 1139 |
*/ |
1139 |
*/ |
| 1140 |
InvocationEvent invocationEvent = (InvocationEvent)executionEventStack.peek(); |
1140 |
InvocationEvent invocationEvent = (InvocationEvent)executionEventStack.peek(); |
| 1141 |
verdictEvent.setId(invocationEvent.getId() + "_verdict"); |
1141 |
verdictEvent.setId(invocationEvent.getId() + "_verdict"); |
| 1142 |
//verdictEvent.setOwnerId(ModelUtil.getHierarchyId(lastAction.getTest())); |
1142 |
//verdictEvent.setOwnerId(ModelUtil.getHierarchyId(lastAction.getTest())); |
| 1143 |
verdictEvent.setParentId(invocationEvent.getId()); |
1143 |
verdictEvent.setParentId(invocationEvent.getId()); |
| 1144 |
verdictEvent.setVerdict(verdict); |
1144 |
verdictEvent.setVerdict(verdict); |
| 1145 |
verdictEvent.setOwnerId(invocationEvent.getId()); |
1145 |
verdictEvent.setOwnerId(invocationEvent.getId()); |
| 1146 |
|
1146 |
|
| 1147 |
if(reason != null && reason.trim().length() > 0) |
1147 |
if(reason != null && reason.trim().length() > 0) |
| 1148 |
{ |
1148 |
{ |
| 1149 |
verdictEvent.setText(reason); |
1149 |
verdictEvent.setText(reason); |
| 1150 |
verdictEvent.setReason(VerdictEvent.REASON_SEE_DESCRIPTION); |
1150 |
verdictEvent.setReason(VerdictEvent.REASON_SEE_DESCRIPTION); |
| 1151 |
} |
1151 |
} |
| 1152 |
ModelUtil.getEventLogger().log(verdictEvent); |
1152 |
ModelUtil.getEventLogger().log(verdictEvent); |
| 1153 |
testInvocation.setVerdictEvent(verdictEvent); |
1153 |
testInvocation.setVerdictEvent(verdictEvent); |
| 1154 |
} |
1154 |
} |
| 1155 |
|
1155 |
|
| 1156 |
|
1156 |
|
| 1157 |
/** |
1157 |
/** |
| 1158 |
* A helper method used to associate id, parentId, ownerId to the event. |
1158 |
* A helper method used to associate id, parentId, ownerId to the event. |
| 1159 |
* |
1159 |
* |
| 1160 |
* @param event |
1160 |
* @param event |
| 1161 |
* @param type 0 indicates loop, 1 indicates test invocation |
1161 |
* @param type 0 indicates loop, 1 indicates test invocation |
| 1162 |
*/ |
1162 |
*/ |
| 1163 |
private void associateEventIds(NamedElement namedElement, ExecutionEvent event) |
1163 |
private void associateEventIds(NamedElement namedElement, ExecutionEvent event) |
| 1164 |
{ |
1164 |
{ |
| 1165 |
String ownerId = namedElement.getId(); |
1165 |
String ownerId = namedElement.getId(); |
| 1166 |
String eventId = (namedElement instanceof Loop ? ownerId + "(" + loopNumbersDetected + ")" : ownerId + "(" + invocationNumbersDetected + ")"); |
1166 |
String eventId = (namedElement instanceof Loop ? ownerId + "(" + loopNumbersDetected + ")" : ownerId + "(" + invocationNumbersDetected + ")"); |
| 1167 |
String parentId = lastContainerId(); |
1167 |
String parentId = lastContainerId(); |
| 1168 |
|
1168 |
|
| 1169 |
event.setOwnerId(ownerId); |
1169 |
event.setOwnerId(ownerId); |
| 1170 |
event.setId(eventId); |
1170 |
event.setId(eventId); |
| 1171 |
event.setParentId(parentId); |
1171 |
event.setParentId(parentId); |
| 1172 |
|
1172 |
|
| 1173 |
|
1173 |
|
| 1174 |
executionEventStack.push(event); |
1174 |
executionEventStack.push(event); |
| 1175 |
} |
1175 |
} |
| 1176 |
|
1176 |
|
| 1177 |
/** |
1177 |
/** |
| 1178 |
* Returns the next execution based on the mode that we're running in. The first |
1178 |
* Returns the next execution based on the mode that we're running in. The first |
| 1179 |
* execution in quick mode is the test case in the testSuite argument passed in |
1179 |
* execution in quick mode is the test case in the testSuite argument passed in |
| 1180 |
* and in the execution mode, it is the next test invocation |
1180 |
* and in the execution mode, it is the next test invocation |
| 1181 |
* |
1181 |
* |
| 1182 |
* @return The next element to be executed |
1182 |
* @return The next element to be executed |
| 1183 |
*/ |
1183 |
*/ |
| 1184 |
private Object nextExecution (byte mode, TestSuite testSuite) |
1184 |
private Object nextExecution (byte mode, TestSuite testSuite) |
| 1185 |
{ |
1185 |
{ |
| 1186 |
Object nextExecution = null; |
1186 |
Object nextExecution = null; |
| 1187 |
|
1187 |
|
| 1188 |
if (mode == QUICK_RUN_MODE) |
1188 |
if (mode == QUICK_RUN_MODE) |
| 1189 |
{ |
1189 |
{ |
| 1190 |
int testCaseSize = testSuite.getTestCases().size(); |
1190 |
int testCaseSize = testSuite.getTestCases().size(); |
| 1191 |
if (currentTestCaseInx >= 0 && currentTestCaseInx < testCaseSize) |
1191 |
if (currentTestCaseInx >= 0 && currentTestCaseInx < testCaseSize) |
| 1192 |
{ |
1192 |
{ |
| 1193 |
nextExecution = testSuite.getTestCases().get(currentTestCaseInx); |
1193 |
nextExecution = testSuite.getTestCases().get(currentTestCaseInx); |
| 1194 |
currentTestCaseInx++; |
1194 |
currentTestCaseInx++; |
| 1195 |
} |
1195 |
} |
| 1196 |
} |
1196 |
} |
| 1197 |
else if (mode == EXECUTION_RUN_MODE) |
1197 |
else if (mode == EXECUTION_RUN_MODE) |
| 1198 |
{ |
1198 |
{ |
| 1199 |
if (!isActionIteratorStackInitialized) |
1199 |
if (!isActionIteratorStackInitialized) |
| 1200 |
{ |
1200 |
{ |
| 1201 |
actionIteratorStack.push(ModelUtil.DEFAULT_EXECUTION_MANAGER.getRoot().getActions().iterator()); |
1201 |
actionIteratorStack.push(ModelUtil.DEFAULT_EXECUTION_MANAGER.getRoot().getActions().iterator()); |
| 1202 |
isActionIteratorStackInitialized = true; |
1202 |
isActionIteratorStackInitialized = true; |
| 1203 |
} |
1203 |
} |
| 1204 |
if (actionIteratorStack.size() > 0) |
1204 |
if (actionIteratorStack.size() > 0) |
| 1205 |
nextExecution = getNextExecutableAction(); |
1205 |
nextExecution = getNextExecutableAction(); |
| 1206 |
} |
1206 |
} |
| 1207 |
|
1207 |
|
| 1208 |
return nextExecution; |
1208 |
return nextExecution; |
| 1209 |
} |
1209 |
} |
| 1210 |
|
1210 |
|
| 1211 |
private Object getNextExecutableAction() |
1211 |
private Object getNextExecutableAction() |
| 1212 |
{ |
1212 |
{ |
| 1213 |
if (actionIteratorStack.size() <= 0) |
1213 |
if (actionIteratorStack.size() <= 0) |
| 1214 |
return null; |
1214 |
return null; |
| 1215 |
|
1215 |
|
| 1216 |
Iterator actionIterator = (Iterator)actionIteratorStack.peek(); |
1216 |
Iterator actionIterator = (Iterator)actionIteratorStack.peek(); |
| 1217 |
if (actionIterator.hasNext()) |
1217 |
if (actionIterator.hasNext()) |
| 1218 |
{ |
1218 |
{ |
| 1219 |
Object nextExecutableAction = actionIterator.next(); |
1219 |
Object nextExecutableAction = actionIterator.next(); |
| 1220 |
if (nextExecutableAction instanceof Loop) |
1220 |
if (nextExecutableAction instanceof Loop) |
| 1221 |
{ |
1221 |
{ |
| 1222 |
actionIteratorStack.push(((Loop)nextExecutableAction).getActions().iterator()); |
1222 |
actionIteratorStack.push(((Loop)nextExecutableAction).getActions().iterator()); |
| 1223 |
} |
1223 |
} |
| 1224 |
|
1224 |
|
| 1225 |
return nextExecutableAction; |
1225 |
return nextExecutableAction; |
| 1226 |
} |
1226 |
} |
| 1227 |
else |
1227 |
else |
| 1228 |
{ |
1228 |
{ |
| 1229 |
actionIteratorStack.pop(); |
1229 |
actionIteratorStack.pop(); |
| 1230 |
return getNextExecutableAction(); |
1230 |
return getNextExecutableAction(); |
| 1231 |
} |
1231 |
} |
| 1232 |
} |
1232 |
} |
| 1233 |
|
1233 |
|
| 1234 |
/** |
1234 |
/** |
| 1235 |
* Runs a verificaiton hook |
1235 |
* Runs a verification hook |
| 1236 |
* |
1236 |
* |
| 1237 |
* @param verfHook The verification hook |
1237 |
* @param verfHook The verification hook |
| 1238 |
*/ |
1238 |
*/ |
| 1239 |
public void runVerificaitonHook(IHyadesTest verificationHook) |
1239 |
public void runVerificationHook(IHyadesTest verificationHook) |
| 1240 |
{ |
1240 |
{ |
| 1241 |
/* Set the root, if it hasn't already been set */ |
1241 |
/* Set the root, if it hasn't already been set */ |
| 1242 |
if (super.getRoot() == null) |
1242 |
if (super.getRoot() == null) |
| 1243 |
super.setRoot (verificationHook); |
1243 |
super.setRoot (verificationHook); |
| 1244 |
|
1244 |
|
| 1245 |
TestResult result = super.createTestResult(); |
1245 |
TestResult result = super.createTestResult(); |
| 1246 |
result.addListener(this); |
1246 |
result.addListener(this); |
| 1247 |
|
1247 |
|
| 1248 |
verificationHook.run(result); |
1248 |
verificationHook.run(result); |
| 1249 |
} |
1249 |
} |
| 1250 |
|
1250 |
|
| 1251 |
|
1251 |
|
| 1252 |
/** |
1252 |
/** |
| 1253 |
* Parses the test script and does the appropriate initializations |
1253 |
* Parses the test script and does the appropriate initializations |
| 1254 |
* |
1254 |
* |
| 1255 |
* @throws Exception |
1255 |
* @throws Exception |
| 1256 |
* @throws UnsupportedEncodingException |
1256 |
* @throws UnsupportedEncodingException |
| 1257 |
*/ |
1257 |
*/ |
| 1258 |
protected TestSuite parseTestScript() throws UnsupportedEncodingException, Exception |
1258 |
protected TestSuite parseTestScript() throws UnsupportedEncodingException, Exception |
| 1259 |
{ |
1259 |
{ |
| 1260 |
TestInvocation.addListener(ModelUtil.DEFAULT_EXECUTION_MANAGER); |
1260 |
TestInvocation.addListener(ModelUtil.DEFAULT_EXECUTION_MANAGER); |
| 1261 |
|
1261 |
|
| 1262 |
ExtendedScriptParser scriptParser = new ExtendedScriptParser(); |
1262 |
ExtendedScriptParser scriptParser = new ExtendedScriptParser(); |
| 1263 |
TestSuite testSuite = scriptParser.parse(testScript.getBytes("UTF-8")); |
1263 |
TestSuite testSuite = scriptParser.parse(testScript.getBytes("UTF-8")); |
| 1264 |
|
1264 |
|
| 1265 |
if(testSuite == null) |
1265 |
if(testSuite == null) |
| 1266 |
{ |
1266 |
{ |
| 1267 |
System.err.println("\n" + testScript); |
1267 |
System.err.println("\n" + testScript); |
| 1268 |
throw new IllegalArgumentException(AutoGUIMessages.AUTO_GUI_ERROR_PLAYBACK_SCRIPT); |
1268 |
throw new IllegalArgumentException(AutoGUIMessages.AUTO_GUI_ERROR_PLAYBACK_SCRIPT); |
| 1269 |
} |
1269 |
} |
| 1270 |
|
1270 |
|
| 1271 |
ModelUtil.DEFAULT_EXECUTION_MANAGER.setRoot(testSuite); |
1271 |
ModelUtil.DEFAULT_EXECUTION_MANAGER.setRoot(testSuite); |
| 1272 |
ModelUtil.DEFAULT_EXECUTION_MANAGER.registerTestInvocations(scriptParser.getTestInvocations()); |
1272 |
ModelUtil.DEFAULT_EXECUTION_MANAGER.registerTestInvocations(scriptParser.getTestInvocations()); |
| 1273 |
ModelUtil.setVerdicts(scriptParser.getVerdicts()); |
1273 |
ModelUtil.setVerdicts(scriptParser.getVerdicts()); |
| 1274 |
|
1274 |
|
| 1275 |
scriptParser.dispose(); |
1275 |
scriptParser.dispose(); |
| 1276 |
|
1276 |
|
| 1277 |
return testSuite; |
1277 |
return testSuite; |
| 1278 |
} |
1278 |
} |
| 1279 |
|
1279 |
|
| 1280 |
|
1280 |
|
| 1281 |
/** |
1281 |
/** |
| 1282 |
* Returns the test script |
1282 |
* Returns the test script |
| 1283 |
* |
1283 |
* |
| 1284 |
* @return The test script |
1284 |
* @return The test script |
| 1285 |
*/ |
1285 |
*/ |
| 1286 |
protected String getTestScript() |
1286 |
protected String getTestScript() |
| 1287 |
{ |
1287 |
{ |
| 1288 |
return testScript; |
1288 |
return testScript; |
| 1289 |
} |
1289 |
} |
| 1290 |
|
1290 |
|
| 1291 |
|
1291 |
|
| 1292 |
/** |
1292 |
/** |
| 1293 |
* Set the test script |
1293 |
* Set the test script |
| 1294 |
* |
1294 |
* |
| 1295 |
* @param data The data for the test script |
1295 |
* @param data The data for the test script |
| 1296 |
*/ |
1296 |
*/ |
| 1297 |
protected void setTestScript(byte[] data) |
1297 |
protected void setTestScript(byte[] data) |
| 1298 |
{ |
1298 |
{ |
| 1299 |
try |
1299 |
try |
| 1300 |
{ |
1300 |
{ |
| 1301 |
testScript = new String(data, "UTF-8"); |
1301 |
testScript = new String(data, "UTF-8"); |
| 1302 |
} |
1302 |
} |
| 1303 |
catch (UnsupportedEncodingException e) |
1303 |
catch (UnsupportedEncodingException e) |
| 1304 |
{ |
1304 |
{ |
| 1305 |
} |
1305 |
} |
| 1306 |
} |
1306 |
} |
| 1307 |
|
1307 |
|
| 1308 |
/** |
1308 |
/** |
| 1309 |
* Overwrite the methods that are invoked when the verification hook result is being |
1309 |
* Overwrite the methods that are invoked when the verification hook result is being |
| 1310 |
* reported. |
1310 |
* reported. |
| 1311 |
*/ |
1311 |
*/ |
| 1312 |
protected VerdictEvent getDefaultVerdictEvent(Test test) |
1312 |
protected VerdictEvent getDefaultVerdictEvent(Test test) |
| 1313 |
{ |
1313 |
{ |
| 1314 |
/* We don't need to do anything here, because by default a verdict on the |
1314 |
/* We don't need to do anything here, because by default a verdict on the |
| 1315 |
* overall test case will be send. */ |
1315 |
* overall test case will be send. */ |
| 1316 |
return null; |
1316 |
return null; |
| 1317 |
} |
1317 |
} |
| 1318 |
|
1318 |
|
| 1319 |
|
1319 |
|
| 1320 |
public void addError(Test test, Throwable throwable) |
1320 |
public void addError(Test test, Throwable throwable) |
| 1321 |
{ |
1321 |
{ |
| 1322 |
if (runningMode == EXECUTION_RUN_MODE && lastAction != null) |
1322 |
if (runningMode == EXECUTION_RUN_MODE && lastAction != null) |
| 1323 |
{ |
1323 |
{ |
| 1324 |
errorOccurred = true; |
1324 |
errorOccurred = true; |
| 1325 |
sendVerdict(lastAction, VerdictEvent.VERDICT_ERROR, BaseString.getStackTrace(throwable)); |
1325 |
sendVerdict(lastAction, VerdictEvent.VERDICT_ERROR, BaseString.getStackTrace(throwable)); |
| 1326 |
} |
1326 |
} |
| 1327 |
} |
1327 |
} |
| 1328 |
|
1328 |
|
| 1329 |
|
1329 |
|
| 1330 |
public void addFailure(Test test, AssertionFailedError throwable) |
1330 |
public void addFailure(Test test, AssertionFailedError throwable) |
| 1331 |
{ |
1331 |
{ |
| 1332 |
if (runningMode == EXECUTION_RUN_MODE && lastAction != null) |
1332 |
if (runningMode == EXECUTION_RUN_MODE && lastAction != null) |
| 1333 |
{ |
1333 |
{ |
| 1334 |
errorOccurred = true; |
1334 |
errorOccurred = true; |
| 1335 |
sendVerdict(lastAction, VerdictEvent.VERDICT_FAIL, BaseString.getStackTrace(throwable)); |
1335 |
sendVerdict(lastAction, VerdictEvent.VERDICT_FAIL, BaseString.getStackTrace(throwable)); |
| 1336 |
} |
1336 |
} |
| 1337 |
} |
1337 |
} |
| 1338 |
|
1338 |
|
| 1339 |
|
1339 |
|
| 1340 |
/** |
1340 |
/** |
| 1341 |
* These methods are over-written to diable the Junit runner from sending anything to |
1341 |
* These methods are over-written to diable the Junit runner from sending anything to |
| 1342 |
* our agent. |
1342 |
* our agent. |
| 1343 |
*/ |
1343 |
*/ |
| 1344 |
protected void runnerExit(boolean runnerStopped, long elapsedTime) {} |
1344 |
protected void runnerExit(boolean runnerStopped, long elapsedTime) {} |
| 1345 |
public void startTest(Test test) {} |
1345 |
public void startTest(Test test) {} |
| 1346 |
public void endTest(Test test) {} |
1346 |
public void endTest(Test test) {} |
| 1347 |
|
1347 |
|
| 1348 |
/** |
1348 |
/** |
| 1349 |
* A primitive interface used to notify the status of the test runs to a caller that invokes |
1349 |
* A primitive interface used to notify the status of the test runs to a caller that invokes |
| 1350 |
* this test runner. |
1350 |
* this test runner. |
| 1351 |
* |
1351 |
* |
| 1352 |
* @author Ali Mehregani |
1352 |
* @author Ali Mehregani |
| 1353 |
*/ |
1353 |
*/ |
| 1354 |
public interface ITestRunnerDelegator |
1354 |
public interface ITestRunnerDelegator |
| 1355 |
{ |
1355 |
{ |
| 1356 |
/** |
1356 |
/** |
| 1357 |
* Invoked to indicate the end of a test suite run |
1357 |
* Invoked to indicate the end of a test suite run |
| 1358 |
*/ |
1358 |
*/ |
| 1359 |
public void finishedTestRun(); |
1359 |
public void finishedTestRun(); |
| 1360 |
} |
1360 |
} |
| 1361 |
|
1361 |
|
| 1362 |
} |
1362 |
} |