KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > customizer > CmpJarPanelBot


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  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.sun.share.customizer;
20
21 import junit.framework.*;
22 // added
23
import junit.extensions.abbot.*;
24 import abbot.tester.*;
25
26 import org.netbeans.modules.j2ee.sun.share.configbean.CmpJar;
27 // dedda
28
/**
29  *
30  * @author vkraemer
31  */

32 public class CmpJarPanelBot extends ComponentTestFixture { // TestCase {
33

34     public CmpJarPanelBot(java.lang.String JavaDoc testName) {
35         super(testName);
36     }
37
38     // Add test methods here, they have to start with 'test' name.
39
// for example:
40
// public void testHello() {}
41

42     // here are the tests
43
private ComponentTester tester;
44     protected void setUp() {
45         tester = ComponentTester.getTester(CmpJarPanel.class);
46     }
47     
48     public void testFocusTraversal() {
49         CmpJarPanel pane = new CmpJarPanel();
50         
51         // ComponentTestFixture provides the frame
52
CmpJar bean = new CmpJar();
53         try {
54             bean.setJndiName("tip-");
55             bean.setPrincipalName("hip-");
56         }
57         catch (Throwable JavaDoc t) {
58             assertTrue("set did not get vetoed",false);
59         }
60         pane.setObject(bean);
61         showFrame(pane);
62         try {
63             Thread.sleep(2000);
64         }
65         catch(Throwable JavaDoc t) {
66         }
67         
68         tester.actionKeyPress("VK_END");
69         tester.actionKeyRelease("VK_END");
70         tester.actionKeyPress("VK_T");
71         tester.actionKeyRelease("VK_T");
72         tester.actionKeyPress("VK_O");
73         tester.actionKeyRelease("VK_O");
74         tester.actionKeyPress("VK_P");
75         tester.actionKeyRelease("VK_P");
76         assertEquals("keystroke did not propigate", "tip-top", bean.getJndiName());
77         tester.actionKeyPress("VK_TAB");
78         tester.actionKeyRelease("VK_TAB");
79         tester.actionKeyPress("VK_END");
80         tester.actionKeyRelease("VK_END");
81         tester.actionKeyPress("VK_H");
82         tester.actionKeyRelease("VK_H");
83         tester.actionKeyPress("VK_O");
84         tester.actionKeyRelease("VK_O");
85         tester.actionKeyPress("VK_P");
86         tester.actionKeyRelease("VK_P");
87         //assertEquals("Missed a keystroke", "hip-hop", pane.getField().getText());
88
assertEquals("keystroke did not propigate", "hip-hop", bean.getPrincipalName());
89         tester.actionKeyPress("VK_TAB");
90         tester.actionKeyRelease("VK_TAB");
91         tester.actionKeyPress("VK_END");
92         tester.actionKeyRelease("VK_END");
93         tester.actionKeyPress("VK_H");
94         tester.actionKeyRelease("VK_H");
95         tester.actionKeyPress("VK_O");
96         tester.actionKeyRelease("VK_O");
97         tester.actionKeyPress("VK_P");
98         tester.actionKeyRelease("VK_P");
99         assertEquals("keystroke did not propigate", "hop", bean.getPrincipalPassword());
100         tester.actionKeyPress("VK_SHIFT");
101         tester.actionKeyPress("VK_TAB");
102         tester.actionKeyRelease("VK_TAB");
103         tester.actionKeyRelease("VK_SHIFT");
104         tester.actionKeyPress("VK_END");
105         tester.actionKeyRelease("VK_END");
106         System.out.println("about to do the clear test");
107         tester.actionKeyPress("VK_BACK_SPACE");
108         tester.actionKeyRelease("VK_BACK_SPACE");
109 /* tester.actionKeyPress("VK_O");
110         tester.actionKeyRelease("VK_O");
111         tester.actionKeyPress("VK_P");
112         tester.actionKeyRelease("VK_P");
113 */

114         tester.actionKeyPress("VK_BACK_SPACE");
115         tester.actionKeyRelease("VK_BACK_SPACE");
116         tester.actionKeyPress("VK_BACK_SPACE");
117         tester.actionKeyRelease("VK_BACK_SPACE");
118         tester.actionKeyPress("VK_BACK_SPACE");
119         tester.actionKeyRelease("VK_BACK_SPACE");
120         tester.actionKeyPress("VK_BACK_SPACE");
121         tester.actionKeyRelease("VK_BACK_SPACE");
122         tester.actionKeyPress("VK_BACK_SPACE");
123         tester.actionKeyRelease("VK_BACK_SPACE");
124         tester.actionKeyPress("VK_BACK_SPACE");
125         tester.actionKeyRelease("VK_BACK_SPACE");
126         System.out.println("about to hit tab");
127         tester.actionKeyPress("VK_TAB");
128         tester.actionKeyRelease("VK_TAB");
129         System.out.println("have hit tab");
130         
131         assertEquals("bug in password clearer", "", bean.getPrincipalPassword());
132
133     }
134     
135 }
136
Popular Tags