1 19 package org.netbeans.test.j2ee.refactoring.usages; 20 21 import java.io.File ; 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 32 public class EjbModTest extends WhereUsedTestCase implements EjbModConstants { 33 34 private static boolean prjOpened = false; 35 36 38 39 public EjbModTest(String 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 58 public static void main(String [] args) { 59 TestRunner.run(suite()); 60 } 61 62 public void prepareProject() { 63 if (prjOpened) { 64 return; 65 } 66 J2eeProjectSupport.openProject(new File (getDataDir(), "projects/League-util")); 67 J2eeProjectSupport.openProject(new File (getDataDir(), "projects/League-ejb")); 68 classPathWorkDir = new File (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 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 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 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 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 |