KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > debuggercore > Breakpoints


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  * The Original Software is NetBeans.
15  * The Initial Developer of the Original Software is Sun Microsystems, Inc.
16  * Portions created by Sun Microsystems, Inc. are Copyright (C) 2005
17  * All Rights Reserved.
18  *
19  * Contributor(s): Sun Microsystems, Inc.
20  */

21
22 package gui.debuggercore;
23
24 import java.io.File JavaDoc;
25 import junit.textui.TestRunner;
26 import org.netbeans.jellytools.EditorOperator;
27 import org.netbeans.jellytools.JellyTestCase;
28 import org.netbeans.jellytools.NbDialogOperator;
29 import org.netbeans.jellytools.TopComponentOperator;
30 import org.netbeans.jellytools.actions.DebugProjectAction;
31 import org.netbeans.jellytools.actions.OpenAction;
32 import org.netbeans.jellytools.modules.debugger.actions.ContinueAction;
33 import org.netbeans.jellytools.modules.debugger.actions.NewBreakpointAction;
34 import org.netbeans.jellytools.nodes.Node;
35 import org.netbeans.jellytools.nodes.SourcePackagesNode;
36 import org.netbeans.jemmy.EventTool;
37 import org.netbeans.jemmy.JemmyProperties;
38 import org.netbeans.jemmy.operators.JComboBoxOperator;
39 import org.netbeans.jemmy.operators.JEditorPaneOperator;
40 import org.netbeans.jemmy.operators.JTableOperator;
41 import org.netbeans.jemmy.operators.JTextFieldOperator;
42 import org.netbeans.jemmy.operators.JPopupMenuOperator;
43 import org.netbeans.jemmy.util.PNGEncoder;
44 import org.netbeans.junit.NbTestSuite;
45
46
47
48 /**
49  *
50  * @author ehucka
51  */

