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.JavaPackage; 25 import org.netbeans.junit.NbTestCase; 26 import org.netbeans.junit.NbTestSuite; 27 import org.netbeans.modules.javacore.internalapi.JavaMetamodel; 28 29 32 public class FindPackageUsagesTest extends NbTestCase { 33 34 public static final String [] USAGES_COLOR_PICKER = { 35 "MultipartId", 36 "MultipartId", 37 "Resource", 38 "Resource", 39 "Resource" 40 }; 41 42 public static final String [] USAGES_IMAGE_VIEWER = { 43 "Resource", 44 "Resource" 45 }; 46 47 public static final String [] USAGES_TEXT_EDITOR = { 48 "Resource", 49 "Resource", 50 "Resource" 51 }; 52 53 public static final String [] USAGES_EXAMPLES = { 54 "MultipartId", 55 "MultipartId", 56 "MultipartId", 57 "MultipartId", 58 "MultipartId", 59 "MultipartId", 60 "MultipartId", 61 "MultipartId", 62 "MultipartId", 63 "MultipartId" 64 }; 65 66 67 public FindPackageUsagesTest(String name) { 68 super(name); 69 70 } 71 72 public static NbTestSuite suite() { 73 NbTestSuite suite = new NbTestSuite(); 74 suite.addTest(new FindPackageUsagesTest("testFindExamplesColorPicker")); 75 suite.addTest(new FindPackageUsagesTest("testFindExamplesImageViewer")); 76 suite.addTest(new FindPackageUsagesTest("testFindExamplesTextEditor")); 77 suite.addTest(new FindPackageUsagesTest("testFindExamples")); 78 return suite; 79 } 80 81 82 public static void main(java.lang.String [] args) { 83 TestRunner.run(suite()); 84 } 85 86 public void testFindExamplesColorPicker() { 87 Collection result = getUsers("examples.colorpicker"); 88 compare(result, USAGES_COLOR_PICKER); 89 } 90 91 public void testFindExamplesImageViewer() { 92 Collection result = getUsers("examples.imageviewer"); 93 compare(result, USAGES_IMAGE_VIEWER); 94 } 95 96 public void testFindExamplesTextEditor() { 97 Collection result = getUsers("examples.texteditor"); 98 compare(result, USAGES_TEXT_EDITOR); 99 } 100 101 public void testFindExamples() { 102 Collection result = getUsers("examples"); 103 compare(result, USAGES_EXAMPLES); 104 } 105 106 private Collection getUsers(String className) { 107 JavaPackage pckg = (JavaPackage) JavaMetamodel.getManager().getDefaultExtent().getJavaPackage().resolvePackage(className); 108 assertNotNull(pckg); 109 return pckg.getReferences(); 110 } 111 112 private void compare(Collection col, String [] classNames) { 113 FindUtils.compare(col, classNames, getLog()); 114 } 115 } 116 | Popular Tags |