Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 165936
Collapse All | Expand All

(-)src/org/eclipse/hyades/use/cases/auto/profiling/logging/PlatformUIProfilingPerspectiveLaunchPart5.java (-346 / +485 lines)
Lines 1-5 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
import java.util.ArrayList;
3
import java.util.Hashtable;
4
import java.util.Hashtable;
4
5
5
import org.eclipse.hyades.use.cases.auto.common.Logger;
6
import org.eclipse.hyades.use.cases.auto.common.Logger;
Lines 14-30 Link Here
14
import org.eclipse.tptp.test.auto.gui.internal.runner.AutoGUIVerificationHook;
15
import org.eclipse.tptp.test.auto.gui.internal.runner.AutoGUIVerificationHook;
15
16
16
/**
17
/**
17
 * Generated code for the test suite <b>Platform.UI.Profiling.PerspectiveLaunch.Part6</b> located at
18
 * Generated code for the test suite <b>Platform.UI.ProfilingPerspective.Launch.Part5</b> located at
18
 * <i>/org.eclipse.hyades.use.cases/gui/Profiling_and_Logging/Platform.UI.ProfilingPerspective.Launch.Part6.testsuite</i>.
19
 * <i>/org.eclipse.hyades.use.cases/gui/Profiling_and_Logging/Launch/Platform.UI.ProfilingPerspective.Launch.Part5.testsuite</i>.
20
 * Please review the Test Overview and adjust varaible wait times (under the Behaviour Tab) before starting.
19
 */
21
 */
20
/*
22
	public class PlatformUIProfilingPerspectiveLaunchPart5 extends
21
 * Author: Mike Hao
22
 */
