diff options
author | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-10-03 07:56:09 +0000 |
---|---|---|
committer | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-10-03 07:56:09 +0000 |
commit | e18d427d07ce7e3a3c4fa57bb340437580b44f3c (patch) | |
tree | f0dd2c2a795de4888a1a1d3514661150db565d64 | |
parent | 2cdc6d4ba1019d751910e6ce0c44265f3d360720 (diff) | |
download | vaadin-framework-e18d427d07ce7e3a3c4fa57bb340437580b44f3c.tar.gz vaadin-framework-e18d427d07ce7e3a3c4fa57bb340437580b44f3c.zip |
Fixed #7699
svn changeset:21494/svn branch:6.7
-rw-r--r-- | tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java | 21 | ||||
-rw-r--r-- | tests/testbench/com/vaadin/tests/VaadinClasses.java | 27 |
2 files changed, 47 insertions, 1 deletions
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<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, |