KickJava   Java API By Example, From Geeks To Geeks.

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


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

32 public class EjbModTest extends WhereUsedTestCase implements EjbModConstants {
33     
34     private static boolean prjOpened = false;
35     
36     //_name_Bean, _name_Local, _name_LocalHome, _name_Remote, _name_RemoteHome, MDB
37

38     /** Creates a new instance of EjbModTest */
39     public EjbModTest(String JavaDoc name) {
40         super(name);
41     }
42     
43     public static TestSuite suite() {
44         NbTestSuite suite = new NbTestSuite();
45         suite.addTest(new EjbModTest("testInterface"));
46         suite.addTest(new EjbModTest("testInterfaceParams"));
47         suite.addTest(new EjbModTest("testClass"));
48         suite.addTest(new EjbModTest("testClassParams"));
49         suite.addTest(new EjbModTest("testMsgHandler"));
50         return suite;
51     }
52     
53     /**
54      * Used for running test from inside the IDE by internal execution.
55      *
56      * @param args the command line arguments
57      */

58     public static void main(String JavaDoc[] args) {
59         TestRunner.run(suite());
60     }
61
62     public void prepareProject() {
63         if (prjOpened) {
64             return;
65         }
66         J2eeProjectSupport.openProject(new File JavaDoc(getDataDir(), "projects/League-util"));
67         J2eeProjectSupport.openProject(new File JavaDoc(getDataDir(), "projects/League-ejb"));
68         classPathWorkDir = new File JavaDoc(getDataDir(), "projects.League-ejb.src.java".replace('.', File.separatorChar));
69         prjOpened = true;
70     }
71
72     public void testClass() {
73         findClass(CLASS_WS_1);
74         findClass(CLASS_SESSION_1);
75         findClass(CLASS_CMP_ENTITY_1);
76         findClass(CLASS_CMP_ENTITY_2);
77         findClass(MDB_QUEUE);
78         try {
79             findClass("com.foo.bar.Ab");
80         } catch (IllegalStateException JavaDoc ise) {
81             ref("");
82             ref(ise.getMessage());
83             ref("");
84             return;
85         }
86         fail("Non existing class was found!");
87     }
88     
89     public void testClassParams() {
90         findClassParams(CLASS_JAVA_1, CLASS_USAGES);
91         findClassParams(CLASS_JAVA_2, CLASS_USAGES);
92         findClassParams(CLASS_WS_1, CLASS_USAGES);
93         findClassParams(CLASS_SESSION_1, CLASS_USAGES);
94         findClassParams(CLASS_CMP_ENTITY_3, CLASS_USAGES);
95         findClassParams(CLASS_CMP_ENTITY_4, CLASS_USAGES);
96         findClassParams(CLASS_CMP_ENTITY_5, CLASS_USAGES);
97         findClassParams(MDB_TOPIC, CLASS_USAGES);
98         try {
99             findClassParams("com.foo.bar.XY", CLASS_USAGES);
100         } catch (IllegalStateException JavaDoc ise) {
101             ref("");
102             ref(ise.getMessage());
103             ref("");
104             return;
105         }
106         fail("Non existing class was found!");
107     }
108     
109     public void testInterface() {
110         findClass(INTERFACE_CMP_ENTITY_LOCAL_1);
111         findClass(INTERFACE_CMP_ENTITY_LOCAL_2);
112         findClass(INTERFACE_CMP_ENTITY_LOCAL_3);
113         findClass(INTERFACE_CMP_ENTITY_LOCAL_HOME_1);
114         findClass(INTERFACE_CMP_ENTITY_LOCAL_HOME_2);
115         findClass(INTERFACE_CMP_ENTITY_LOCAL_HOME_3);
116         findClass(INTERFACE_SESSION_REMOTE_1);
117         findClass(INTERFACE_SESSION_REMOTE_HOME_1);
118         findClass(INTERFACE_WS_1);
119         try {
120             findClass("com.foo.bar.Ij");
121         } catch (IllegalStateException JavaDoc ise) {
122             ref("");
123             ref(ise.getMessage());
124             ref("");
125             return;
126         }
127         fail("Non existing interface was found!");
128     }
129     
130     public void testInterfaceParams() {
131         findClassParams(INTERFACE_CMP_ENTITY_LOCAL_4, CLASS_USAGES);
132         findClassParams(INTERFACE_CMP_ENTITY_LOCAL_5, CLASS_USAGES);
133         findClassParams(INTERFACE_CMP_ENTITY_LOCAL_HOME_4, CLASS_USAGES);
134         findClassParams(INTERFACE_CMP_ENTITY_LOCAL_HOME_5, CLASS_USAGES);
135         findClassParams(INTERFACE_SESSION_REMOTE_1, CLASS_USAGES);
136         findClassParams(INTERFACE_SESSION_REMOTE_HOME_1, CLASS_USAGES);
137         findClassParams(INTERFACE_WS_1, CLASS_USAGES);
138         try {
139             findClassParams("com.foo.bar.Iss", CLASS_USAGES);
140         } catch (IllegalStateException JavaDoc ise) {
141             ref("");
142             ref(ise.getMessage());
143             ref("");
144             return;
145         }
146         fail("Non existing interface was found!");
147     }
148     
149     public void testMsgHandler() {
150         findClassParams(CLASS_HANDLER_1, CLASS_USAGES);
151         findClass(CLASS_HANDLER_2);
152     }
153
154 }
155
Popular Tags