23
public class PlatformUIProfilingPerspectiveLaunchPart5 extends
24
		AutoGUIVerificationHook {
23
		AutoGUIVerificationHook {
25
24
26
	/**
25
	/**
27
	 * Constructor for PlatformUIProfilingPerspectiveLaunchPart6.  An instance of this class is created to
26
	 * Constructor for PlatformUIProfilingPerspectiveLaunchPart5.  An instance of this class is created to
28
	 * test a test method.
27
	 * test a test method.
29
	 *
28
	 *
30
	 * @param testMethodName The test method to be tested.
29
	 * @param testMethodName The test method to be tested.
Lines 46-334 Link Here
46
	 * @see junit.framework.TestCase#tearDown()
45
	 * @see junit.framework.TestCase#tearDown()
47
	 */
46
	 */
48
	protected void tearDown() throws Exception {
47
	protected void tearDown() throws Exception {
49
		Logger.getInstance().close();
50
	}
48
	}
51
49
52
    /**
50
	/**
53
	* Verify Java Application launch configuration automatic creation.
51
	* TestJavaAppLaunchShortCut
54
	* <p>
52
	*  
55
	* <b>Testing Steps:</b>
53
	*  A test to ensure that the shortcut to launching a Profile of a Java application
56
	* <ol>
54
	*  succeeds and collectes data correctly
57
	* <li>Remove all existing Java Application launch configurations.</li>
55
	*  
58
	* <li>Create a new Java Project in your workspace containing a class with a main() method.</li>
56
	*  1) Import a Java Application (done in test ImportJavaApp)
59
	* <li>In the <b>Package Explorer</b> of the <b>Java Perspective</b>, right click on the class, select <b>Profile As</b>, then <b>Java Application</b>.</li>    
57
	*  2) Select the .java file and Select Profile As >Java Application
60
	* <li>Verify the launch configuration dialog opens with valid defaults. Click <b>Profile</b></li>    
58
	*  3) Select Execution Statistics
61
	* <li>Verify the application is profiled and contains valid data.</li> 
59
	*  4) Select Profile
62
	* </ol>
60
	*  5) Verify that the correct Execution Statistics were collected
63
	* <p>
61
	*  
64
	* <b>Purpose:</b> Perform the verification in step #5
62
	*  This method performs the verification in Step 5)
63
	*  
64
	* @param arg0 The Viewpart selected in the View
65
	* @throws Exception
65
	* @throws Exception
66
	*/		
66
	*/
67
	public void verifyLaunchShortCut(org.eclipse.ui.IViewPart arg0)
67
	public void verifyCollectedData(org.eclipse.ui.IViewPart arg0)
68
	throws Exception
68
	throws Exception
69
	{
69
	{
70
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLaunchShortCut");	
70
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyCollectedData");
71
		verifyCallsDetails(arg0, new String[]{"HelloWorld()"}, new int[] {1}, true);		
71
		verifyCallsDetails(arg0, new String[]{"HelloWorld()"}, new int[] {1}, true);		
72
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLaunchShortCut");
72
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyCollectedData");
73
	}
73
	}
74
74
75
	/**
76
	* Verify Java Application launch configuration automatic creation.
77
	* <p>
78
	* <b>Testing Steps:</b>
79
	* <ol>
80
	* <li>Remove all existing Java Application launch configurations.</li>
81
	* <li>Create a new Java Project in your workspace containing a class with a main() method.</li>
82
	* <li>In the <b>Package Explorer</b> of the <b>Java Perspective</b>, right click on the class, select <b>Profile As</b>, then <b>Java Application</b>.</li>    
83
	* <li>Verify the launch configuration dialog opens with valid defaults.</li>   
84
	* <li>Add some filter to the profiled class. Click <b>Profile</b></li>     
85
	* <li>Verify the application is profiled and contains valid filtered data.</li> 
86
	* </ol>
87
	* <p>
88
	* <b>Purpose:</b> Perform the verification in step #5
89
	* @throws Exception
90
	*/		
91
	public void verifyLaunchShortCutWithFilter(org.eclipse.ui.IViewPart arg0)
92
	throws Exception
93
	{
94
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLaunchShortCutWithFilter");	
95
		verifyCallsDetails(arg0, new String[]{"HelloWorld()"}, new int[]{1}, true);		
96
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLaunchShortCutWithFilter");
97
	}
98
99
	/**
100
	* Verify Java Application launch shortcut with selection.
101
	* <p>
102
	* <b>Testing Steps:</b>
103
	* <ol>
104
	* <li>Remove all existing Java Application launch configurations.</li>
105
	* <li>Create a new Java Project in your workspace containing a class with a main() method.</li>
106
	* <li>Create a Java Application profile configuration for this new Java class with a name.</li>
107
	* <li>In the <b>Package Explorer</b> of the <b>Java Perspective</b>, right click on the class, select <b>Profile As</b>, then <b>Java Application</b>.</li>
108
	* <li>Verify the launch configuration dialog appears with the existing launch configuration.</li>
109
	* <li>Create a second Java Application profile configuration for the same class with different name and profiling settings.</li>
110
	* <li>In the <b>Package Explorer</b> of the <b>Java Perspective</b>, right click on the class, select <b>Profile As</b>, then <b>Java Application</b>.</li>    
111
	* <li>Verify a dialog appears with two launch configurations available.</li>   
112
	* <li>Select one configuration and Click <b>Ok</b></li>     
113
	* <li>Verify the application is profiled with the selected configuration.</li> 
114
	* </ol>
115
	* <p>
116
	* <b>Purpose:</b> Perform the verification in step #5
117
	* @throws Exception
118
	*/		
119
	public void verifyLaunchConfigName(org.eclipse.swt.widgets.Shell arg0)
120
	throws Exception
121
	{
122
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyLaunchConfigName");	
123
		assertNotNull(VerifyHookUtil.findControl(arg0, VerifyHookUtil.TEXT_CONTROL_TYPE, "HelloWorldNoFilter"));
124
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyLaunchConfigName");
125
	}
126
127
	/**
128
	* Verify Java Application launch shortcut with selection.
129
	* <p>
130
	* <b>Testing Steps:</b>
131
	* <ol>
132
	* <li>Remove all existing Java Application launch configurations.</li>
133
	* <li>Create a new Java Project in your workspace containing a class with a main() method.</li>
134
	* <li>Create a Java Application profile configuration for this new Java class with a name.</li>
135
	* <li>In the <b>Package Explorer</b> of the <b>Java Perspective</b>, right click on the class, select <b>Profile As</b>, then <b>Java Application</b>.</li>
136
	* <li>Verify the launch configuration dialog appears with the existing launch configuration.</li>
137
	* <li>Create a second Java Application profile configuration for the same class with different name and profiling settings.</li>
138
	* <li>In the <b>Package Explorer</b> of the <b>Java Perspective</b>, right click on the class, select <b>Profile As</b>, then <b>Java Application</b>.</li>    
139
	* <li>Verify a dialog appears with two launch configurations available.</li>   
140
	* <li>Select one configuration and Click <b>Ok</b></li>     
141
	* <li>Verify the application is profiled with the selected configuration.</li> 
142
	* </ol>
143
	* <p>
144
	* <b>Purpose:</b> Perform the verification in step #5
145
	* @throws Exception
146
	*/		
147
	public void verifyShortCutSelection(org.eclipse.ui.IViewPart arg0)
148
	throws Exception
149
	{
150
        Logger.getInstance().logMessage(Logger.INFO, "Entering verifyShortCutSelection");	
151
		verifyCallsDetails(arg0, new String[]{"HelloWorld()"}, new int[]{1}, true);		
152
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyShortCutSelection");
153
	}
154
155
	/**
156
	* Verify Java Applet launch configuration automatic creation.
157
	* <p>
158
	* <b>Testing Steps:</b>
159
	* <ol>
160
	* <li>Remove all existing Java Applet launch configurations.</li>
161
	* <li>Create a new Java Project in your workspace containing a class that extends Applet.</li>
162
	* <li>In the <b>Package Explorer</b> of the <b>Java Perspective</b>, right click on the class, select <b>Profile As</b>, then <b>Java Applet</b>.</li>    
163
	* <li>Verify the launch configuration dialog opens with valid defaults. Click <b>Profile</b></li>    
164
	* <li>Verify the application is profiled and contains valid data.</li> 
165
	* </ol>
166
	* <p>
167
	* <b>Purpose:</b> Perform the verification in step #5
168
	* @throws Exception
169
	*/		
170
	public void verifyAppletLaunchShortCut(org.eclipse.ui.IViewPart arg0)
171
	throws Exception
172
	{
173
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyAppletLaunchShortCut");	
174
		verifyCallsDetails(arg0, new String[]{"TestApplet()"}, new int[]{1}, true);		
175
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyAppletLaunchShortCut");
176
177
	}
178
	
75
	
179
180
	/**
76
	/**
181
	* Verify Java application arguments passed correctly.
77
	 *  A private helper method which verifies the information in a Statistics View
182
	* <p>
78
	 *  of the Profiling and Logging Perspective.
183
	* <b>Testing Steps:</b>
79
	 *  It takes in the number of calls we are expecting and compares them to what is
184
	* <ol>
80
	 *  actually there.
185
	* <li>Create a simple java application that prints out all its program arguments.</li>
81
	 *  
186
	* <li>Profile this java application as a <b>Java Application</b></li>
82
	 * @param tree The tree input
187
	* <li>Specify several program arguments, including some in the middle starting with a dash '-'.</li>    
83
	 * @param treeItems The TreeItems in tree
188
	* <li>Verify the arguments were passed correctly.</li>   
84
	 * @param names The names of the methods we are looking for
189
	* </ol>
85
	 * @param callTimes The expected callTimes
190
	* <p>
86
	 * @param equal boolean of whether we expect them to be equal or not
191
	* <b>Purpose:</b> Perform the verification in step #4
87
	 */
192
	* @throws Exception
193
	*/	
194
	public void verifyJavaAppArgs(org.eclipse.ui.IViewPart arg0)
195
	throws Exception
196
	{
197
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyJavaAppArgs");	
198
		verifyConsoleMessage(arg0, new String[] {"arg1", "-arg2", "arg3"});		
199
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyJavaAppArgs");
200
	}
201
202
	/**
203
	* Verify Java Applet launch configuration automatic creation.
204
	* <p>
205
	* <b>Testing Steps:</b>
206
	* <ol>
207
	* <li>Remove all existing Java Applet launch configurations.</li>
208
	* <li>Create a new Java Project in your workspace containing a class that extends Applet.</li>
209
	* <li>In the <b>Package Explorer</b> of the <b>Java Perspective</b>, right click on the class, select <b>Profile As</b>, then <b>Java Applet</b>.</li>    
210
	* <li>Verify the launch configuration dialog opens with valid defaults. Click <b>Profile</b></li>    
211
	* <li>Verify the application is profiled and contains valid data.</li> 
212
	* </ol>
213
	* <p>
214
	* <b>Purpose:</b> Perform the verification in step #5
215
	* @throws Exception
216
	*/	
217
	public void verifyJUnitLaunchShortCut(org.eclipse.ui.IViewPart arg0)
218
	throws Exception
219
	{
220
		boolean doesExist = false;
221
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyJUnitFailure");
222
		Composite junitView = VerifyHookUtil.getWorkbenchPartControl(arg0);
223
		assertNotNull (junitView);
224
		Control[] tables = VerifyHookUtil.findAllControl(junitView, VerifyHookUtil.TABLE_CONTROL_TYPE, null);
225
		for (int i = 0; i < tables.length; i++) 
226
		{
227
			TableItem item= VerifyHookUtil.findTableItem((Table)tables[i], 0, "junit.framework.AssertionFailedError");
228
			if (item !=null){
229
				doesExist = true;
230
				break;
231
			}
232
		}
233
		assertTrue(doesExist);
234
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyJUnitFailure");
235
	}
236
	
237
	/**
238
	* Verify profiling filters via Properties.
239
	* <p>
240
	* <b>Testing Steps:</b>
241
	* <ol>
242
	* <li>Click on <b>Profile</b> button from the tool bar.</li>
243
	* <li>Double click on <b>External Java Application</b>.</li>
244
	* <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> button.</li>    
245
	* <li>Switch to <b>Profile</b> tab.</li>  
246
	* <li>Select <b>Execution History</b>, then click on the <b>Edit</b> button.<li>    
247
	* <li>Click <b>Next</b> in the resulting dialog.</li>
248
	* <li>Add some filters to the profiling set.</li>
249
	* <li>Finish the wizard, then click on the <b>Profile</b> button.</li>
250
	* <li>The application should be profiled.</li> 
251
	* <li>Right click on the profile agent and select <b>Properties</b>.</li>
252
	* <li>Find the filters page and modify the filter set. Click <b>Finish.</b></li>
253
	* <li>Verify all the data collected after the filter change complies with the changed filters.</li> 
254
	* </ol>
255
	* <p>
256
	* <b>Purpose:</b> Perform the verification in step #10
257
	* @throws Exception
258
	*/		
259
	public void verifyFilterViaProperties(org.eclipse.ui.IViewPart arg0)
260
	throws Exception
261
	{
262
		  Logger.getInstance().logMessage(Logger.INFO, "Entering verifyFilterViaProperties");
263
			
264
		  Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0);
265
		  assertNotNull (memoryStatisticsView);				
266
		  Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null);
267
		  assertNotNull (tree);	
268
		  TreeItem[] treeItems = tree.getItems();		
269
		  
270
			for(int i = 0; i < treeItems.length; i++){
271
				Logger.getInstance().logMessage(Logger.INFO, treeItems[i].getText());
272
			}
273
274
		  assertTrue(getTreeItemIndex(treeItems, "methodB() void") == -1 );	
275
					
276
		  Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyFilterViaProperties");
277
278
	}
