]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed #7699
authorJonatan Kronqvist <jonatan.kronqvist@itmill.com>
Mon, 3 Oct 2011 07:56:09 +0000 (07:56 +0000)
committerJonatan Kronqvist <jonatan.kronqvist@itmill.com>
Mon, 3 Oct 2011 07:56:09 +0000 (07:56 +0000)
svn changeset:21494/svn branch:6.7

tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java
tests/testbench/com/vaadin/tests/VaadinClasses.java

index f7beafb9270cc53b6fb25b1945a00dc7f2df55dc..33c1dfaf5f438dce03722d445d7913163fbfddc6 100644 (file)
@@ -3,6 +3,7 @@ package com.vaadin.tests.server;
 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
@@ -14,6 +15,8 @@ import java.util.jar.JarFile;
 \r
 import junit.framework.TestCase;\r
 \r
+import org.junit.Test;\r
+\r
 public class TestClassesSerializable extends TestCase {\r
 \r
     /**\r
@@ -70,6 +73,18 @@ public class TestClassesSerializable extends TestCase {
             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
@@ -164,6 +179,12 @@ public class TestClassesSerializable extends TestCase {
                     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
index 6f826402f4e6a95b775a2dd68579b0ab94254a05..0f4e2ff4da9dfef5d28a14eb4c023946f621f535 100644 (file)
@@ -2,6 +2,7 @@ package com.vaadin.tests;
 
 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;
@@ -14,6 +15,8 @@ import java.util.Enumeration;
 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;
@@ -61,7 +64,7 @@ public class VaadinClasses {
 
     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();
@@ -146,7 +149,29 @@ public class VaadinClasses {
 
         });
         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,