1 19 20 package org.netbeans.test.j2ee.refactoring.usages; 21 22 import java.io.File ; 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 33 public class WebAppTest extends WhereUsedTestCase implements WebAppConstants { 34 35 private static boolean prjOpened = false; 36 37 38 public WebAppTest(String 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 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 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 try { 84 findClassParams("com.foo.bar.Pop", CLASS_USAGES); 85 } catch (IllegalStateException 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 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 117 public static void main(String [] args) { 118 TestRunner.run(suite()); 119 } 120 121 public void prepareProject() { 122 if (prjOpened) { 123 return; 124 } 125 J2eeProjectSupport.openProject(new File (getDataDir(), "projects/LoggingWS")); 126 classPathWorkDir = new File (getDataDir(), "projects.LoggingWS.src.java".replace('.', File.separatorChar)); 127 prjOpened = true; 128 } 129 130 } 131 | Popular Tags |