279
	
280
281
282
	/**
283
	* Verify profiling agent paused and then terminated status.
284
	* <p>
285
	* <b>Testing Steps:</b>
286
	* <ol>
287
	* <li>Click on <b>Profile</b> button from the tool bar.</li>
288
    * <li>Double click on <b>External Java Application</b>.</li>
289
    * <li>In the <b>Main</b> tab, browse for a class name, and then click <b>Apply</b> button.</li>    
290
    * <li>Click <b>Profile</b> button.</li>   
291
    * <li>Right click on the agent, and select <b>Pause</b>.</li>
292
    * <li>Right click on the agent, and select <b>Terminate</b>.</li>	   
293
    * <li>Verify agent is terminated.</li> 
294
    * </ol>
295
	* <p>
296
	* <b>Purpose:</b> Perform the verification in step #7
297
	* @throws Exception
298
	*/		
299
	public void verifyPausedTerminated(org.eclipse.ui.IViewPart arg0)
300
	throws Exception
301
	{
302
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyPausedTerminate");
303
		 verifyAgentStatus(arg0, "terminated");					
304
		 Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyPausedTerminate");
305
	}
306
		
307
	private void verifyAgentStatus(org.eclipse.ui.IViewPart arg0, String status){
308
		boolean found = false;
309
		Composite profileMonitor = VerifyHookUtil.getWorkbenchPartControl(arg0);
310
		assertNotNull (profileMonitor);		
311
		
312
		Tree tree = (Tree)VerifyHookUtil.findControl(profileMonitor, VerifyHookUtil.TREE_CONTROL_TYPE, null);
313
		assertNotNull (tree);	
314
		 
315
		TreeItem[] treeItemSelected  = tree.getSelection();	
316
			
317
		for(int i = 0; i < treeItemSelected.length; i++){
318
			if (treeItemSelected[i].getText().indexOf(status) >= 0){
319
				found = true;
320
			    break;
321
			}
322
		}	
323
		assertTrue(found);
324
	}
325
	
88
	
326
	private void verifyCallsDetails(org.eclipse.ui.IViewPart arg0, String[] names, int[] callTimes, boolean equal)
89
	private void verifyCallsDetails(org.eclipse.ui.IViewPart arg0, String[] names, int[] callTimes, boolean equal)
327
	{	
90
	{	
328
		Composite statisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0);
91
		Composite statisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0);
329
		assertNotNull (statisticsView);				
92
		assertNotNull (" The Statistics View Contains no data", statisticsView);				
330
		Tree tree = (Tree)VerifyHookUtil.findAllControl(statisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null)[1];
93
		Tree tree = (Tree)VerifyHookUtil.findAllControl(statisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null)[1];
331
		assertNotNull (tree);	
94
		assertNotNull (" The Selected Tree is null", tree);	
332
		TreeItem[] treeItems = tree.getItems();
95
		TreeItem[] treeItems = tree.getItems();
333
		
96
		
334
		int callsClmnIndex = getTreeColumnIndex(tree, "Calls");
97
		int callsClmnIndex = getTreeColumnIndex(tree, "Calls");
Lines 350-359 Link Here
350
		}
113
		}
351
	}
114
	}
352
115
353
	
116
	/**
354
	private int getTreeItemIndex(TreeItem[] items, String item){
117
	 * A private helper method meant to return the index of a given item in a tree
118
	 * It takes in the Array of TreeItems and the String we are looking for and returns
119
	 * the int representation of the index of the given String in the TreeItem array.
120
	 * 
121
	 * @param items The Array of TreeItems to search
122
	 * @param item The String representation of the item we are looking for
123
	 * @return an int representing the index of item in items
124
	 */
125
	private int getTreeItemIndex(TreeItem[] items, String item)