52 public class Breakpoints extends JellyTestCase {
53     
54     //MainWindowOperator.StatusTextTracer stt = null;
55

56     /**
57      *
58      * @param name
59      */

60     public Breakpoints(String JavaDoc name) {
61         super(name);
62     }
63     
64     /**
65      *
66      * @param args
67      */

68     public static void main(String JavaDoc[] args) {
69         TestRunner.run(suite());
70     }
71     
72     /**
73      *
74      * @return
75      */

76     public static NbTestSuite suite() {
77         NbTestSuite suite = new NbTestSuite();
78         suite.addTest(new Breakpoints("testLineBreakpointCreation"));
79         suite.addTest(new Breakpoints("testLineBreakpointFunctionality"));
80         suite.addTest(new Breakpoints("testLineBreakpointFunctionalityAfterContinue"));
81         suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInStaticMethod"));
82         suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInInitializer"));
83         suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInConstructor"));
84         suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInInnerClass"));
85         suite.addTest(new Breakpoints("testLineBreakpointFunctionalityInSecondaryClass"));
86         suite.addTest(new Breakpoints("testConditionalLineBreakpointFunctionality"));
87         suite.addTest(new Breakpoints("testMethodBreakpointPrefilledConstructor"));
88         //suite.addTest(new Breakpoints("testMethodBreakpointPrefilledInitializer"));
89
suite.addTest(new Breakpoints("testMethodBreakpointPrefilledMethod"));
90         suite.addTest(new Breakpoints("testMethodBreakpointCreation"));
91         suite.addTest(new Breakpoints("testMethodBreakpointFunctionalityInPrimaryClass"));
92         suite.addTest(new Breakpoints("testMethodBreakpointFunctionalityInSecondClass"));
93         suite.addTest(new Breakpoints("testMethodBreakpointFunctionalityOnAllMethods"));
94         suite.addTest(new Breakpoints("testClassBreakpointPrefilledInClass"));
95         suite.addTest(new Breakpoints("testClassBreakpointPrefilledInInitializer"));
96         suite.addTest(new Breakpoints("testClassBreakpointPrefilledInConstructor"));
97         suite.addTest(new Breakpoints("testClassBreakpointPrefilledInMethod"));
98         suite.addTest(new Breakpoints("testClassBreakpointPrefilledInSecondClass"));
99         suite.addTest(new Breakpoints("testClassBreakpointCreation"));
100         suite.addTest(new Breakpoints("testClassBreakpointFunctionalityOnPrimaryClass"));
101         suite.addTest(new Breakpoints("testClassBreakpointFunctionalityOnSecondClass"));
102         suite.addTest(new Breakpoints("testClassBreakpointFunctionalityWithFilter"));
103         suite.addTest(new Breakpoints("testFieldBreakpointPrefilledValues"));
104         suite.addTest(new Breakpoints("testFieldBreakpointCreation"));
105         suite.addTest(new Breakpoints("testFieldBreakpointFunctionalityAccess"));
106         suite.addTest(new Breakpoints("testFieldBreakpointFunctionalityModification"));
107         suite.addTest(new Breakpoints("testThreadBreakpointCreation"));
108         suite.addTest(new Breakpoints("testThreadBreakpointFunctionality"));
109         suite.addTest(new Breakpoints("testExceptionBreakpointCreation"));
110         suite.addTest(new Breakpoints("testExceptionBreakpointFunctionality"));
111         return suite;
112     }
113     
114     /**
115      *
116      */

117     public void setUp() {
118         System.out.println("######## " + getName() + " ####### ");
119     }
120     
121     /**
122      *
123      */

124     public void tearDown() {
125         JemmyProperties.getCurrentOutput().printTrace("\nteardown\n");
126         Utilities.endAllSessions();
127         Utilities.deleteAllBreakpoints();
128     }
129     
130     /**
131      *
132      */

133     public void testLineBreakpointCreation() throws Throwable JavaDoc {
134         try {
135             //open source
136
Node beanNode = new Node(new SourcePackagesNode(Utilities.testProjectName), "examples.advanced|MemoryView.java"); //NOI18N
137
new OpenAction().performAPI(beanNode);
138             EditorOperator eo = new EditorOperator("MemoryView.java");
139             //toggle breakpoints
140
Utilities.toggleBreakpoint(eo, 73);
141             Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
142             JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
143             assertEquals("Line MemoryView.java:73", jTableOperator.getValueAt(0, 0).toString());
144             eo = new EditorOperator("MemoryView.java");
145             Utilities.toggleBreakpoint(eo, 73, false);
146             new EventTool().waitNoEvent(1000);
147             jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
148             assertEquals(0, jTableOperator.getRowCount());
149         } catch (Throwable JavaDoc th) {
150             try {
151                 // capture screen before cleanup in finally clause is completed
152
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
153             } catch (Exception JavaDoc e1) {
154                 // ignore it
155
}
156             throw th;
157         }
158     }
159     
160     /**
161      *
162      */

163     public void testLineBreakpointFunctionality() throws Throwable JavaDoc {
164         try {
165             EditorOperator eo = new EditorOperator("MemoryView.java");
166             //toggle breakpoints
167
Utilities.toggleBreakpoint(eo, 73);
168             Utilities.startDebugger();
169             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:73", 0);
170         } catch (Throwable JavaDoc th) {
171             try {
172                 // capture screen before cleanup in finally clause is completed
173
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
174             } catch (Exception JavaDoc e1) {
175                 // ignore it
176
}
177             throw th;
178         }
179     }
180     
181     /**
182      *
183      */

184     public void testLineBreakpointFunctionalityAfterContinue() throws Throwable JavaDoc {
185         try {
186             EditorOperator eo = new EditorOperator("MemoryView.java");
187             //toggle breakpoints
188
Utilities.toggleBreakpoint(eo, 52);
189             Utilities.startDebugger();
190             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:52", 0);
191             eo = new EditorOperator("MemoryView.java");
192             Utilities.toggleBreakpoint(eo, 74);
193             new ContinueAction().perform();
194             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:74", 0);
195         } catch (Throwable JavaDoc th) {
196             try {
197                 // capture screen before cleanup in finally clause is completed
198
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
199             } catch (Exception JavaDoc e1) {
200                 // ignore it
201
}
202             throw th;
203         }
204     }
205     
206     /**
207      *
208      */

209     public void testLineBreakpointFunctionalityInStaticMethod() throws Throwable JavaDoc {
210         try {
211             EditorOperator eo = new EditorOperator("MemoryView.java");
212             //toggle breakpoints
213
Utilities.toggleBreakpoint(eo, 114);
214             Utilities.startDebugger();
215             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:114", 0);
216         } catch (Throwable JavaDoc th) {
217             try {
218                 // capture screen before cleanup in finally clause is completed
219
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
220             } catch (Exception JavaDoc e1) {
221                 // ignore it
222
}
223             throw th;
224         }
225     }
226     
227     /**
228      *
229      */

230     public void testLineBreakpointFunctionalityInInitializer() throws Throwable JavaDoc {
231         try {
232             EditorOperator eo = new EditorOperator("MemoryView.java");
233             //toggle breakpoints
234
Utilities.toggleBreakpoint(eo, 45);
235             Utilities.startDebugger();
236             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:45", 0);
237         } catch (Throwable JavaDoc th) {
238             try {
239                 // capture screen before cleanup in finally clause is completed
240
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
241             } catch (Exception JavaDoc e1) {
242                 // ignore it
243
}
244             throw th;
245         }
246     }
247     
248     /**
249      *
250      */

251     public void testLineBreakpointFunctionalityInConstructor() throws Throwable JavaDoc {
252         try {
253             EditorOperator eo = new EditorOperator("MemoryView.java");
254             //toggle breakpoints
255
Utilities.toggleBreakpoint(eo, 54);
256             Utilities.startDebugger();
257             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:54", 0);
258         } catch (Throwable JavaDoc th) {
259             try {
260                 // capture screen before cleanup in finally clause is completed
261
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
262             } catch (Exception JavaDoc e1) {
263                 // ignore it
264
}
265             throw th;
266         }
267     }
268     
269     /**
270      *
271      */

272     public void testLineBreakpointFunctionalityInInnerClass() throws Throwable JavaDoc {
273         try {
274             EditorOperator eo = new EditorOperator("MemoryView.java");
275             //toggle breakpoints
276
Utilities.toggleBreakpoint(eo, 123);
277             Utilities.startDebugger();
278             Utilities.waitDebuggerConsole("Thread Thread-0 stopped at MemoryView.java:123", 0);
279         } catch (Throwable JavaDoc th) {
280             try {
281                 // capture screen before cleanup in finally clause is completed
282
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
283             } catch (Exception JavaDoc e1) {
284                 // ignore it
285
}
286             throw th;
287         }
288     }
289     
290     /**
291      *
292      */

293     public void testLineBreakpointFunctionalityInSecondaryClass() throws Throwable JavaDoc {
294         try {
295             EditorOperator eo = new EditorOperator("MemoryView.java");
296             //toggle breakpoints
297
Utilities.toggleBreakpoint(eo, 154);
298             Utilities.startDebugger();
299             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:154", 0);
300         } catch (Throwable JavaDoc th) {
301             try {
302                 // capture screen before cleanup in finally clause is completed
303
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
304             } catch (Exception JavaDoc e1) {
305                 // ignore it
306
}
307             throw th;
308         }
309     }
310     
311     /**
312      *
313      */

314     public void testConditionalLineBreakpointFunctionality() throws Throwable JavaDoc {
315         try {
316             EditorOperator eo = new EditorOperator("MemoryView.java");
317             //toggle breakpoints
318
Utilities.toggleBreakpoint(eo, 63);
319             Utilities.toggleBreakpoint(eo, 64);
320             
321             Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
322             JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
323             assertEquals("Line MemoryView.java:64", jTableOperator.getValueAt(1, 0).toString());
324             new JPopupMenuOperator(jTableOperator.callPopupOnCell(1, 0)).pushMenuNoBlock("Customize");
325             NbDialogOperator dialog = new NbDialogOperator(Utilities.customizeBreakpointTitle);
326             new JEditorPaneOperator(dialog, 0).setText("i > 0");
327             dialog.ok();
328             Utilities.startDebugger();
329             int lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:63", 0);
330             new ContinueAction().perform();
331             lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:63", lines+1);
332             new ContinueAction().perform();
333             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:64", lines+1);
334         } catch (Throwable JavaDoc th) {
335             try {
336                 // capture screen before cleanup in finally clause is completed
337
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
338             } catch (Exception JavaDoc e1) {
339                 // ignore it
340
}
341             throw th;
342         }
343     }
344     
345     /**
346      *
347      */

348     public void testMethodBreakpointPrefilledConstructor() throws Throwable JavaDoc {
349         try {
350             NbDialogOperator dialog = Utilities.newBreakpoint(53);
351             new JComboBoxOperator(dialog, 0).selectItem("Method");
352             assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 1).getText());
353             assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 2).getText());
354             assertEquals("Method Name was not set to correct value.", "<init>", new JTextFieldOperator(dialog, 3).getText());
355             dialog.cancel();
356         } catch (Throwable JavaDoc th) {
357             try {
358                 // capture screen before cleanup in finally clause is completed
359
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
360             } catch (Exception JavaDoc e1) {
361                 // ignore it
362
}
363             throw th;
364         }
365     }
366     
367     /**
368      *
369      */

