|
Lines 1-28
Link Here
|
| 1 |
package org.eclipse.hyades.use.cases.auto.profiling.logging; |
1 |
package org.eclipse.hyades.use.cases.auto.profiling.logging; |
| 2 |
|
2 |
|
|
|
3 |
|
| 3 |
import java.util.ArrayList; |
4 |
import java.util.ArrayList; |
| 4 |
|
5 |
|
| 5 |
import org.eclipse.hyades.use.cases.auto.common.Logger; |
6 |
import org.eclipse.hyades.use.cases.auto.common.Logger; |
| 6 |
import org.eclipse.hyades.use.cases.auto.common.VerifyHookUtil; |
7 |
import org.eclipse.hyades.use.cases.auto.common.VerifyHookUtil; |
| 7 |
import org.eclipse.swt.widgets.Composite; |
8 |
import org.eclipse.swt.widgets.Composite; |
| 8 |
import org.eclipse.swt.widgets.Control; |
|
|
| 9 |
import org.eclipse.swt.widgets.Label; |
| 10 |
import org.eclipse.swt.widgets.Table; |
| 11 |
import org.eclipse.swt.widgets.TableItem; |
| 12 |
import org.eclipse.swt.widgets.Tree; |
9 |
import org.eclipse.swt.widgets.Tree; |
| 13 |
import org.eclipse.swt.widgets.TreeColumn; |
10 |
import org.eclipse.swt.widgets.TreeColumn; |
| 14 |
import org.eclipse.swt.widgets.TreeItem; |
11 |
import org.eclipse.swt.widgets.TreeItem; |
| 15 |
import org.eclipse.tptp.test.auto.gui.internal.runner.AutoGUIVerificationHook; |
12 |
import org.eclipse.tptp.test.auto.gui.internal.runner.AutoGUIVerificationHook; |
| 16 |
|
13 |
|
| 17 |
/** |
14 |
/** |
| 18 |
* Generated code for the test suite <b>Platform.UI.ProfilingPerspective.Launch.Part5</b> located at |
15 |
* Generated code for the test suite <b>Platform.UI.ProfilingPerspective.Launch.Part4</b> located at |
| 19 |
* <i>/org.eclipse.hyades.use.cases/gui/Profiling_and_Logging/Platform.UI.ProfilingPerspective.Launch.Part5.testsuite</i>. |
16 |
* <i>/org.eclipse.hyades.use.cases/gui/Profiling_and_Logging/Launch/Platform.UI.ProfilingPerspective.Launch.Part4.testsuite</i>. |
|
|
17 |
* |
| 18 |
* Note: Prior to running these tests, testers must ensure that the wait time variables are configured accordingly. For an avergae speed, try |
| 19 |
* 1000, for slower amchines increase to 2000 or 3000 if you are getting failures. Some, such as those used for ProfilingLimitsCalls must be set higher. |
| 20 |
*/ |
20 |
*/ |
| 21 |
public class PlatformUIProfilingPerspectiveLaunchPart4 extends |
21 |
public class PlatformUIProfilingPerspectiveLaunchPart4 extends |
| 22 |
AutoGUIVerificationHook { |
22 |
AutoGUIVerificationHook { |
| 23 |
|
23 |
|
| 24 |
/** |
24 |
/** |
| 25 |
* Constructor for PlatformUIProfilingPerspectiveLaunchPart5. An instance of this class is created to |
25 |
* Constructor for PlatformUIProfilingPerspectiveLaunchPart4. An instance of this class is created to |
| 26 |
* test a test method. |
26 |
* test a test method. |
| 27 |
* |
27 |
* |
| 28 |
* @param testMethodName The test method to be tested. |
28 |
* @param testMethodName The test method to be tested. |
|
Lines 44-546
Link Here
|
| 44 |
* @see junit.framework.TestCase#tearDown() |
44 |
* @see junit.framework.TestCase#tearDown() |
| 45 |
*/ |
45 |
*/ |
| 46 |
protected void tearDown() throws Exception { |
46 |
protected void tearDown() throws Exception { |
| 47 |
Logger.getInstance().close(); |
|
|
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Verify the profiling set removement warning. |
| 52 |
* <p> |
| 53 |
* <b>Testing Steps:</b> |
| 54 |
* <ol> |
| 55 |
* <li>Open a new profiling launch configuration.</li> |
| 56 |
* <li>Click the <b>Profiling</b> tab, then the <b>Overview</b> tab.</li> |
| 57 |
* <li>Select a profiling set that is shared by more than one launch configurations.</li> |
| 58 |
* <li>Click <b>Remove</b> button.</li> |
| 59 |
* <li>A warning dialog should show up with an appropriate message.</li> |
| 60 |
* <li>Click <b>No</b></li> |
| 61 |
* <li>Ensure the profiling set was not removed.</li> |
| 62 |
* </ol> |
| 63 |
* <p> |
| 64 |
* <b>Purpose:</b> Perform the verification in step #5 |
| 65 |
* @throws Exception |
| 66 |
*/ |
| 67 |
public void verifyProfilingSetRemoveWarning(org.eclipse.swt.widgets.Shell arg0) |
| 68 |
throws Exception |
| 69 |
{ |
| 70 |
boolean doesWarningExist = false; |
| 71 |
|
| 72 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfilingSetRemoveWarning"); |
| 73 |
|
| 74 |
Control[] labels = VerifyHookUtil.findAllControl(arg0, VerifyHookUtil.LABEL_CONTROL_TYPE, null); |
| 75 |
|
| 76 |
for (int i = 0; i < labels.length; i++){ |
| 77 |
int index = ((Label)labels[i]).getText().trim().indexOf("The profiling set about to be removed is applied in more then one configurations"); |
| 78 |
|
| 79 |
if(index >= 0){ |
| 80 |
doesWarningExist = true; |
| 81 |
break; |
| 82 |
} |
| 83 |
} |
| 84 |
assertTrue(doesWarningExist); |
| 85 |
|
| 86 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfilingSetRemoveWarning"); |
| 87 |
} |
47 |
} |
| 88 |
|
48 |
|
| 89 |
/** |
49 |
/** |
| 90 |
* Verify the profiling set removement warning. |
50 |
* TestLaunchLocalDetached |
| 91 |
* <p> |
51 |
* The purpose of this test case is to launch a local external Java application |
| 92 |
* <b>Testing Steps:</b> |
52 |
* and attach/detach from the agent. |
| 93 |
* <ol> |
53 |
* |
| 94 |
* <li>Open a new profiling launch configuration.</li> |
54 |
* The steps are: |
| 95 |
* <li>Click the <b>Profiling</b> tab, then the <b>Overview</b> tab.</li> |
55 |
* 1)Select Profiling Button > Profile ... |
| 96 |
* <li>Select a profiling set that is shared by more than one launch configurations.</li> |
56 |
* 2) Select the launch configuration created in the CreateLaunchConfiguration Test Suite |
| 97 |
* <li>Click <b>Remove</b> button.</li> |
57 |
* 3) Select Profile |
| 98 |
* <li>A warning dialog should show up with an appropriate message.</li> |
58 |
* 4) Select the Agent and Select Detach |
| 99 |
* <li>Click <b>Yes</b></li> |
59 |
* 5) Verify that the agent is detached |
| 100 |
* <li>Check to ensure that the profiling set for the involved launch configurations in step 3 updated accordingly.</li> |
60 |
* 6) Terminate the Profiling |
| 101 |
* </ol> |
61 |
* |
| 102 |
* <p> |
62 |
* This method performs the verification described in Step 5) above |
| 103 |
* <b>Purpose:</b> Perform the verification in step #7 |
|
|
| 104 |
* @throws Exception |
63 |
* @throws Exception |
| 105 |
*/ |
64 |
*/ |
| 106 |
public void verifyProfilingSetRemoveWarningYes1(org.eclipse.swt.widgets.Shell arg0) |
65 |
public void verifyDetach(org.eclipse.ui.IViewPart arg0) |
| 107 |
throws Exception |
66 |
throws Exception |
| 108 |
{ |
67 |
{ |
| 109 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfilingSetRemoveWarningYes1"); |
68 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyDetach"); |
| 110 |
verifySelectedTreeItem(arg0, "RemovingSetWarningYes1"); |
69 |
verifyAgentStatus(arg0, "detached"); |
| 111 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfilingSetRemoveWarningYes1"); |
70 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyDetach"); |
| 112 |
} |
71 |
} |
| 113 |
|
72 |
|
| 114 |
/** |
73 |
|
| 115 |
* Verify the profiling set removement warning. |
74 |
|
| 116 |
* <p> |
75 |
private void verifyAgentStatus(org.eclipse.ui.IViewPart arg0, String status) |
| 117 |
* <b>Testing Steps:</b> |
76 |
{ |
| 118 |
* <ol> |
77 |
boolean found = false; |
| 119 |
* <li>Open a new profiling launch configuration.</li> |
78 |
Composite profileMonitor = VerifyHookUtil.getWorkbenchPartControl(arg0); |
| 120 |
* <li>Click the <b>Profiling</b> tab, then the <b>Overview</b> tab.</li> |
79 |
assertNotNull ("The profiling monitor selected is null", profileMonitor); |
| 121 |
* <li>Select a profiling set that is shared by more than one launch configurations.</li> |
80 |
VerifyHookUtil.widgetDump(profileMonitor); |
| 122 |
* <li>Click <b>Remove</b> button.</li> |
81 |
Tree tree = (Tree)VerifyHookUtil.findControl(profileMonitor, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 123 |
* <li>A warning dialog should show up with an appropriate message.</li> |
82 |
assertNotNull ("The tree in this view is null",tree); |
| 124 |
* <li>Click <b>Yes</b></li> |
83 |
TreeItem[] treeItemSelected = tree.getSelection(); |
| 125 |
* <li>Check to ensure that the profiling set for the involved launch configurations in step 3 updated accordingly.</li> |
|
|
| 126 |
* </ol> |
| 127 |
* <p> |
| 128 |
* <b>Purpose:</b> Perform the verification in step #7 |
| 129 |
* @throws Exception |
| 130 |
*/ |
| 131 |
public void verifyProfilingSetRemoveWarningYes2(org.eclipse.swt.widgets.Shell arg0) |
| 132 |
throws Exception |
| 133 |
{ |
| 134 |
boolean foundSet = false; |
| 135 |
|
| 136 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfilingSetRemoveWarningYes2"); |
| 137 |
|
| 138 |
Control tables[] = VerifyHookUtil.findAllControl(arg0, VerifyHookUtil.TABLE_CONTROL_TYPE, null); |
| 139 |
TableItem[] tableItemsSelected = null; |
| 140 |
|
| 141 |
for(int i = 0; i < tables.length; i++){ |
| 142 |
tableItemsSelected = ((Table)tables[i]).getSelection(); |
| 143 |
|
84 |
|
| 144 |
for(int j = 0; j < tableItemsSelected.length; j++){ |
85 |
for(int i = 0; i < treeItemSelected.length; i++) |
| 145 |
if(tableItemsSelected[j].getText(0).trim().equals("RemovingSet")) |
86 |
{ |
| 146 |
foundSet = true; |
87 |
if (treeItemSelected[i].getText().indexOf(status) >= 0){ |
|
|
88 |
found = true; |
| 89 |
|
| 90 |
break; |
| 147 |
} |
91 |
} |
| 148 |
} |
92 |
} |
| 149 |
|
93 |
assertTrue( found); |
| 150 |
assertFalse(foundSet); |
|
|
| 151 |
|
| 152 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfilingSetRemoveWarningYes2"); |
| 153 |
} |
94 |
} |
| 154 |
|
|
|
| 155 |
/** |
95 |
/** |
| 156 |
* Verify the profiling set removement warning. |
96 |
* |
| 157 |
* <p> |
97 |
* Meant to be a follow up to ensure that the agent was detached before we started collecting data |
| 158 |
* <b>Testing Steps:</b> |
98 |
* Need to ensure that the number of collected instances is zero in this view |
| 159 |
* <ol> |
99 |
* |
| 160 |
* <li>Open a new profiling launch configuration.</li> |
100 |
* @param arg0, the View part selected in the View |
| 161 |
* <li>Click the <b>Profiling</b> tab, then the <b>Overview</b> tab.</li> |
101 |
*/ |
| 162 |
* <li>Select a profiling set that is shared by more than one launch configurations.</li> |
102 |
public void verifyNoCollectedInstances(org.eclipse.ui.IViewPart arg0) |
| 163 |
* <li>Click <b>Remove</b> button.</li> |
|
|
| 164 |
* <li>A warning dialog should show up with an appropriate message.</li> |
| 165 |
* <li>Click <b>Yes</b></li> |
| 166 |
* <li>Check to ensure that the profiling set for the involved launch configurations in step 3 updated accordingly.</li> |
| 167 |
* </ol> |
| 168 |
* <p> |
| 169 |
* <b>Purpose:</b> Perform the verification in step #7 |
| 170 |
* @throws Exception |
| 171 |
*/ |
| 172 |
public void verifyProfilingSetRemoveWarningYes3(org.eclipse.swt.widgets.Shell arg0) |
| 173 |
throws Exception |
| 174 |
{ |
| 175 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfilingSetRemoveWarningYes3"); |
| 176 |
verifySelectedTreeItem(arg0, "RemovingSetWarningYes2"); |
| 177 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfilingSetRemoveWarningYes3"); |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Verify profiling agent detached status. |
| 182 |
* <p> |
| 183 |
* <b>Testing Steps:</b> |
| 184 |
* <ol> |
| 185 |
* <li>Click on <b>Profile</b> button from the tool bar.</li> |
| 186 |
* <li>Double click on <b>External Java Application</b>.</li> |
| 187 |
* <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> button.</li> |
| 188 |
* <li>Click <b>Profile</b> button.</li> |
| 189 |
* <li>Right click on the agent, and select <b>Detach from Agent</b>.</li> |
| 190 |
* <li>Verify agent is detached.</li> |
| 191 |
* </ol> |
| 192 |
* <p> |
| 193 |
* <b>Purpose:</b> Perform the verification in step #6 |
| 194 |
* @throws Exception |
| 195 |
*/ |
| 196 |
public void verifyLocalDetached(org.eclipse.ui.IViewPart arg0) |
| 197 |
throws Exception |
| 198 |
{ |
| 199 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLocalDetached"); |
| 200 |
verifyAgentStatus(arg0, "detached"); |
| 201 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLocalDetached"); |
| 202 |
} |
| 203 |
|
| 204 |
/** |
| 205 |
* Verify profiling agent paused status. |
| 206 |
* <p> |
| 207 |
* <b>Testing Steps:</b> |
| 208 |
* <ol> |
| 209 |
* <li>Click on <b>Profile</b> button from the tool bar.</li> |
| 210 |
* <li>Double click on <b>External Java Application</b>.</li> |
| 211 |
* <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> button.</li> |
| 212 |
* <li>Click <b>Profile</b> button.</li> |
| 213 |
* <li>Right click on the agent, and select <b>Pause</b>.</li> |
| 214 |
* <li>Verify agent is paused.</li> |
| 215 |
* </ol> |
| 216 |
* <p> |
| 217 |
* <b>Purpose:</b> Perform the verification in step #6 |
| 218 |
* @throws Exception |
| 219 |
*/ |
| 220 |
public void verifyLocalPaused(org.eclipse.ui.IViewPart arg0) |
| 221 |
throws Exception |
103 |
throws Exception |
| 222 |
{ |
104 |
{ |
| 223 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLocalPaused"); |
105 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyNoCollectedInstances"); |
| 224 |
verifyAgentStatus(arg0, "attached"); |
|
|
| 225 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLocalPaused"); |
| 226 |
} |
| 227 |
|
| 228 |
/** |
| 229 |
* Verify profiling agent paused status. |
| 230 |
* <p> |
| 231 |
* <b>Testing Steps:</b> |
| 232 |
* <ol> |
| 233 |
* <li>Click on <b>Profile</b> button from the tool bar.</li> |
| 234 |
* <li>Double click on <b>External Java Application</b>.</li> |
| 235 |
* <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> button.</li> |
| 236 |
* <li>Click <b>Profile</b> button.</li> * |
| 237 |
* <li>Verify agent is monitoring.</li> |
| 238 |
* </ol> |
| 239 |
* <p> |
| 240 |
* <b>Purpose:</b> Perform the verification in step #5 |
| 241 |
* @throws Exception |
| 242 |
*/ |
| 243 |
public void verifyLocalMonitoring(org.eclipse.ui.IViewPart arg0) |
| 244 |
throws Exception |
| 245 |
{ |
| 246 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLocalMonitoring"); |
| 247 |
verifyAgentStatus(arg0, "monitoring"); |
| 248 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLocalMonitoring"); |
| 249 |
} |
| 250 |
|
| 251 |
/** |
| 252 |
* Verify relaunch from the profile dropdown menu on the toolbar. |
| 253 |
* <p> |
| 254 |
* <b>Testing Steps:</b> |
| 255 |
* <ol> |
| 256 |
* <li>Click on <b>Profile</b> button from the tool bar.</li> |
| 257 |
* <li>Double click on <b>External Java Application</b>.</li> |
| 258 |
* <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> button.</li> |
| 259 |
* <li>Click <b>Profile</b> button.</li> * |
| 260 |
* <li>The application should be profiled.</li> |
| 261 |
* <li>Click on the profile drop down button on the menu bar.</li> |
| 262 |
* <li>Select the configuration that corresponds to the last launched class (e.g. HelloWorld)</li> |
| 263 |
* <li>Verify the java process is relaunched and traced.</li> |
| 264 |
* </ol> |
| 265 |
* <p> |
| 266 |
* <b>Purpose:</b> Perform the verification in step #8 |
| 267 |
* @throws Exception |
| 268 |
*/ |
| 269 |
public void verifyDropDownRelaunch(org.eclipse.ui.IViewPart arg0) |
| 270 |
throws Exception |
| 271 |
{ |
| 272 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyDropDownRelaunch"); |
| 273 |
|
106 |
|
| 274 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
107 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
| 275 |
assertNotNull (memoryStatisticsView); |
108 |
assertNotNull (memoryStatisticsView); |
| 276 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
109 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 277 |
assertNotNull (tree); |
110 |
assertNotNull (tree); |
| 278 |
TreeItem[] treeItems = tree.getItems(); |
111 |
TreeItem[] treeItems = tree.getItems(); |
| 279 |
verifyAppInstances(tree, treeItems, "HelloWorld", 1, 1); |
112 |
verifyCollInstances(tree, treeItems, "StartStop", 0); |
| 280 |
|
113 |
|
| 281 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyDropDownRelaunch"); |
114 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyNoCollectedInstances"); |
| 282 |
|
115 |
} |
| 283 |
} |
116 |
|
| 284 |
|
117 |
|
| 285 |
/** |
118 |
|
| 286 |
* Verify relaunch from toolbar dropdown menu. |
119 |
/** |
| 287 |
* <p> |
120 |
* verifyCollInstances method to verify the number of collected instances in the Memory Statistics View |
| 288 |
* <b>Testing Steps:</b> |
121 |
* and it is meant to show that when the agent is detached, no instances are collected by the profiler |
| 289 |
* <ol> |
122 |
* |
| 290 |
* <li>Click on <b>Profile</b> button from the tool bar.</li> |
123 |
* @param tree, the selected tree in the view |
| 291 |
* <li>Double click on <b>External Java Application</b>.</li> |
124 |
* @param treeItems, an array containing the tree items of tree |
| 292 |
* <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> button.</li> |
125 |
* @param app, the name of application we are profiling |
| 293 |
* <li>Click <b>Profile</b> button.</li> * |
126 |
* @param totalExpected, the number of collected instances we are expecting for app |
| 294 |
* <li>The application should be profiled.</li> |
|
|
| 295 |
* <li>Click on the <b>Profile</b> button on the tool bar.</li> |
| 296 |
* <li>Verify the java process is relaunched and traced.</li> |
| 297 |
* </ol> |
| 298 |
* <p> |
| 299 |
* <b>Purpose:</b> Perform the verification in step #7 |
| 300 |
* @throws Exception |
127 |
* @throws Exception |
| 301 |
*/ |
128 |
*/ |
| 302 |
public void verifyProfileButtonRelaunch(org.eclipse.ui.IViewPart arg0) |
129 |
private void verifyCollInstances(Tree tree, TreeItem[] treeItems, String app, int totalExpected) |
| 303 |
throws Exception |
|
|
| 304 |
{ |
130 |
{ |
| 305 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfileButtonRelaunch"); |
131 |
int collectedInstancesClmnIndex = getTreeColumnIndex(tree, "Collected"); |
| 306 |
|
132 |
int appItemIndex = getTreeItemIndex(treeItems, app); |
| 307 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
133 |
int appCollInst = 0; |
| 308 |
assertNotNull (memoryStatisticsView); |
|
|
| 309 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 310 |
assertNotNull (tree); |
| 311 |
TreeItem[] treeItems = tree.getItems(); |
| 312 |
verifyAppInstances(tree, treeItems, "HelloWorld", 1, 1); |
| 313 |
|
134 |
|
| 314 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfileButtonRelaunch"); |
135 |
for(int i = 0; i < treeItems.length; i++) |
|
|
136 |
{ |
| 137 |
if( i == appItemIndex ){ |
| 138 |
appCollInst = Integer.parseInt((String)treeItems[i].getText(collectedInstancesClmnIndex)); |
| 139 |
} |
| 140 |
} |
| 141 |
/* verify the Collected Instances of the given application */ |
| 142 |
assertTrue(appCollInst == totalExpected); |
| 315 |
} |
143 |
} |
| 316 |
|
144 |
|
| 317 |
/** |
145 |
/** |
| 318 |
* Verify last launched relaunch. |
146 |
* A private helper method meant to return the index of a Tree Item given a list of all the |
| 319 |
* <p> |
147 |
* TreeItems and the String (text) we are looking for. |
| 320 |
* <b>Testing Steps:</b> |
148 |
* |
| 321 |
* <ol> |
149 |
* @param items, the array of TreeItems |
| 322 |
* <li>Profile an external Java application.</li> |
150 |
* @param item, the String text of the item we are looking for |
| 323 |
* <li>Click <b>Run</b> from toolbar, and then choose </b>Profile</b>.</li> |
151 |
* @return the index of the treeItem we are looking for |
| 324 |
* <li>Select the Java application just profiled.</li> |
152 |
*/ |
| 325 |
* <li>The application should be profiled.</li> |
153 |
private int getTreeItemIndex(TreeItem[] items, String item) |
| 326 |
* <li>Verify the java process is relaunched and traced.</li> |
|
|
| 327 |
* </ol> |
| 328 |
* <p> |
| 329 |
* <b>Purpose:</b> Perform the verification in step #5 |
| 330 |
* @throws Exception |
| 331 |
*/ |
| 332 |
public void verifyProfileLastLaunchedRelaunch(org.eclipse.ui.IViewPart arg0) |
| 333 |
throws Exception |
| 334 |
{ |
154 |
{ |
| 335 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfileLastLaunchedRelaunch"); |
155 |
int index = -1; |
| 336 |
|
156 |
for(int i = 0; i < items.length; i++) |
| 337 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
157 |
{ |
| 338 |
assertNotNull (memoryStatisticsView); |
158 |
if(items[i].getText().trim().equals(item.trim())) |
| 339 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
159 |
{ |
| 340 |
assertNotNull (tree); |
160 |
index = i; |
| 341 |
TreeItem[] treeItems = tree.getItems(); |
161 |
break; |
| 342 |
verifyAppInstances(tree, treeItems, "HelloWorld", 1, 1); |
162 |
} |
| 343 |
|
163 |
} |
| 344 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfileLastLaunchedRelaunch"); |
164 |
return index; |
| 345 |
} |
165 |
} |
| 346 |
|
166 |
|
| 347 |
|
|
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
/** |
167 |
/** |
| 352 |
* Verify profiling trace data limits for method invocations. |
168 |
* A private helper method meant to return the index of a column in the |
| 353 |
* <p> |
169 |
* Statistics view, given the Tree and the Column's header as a String |
| 354 |
* <b>Testing Steps:</b> |
170 |
* |
| 355 |
* <ol> |
171 |
* @param tree A Tree of all the columns |
| 356 |
* <li>Click on <b>Profile</b> button from the tool bar.</li> |
172 |
* @param column the String representing the column header we are looking for |
| 357 |
* <li>Double click on <b>External Java Application</b>.</li> |
173 |
* @return the index of the header |
| 358 |
* <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> |
174 |
*/ |
| 359 |
* <li>In the <b>Overview</b> tab, select <b>Execution History - Statistical</b>.</li> |
175 |
private int getTreeColumnIndex(Tree tree, String column) |
| 360 |
* <li>Go to the <b>Limits</b> tab, set the number of method invocations to limit.</li> |
|
|
| 361 |
* <li>Click <b>Profile</b> button.</li> |
| 362 |
* <li>Verify no new data is received after the specified method invocation times.</li> |
| 363 |
* </ol> |
| 364 |
* <p> |
| 365 |
* <b>Purpose:</b> Perform the verification in step #7 |
| 366 |
* @throws Exception |
| 367 |
*/ |
| 368 |
public void verifyLimitsCalls(org.eclipse.ui.IViewPart arg0) |
| 369 |
throws Exception |
| 370 |
{ |
176 |
{ |
| 371 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLimitsCalls"); |
177 |
int index = -1; |
| 372 |
|
178 |
TreeColumn[] columns = tree.getColumns(); |
| 373 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
179 |
for(int i = 0; i < columns.length; i++) |
| 374 |
assertNotNull (memoryStatisticsView); |
180 |
{ |
| 375 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
181 |
if(columns[i].getText().trim().equals(column.trim())) |
| 376 |
assertNotNull (tree); |
182 |
{ |
| 377 |
TreeItem[] treeItems = tree.getItems(); |
183 |
index = i; |
| 378 |
|
184 |
break; |
| 379 |
verifyCallsDetails(tree, treeItems, new String[]{"(default package)"}, 7, true); |
185 |
} |
| 380 |
|
186 |
} |
| 381 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLimitsCalls"); |
187 |
return index; |
| 382 |
} |
188 |
} |
| 383 |
|
189 |
|
| 384 |
/** |
190 |
/** |
| 385 |
* Verify profiling trace data limits for time. |
191 |
* TestLaunchAndAttach |
| 386 |
* <p> |
192 |
* Note: The methods below are used to verify various relaunch scenarios including: |
| 387 |
* <b>Testing Steps:</b> |
193 |
* 1- Profile last Launched |
| 388 |
* <ol> |
194 |
* 2- Using the Profile Button to Relaunch |
| 389 |
* <li>Click on <b>Profile</b> button from the tool bar.</li> |
195 |
* 3- Using the Profile Drop Down Menu to Relaunch |
| 390 |
* <li>Double click on <b>External Java Application</b>.</li> |
196 |
* |
| 391 |
* <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> |
197 |
* This test is meant to launch an external local Java applaictaion, attach |
| 392 |
* <li>In the <b>Overview</b> tab, select <b>Execution History - Statistical</b>.</li> |
198 |
* and profile and then verify the results using the two verification hooks below. |
| 393 |
* <li>Go to the <b>Limits</b> tab, specify some amount of profiling time.</li> |
199 |
* The steps to execute this test manually are: |
| 394 |
* <li>Click <b>Profile</b> button.</li> |
200 |
* 1) Select Profile> Profile.. |
| 395 |
* <li>Verify no new data is received after the specified profiling time.</li> |
201 |
* 2) Double Click External Java Application |
| 396 |
* </ol> |
202 |
* 3) Select the HelloWorld application avaiblae in the Resources folder |
| 397 |
* <p> |
203 |
* 4) Select Profile |
| 398 |
* <b>Purpose:</b> Perform the verification in step #7 |
204 |
* 5) After termination, open the Memory Statistics View |
| 399 |
* @throws Exception |
205 |
* 6) Verify that the application was profiled and appropriate data was collected |
| 400 |
*/ |
206 |
*/ |
| 401 |
public void verifyProfilingLimitsTime(org.eclipse.ui.IViewPart arg0) |
207 |
/** |
|
|
208 |
* A Method to ensure that the application in question ahs terminated profiling |
| 209 |
* In order to verify this we check teh status. Meant to ensure we do not open the |
| 210 |
* Statistics views too early |
| 211 |
* @param arg0, the ViewPart Selected (normally one of the statistics views in the Profiling and Logging Perspective) |
| 212 |
* @throws Exception |
| 213 |
*/ |
| 214 |
public void verifyMonitoringCollecting(org.eclipse.ui.IViewPart arg0) |
| 215 |
throws Exception |
| 216 |
{ |
| 217 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyMonitoringCollecting"); |
| 218 |
verifyAgentStatus(arg0, "terminated"); |
| 219 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyMonitoringCollecting"); |
| 220 |
} |
| 221 |
|
| 222 |
/** |
| 223 |
* A Method to verify the Class Level instance information in the Memory Statistics View |
| 224 |
* after an application has terminated its profiling. |
| 225 |
* |
| 226 |
* @param arg0, the View Part selected in the View |
| 227 |
* @throws Exception |
| 228 |
*/ |
| 229 |
public void verifyClassLevel(org.eclipse.ui.IViewPart arg0) |
| 402 |
throws Exception |
230 |
throws Exception |
| 403 |
{ |
231 |
{ |
| 404 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfilingLimitsTime"); |
232 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyClassLevel"); |
| 405 |
|
233 |
|
| 406 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
234 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
| 407 |
assertNotNull (memoryStatisticsView); |
235 |
assertNotNull (memoryStatisticsView); |
| 408 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
236 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 409 |
assertNotNull (tree); |
237 |
assertNotNull (tree); |
| 410 |
TreeItem[] treeItems = tree.getItems(); |
238 |
TreeItem[] treeItems = tree.getItems(); |
| 411 |
|
239 |
assertTrue(" The Tree Selected contains no items", treeItems.length > 0); |
| 412 |
assertTrue("methodB is present even though it wasn't expected to be incldued as part of the trace", getTreeItemIndex(treeItems, "methodB() void") == -1); |
240 |
/* call to verify the instances collected in this view for this particualr app*/ |
| 413 |
|
241 |
verifyAppInstances(tree, treeItems, "HelloWorld", 1, 1); |
| 414 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfilingLimitsTime"); |
242 |
|
| 415 |
} |
243 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyClassLevel"); |
| 416 |
|
|
|
| 417 |
private void verifyAgentStatus(org.eclipse.ui.IViewPart arg0, String status){ |
| 418 |
boolean found = false; |
| 419 |
Composite profileMonitor = VerifyHookUtil.getWorkbenchPartControl(arg0); |
| 420 |
assertNotNull (profileMonitor); |
| 421 |
VerifyHookUtil.widgetDump(profileMonitor); |
| 422 |
|
| 423 |
Tree tree = (Tree)VerifyHookUtil.findControl(profileMonitor, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 424 |
assertNotNull (tree); |
| 425 |
|
| 426 |
TreeItem[] treeItemSelected = tree.getSelection(); |
| 427 |
|
| 428 |
for(int i = 0; i < treeItemSelected.length; i++){ |
| 429 |
if (treeItemSelected[i].getText().indexOf(status) >= 0){ |
| 430 |
found = true; |
| 431 |
break; |
| 432 |
} |
| 433 |
} |
| 434 |
assertTrue(found); |
| 435 |
} |
| 436 |
|
| 437 |
private void verifySelectedTreeItem(org.eclipse.swt.widgets.Shell arg0, String label){ |
| 438 |
Control trees[] = VerifyHookUtil.findAllControl(arg0, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 439 |
TreeItem[] treeItemsSelected = null; |
| 440 |
boolean itemFound = false; |
| 441 |
|
| 442 |
for (int i = 0; i < trees.length; i++){ |
| 443 |
treeItemsSelected = ((Tree)trees[i]).getSelection(); |
| 444 |
|
| 445 |
for (int j = 0; j < treeItemsSelected.length; j ++){ |
| 446 |
if(treeItemsSelected[j].getText().trim().equals(label)){ |
| 447 |
itemFound = true; |
| 448 |
break; |
| 449 |
} |
| 450 |
} |
| 451 |
} |
| 452 |
assertTrue(itemFound); |
| 453 |
} |
244 |
} |
|
|
245 |
|
| 246 |
/** |
| 247 |
* A private helper method intended to verify the numebr of instances listed in the |
| 248 |
* Class level view of the Memory Statistics view for an application. |
| 249 |
* It takes in an expected number of total and live instances and compares them |
| 250 |
* with the numbers reproted in the view, making sure they are equal |
| 251 |
* |
| 252 |
* @param tree, the selected tree in the View |
| 253 |
* @param treeItems, an arary of the items in tree |
| 254 |
* @param app, the name as a String of the application we are profiling |
| 255 |
* @param totalExpected, the total number of instances expected |
| 256 |
* @param activeExpected, the total number of live instances expected |
| 257 |
*/ |
| 258 |
private void verifyAppInstances(Tree tree, TreeItem[] treeItems, String app, int totalExpected, int activeExpected) |
| 259 |
{ |
| 454 |
|
260 |
|
| 455 |
|
261 |
// in order to make the test case more flexible so it can be run on different machines, we allow a threshold of error for the |
| 456 |
private void verifyAppInstances(Tree tree, TreeItem[] treeItems, String app, int totalExpected, int activeExpected){ |
262 |
// hard-coded values for number of instances in StartStop |
| 457 |
|
263 |
|
| 458 |
int totalInstancesClmnIndex = getTreeColumnIndex(tree, "Total Instances"); |
264 |
int totalInstancesClmnIndex = getTreeColumnIndex(tree, "Total Instances"); |
| 459 |
int liveInstancesClmnIndex = getTreeColumnIndex(tree, "Live Instances"); |
265 |
int liveInstancesClmnIndex = getTreeColumnIndex(tree, "Live Instances"); |
| 460 |
|
|
|
| 461 |
int appItemIndex = getTreeItemIndex(treeItems, app); |
266 |
int appItemIndex = getTreeItemIndex(treeItems, app); |
| 462 |
|
|
|
| 463 |
int appTotalInst = 0; |
267 |
int appTotalInst = 0; |
| 464 |
int appLiveInst = 0; |
268 |
int appLiveInst = 0; |
| 465 |
|
269 |
|
| 466 |
for(int i = 0; i < treeItems.length; i++){ |
270 |
for(int i = 0; i < treeItems.length; i++) |
| 467 |
if( i == appItemIndex ){ |
271 |
{ |
|
|
272 |
if( i == appItemIndex ) |
| 273 |
{ |
| 468 |
appTotalInst = Integer.parseInt((String)treeItems[i].getText(totalInstancesClmnIndex)); |
274 |
appTotalInst = Integer.parseInt((String)treeItems[i].getText(totalInstancesClmnIndex)); |
| 469 |
appLiveInst = Integer.parseInt((String)treeItems[i].getText(liveInstancesClmnIndex)); |
275 |
appLiveInst = Integer.parseInt((String)treeItems[i].getText(liveInstancesClmnIndex)); |
|
|
276 |
|
| 470 |
} |
277 |
} |
| 471 |
} |
278 |
} |
| 472 |
|
279 |
if (totalExpected > 5000) |
| 473 |
/* verify the Total Instances and Live Instances of App */ |
280 |
{ |
| 474 |
assertTrue(appTotalInst == totalExpected); |
281 |
// then we know we are in the StartStop case so we allow a threshold to make the tes more flexible |
| 475 |
assertTrue(appLiveInst == activeExpected); |
282 |
assertTrue("<EXPECTED TOTAL INSTANCES ARE TOO FAR FROM THE ACTUAL VALUES>",(appTotalInst <= totalExpected + 500) && (appTotalInst >= totalExpected-500) ); |
| 476 |
} |
283 |
assertTrue("<EXPECTED ACTIVE INSTANCES ARE TOO FAR FROM THE ACTUAL VALUES>",(appLiveInst <= activeExpected + 500) && (appLiveInst >= activeExpected-500) ); |
| 477 |
|
284 |
} |
| 478 |
private int getTreeItemIndex(TreeItem[] items, String item){ |
285 |
else |
| 479 |
int index = -1; |
286 |
{ /* verify the Total Instances and Live Instances of App */ |
| 480 |
|
287 |
assertTrue("<EXPECTED TOTAL INSTANCES>" + totalExpected + "<ACTUAL TOTAL INSTANCES> " + appTotalInst,appTotalInst == totalExpected); |
| 481 |
for(int i = 0; i < items.length; i++){ |
288 |
assertTrue("<EXPECTED ACTIVE INSTANCES>" + activeExpected + "<ACTUAL ACTIVE INSTANCES> " + appLiveInst, appLiveInst == activeExpected); |
| 482 |
if(items[i].getText().trim().equals(item.trim())){ |
|
|
| 483 |
index = i; |
| 484 |
break; |
| 485 |
} |
| 486 |
} |
289 |
} |
| 487 |
return index; |
|
|
| 488 |
} |
| 489 |
|
| 490 |
private int[] getTreeItemIndexes(TreeItem[] items, String[] names){ |
| 491 |
|
| 492 |
int[] indexes = new int[names.length]; |
| 493 |
|
| 494 |
for(int i = 0; i < names.length; i++){ |
| 495 |
indexes[i] = getTreeItemIndex(items, names[i]); |
| 496 |
} |
| 497 |
return indexes; |
| 498 |
} |
290 |
} |
|
|
291 |
|
| 499 |
|
292 |
|
| 500 |
private int getTreeColumnIndex(Tree tree, String column){ |
293 |
|
| 501 |
int index = -1; |
294 |
/** |
|
|
295 |
* TestProfilingLimitCalls |
| 296 |
* |
| 297 |
* This test case is designed to test the feature allowing a user to |
| 298 |
* limit the data collected and stop profilign after a certain number |
| 299 |
* of method invocations. The steps are as follows: |
| 300 |
* |
| 301 |
* 1) Select Profile> Profile... |
| 302 |
* 2) Double Click on External Java Application |
| 303 |
* 3) Name it Limits |
| 304 |
* 4) Under the Main Tab point to the Limits.class in the Resource Folder |
| 305 |
* 5) Select only Execution Time Analysis under Monitor |
| 306 |
* 6) Select Java Profiling Options |
| 307 |
* 7) Select Edit Options |
| 308 |
* 8) Next |
| 309 |
* 9) Check next to 'stop after a certain number of invocations' |
| 310 |
* 10) Enter '7' in the field |
| 311 |
* 11) Finish> Profile |
| 312 |
* 12) Verify that once profilign has terminated, you see 7 calls in total in |
| 313 |
* the package level view. |
| 314 |
* |
| 315 |
* @param arg0, the view part selected in the view |
| 316 |
* @throws Exception |
| 317 |
*/ |
| 318 |
public void verifyProfilingLimitsCalls(org.eclipse.ui.IViewPart arg0) |
| 319 |
throws Exception |
| 320 |
{ |
| 321 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfilingLimitsCalls"); |
| 502 |
|
322 |
|
| 503 |
TreeColumn[] columns = tree.getColumns(); |
323 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
| 504 |
for(int i = 0; i < columns.length; i++){ |
324 |
assertNotNull (memoryStatisticsView); |
| 505 |
if(columns[i].getText().trim().equals(column.trim())){ |
325 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 506 |
index = i; |
326 |
assertNotNull (tree); |
| 507 |
break; |
327 |
TreeItem[] treeItems = tree.getItems(); |
| 508 |
} |
328 |
assertTrue(" The selected Tree has no treeItems", treeItems.length >0); |
| 509 |
} |
329 |
verifyCallsDetails(tree, treeItems, new String[]{"(default package)"}, 7, true); |
| 510 |
return index; |
330 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLimitsCalls"); |
|
|
331 |
|
| 332 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfilingLimitsCalls"); |
| 511 |
} |
333 |
} |
|
|
334 |
|
| 335 |
/** |
| 336 |
* A private helper method which verifies the information in a Statistics View |
| 337 |
* of the Profiling and Logging Perspective. |
| 338 |
* It takes in the number of calls we are expecting and compares them to what is |
| 339 |
* actually there. |
| 340 |
* |
| 341 |
* @param tree |
| 342 |
* @param treeItems |
| 343 |
* @param names |
| 344 |
* @param callTimes |
| 345 |
* @param equal |
| 346 |
*/ |
| 512 |
|
347 |
|
| 513 |
private void verifyCallsDetails(Tree tree, TreeItem[] treeItems, String[] names, int callTimes, boolean equal){ |
348 |
private void verifyCallsDetails(Tree tree, TreeItem[] treeItems, String[] names, int callTimes, boolean equal) |
| 514 |
|
349 |
{ |
| 515 |
int callsClmnIndex = getTreeColumnIndex(tree, "Calls"); |
350 |
int callsClmnIndex = getTreeColumnIndex(tree, "Calls"); |
| 516 |
int[] indexes = getTreeItemIndexes(treeItems, names); |
351 |
int[] indexes = getTreeItemIndexes(treeItems, names); |
| 517 |
|
|
|
| 518 |
ArrayList calls = new ArrayList(); |
352 |
ArrayList calls = new ArrayList(); |
| 519 |
|
353 |
|
| 520 |
for(int i = 0; i < treeItems.length; i++){ |
354 |
for(int i = 0; i < treeItems.length; i++) |
| 521 |
if(isIn(i, indexes)){ |
355 |
{ |
|
|
356 |
if(isIn(i, indexes)) |
| 357 |
{ |
| 522 |
calls.add(treeItems[i].getText(callsClmnIndex)); |
358 |
calls.add(treeItems[i].getText(callsClmnIndex)); |
| 523 |
} |
359 |
} |
| 524 |
} |
360 |
} |
| 525 |
|
361 |
|
| 526 |
/* This section verifies following requirments: calls >= callTimes */ |
362 |
/* This section verifies following requirments: calls >= callTimes */ |
| 527 |
Object[] callsObj = calls.toArray(); |
363 |
Object[] callsObj = calls.toArray(); |
|
|
364 |
assertTrue(" The calls Column has not been properly selected",callsObj.length >0); |
| 528 |
|
365 |
|
| 529 |
for(int j = 0; j < callsObj.length; j++){ |
366 |
for(int j = 0; j < callsObj.length; j++) |
| 530 |
if(equal){ |
367 |
{ |
| 531 |
assertTrue(Integer.parseInt((String)callsObj[j]) == callTimes); |
368 |
if(equal) |
| 532 |
}else{ |
369 |
{ |
|
|
370 |
assertTrue("<ACTUAL NUMBER OF INVOCATIONS> " + (String)callsObj[j] + " <EXPECTED NUMBER OF INVOCATIONS> " + callTimes,Integer.parseInt((String)callsObj[j]) == callTimes); |
| 371 |
}else |
| 372 |
{ |
| 533 |
assertTrue(Integer.parseInt((String)callsObj[j]) >= callTimes); |
373 |
assertTrue(Integer.parseInt((String)callsObj[j]) >= callTimes); |
| 534 |
} |
374 |
} |
| 535 |
} |
375 |
} |
| 536 |
} |
376 |
} |
| 537 |
|
377 |
|
| 538 |
private boolean isIn(int index, int[] nums){ |
378 |
/** |
| 539 |
for(int i = 0; i < nums.length; i++){ |
379 |
* A private helper method which returns a boolean value representing whether |
| 540 |
if(index == nums[i]){ |
380 |
* or not a given int is in a given array of numbers. |
|
|
381 |
* |
| 382 |
* @param index The int we are looking for |
| 383 |
* @param nums The array of ints we are looking in |
| 384 |
* @return True if index IsIn nums, False otherwise. |
| 385 |
*/ |
| 386 |
private boolean isIn(int index, int[] nums) |
| 387 |
{ |
| 388 |
for(int i = 0; i < nums.length; i++) |
| 389 |
{ |
| 390 |
if(index == nums[i]) |
| 391 |
{ |
| 541 |
return true; |
392 |
return true; |
| 542 |
} |
393 |
} |
| 543 |
} |
394 |
} |
| 544 |
return false; |
395 |
return false; |
|
|
396 |
} |
| 397 |
|
| 398 |
private int[] getTreeItemIndexes(TreeItem[] items, String[] names){ |
| 399 |
|
| 400 |
int[] indexes = new int[names.length]; |
| 401 |
|
| 402 |
for(int i = 0; i < names.length; i++){ |
| 403 |
indexes[i] = getTreeItemIndex(items, names[i]); |
| 404 |
} |
| 405 |
return indexes; |
| 545 |
} |
406 |
} |
|
|
407 |
|
| 408 |
/** |
| 409 |
* TestProfilingLimitsTime |
| 410 |
* |
| 411 |
* This test case is designed to test the feature allowing a user to |
| 412 |
* limit the data collected and stop profiling after a certain number |
| 413 |
* of seconds. The steps are as follows: |
| 414 |
* |
| 415 |
* 1) Select Profile> Profile... |
| 416 |
* 2) Double Click on External Java Application |
| 417 |
* 3) Name it Limits |
| 418 |
* 4) Under the Main Tab point to the Limits.class in the Resource Folder |
| 419 |
* 5) Select only Execution Time Analysis under Monitor |
| 420 |
* 6) Select Java Profiling Options |
| 421 |
* 7) Select Edit Options |
| 422 |
* 8) Next |
| 423 |
* 9) Check next to 'stop profiling after a specified amount of time' |
| 424 |
* 10) Enter '5' in the field (or accept default if its 5) |
| 425 |
* 11) Finish> Profile |
| 426 |
* 12) Verify that once profilign has terminated, you do not see the MethodB invocatoinas called since it takes longer than 5 seconds to |
| 427 |
* be called. |
| 428 |
* |
| 429 |
* @param arg0, the ViewPart selected in the View |
| 430 |
* @throws Exception |
| 431 |
*/ |
| 432 |
|
| 433 |
public void verifyProfilingLimitsTime(org.eclipse.ui.IViewPart arg0) |
| 434 |
throws Exception |
| 435 |
{ |
| 436 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfilingLimitsTime"); |
| 437 |
|
| 438 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
| 439 |
assertNotNull (memoryStatisticsView); |
| 440 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 441 |
assertNotNull (tree); |
| 442 |
TreeItem[] treeItems = tree.getItems(); |
| 443 |
assertTrue("The selected Tree has no treeItems", treeItems.length >0); |
| 444 |
assertTrue("methodB is present even though it wasn't expected to be incldued as part of the trace", getTreeItemIndex(treeItems, "methodB() void") == -1); |
| 445 |
|
| 446 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfilingLimitsTime"); |
| 447 |
} |
| 448 |
|
| 449 |
/** |
| 450 |
* |
| 451 |
* A test to verify that when Monitoring is paused, there is no data being collected |
| 452 |
* and when monitoring is resumed, data is collected again from the application. |
| 453 |
* |
| 454 |
* This method does so by verifying that the status of teh agent is set to paused when the |
| 455 |
* Pause option is selected. Verification of the data collection being paused is accomplished in otehr methods |
| 456 |
* |
| 457 |
* @throws Exception |
| 458 |
*/ |
| 459 |
public void verifyLocalPaused(org.eclipse.ui.IViewPart arg0) |
| 460 |
throws Exception |
| 461 |
{ |
| 462 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLocalPaused"); |
| 463 |
verifyAgentStatus(arg0, "attached"); |
| 464 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLocalPaused"); |
| 465 |
} |
| 466 |
|
| 467 |
/** |
| 468 |
* TestLocalPauseAndResume |
| 469 |
* |
| 470 |
* This verification method tests to ensure that the data collection is also paused |
| 471 |
* when monitoring has been paused. |
| 472 |
* |
| 473 |
* 1) Select Profile> Profile... |
| 474 |
* 2) Double Click on External Java Application |
| 475 |
* 3) Name it StartStop |
| 476 |
* 4) Under the Main Tab point to the Limits.class in the Resource Folder |
| 477 |
* 5) Select only Memory Statistics under Monitor |
| 478 |
* 6) Sleect Profile |
| 479 |
* 7) Once profiling has started, press Enter once in the Console View |
| 480 |
* 8) Select the AGent and Right Click > Pause |
| 481 |
* 9) Verify that the status changes to paused |
| 482 |
* 10) Open the Memory Statistic View and check the numebr of instances (total and active) |
| 483 |
* 11) Resume Monitoring |
| 484 |
* 12) Press Enter againin the console View |
| 485 |
* 13) Open the Mem Stats again and ensure taht monitoring resumed and taht tehre are more instances |
| 486 |
* (active and total) than there were in step 10. |
| 487 |
* |
| 488 |
* verifyLocalInstancesPaused performs the verification is Step 10) |
| 489 |
* |
| 490 |
* @arg0 The viewPart selected in the View |
| 491 |
* @throws Exception |
| 492 |
*/ |
| 493 |
public void verifyLocalInstancesPaused(org.eclipse.ui.IViewPart arg0) |
| 494 |
throws Exception |
| 495 |
{ |
| 496 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLocalInstancesPaused"); |
| 497 |
|
| 498 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
| 499 |
assertNotNull (memoryStatisticsView); |
| 500 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 501 |
assertNotNull (tree); |
| 502 |
TreeItem[] treeItems = tree.getItems(); |
| 503 |
assertTrue(" The selected Tree has no treeItems", treeItems.length >0); |
| 504 |
verifyAppInstances(tree, treeItems, "(default package)", 5163,5163); |
| 505 |
|
| 506 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLocalInstancesPaused"); |
| 507 |
} |
| 508 |
|
| 509 |
/** |
| 510 |
* TestLocalPauseAndResume |
| 511 |
* |
| 512 |
* This method is meant to verify that after a pause ahs been resumed, the agent's status |
| 513 |
* read's 'Monitoring' again. The verification of data collection is doen in other methods |
| 514 |
* |
| 515 |
* @throws Exception |
| 516 |
*/ |
| 517 |
public void verifyLocalMonitoring(org.eclipse.ui.IViewPart arg0) |
| 518 |
throws Exception |
| 519 |
{ |
| 520 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLocalMonitoring"); |
| 521 |
verifyAgentStatus(arg0, "monitoring"); |
| 522 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLocalMonitoring"); |
| 523 |
} |
| 524 |
|
| 525 |
/** |
| 526 |
* This method performs the verification in Step 13) of verifyLocalPauseAndResume |
| 527 |
* It is meant to show that the data collection resumes correctly after a pause and resume |
| 528 |
* of the agent. |
| 529 |
* |
| 530 |
* @throws Exception |
| 531 |
*/ |
| 532 |
public void verifyLocalInstancesMonitoring(org.eclipse.ui.IViewPart arg0) |
| 533 |
throws Exception |
| 534 |
{ |
| 535 |
Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLocalInstancesMonitoring"); |
| 536 |
|
| 537 |
Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0); |
| 538 |
assertNotNull (memoryStatisticsView); |
| 539 |
Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null); |
| 540 |
assertNotNull (tree); |
| 541 |
TreeItem[] treeItems = tree.getItems(); |
| 542 |
assertTrue(" The selected Tree has no treeItems", treeItems.length >0); |
| 543 |
verifyAppInstances(tree, treeItems, "(default package)", 5204,5204); |
| 544 |
|
| 545 |
Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLocalInstancesMonitoring"); |
| 546 |
} |
| 547 |
|
| 548 |
|
| 549 |
|
| 546 |
} |
550 |
} |