126
	{
355
		int index = -1;		
127
		int index = -1;		
356
		
357
		for(int i = 0; i < items.length; i++){		
128
		for(int i = 0; i < items.length; i++){		
358
			if(items[i].getText().trim().equals(item.trim())){
129
			if(items[i].getText().trim().equals(item.trim())){
359
				index = i;
130
				index = i;
Lines 363-377 Link Here
363
		return index;	
134
		return index;	
364
	}
135
	}
365
	
136
	
366
	private void verifyConsoleMessage(org.eclipse.ui.IViewPart arg0, String[] keywords)
137
	/**
367
	throws Exception
138
	 *  A private helper method which takes in an array of ints and an index
368
	{		
139
	 *  and returns true if index is in nums and false otherwise.
369
		Composite consoleComposite = VerifyHookUtil.getWorkbenchPartControl(arg0);
140
	 *  
370
		assertNotNull (consoleComposite);			
141
	 * @param index The int we are looking for
371
		assertTrue (VerifyHookUtil.verifyControlValue(consoleComposite, VerifyHookUtil.STYLED_TEXT_CONTROL_TYPE, keywords));
142
	 * @param nums The array of ints we are looking in
143
	 * @return true if index is in nums, false otherwise
144
	 */
145
	private boolean isIn(int index, int[] nums)
146
	{
147
		for(int i = 0; i < nums.length; i++)
148
		{
149
			if(index == nums[i])
150
			{
151
				return true;
152
			}
153
		}
154
		return false;
372
	}
155
	}
373
156
	/**
374
	private Hashtable getTreeItemIndexes(TreeItem[] items, String[] names){		
157
	 * A private helper method which returns a Hashtable of the indices
158
	 * of the given names in the selected Tree.
159
	 * 
160
	 * @param items The given TreeItems to search
161
	 * @param names The names to search for
162
	 * @return indices, a hashtable representation of the indices of names in items
163
	 */
164
	private Hashtable getTreeItemIndexes(TreeItem[] items, String[] names)
165
	{		
375
		
166
		
376
		Hashtable indices = new Hashtable();
167
		Hashtable indices = new Hashtable();
377
		
168
		
Lines 382-388 Link Here
382
		}						
173
		}						
383
		return indices;	
174
		return indices;	
384
	}
175
	}
385
	
176
	/**
177
	 * A private helper method which returns just one index of the given 
178
	 * column header in the tree.
179
	 * 
180
	 * @param tree The tree view we are seraching in
181
	 * @param column The cokumn header we are seraching for
182
	 * @return an int representation of the index of the column in the view
183
	 */