370     public void testMethodBreakpointPrefilledMethod() throws Throwable JavaDoc {
371         try {
372             NbDialogOperator dialog = Utilities.newBreakpoint(92);
373             new JComboBoxOperator(dialog, 0).selectItem("Method");
374             assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 1).getText());
375             assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 2).getText());
376             assertEquals("Method Name was not set to correct value.", "updateStatus", new JTextFieldOperator(dialog, 3).getText());
377             dialog.cancel();
378         } catch (Throwable JavaDoc th) {
379             try {
380                 // capture screen before cleanup in finally clause is completed
381
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
382             } catch (Exception JavaDoc e1) {
383                 // ignore it
384
}
385             throw th;
386         }
387     }
388     
389     /**
390      *
391      */

392     public void testMethodBreakpointCreation() throws Throwable JavaDoc {
393         try {
394             NbDialogOperator dialog = Utilities.newBreakpoint(92);
395             new JComboBoxOperator(dialog, 0).selectItem("Method");
396             dialog.ok();
397             Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
398             JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
399             assertEquals("Method MemoryView.updateStatus", jTableOperator.getValueAt(0, 0).toString());
400         } catch (Throwable JavaDoc th) {
401             try {
402                 // capture screen before cleanup in finally clause is completed
403
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
404             } catch (Exception JavaDoc e1) {
405                 // ignore it
406
}
407             throw th;
408         }
409     }
410     
411     /**
412      *
413      */

