KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > j2ee > refactoring > usages > WebAppTest


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
20 package org.netbeans.test.j2ee.refactoring.usages;
21
22 import java.io.File JavaDoc;
23 import junit.framework.TestSuite;
24 import junit.textui.TestRunner;
25 import org.netbeans.junit.NbTestSuite;
26 import org.netbeans.test.j2ee.lib.J2eeProjectSupport;
27 import org.netbeans.test.j2ee.refactoring.WebAppConstants;
28
29 /**
30  * Find Usages simple tests
31  * @author jungi
32  */

33 public class WebAppTest extends WhereUsedTestCase implements WebAppConstants {
34
35     private static boolean prjOpened = false;
36
37     /** Creates a new instance of Signature1Test */
38     public WebAppTest(String JavaDoc name) {
39         super(name);
40     }
41     
42     public static TestSuite suite() {
43         NbTestSuite suite = new NbTestSuite();
44         suite.addTest(new WebAppTest("testInterface"));
45         suite.addTest(new WebAppTest("testInterfaceParams"));
46         suite.addTest(new WebAppTest("testClass"));
47         suite.addTest(new WebAppTest("testClassParams"));
48         suite.addTest(new WebAppTest("testMsgHandler"));
49         return suite;
50     }
51     
52     public void testClass() {
53         findClass(CLASS_NAME_1);
54         findClass(CLASS_NAME_2);
55         try {
56             findClass("com.foo.bar.XY");
57         } catch (IllegalStateException JavaDoc ise) {
58             ref("");
59             ref(ise.getMessage());
60             ref("");
61             return;
62         }
63         fail("Non existing class was found!");
64     }
65     
66     public void testInterface() {
67         findClass(IFACE_NAME_1);
68         try {
69             findClass("com.foo.bar.Jkkl");
70         } catch (IllegalStateException JavaDoc ise) {
71             ref("");
72             ref(ise.getMessage());
73             ref("");
74             return;
75         }
76         fail("Non existing interface was found!");
77     }
78     
79     public void testClassParams() {
80         findClassParams(CLASS_NAME_1, CLASS_USAGES);
81         findClassParams(CLASS_NAME_2, CLASS_USAGES);
82         //findClassParams("java.lang.String", CLASS_USAGES);
83
try {
84             findClassParams("com.foo.bar.Pop", CLASS_USAGES);
85         } catch (IllegalStateException JavaDoc ise) {
86             ref("");
87             ref(ise.getMessage());
88             ref("");
89             return;
90         }
91         fail("Non existing class was found!");
92     }
93     
94     public void testInterfaceParams() {
95         findClassParams(IFACE_NAME_1, CLASS_USAGES);
96         try {
97             findClassParams("com.foo.bar.Mno", CLASS_USAGES);
98         } catch (IllegalStateException JavaDoc ise) {
99             ref("");
100             ref(ise.getMessage());
101             ref("");
102             return;
103         }
104         fail("Non existing interface was found!");
105     }
106     
107     public void testMsgHandler() {
108         findClass(HANDLER_NAME_1);
109         findClassParams(HANDLER_NAME_2, CLASS_USAGES);
110     }
111     
112     /**
113      * Used for running test from inside the IDE by internal execution.
114      *
115      * @param args the command line arguments
116      */

117     public static void main(String JavaDoc[] args) {
118         TestRunner.run(suite());
119     }
120
121     public void prepareProject() {
122         if (prjOpened) {
123             return;
124         }
125         J2eeProjectSupport.openProject(new File JavaDoc(getDataDir(), "projects/LoggingWS"));
126         classPathWorkDir = new File JavaDoc(getDataDir(), "projects.LoggingWS.src.java".replace('.', File.separatorChar));
127         prjOpened = true;
128     }
129     
130 }
131
Popular Tags