386
	private int getTreeColumnIndex(Tree tree, String column){
184
	private int getTreeColumnIndex(Tree tree, String column){
387
		int index = -1;
185
		int index = -1;
388
		
186
		
Lines 398-484 Link Here
398
	
196
	
399
	
197
	
400
	/**
198
	/**
401
	 * - Open the profile launch configuration
199
	* A Verification hook called in multiple test cases which checks the
402
	 * - Create an external application
200
	* Agent's status to ensure that profiling has terminated before we open 
403
	 * - Select only the Execution Time Analysis
201
	* a statistical view.
404
	 * - Go to its configuration and select compressed data with manual polling of 2 seconds
202
	*  
405
	 * - Click on profile
203
	* @param arg0 the ViewPart selected in the View 
406
	 * - Wait 20 seconds
204
	* @throws Exception
407
	 * - Double click the agent and refresh
205
	*/
408
	 * - Verify the first stage of the application's status (methodA = 2 calls, methodB = 2 calls)
206
	public void verifyTerminatedStatus(org.eclipse.ui.IViewPart arg0)
409
	 * - Press enter in the console
207
	throws Exception
410
	 * - wait 20 seconds
208
	{
411
	 * - Verify the second stage of the application's status (methodA = 2 calls, methodB = 2 calls, flatMethod1 = flatMethod2 = 1 call)
209
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyTerminatedStatus");
412
	 * - Press enter
210
		verifyAgentStatus(arg0, "terminated");	
413
	 * - Verify the final stage of the application's status (methodA = 2 calls, methodB = 2 calls, flatMethod1 = flatMethod2 = 1 call, main = 1 call)
211
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyTerminatedStatus");
212
	}
213
	
214
	/**
215
	 * A private helper method to verify the String-listed status of the Agent.
216
	 * It takes in a status to compare to and seerts that this is also the status
217
	 * present during the verification.
218
	 * 
219
	 * @param arg0 The ViewPart selected in the View
220
	 * @param status The String representation of the status we are expecting
221
	 */
222
	private void verifyAgentStatus(org.eclipse.ui.IViewPart arg0, String status)
223
	{
224
		boolean found = false;
225
		Composite profileMonitor = VerifyHookUtil.getWorkbenchPartControl(arg0);
226
		assertNotNull ("The profiling monitor selected is null", profileMonitor);		
227
		VerifyHookUtil.widgetDump(profileMonitor);
228
		Tree tree = (Tree)VerifyHookUtil.findControl(profileMonitor, VerifyHookUtil.TREE_CONTROL_TYPE, null);
229
		assertNotNull ("The tree in this view is null",tree);	
230
		TreeItem[] treeItemSelected  = tree.getSelection();	
231
			
232
		for(int i = 0; i < treeItemSelected.length; i++)
233
		{
234
			if (treeItemSelected[i].getText().indexOf(status) >= 0){
235
				found = true;
236
				
237
			    break;
238
			}
239
		}	
240
		assertTrue( found);
241
	}
242
243
	/**
244
	 * A verification of the data collected when we launch a Java application with
245
	 * arguments using the shortcut
246
	 * 
247
	 * @param arg0 The ViewPart selected in the View
248
	 * @throws Exception
414
	 */
249
	 */
415
	public void verifyAggStage1(org.eclipse.ui.IViewPart arg0)
250
	public void verifyTestJavaAppLaunchShortCut(org.eclipse.ui.IViewPart arg0)
416
	throws Exception
251
	throws Exception
417
	{
252
	{
418
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyAggStage1");
253
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyTestJavaAppLaunchShortCut");
419
		verifyCallsDetails(arg0, new String[] {"methodA() void", "methodB() void"}, new int[]{2, 2}, true);
254
		verifyCallsDetails(arg0, new String[]{"HelloWorld()"}, new int[] {1}, true);
420
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyAggStage1");
255
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyTestJavaAppLaunchShortCut");
421
	}
256
	}
422
257
423
	/**
258
	/**
424
	 * - Open the profile launch configuration
259
	* TestJavaAppWithFiltersShortCut
425
	 * - Create an external application
260
	*  
426
	 * - Select only the Execution Time Analysis
261
	*  A test of the functionality of the profiling launch configuration
427
	 * - Go to its configuration and select compressed data with manual polling of 2 seconds
262
	*  with filters.
428
	 * - Click on profile
263
	*  
429
	 * - Wait 20 seconds
264
	*  1) Import a Java Application (done in test ImportJavaApp)
430
	 * - Double click the agent and refresh
265
	*  2) Select the .java file and Select Profile As> Java Application
431
	 * - Verify the first stage of the application's status (methodA = 2 calls, methodB = 2 calls)
266
	*  3) Select only Executioin statistics
432
	 * - Press enter in the console
267
	*  4) Edit filters
433
	 * - wait 20 seconds
268
	*  5) Add a new Filter which excludes the rootMethod1 in the HelloWorld Class
434
	 * - Verify the second stage of the application's status (methodA = 2 calls, methodB = 2 calls, flatMethod1 = flatMethod2 = 1 call)
269
	*  6) Profile
435
	 * - Press enter
270
	*  7) Verify that the rootMethod1 has been omitted from the Execution Statistics View
436
	 * - Verify the final stage of the application's status (methodA = 2 calls, methodB = 2 calls, flatMethod1 = flatMethod2 = 1 call, main = 1 call)
271
	*  
272
	*  The method below performs the verificationin Step 7)
273
	* @param arg0 The ViewPart selected in the View
274
	* @throws Exception
275
	*/
276
	public void verifyTestJavaAppWIthFiltersShortCut(org.eclipse.ui.IViewPart arg0)
277
	throws Exception
278
	{
279
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyTestJavaAppWIthFiltersShortCut");
280
		verifyNotInList(arg0, new String[]{"rootMethod1()"});	
281
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyTestJavaAppWIthFiltersShortCut");
282
	}
283
	
284
	/**
285
	 * A private helper method to verify that the given methodName was excluded from 
286
	 * the data collection due to filtering.
287
	 * 
288
	 * @param arg0, the View selected
289
	 * @param names, the list of names we want to ensure are not in the View
437
	 */
290
	 */
438
	public void verifyAggStage2(org.eclipse.ui.IViewPart arg0)
291
	private void verifyNotInList(org.eclipse.ui.IViewPart arg0, String[] names ){
292
	
293
	Composite statisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0);
294
	assertNotNull (" The Statistics View is null", statisticsView);				
295
	Tree tree = (Tree)VerifyHookUtil.findAllControl(statisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null)[1];
296
	assertNotNull ("There is no tree Selected in the View", tree);	
297
	TreeItem[] treeItems = tree.getItems();
298
	
299
	Hashtable indices = getTreeItemIndexes(treeItems, names); 		
300
	
301
	for (int i = 0; i < names.length; i++) 
302
	{
303
		Integer inx = (Integer)indices.get(names[i]);
304
		// need to assert that it is null because we want to ensure it has been excluded
305
		// from the list
306
		assertNull("Method " + names[i] + " was found in error", inx);	
307
	}
308
}
309
310
	/**
311
	* TestJavaAppMultiConfigs
312
	*  
313
	*  This method performs the verification in Step 6)
314
	*  
315
	* @param arg0 The Shell selected
316
	* @throws Exception
317
	*/
318
	public void verifyConfigName(org.eclipse.swt.widgets.Shell arg0)
319
	throws Exception
320
	{
321
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyConfigName");
322
		assertNotNull(VerifyHookUtil.findControl(arg0, VerifyHookUtil.TEXT_CONTROL_TYPE, "HelloWorld"));
323
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyConfigName");
324
	}
325
326
	/**
327
	* TestJavaAppMultiConfigs
328
	*  
329
	*  This method performs the verification in Step 11)
330
	*  
331
	* @param arg0 The Shell selected
332
	* @throws Exception
333
	*/
334
	public void verifyBothConfigs(org.eclipse.swt.widgets.Shell arg0)
439
	throws Exception
335
	throws Exception
440
	{
336
	{
441
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyAggStage2");
337
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyBothConfig");	
442
		verifyCallsDetails(arg0, new String[] {"methodA() void", "methodB() void",
338
		boolean doesExist = false;				
443
				"flatMethod1() void", "flatMethod2() void"}, new int[]{2, 2, 1, 1}, true);
339
		Control tables[] = VerifyHookUtil.findAllControl(arg0, VerifyHookUtil.TABLE_CONTROL_TYPE, null);
444
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyAggStage2");
340
	
341
		for(int i = 0; i < tables.length; i++)
342
		{
343
			TableItem tableItem = VerifyHookUtil.findTableItem((Table)tables[i], 0, "HelloWorld");
344
			TableItem tableItem2 = VerifyHookUtil.findTableItem((Table)tables[i], 0, "HelloWorld_2");
345
			if (tableItem != null && tableItem2 !=null)
346
			{
347
				doesExist = true;
348
				
349
			}
350
			assertTrue("The Specified Launch config is missing one or more" , doesExist);
351
			Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyBothConfig");	
352
		}
445
	}
353
	}
446
354
447
	/**
355
	/**
448
	 * - Open the profile launch configuration
356
	* TestJavaAppMultiConfigs
449
	 * - Create an external application
357
	*  
450
	 * - Select only the Execution Time Analysis
358
	*  A Test to ensure that multiple Launch configuratoins can be created for
451
	 * - Go to its configuration and select compressed data with manual polling of 2 seconds
359
	*  the same class (Profiling Launch configurations).
452
	 * - Click on profile
360
	*  
453
	 * - Wait 20 seconds
361
	*  1) Select Profile...
454
	 * - Double click the agent and refresh
362
	*  2) Create a new Profile launch configuration for a Java Application
455
	 * - Verify the first stage of the application's status (methodA = 2 calls, methodB = 2 calls)
363
	*  3) Name it HelloWorld
456
	 * - Press enter in the console
364
	*  4) Save it
457
	 * - wait 20 seconds
365
	*  5) Select the Application in the Navigator view and Select Profile As> Java Application
458
	 * - Verify the second stage of the application's status (methodA = 2 calls, methodB = 2 calls, flatMethod1 = flatMethod2 = 1 call)
366
	*  6) Verify that the name of the application is HelloWorld
459
	 * - Press enter
367
	*  7) Create a second Proflie Launch configurationfor the same application
460
	 * - Verify the final stage of the application's status (methodA = 2 calls, methodB = 2 calls, flatMethod1 = flatMethod2 = 1 call, main = 1 call)
368
	*  8) Name it HelloWorld_2 and select a different profiling set than HelloWorld
369
	*  9)  Save it
370
	*  10) Select the application and Select Profile As> Java Application
371
	*  11) Verify that both HelloWorld and HelloWorld_2 are there and Select HelloWorld
372
	*  12) Verify that the statistics specified in HelloWorld are collected correctly
373
	*  
374
	*  This method performs the verification in Step 12)
375
	*  
376
	* @param arg0 The ViewPart selected in the View
377
	* @throws Exception
378
	*/
379
	public void verifyExecutionStats(org.eclipse.ui.IViewPart arg0)
380
	throws Exception
381
	{
382
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyExecutionStats");	
383
		
384
		Composite memoryStatisticsView = VerifyHookUtil.getWorkbenchPartControl(arg0);
385
		assertNotNull (memoryStatisticsView);				
386
		Tree tree = (Tree)VerifyHookUtil.findControl(memoryStatisticsView, VerifyHookUtil.TREE_CONTROL_TYPE, null);
387
		assertNotNull (tree);	
388
		TreeItem[] treeItems = tree.getItems();
389
		assertTrue(" The Tree Selected contains no items", treeItems.length > 0);
390
		/* call to verify the instances collected in this view for this particualr app*/
391
		
392
		Logger.getInstance().logMessage(Logger.INFO, "Exiting  verifyExecutionStats");
393
		verifyAppInstances(tree, treeItems, "HelloWorld", 1, 1);
394
	}
395
	/**
396
	 * A private helper method 
397
	 * @param tree
398
	 * @param treeItems
399
	 * @param app
400
	 * @param totalExpected
401
	 * @param activeExpected
461
	 */
402
	 */
462
	public void verifyAggStage3(org.eclipse.ui.IViewPart arg0)
403
	private void verifyAppInstances(Tree tree, TreeItem[] treeItems, String app, int totalExpected, int activeExpected)
404
	{
405
	
406
		// 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 
407
		// hard-coded values for number of instances in StartStop
408
		
409
		int totalInstancesClmnIndex = getTreeColumnIndex(tree, "Total Instances");
410
		int liveInstancesClmnIndex = getTreeColumnIndex(tree, "Live Instances");	
411
		int appItemIndex = getTreeItemIndex(treeItems, app);		
412
		int appTotalInst = 0;
413
		int appLiveInst = 0;
414
	
415
		for(int i = 0; i < treeItems.length; i++)
416
		{
417
			if( i == appItemIndex )
418
			{				
419
				appTotalInst = Integer.parseInt((String)treeItems[i].getText(totalInstancesClmnIndex));
420
				appLiveInst = Integer.parseInt((String)treeItems[i].getText(liveInstancesClmnIndex));
421
				
422
			}		
423
		}	
424
		if (totalExpected > 5000)
425
		{
426
			// then we know we are in the StartStop case so we allow a threshold to make the tes more flexible
427
			assertTrue("<EXPECTED TOTAL INSTANCES ARE TOO FAR FROM THE ACTUAL VALUES>",(appTotalInst <= totalExpected + 500) && (appTotalInst >= totalExpected-500) );
428
			assertTrue("<EXPECTED ACTIVE INSTANCES ARE TOO FAR FROM THE ACTUAL VALUES>",(appLiveInst <= activeExpected + 500) && (appLiveInst >= activeExpected-500) );
429
		}
430
		else
431
		{		/* verify the Total Instances and Live Instances of App */
432
			assertTrue("<EXPECTED TOTAL INSTANCES>" + totalExpected + "<ACTUAL TOTAL INSTANCES> " + appTotalInst,appTotalInst == totalExpected);
433
			assertTrue("<EXPECTED ACTIVE INSTANCES>" + activeExpected + "<ACTUAL ACTIVE INSTANCES> " + appLiveInst, appLiveInst == activeExpected);
434
		}
435
	}
436
437
	/**
438
	* TestAggregatedAgentLaunch
439
	*  
440
	*  A test case to test the profiling of an application at multiple stages
441
	*  of execution and to verify the data collected at each stage.
442
	*  
443
	*  1)Select Profile> External Java Application
444
	*  2) Point to the AggregateAgent class in the project location/Resources
445
	*  3) Select Execution Time Analysis
446
	*  4) Profile
447
	*  5) Verify beofre you press enter in the console that the correct Methods have been profiled
448
	*  6) Press Enter
449
	*  7) Verify that in this second stage, the correct classes have been profiled
450
	*  
451
	*  
452
	*  This method performs the verification in Step 5)
453
	*  
454
	* @param arg0, the ViewPart selected in the View
455
	* @throws Exception
456
	*/
457
	public void verifyInitialCalls(org.eclipse.ui.IViewPart arg0)
458
	throws Exception
459
	{
460
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyInitialCalls");
461
		verifyCallsDetails(arg0, new String[] {"methodA() void", "methodB() void"}, new int[]{2, 2}, true);
462
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyInitialCalls");
463
	}
464
465
	/**
466
	* TestAggregatedAgentLaunch
467
	*  
468
	*  This method performs the verification in Step 7)
469
	*  
470
	* @param arg0 the ViewPart selected in the View
471
	* @throws Exception
472
	*/
473
	public void verifyCallsAfterStageTwo(org.eclipse.ui.IViewPart arg0)
463
	throws Exception
474
	throws Exception
464
	{
475
	{
465
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyAggStage3");
476
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyCallsAfterStageTwo");
466
		verifyCallsDetails(arg0, new String[] {"methodA() void", "methodB() void",
477
		verifyCallsDetails(arg0, new String[] {
467
				"flatMethod1() void", "flatMethod2() void", "main(java.lang.String[]) void"}, new int[]{2, 2, 1, 1, 1}, true);
478
				"flatMethod1() void", "flatMethod2() void"}, new int[]{1, 1}, true);
468
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyAggStage3");
479
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyCallsAfterStageTwo");
480
	}
481
	
482
	/**
483
	* TestJavaAppletLaunchShortCut
484
	*  
485
	* @throws Exception
486
	*/
487
	public void verifyTestJavaAppletLaunchSHortCut(org.eclipse.ui.IViewPart arg0)
488
	throws Exception
489
	{
490
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyTestJavaAppletLaunchSHortCut");	
491
		verifyCallsDetails(arg0, new String[]{"paint(java.awt.Graphics) void"}, new int[]{1}, true);		
492
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyTestJavaAppletLaunchSHortCut");
493
	}
494
495
	/**
496
	* TestJavaAppArgs
497
	*  
498
	* @throws Exception
499
	*/
500
	public void verifyExecutionStatsArgs(org.eclipse.ui.IViewPart arg0)
501
	throws Exception{
502
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyExecutionStatsArgs");	
503
		verifyCallsDetails(arg0, new String[]{"AppArgs()"}, new int[]{1}, true);		
504
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyExecutionStatsArgs");
505
		
506
	}
507
	/**
508
	 * A private helper method which verifies the information in the Console view
509
	 * By seraching for it in the Control selected.
510
	 * 
511
	 * @param arg0 The ViewPart selected in the View
512
	 * @param keywords The console output we are looking for
513
	 * @throws Exception
514
	 */
515
	
516
	private void verifyConsoleMessage(org.eclipse.ui.IViewPart arg0, String[] keywords)
517
	throws Exception
518
	{	
519
		Composite consoleComposite = VerifyHookUtil.getWorkbenchPartControl(arg0);
520
		assertNotNull ("There is no data in the console view", consoleComposite);			
521
		assertTrue ("Not found: " + keywords.toString(), VerifyHookUtil.verifyControlValue(consoleComposite, VerifyHookUtil.STYLED_TEXT_CONTROL_TYPE, keywords));
469
	}
522
	}
470
523
471
	/**
524
	/**
472
	* Automated GUI Test
525
	* TestJavaAppArgs
526
	*  
527
	*  This test is meant to verify the console information.
473
	*  
528
	*  
529
	* @param arg0 The ViewPart selected in the View
474
	* @throws Exception
530
	* @throws Exception
475
	*/
531
	*/
476
	public void verifyState(org.eclipse.ui.IViewPart arg0)
532
	public void verifyConsolePrintout(org.eclipse.ui.IViewPart arg0)
533
	throws Exception
534
	{
535
		{
536
			Logger.getInstance().logMessage(Logger.INFO, "Entering verifyConsolePrintout");	
537
			verifyConsoleMessage(arg0, new String[] {"-arg1", "-arg2", "-arg3"});		
538
			Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyConsolePrintout");
539
		}
540
	}
541
	/**
542
	 * A test meant to check on the profiling Data before the agent has been detached so we know
543
	 * that even after interaction (pressing Enter in StartStop), the detached agent should
544
	 * not collect any more data and we should be able to safely exclude ceratin methods from the 
545
	 * output as a verification
546
	 * 
547
	 * @param arg0 The View selected in the ViewPart
548
	 * @throws Exception
549
	 */
550
	public void verifyProfilingDataBefore(org.eclipse.ui.IViewPart arg0)
551
	throws Exception
552
	{
553
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyProfilingDataBefore");	
554
		verifyCallsDetails(arg0, new String[]{"main(java.lang.String [])void"}, new int[]{1}, true);		
555
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyProfilingDataBefore");
556
	}
557
	/**
558
	 * A private helper method which performs the second stage verification, after 
559
	 * we have interacted with the console to produce more datat, ened to verify
560
	 * that this data was not collected in the Statistics view as the agent should be
561
	 * detached.
562
	 * 
563
	 * @param arg0 The ViewPart selected in the View
564
	 * @throws Exception
565
	 */
566
	public void verifyDataPausedTerminated(org.eclipse.ui.IViewPart arg0)
567
	throws Exception
568
	{
569
		verifyNotInList(arg0, new String[]{"methodA()", "methodB()"});	
570
	}
571
572
	/**
573
	 * A verification method which checks the String representation of the
574
	 * agent status against what is expected.
575
	 * 
576
	 * @param arg0 The ViewPart selected in the View
577
	 * @throws Exception
578
	 */
579
	public void verifyDetachedStatus (org.eclipse.ui.IViewPart arg0)
580
	throws Exception
581
	{
582
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyDetachedStatus");
583
		verifyAgentStatus(arg0, "detached");	
584
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyDetachedStatus");
585
	}
586
587
	/**
588
	 * TestJunitLaunchShortCut
589
	 * 
590
	 * This test is designed to ensure that launching a Junit test profile
591
	 * through the Profile As function produces correct collection of data.
592
	 * 
593
	 * 1) Create a Junit test inside a Java Project (performed by ImportJunitTest)
594
	 * 2) Select the Junit file and SElect Profile As> Junit Test
595
	 * 3) Verify that the Junit test is profiled and that the results of the
596
	 * Junit test are correctly diplayed in the Profiling Perspective.
597
	 * 
598
	 * This test is meant to perform the verification in Step 3)
599
	 * 
600
	 * @param arg0 The ViewPart selected in the View
601
	 * @throws Exception
602
	 */
603
	public void verifyJunitFailure(org.eclipse.ui.IViewPart arg0)
477
	throws Exception
604
	throws Exception
478
	{
605
	{
479
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyAggStage3");
606
		boolean doesExist = false;
480
		verifyCallsDetails(arg0, new String[] {"methodA() void", "methodB() void",
607
		Logger.getInstance().logMessage(Logger.INFO, "Entering verifyJUnitFailure");
481
				"flatMethod1() void", "flatMethod2() void", "main(java.lang.String[]) void"}, new int[]{8, 8, 2, 2, 1}, true);
608
		Composite junitView = VerifyHookUtil.getWorkbenchPartControl(arg0);
482
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyAggStage3");
609
		assertNotNull (junitView);
610
		Control[] tables = VerifyHookUtil.findAllControl(junitView, VerifyHookUtil.TABLE_CONTROL_TYPE, null);
611
		for (int i = 0; i < tables.length; i++) 
612
		{
613
			TableItem item= VerifyHookUtil.findTableItem((Table)tables[i], 0, "junit.framework.AssertionFailedError");
614
			if (item !=null){
615
				doesExist = true;
616
				break;
617
			}
618
		}
619
		assertTrue(doesExist);
620
		Logger.getInstance().logMessage(Logger.INFO, "Exiting verifyJUnitFailure");
483
	}
621
	}
622
484
}
623
}
(-)src/org/eclipse/hyades/use/cases/auto/profiling/logging/PlatformUIProfilingPerspectiveLaunchPart4.java (-428 / +432 lines)
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
}
(-)gui/Profiling_and_Logging/Common/Common.Resources/StartStop.java (-85 lines)
Removed Link Here
1
import java.io.BufferedReader;
2
import java.io.InputStreamReader;
3
import java.util.Date;
4
5
/**********************************************************************
6
 * Copyright (c) 2004 Hyades project.
7
 * All rights reserved.   This program and the accompanying materials
8
 * are made available under the terms of the Common Public License v1.0
9
 * which accompanies this distribution, and is available at
10
 * http://www.eclipse.org/legal/cpl-v10.html
11
 * 
12
 * Contributors: 
13
 * IBM - Initial API and implementation
14
 **********************************************************************/