414     public void testMethodBreakpointFunctionalityInPrimaryClass() throws Throwable JavaDoc {
415         try {
416             NbDialogOperator dialog = Utilities.newBreakpoint(92);
417             new JComboBoxOperator(dialog, 0).selectItem("Method");
418             dialog.ok();
419             Utilities.startDebugger();
420             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:92", 0);
421         } catch (Throwable JavaDoc th) {
422             try {
423                 // capture screen before cleanup in finally clause is completed
424
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
425             } catch (Exception JavaDoc e1) {
426                 // ignore it
427
}
428             throw th;
429         }
430     }
431     
432     /**
433      *
434      */

435     public void testMethodBreakpointFunctionalityInSecondClass() throws Throwable JavaDoc {
436         try {
437             NbDialogOperator dialog = Utilities.newBreakpoint(154);
438             new JComboBoxOperator(dialog, 0).selectItem("Method");
439             dialog.ok();
440             Utilities.startDebugger();
441             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:154", 0);
442         } catch (Throwable JavaDoc th) {
443             try {
444                 // capture screen before cleanup in finally clause is completed
445
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
446             } catch (Exception JavaDoc e1) {
447                 // ignore it
448
}
449             throw th;
450         }
451     }
452     
453     /**
454      *
455      */

456     public void testMethodBreakpointFunctionalityOnAllMethods() throws Throwable JavaDoc {
457         try {
458             NbDialogOperator dialog = Utilities.newBreakpoint(37);
459             new JComboBoxOperator(dialog, 0).selectItem("Method");
460             dialog.ok();
461             Utilities.startDebugger();
462             int lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:39", 0);
463             new ContinueAction().perform();
464             lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:114", lines+1);
465             new ContinueAction().perform();
466             lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:50", lines+1);
467             new ContinueAction().perform();
468             lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:51", lines+1);
469             new ContinueAction().perform();
470             lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:121", lines+1);
471             new ContinueAction().perform();
472             lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:79", lines+1);
473             new ContinueAction().perform();
474             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:92", lines+1);
475         } catch (Throwable JavaDoc th) {
476             try {
477                 // capture screen before cleanup in finally clause is completed
478
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
479             } catch (Exception JavaDoc e1) {
480                 // ignore it
481
}
482             throw th;
483         }
484     }
485     
486     /**
487      *
488      */

