1 19 20 package org.netbeans.jmi.javamodel.usages; 21 22 import java.util.Collection ; 23 import junit.textui.TestRunner; 24 import org.netbeans.jmi.javamodel.JavaClass; 25 import org.netbeans.jmi.javamodel.codegen.Utility; 26 import org.netbeans.junit.NbTestCase; 27 import org.netbeans.junit.NbTestSuite; 28 import org.netbeans.modules.javacore.internalapi.JavaMetamodel; 29 30 33 public class FindClassUsagesTest extends NbTestCase { 34 35 public static final String [] USAGES_COLOR_PICKER = {"NewClassExpression"}; 36 public static final String [] USAGES_COLOR_PREVIEW = { 37 "ClassExpression", 38 "ClassExpression", 39 "ClassExpression", 40 "ClassExpression", 41 "Field", 42 "NewClassExpression"}; 43 public static final String [] USAGES_COLOR_PREVIEW_BEANINFO = {}; 44 public static final String [] USAGES_IMAGE_FRAME = {"LocalVarDeclaration", "NewClassExpression"}; 45 public static final String [] USAGES_IMAGE_VIEWER = {"NewClassExpression"}; 46 public static final String [] USAGES_ABOUT = {"NewClassExpression"}; 47 public static final String [] USAGES_FINDER = {"NewClassExpression"}; 48 public static final String [] USAGES_TED = {"NewClassExpression"}; 49 50 51 public FindClassUsagesTest(String name) { 52 super(name); 53 54 } 55 56 public static NbTestSuite suite() { 57 NbTestSuite suite = new NbTestSuite(); 58 suite.addTest(new FindClassUsagesTest("testFindColorPicker")); 59 suite.addTest(new FindClassUsagesTest("testFindColorPreview")); 60 suite.addTest(new FindClassUsagesTest("testFindColorPreviewBeanInfo")); 61 suite.addTest(new FindClassUsagesTest("testFindImageFrame")); 62 suite.addTest(new FindClassUsagesTest("testFindImageViewer")); 63 suite.addTest(new FindClassUsagesTest("testFindAbout")); 64 suite.addTest(new FindClassUsagesTest("testFindFinder")); 65 suite.addTest(new FindClassUsagesTest("testFindTed")); 66 return suite; 67 } 68 69 70 public static void main(java.lang.String [] args) { 71 TestRunner.run(suite()); 72 } 73 74 public void testFindColorPicker() { 75 Collection result = getUsers("examples.colorpicker.ColorPicker"); 76 compare(result, USAGES_COLOR_PICKER); 77 } 78 79 public void testFindColorPreview() { 80 Collection result = getUsers("examples.colorpicker.ColorPreview"); 81 compare(result, USAGES_COLOR_PREVIEW); 82 } 83 84 public void testFindColorPreviewBeanInfo() { 85 Collection result = getUsers("examples.colorpicker.ColorPreviewBeanInfo"); 86 compare(result, USAGES_COLOR_PREVIEW_BEANINFO); 87 } 88 89 public void testFindImageFrame() { 90 Collection result = getUsers("examples.imageviewer.ImageFrame"); 91 compare(result, USAGES_IMAGE_FRAME); 92 } 93 94 public void testFindImageViewer() { 95 Collection result = getUsers("examples.imageviewer.ImageViewer"); 96 compare(result, USAGES_IMAGE_VIEWER); 97 } 98 99 public void testFindAbout() { 100 Collection result = getUsers("examples.texteditor.About"); 101 compare(result, USAGES_ABOUT); 102 } 103 104 public void testFindFinder() { 105 Collection result = getUsers("examples.texteditor.Finder"); 106 compare(result, USAGES_FINDER); 107 } 108 109 public void testFindTed() { 110 Collection result = getUsers("examples.texteditor.Ted"); 111 compare(result, USAGES_TED); 112 } 113 114 private Collection getUsers(String className) { 115 JavaClass myclass = Utility.findClass(className); 116 assertNotNull(myclass); 117 return myclass.getReferences(); 118 } 119 120 private void compare(Collection col, String [] classNames) { 121 FindUtils.compare(col, classNames, getLog()); 122 } 123 } 124 | Popular Tags |