1 19 20 package org.netbeans.modules.search; 21 22 import java.lang.reflect.Field ; 23 import junit.framework.TestCase; 24 import junit.framework.*; 25 26 31 public final class ResultModelTest extends TestCase { 32 33 private static final String FIELD_SEARCH_TYPE_PACKAGE = "DEF_SEARCH_TYPES_PACKAGE"; 34 private static final String FIELD_FULLTEXT_SEARCH_TYPE = "FULLTEXT_SEARCH_TYPE"; 35 36 public ResultModelTest(String testName) { 37 super(testName); 38 } 39 40 42 public void testConstants() throws Exception { 43 Class clazz = ResultModel.class; 44 String pkg = getStaticString(clazz, FIELD_SEARCH_TYPE_PACKAGE); 45 String className = getStaticString(clazz, FIELD_FULLTEXT_SEARCH_TYPE); 46 String fullClassName = pkg + '.' + className; 47 try { 48 Class.forName(fullClassName, false, getClass().getClassLoader()); 49 } catch (ClassNotFoundException ex) { 50 fail("class " + fullClassName + " does not exist" + 51 " (wrong values of fields " + FIELD_SEARCH_TYPE_PACKAGE + 52 " and/or " + FIELD_FULLTEXT_SEARCH_TYPE + ")"); 53 } 54 } 55 56 58 private static String getStaticString(Class clazz, 59 String fieldName) throws Exception { 60 Field field = clazz.getDeclaredField(fieldName); 61 field.setAccessible(true); 62 return (String ) field.get(null); 63 } 64 65 } 66 | Popular Tags |