489     public void testClassBreakpointPrefilledInClass() throws Throwable JavaDoc {
490         try {
491             NbDialogOperator dialog = Utilities.newBreakpoint(27);
492             if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class"))
493                 new JComboBoxOperator(dialog, 0).selectItem("Class");
494             assertEquals("Package Name was not set to correct value.", "", new JTextFieldOperator(dialog, 0).getText());
495             assertEquals("Class Name was not set to correct value.", "", new JTextFieldOperator(dialog, 1).getText());
496             dialog.cancel();
497         } catch (Throwable JavaDoc th) {
498             try {
499                 // capture screen before cleanup in finally clause is completed
500
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
501             } catch (Exception JavaDoc e1) {
502                 // ignore it
503
}
504             throw th;
505         }
506     }
507     
508     /**
509      *
510      */

511     public void testClassBreakpointPrefilledInInitializer() throws Throwable JavaDoc {
512         try {
513             NbDialogOperator dialog = Utilities.newBreakpoint(38);
514             if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class"))
515                 new JComboBoxOperator(dialog, 0).selectItem("Class");
516             assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 0).getText());
517             assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 1).getText());
518             dialog.cancel();
519         } catch (Throwable JavaDoc th) {
520             try {
521                 // capture screen before cleanup in finally clause is completed
522
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
523             } catch (Exception JavaDoc e1) {
524                 // ignore it
525
}
526             throw th;
527         }
528     }
529     
530     /**
531      *
532      */

533     public void testClassBreakpointPrefilledInConstructor() throws Throwable JavaDoc {
534         try {
535             NbDialogOperator dialog = Utilities.newBreakpoint(45);
536             if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class"))
537                 new JComboBoxOperator(dialog, 0).selectItem("Class");
538             assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 0).getText());
539             assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 1).getText());
540             dialog.cancel();
541         } catch (Throwable JavaDoc th) {
542             try {
543                 // capture screen before cleanup in finally clause is completed
544
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
545             } catch (Exception JavaDoc e1) {
546                 // ignore it
547
}
548             throw th;
549         }
550     }
551     
552     /**
553      *
554      */