15
16
/**
17
 * StartStop test class to verify the object reference using UI. 
18
 * 
19
 * 
20
 * @author Praful Rajawat
21
 * @author Paul E. Slauenwhite
22
 * @version February 10, 2005
23
 */
24
public class StartStop {
25
26
    public static void main(String[] args) {
27
28
        StartStop aStartStop = new StartStop();
29
30
        Date strtDate = new Date();
31
        
32
        System.out.println("Start timestamp = " + strtDate);
33
34
        //Read standard in, just as a way of pausing the exit:
35
        try {
36
            System.out.println("\nStop monitoring or detach and then press the Enter key.");
37
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
38
            String line = in.readLine();
39
        } 
40
        catch (Exception e) {}
41
42
        aStartStop.methodA();
43
44
        //Read standard in, just as a way of pausing the exit:
45
        try {
46
            System.out.println("\nStart monitoring or attach and then press the Enter key.");
47
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
48
            String line = in.readLine();
49
        } 
50
        catch (Exception e) {}
51
52
        aStartStop.methodB();
53
54
        Date endDate = new Date();
55
        
56
        System.out.println("End timestamp = " + endDate);
57
        System.out.println("Start time = " + strtDate.getTime());
58
        System.out.println("End   time = " + endDate.getTime());
59
        System.out.println("elapsed time = " + (endDate.getTime() - strtDate.getTime()) + " msec");
60
    }
61
62
    public void methodA() {
63
        
64
        Date curdate = new Date();
65
        int count = 1;
66
        
67
        for (int counter = 0; counter < 10000; counter++) {
68
            count = (counter * 3 + count);
69
        }
70
        
71
        System.out.println("\nmethodA - Current timestamp = " + curdate);
72
    }
73
74
    public void methodB() {
75
76
        Date curdate = new Date();
77
        int count = 1;
78
        
79
        for (int counter = 0; counter < 10000; counter++) {
80
            count = (counter * 3 + count);
81
        }
82
        
83
        System.out.println("methodB - Current timestamp = " + curdate + "\n");
84
    }
85
}
(-).settings/org.eclipse.core.resources.prefs (-1 / +3 lines)
Lines 1-4 Link Here
1
#Wed Sep 20 14:48:26 EDT 2006
1
#Mon Dec 04 09:37:59 EST 2006
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
encoding//src/org/eclipse/hyades/use/cases/auto/profiling/logging/PlatformUIProfilingPerspectiveLaunchPart4.java=UTF-8
4
encoding//src/org/eclipse/hyades/use/cases/auto/profiling/logging/PlatformUIProfilingPerspectiveLaunchPart5.java=UTF-8
3
encoding//src/org/eclipse/hyades/use/cases/auto/profiling/logging/PlatformUIProfilingPerspectiveLaunchPart6.java=UTF-8
5
encoding//src/org/eclipse/hyades/use/cases/auto/profiling/logging/PlatformUIProfilingPerspectiveLaunchPart6.java=UTF-8
4
encoding//src/org/eclipse/hyades/use/cases/auto/profiling/logging/PlatformUIProfilingPerspectiveLaunchPart7.java=UTF-8
6
encoding//src/org/eclipse/hyades/use/cases/auto/profiling/logging/PlatformUIProfilingPerspectiveLaunchPart7.java=UTF-8
(-)src/HelloWorld.java (+29 lines)
Added Link Here
1
2
public class HelloWorld {
3
	
4
		public static void main(String[] args) 
5
		{
6
			HelloWorld hellWorld = new HelloWorld();
7
			hellWorld.rootMethod1();
8
			hellWorld.rootMethod2();
9
		}
10
		
11
		public void rootMethod1()
12
		{
13
			System.out.println("rootMethod1 called");
14
			childMethod1();
15
		}
16
		
17
		public void rootMethod2()
18
		{
19
			System.out.println("rootMethod2 called");
20
		}
21
			
22
		public void childMethod1()
23
		{
24
			System.out.println("childMethod1 called");
25
		}
26
27
	}
