import java.io.File;\r
import java.io.IOException;\r
import java.io.Serializable;\r
+import java.lang.reflect.Method;\r
import java.util.ArrayList;\r
import java.util.Collection;\r
import java.util.Collections;\r
\r
import junit.framework.TestCase;\r
\r
+import org.junit.Test;\r
+\r
public class TestClassesSerializable extends TestCase {\r
\r
/**\r
if (cls.isAnnotation() || cls.isSynthetic()) {\r
continue;\r
}\r
+ // Don't add classes that have a @Test annotation on any methods\r
+ boolean testPresent = false;\r
+ for (Method method : cls.getMethods()) {\r
+ if (method.isAnnotationPresent(Test.class)) {\r
+ testPresent = true;\r
+ break;\r
+ }\r
+ }\r
+ if (testPresent) {\r
+ continue;\r
+ }\r
+\r
// report non-serializable classes and interfaces\r
if (!Serializable.class.isAssignableFrom(cls)) {\r
nonSerializableClasses.add(cls);\r
break;\r
}\r
}\r
+\r
+ // Don't add test classes\r
+ if (className.contains("Test")) {\r
+ ok = false;\r
+ }\r
+\r
if (ok) {\r
filteredClasses.add(className);\r
}\r
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.JarURLConnection;
import java.net.URISyntaxException;
import java.util.List;
import java.util.jar.JarEntry;
+import org.junit.Test;
+
import com.vaadin.Application;
import com.vaadin.tests.components.AbstractComponentTest;
import com.vaadin.ui.Component;
public static List<Class<? extends Object>> getAllServerSideClasses() {
try {
- return findClasses(Object.class, "com.vaadin", new String[] {
+ return findClassesNoTests(Object.class, "com.vaadin", new String[] {
"com.vaadin.tests", "com.vaadin.terminal.gwt.client" });
} catch (IOException e) {
e.printStackTrace();
});
return classes;
+ }
+ private static <T> List<Class<? extends T>> findClassesNoTests(
+ Class<T> baseClass, String basePackage, String[] ignoredPackages)
+ throws IOException {
+ List<Class<? extends T>> classes = findClasses(baseClass, basePackage,
+ ignoredPackages);
+ List<Class<? extends T>> classesNoTests = new ArrayList<Class<? extends T>>();
+ for (Class<? extends T> clazz : classes) {
+ if (!clazz.getName().contains("Test")) {
+ boolean testPresent = false;
+ for (Method method : clazz.getMethods()) {
+ if (method.isAnnotationPresent(Test.class)) {
+ testPresent = true;
+ break;
+ }
+ }
+ if (!testPresent) {
+ classesNoTests.add(clazz);
+ }
+ }
+ }
+ return classesNoTests;
}
private static <T> void findPackages(JarURLConnection juc,