555     public void testClassBreakpointPrefilledInMethod() throws Throwable JavaDoc {
556         try {
557             NbDialogOperator dialog = Utilities.newBreakpoint(80);
558             if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class"))
559                 new JComboBoxOperator(dialog, 0).selectItem("Class");
560             assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 0).getText());
561             assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 1).getText());
562             dialog.cancel();
563         } catch (Throwable JavaDoc th) {
564             try {
565                 // capture screen before cleanup in finally clause is completed
566
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
567             } catch (Exception JavaDoc e1) {
568                 // ignore it
569
}
570             throw th;
571         }
572     }
573     
574     /**
575      *
576      */

577     public void testClassBreakpointPrefilledInSecondClass() throws Throwable JavaDoc {
578         try {
579             NbDialogOperator dialog = Utilities.newBreakpoint(154);
580             if (!new JComboBoxOperator(dialog, 0).getSelectedItem().equals("Class"))
581                 new JComboBoxOperator(dialog, 0).selectItem("Class");
582             assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 0).getText());
583             assertEquals("Class Name was not set to correct value.", "Helper", new JTextFieldOperator(dialog, 1).getText());
584             dialog.cancel();
585         } catch (Throwable JavaDoc th) {
586             try {
587                 // capture screen before cleanup in finally clause is completed
588
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
589             } catch (Exception JavaDoc e1) {
590                 // ignore it
591
}
592             throw th;
593         }
594     }
595     
596     /**
597      *
598      */

599     public void testClassBreakpointCreation() throws Throwable JavaDoc {
600         try {
601             NbDialogOperator dialog = Utilities.newBreakpoint(73);
602             new JComboBoxOperator(dialog, 0).selectItem("Class");
603             dialog.ok();
604             Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
605             JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
606             assertEquals("Class breakpoint was not created.", "Class MemoryView prepare / unload", jTableOperator.getValueAt(0, 0).toString());
607         } catch (Throwable JavaDoc th) {
608             try {
609                 // capture screen before cleanup in finally clause is completed
610
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
611             } catch (Exception JavaDoc e1) {
612                 // ignore it
613
}
614             throw th;
615         }
616     }
617     
618     /**
619      *
620      */

621     public void testClassBreakpointFunctionalityOnPrimaryClass() throws Throwable JavaDoc {
622         try {
623             NbDialogOperator dialog = Utilities.newBreakpoint(73);
624             new JComboBoxOperator(dialog, 0).selectItem("Class");
625             dialog.ok();
626             new EventTool().waitNoEvent(500);
627             Utilities.startDebugger();
628             int lines = Utilities.waitDebuggerConsole("Thread main stopped.", 0);
629             new ContinueAction().perform();
630             Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, lines+1);
631         } catch (Throwable JavaDoc th) {
632             try {
633                 // capture screen before cleanup in finally clause is completed
634
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
635             } catch (Exception JavaDoc e1) {
636                 // ignore it
637
}
638             throw th;
639         }
640     }
641     
642     /**
643      *
644      */

645     public void testClassBreakpointFunctionalityOnSecondClass() throws Throwable JavaDoc {
646         try {
647             NbDialogOperator dialog = Utilities.newBreakpoint(154);
648             new JComboBoxOperator(dialog, 0).selectItem("Class");
649             dialog.ok();
650             Utilities.startDebugger();
651             int lines = Utilities.waitDebuggerConsole("Thread main stopped.", 0);
652             new ContinueAction().perform();
653             Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, lines+1);
654         } catch (Throwable JavaDoc th) {
655             try {
656                 // capture screen before cleanup in finally clause is completed
657
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
658             } catch (Exception JavaDoc e1) {
659                 // ignore it
660
}
661             throw th;
662         }
663     }
664     
665     /**
666      *
667      */