28
29
(-)gui/Profiling_and_Logging/Launch/Platform.UI.ProfilingPerspective.Launch.Part4.Resources/Platform.UI.ProfilingPerspective.Launch.Part4.datapool (+4 lines)
Added Link Here
1
PKwF„5ResourceContents•T]oÚ0}Ÿ´ÿ`ùao‹óI`¡8DëÄ*$Zmo“—¸`ɉ3Û@ûï{ùH(TPöæÜë{ιçÞ8¹}.%Zqm„ªØs\Œx•«BTó~|È¾Æøöæó§„ª²T՟”YV+%ûétҜÑs)ú-„¿?ÐÊô!>Àkë>!ëõÚQåÜQzN~ÿ¼k®œÀ]ç¹µáےÅ+¸!¥*¸4$ßV‘b_åF¢à±?Å~Ã(¢]:
2
ÓÔsÝÌ?ÆYèyé#@ɵ¨íVkÛ?Uh¡d?VLöWrƒž”FvÁÑT2çÒy¼s¦Z=		ÎL¡ÙšçV¬¸3aË*_8S¦mYn,2Ka¹ƒQÅJ>Àÿ€Áj„þo)VL 8•ÌÐs¡;ÿÐݎr|Rîí`Xó\éÂì?!?s)
3
´-—P÷EÚoЮ™¼™YÐ3³ªÞIÅ­CgÕ­rÍwH¨_JËâ,OÐÎ(ô‡i{a×¥A8г˜ºQæ?¯æ™ˆRXs–#íR¿G{ÝN7ö½Žºèz>pÐèˆ#!o-LÈûIíÍjÎ`ʗfçµn5‡¼PœŽ¼Ý¬­Š{ˆad_jÈ̬†ð¡?cüÍÝãQ֒ÿ`+6¬ëëá?ôu/7ãy€Ÿ°.$ä­±›w‰\x˜ ÿ
4
PK¹$ä¾õàPKwF„5¹$ä¾õàResourceContentsPK>3
(-)src/Hello_World.java (+4 lines)
Added Link Here
1
2
public class Hello_World {
3
4
}
(-)gui/Profiling_and_Logging/Launch/Platform.UI.ProfilingPerspective.Launch.Part5.Resources/Platform.UI.ProfilingPerspective.Launch.Part5.datapool (+6 lines)
Added Link Here
1
PK\?…5ResourceContents?SÉnÂ0½Wê?X>ôFL–ÒD•*Q)Eê­r,9qj›¥ß	%”­ˆ‹e{æ½7oÆö›\ SšË"À¶ÕĈ‰Ly‘xööÜèâAÿþÎÉ<—ÅGD
2
-¥½(žÔ{´ÉyoOáT@ZèÜxaLÙ#d½^[2Ï,©2òþúR§œÐ¥³DðR³-dñMS¦I.S&4I¶(’îPaÄÓ?]¯õzͦç†?á°EÃN»Ûiv½Ðµí(Ĩ 9p,¨™K•[³+VrÎø?ÁBÉÃW̚Ðe‘,¬˜*ÓÂà!Ÿ}-ùŠ
3
è	ª5Ó×$?SÉñ	Üþ¥bÅ©R½;ÂE„В—€{æiÂ
4
STôTe6ªVg»ºU?ÔQÅé§`«z?ö_#È
5
rSö§F–7Ë8?qä†ÝJÆ;’ñÉ¡KŸœ7ó7P?t
6
ƒ¸Ö^{o¤¨‹úw*ÇþwSªLcd¾KØO?‚WðWòuÆ3«;Æ}Ó.ÒúäÐaõ±È•ŸñPK|æKJ?¡PK\?…5|æKJ?¡ResourceContentsPK>Ë

Return to bug 165936