From e18d427d07ce7e3a3c4fa57bb340437580b44f3c Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Mon, 3 Oct 2011 07:56:09 +0000 Subject: [PATCH] Fixed #7699 svn changeset:21494/svn branch:6.7 --- .../tests/server/TestClassesSerializable.java | 21 +++++++++++++++ .../com/vaadin/tests/VaadinClasses.java | 27 ++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java b/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java index f7beafb927..33c1dfaf5f 100644 --- a/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java +++ b/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java @@ -3,6 +3,7 @@ package com.vaadin.tests.server; import java.io.File; import java.io.IOException; import java.io.Serializable; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -14,6 +15,8 @@ import java.util.jar.JarFile; import junit.framework.TestCase; +import org.junit.Test; + public class TestClassesSerializable extends TestCase { /** @@ -70,6 +73,18 @@ public class TestClassesSerializable extends TestCase { if (cls.isAnnotation() || cls.isSynthetic()) { continue; } + // Don't add classes that have a @Test annotation on any methods + boolean testPresent = false; + for (Method method : cls.getMethods()) { + if (method.isAnnotationPresent(Test.class)) { + testPresent = true; + break; + } + } + if (testPresent) { + continue; + } + // report non-serializable classes and interfaces if (!Serializable.class.isAssignableFrom(cls)) { nonSerializableClasses.add(cls); @@ -164,6 +179,12 @@ public class TestClassesSerializable extends TestCase { break; } } + + // Don't add test classes + if (className.contains("Test")) { + ok = false; + } + if (ok) { filteredClasses.add(className); } diff --git a/tests/testbench/com/vaadin/tests/VaadinClasses.java b/tests/testbench/com/vaadin/tests/VaadinClasses.java index 6f826402f4..0f4e2ff4da 100644 --- a/tests/testbench/com/vaadin/tests/VaadinClasses.java +++ b/tests/testbench/com/vaadin/tests/VaadinClasses.java @@ -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> 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 List> findClassesNoTests( + Class baseClass, String basePackage, String[] ignoredPackages) + throws IOException { + List> classes = findClasses(baseClass, basePackage, + ignoredPackages); + List> classesNoTests = new ArrayList>(); + for (Class 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 void findPackages(JarURLConnection juc, -- 2.39.5