1 54 55 package junitx.util; 56 57 import java.io.File ; 58 import java.lang.reflect.Modifier ; 59 60 67 public class SimpleTestFilter implements TestFilter { 68 69 72 public SimpleTestFilter() { 73 } 74 75 81 public boolean include(String classpath) { 82 return classpath.endsWith("Test.class"); 83 } 84 85 91 public boolean include(Class cls) { 92 int modifiers = cls.getModifiers(); 93 return !Modifier.isAbstract(modifiers) && !Modifier.isInterface(modifiers); 94 } 95 96 99 public static String getClassName(Class cls) { 100 int pos = cls.getName().lastIndexOf('.'); 101 if (pos != -1) { 102 return cls.getName().substring(pos + 1); 103 } else { 104 return cls.getName(); 105 } 106 } 107 108 112 public static String getPackageName(Class cls) { 113 int pos = cls.getName().lastIndexOf('.'); 114 if (pos != -1) { 115 return cls.getName().substring(0, pos); 116 } else { 117 return ""; 118 } 119 } 120 121 124 public static String getClassName(String classpath) { 125 int pos = classpath.lastIndexOf('/'); 126 if (pos > 0) { 127 return classpath.substring(pos + 1, classpath.length() - 6); 128 } 129 return classpath.substring(0, classpath.length() - 6); 130 } 131 132 137 public static String getPackageName(String classpath) { 138 int pos = classpath.lastIndexOf('/'); 139 if (pos > 0) { 140 return classpath.substring(0, pos).replace(File.separatorChar, '.'); 141 } 142 return ""; 143 } 144 145 } 146 | Popular Tags |