668     public void testClassBreakpointFunctionalityWithFilter() throws Throwable JavaDoc {
669         try {
670             NbDialogOperator dialog = Utilities.newBreakpoint(73);
671             new JComboBoxOperator(dialog, 0).selectItem("Class");
672             new JTextFieldOperator(dialog, 1).setText("*");
673             dialog.ok();
674             
675             new DebugProjectAction().perform();
676             Utilities.getDebugToolbar().waitComponentVisible(true);
677             //Class breakpoint hit for class examples.advanced.Helper.");
678
int lines = Utilities.waitDebuggerConsole("Thread main stopped.", 0);
679             new EventTool().waitNoEvent(500);
680             new ContinueAction().perform();
681             //Class breakpoint hit for class examples.advanced.MemoryView
682
lines = Utilities.waitDebuggerConsole("Thread main stopped.", lines+1);
683             new ContinueAction().perform();
684             //Class breakpoint hit for class examples.advanced.MemoryView$1
685
lines = Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:121.", lines+1);
686             new ContinueAction().perform();
687             Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, lines+1);
688         } catch (Throwable JavaDoc th) {
689             try {
690                 // capture screen before cleanup in finally clause is completed
691
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
692             } catch (Exception JavaDoc e1) {
693                 // ignore it
694
}
695             throw th;
696         }
697     }
698     
699     /**
700      *
701      */

702     public void testFieldBreakpointPrefilledValues() throws Throwable JavaDoc {
703         try {
704             NbDialogOperator dialog = Utilities.newBreakpoint(36, 36);
705             new JComboBoxOperator(dialog, 0).selectItem("Field");
706             assertEquals("Package Name was not set to correct value.", "examples.advanced", new JTextFieldOperator(dialog, 1).getText());
707             assertEquals("Class Name was not set to correct value.", "MemoryView", new JTextFieldOperator(dialog, 2).getText());
708             assertEquals("Field Name was not set to correct value.", "msgMemory", new JTextFieldOperator(dialog, 3).getText());
709             dialog.cancel();
710         } catch (Throwable JavaDoc th) {
711             try {
712                 // capture screen before cleanup in finally clause is completed
713
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
714             } catch (Exception JavaDoc e1) {
715                 // ignore it
716
}
717             throw th;
718         }
719     }
720     
721     /**
722      *
723      */

724     public void testFieldBreakpointCreation() throws Throwable JavaDoc {
725         try {
726             NbDialogOperator dialog = Utilities.newBreakpoint(36, 36);
727             new JComboBoxOperator(dialog, 0).selectItem("Field");
728             new JComboBoxOperator(dialog, 1).selectItem("Field Access");
729             dialog.ok();
730             Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
731             JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
732             assertEquals("Field breakpoint was not created.", "Field MemoryView.msgMemory access", jTableOperator.getValueAt(0, 0).toString());
733         } catch (Throwable JavaDoc th) {
734             try {
735                 // capture screen before cleanup in finally clause is completed
736
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
737             } catch (Exception JavaDoc e1) {
738                 // ignore it
739
}
740             throw th;
741         }
742     }
743     
744     /**
745      *
746      */

747     public void testFieldBreakpointFunctionalityAccess() throws Throwable JavaDoc {
748         try {
749             NbDialogOperator dialog = Utilities.newBreakpoint(36, 36);
750             new JComboBoxOperator(dialog, 0).selectItem("Field");
751             new JComboBoxOperator(dialog, 1).selectItem("Field Access");
752             dialog.ok();
753             Utilities.startDebugger();
754             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:104.", 0);
755         } catch (Throwable JavaDoc th) {
756             try {
757                 // capture screen before cleanup in finally clause is completed
758
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
759             } catch (Exception JavaDoc e1) {
760                 // ignore it
761
}
762             throw th;
763         }
764     }
765     
766     /**
767      *
768      */

769     public void testFieldBreakpointFunctionalityModification() throws Throwable JavaDoc {
770         try {
771             NbDialogOperator dialog = Utilities.newBreakpoint(36, 36);
772             new JComboBoxOperator(dialog, 0).selectItem("Field");
773             new JComboBoxOperator(dialog, 1).selectItem("Field Modification");
774             dialog.ok();
775             Utilities.startDebugger();
776             Utilities.waitDebuggerConsole("Thread main stopped at MemoryView.java:45", 0);
777         } catch (Throwable JavaDoc th) {
778             try {
779                 // capture screen before cleanup in finally clause is completed
780
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
781             } catch (Exception JavaDoc e1) {
782                 // ignore it
783
}
784             throw th;
785         }
786     }
787     
788     /**
789      *
790      */

791     public void testThreadBreakpointCreation() throws Throwable JavaDoc {
792         try {
793             new NewBreakpointAction().perform();
794             NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle);
795             new JComboBoxOperator(dialog, 0).selectItem("Thread");
796             dialog.ok();
797             Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
798             JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
799             assertEquals("Thread breakpoint was not created.", "Thread started", jTableOperator.getValueAt(0, 0).toString());
800         } catch (Throwable JavaDoc th) {
801             try {
802                 // capture screen before cleanup in finally clause is completed
803
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
804             } catch (Exception JavaDoc e1) {
805                 // ignore it
806
}
807             throw th;
808         }
809     }
810     
811     /**
812      *
813      */

814     public void testThreadBreakpointFunctionality() throws Throwable JavaDoc {
815         try {
816             new NewBreakpointAction().perform();
817             NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle);
818             new JComboBoxOperator(dialog, 0).selectItem("Thread");
819             dialog.ok();
820             
821             Utilities.startDebugger();
822             int lines = Utilities.waitDebuggerConsole("Thread breakpoint hit by thread ", 0);
823             new ContinueAction().perform();
824             lines = Utilities.waitDebuggerConsole("Thread breakpoint hit by thread ", lines+1);
825             new ContinueAction().perform();
826             Utilities.waitDebuggerConsole(Utilities.runningStatusBarText, lines+1);
827         } catch (Throwable JavaDoc th) {
828             try {
829                 // capture screen before cleanup in finally clause is completed
830
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
831             } catch (Exception JavaDoc e1) {
832                 // ignore it
833
}
834             throw th;
835         }
836     }
837     
838     /**
839      *
840      */

841     public void testExceptionBreakpointCreation() throws Throwable JavaDoc {
842         try {
843             new NewBreakpointAction().perform();
844             NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle);
845             new JComboBoxOperator(dialog, 0).selectItem("Exception");
846             
847             new JTextFieldOperator(dialog, 2).setText("java.lang");
848             new JComboBoxOperator(dialog, 2).typeText("NullPointerException");
849             new JComboBoxOperator(dialog, 1).selectItem("Caught or Uncaught");
850             dialog.ok();
851             Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
852             JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
853             assertEquals("Thread breakpoint was not created.", "Exception NullPointerException", jTableOperator.getValueAt(0, 0).toString());
854         } catch (Throwable JavaDoc th) {
855             try {
856                 // capture screen before cleanup in finally clause is completed
857
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
858             } catch (Exception JavaDoc e1) {
859                 // ignore it
860
}
861             throw th;
862         }
863     }
864     
865     /**
866      *
867      */

868     public void testExceptionBreakpointFunctionality() throws Throwable JavaDoc {
869         try {
870             new NewBreakpointAction().perform();
871             NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle);
872             new JComboBoxOperator(dialog, 0).selectItem("Exception");
873             new JTextFieldOperator(dialog, 2).setText("java.lang");
874             new JComboBoxOperator(dialog, 2).typeText("ClassNotFoundException");
875             new JComboBoxOperator(dialog, 1).selectItem("Caught or Uncaught");
876             dialog.ok();
877             Utilities.startDebugger();
878             new ContinueAction().perform();
879             Utilities.waitDebuggerConsole("Thread main stopped at URLClassLoader.java", 0);
880         } catch (Throwable JavaDoc th) {
881             try {
882                 // capture screen before cleanup in finally clause is completed
883
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
884             } catch (Exception JavaDoc e1) {
885                 // ignore it
886
}
887             throw th;
888         }
889     }
890 }
891
Popular Tags