Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct all tests that introspect classpath for Vaadin classes.
Fixes vaadin/framework8-issues#399 RemoveListenersDeprecatedTest test is fixed. Corrections are made to make the test above passes. Change-Id: I209a4693d241a1488b69b4742f48549dbf4bf0ac
- Loading branch information
Denis Anisimov
authored and
Vaadin Code Review
committed
Nov 29, 2016
1 parent
0d57c15
commit b8e84da
Showing
27 changed files
with
431 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 47 additions & 13 deletions
60
compatibility-server/src/test/java/com/vaadin/v7/tests/VaadinClasses.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,31 +1,65 @@ | |||
package com.vaadin.v7.tests; | package com.vaadin.v7.tests; | ||
|
|
||
import java.io.IOException; | import java.io.File; | ||
import java.lang.reflect.Modifier; | |||
import java.net.URISyntaxException; | |||
import java.util.HashSet; | |||
import java.util.List; | import java.util.List; | ||
import java.util.Set; | |||
import java.util.function.Predicate; | |||
import java.util.stream.Collectors; | |||
import java.util.stream.Stream; | |||
|
|
||
import com.vaadin.tests.server.ClasspathHelper; | |||
import com.vaadin.ui.Component; | import com.vaadin.ui.Component; | ||
import com.vaadin.v7.ui.Field; | import com.vaadin.v7.ui.Field; | ||
|
|
||
@SuppressWarnings("deprecation") | @SuppressWarnings("deprecation") | ||
public class VaadinClasses { | public class VaadinClasses { | ||
|
|
||
private static final Set<String> WHITE_LIST_FQNS = new HashSet<>(); | |||
|
|||
public static List<Class<? extends Field>> getFields() { | public static List<Class<? extends Field>> getFields() { | ||
return getServerClasses(Field.class::isAssignableFrom) | |||
.map(VaadinClasses::castFieldClass) | |||
.collect(Collectors.toList()); | |||
} | |||
|
|||
public static Stream<Class<?>> getServerClasses( | |||
Predicate<? super Class<?>> predicate) { | |||
try { | try { | ||
return com.vaadin.tests.VaadinClasses.findClasses(Field.class, | File testRoot = new File(com.vaadin.tests.VaadinClasses.class | ||
"com.vaadin.v7.ui"); | .getResource("/").toURI()); | ||
} catch (IOException e) { | File compatibilityTestRoot = new File( | ||
e.printStackTrace(); | VaadinClasses.class.getResource("/").toURI()); | ||
return null; | ClasspathHelper helper = new ClasspathHelper( | ||
fqn -> !fqn.startsWith("com.vaadin.v7.ui")); | |||
return helper.getVaadinClassesFromClasspath( | |||
entry -> !compatibilityTestRoot.equals(new File(entry)) | |||
&& !testRoot.equals(new File(entry)), | |||
cls -> predicate.test(cls) && !cls.isInterface() | |||
&& !Modifier.isAbstract(cls.getModifiers())); | |||
} catch (URISyntaxException e) { | |||
throw new RuntimeException(e); | |||
} | } | ||
} | } | ||
|
|
||
public static List<Class<? extends Component>> getComponents() { | public static List<Class<? extends Component>> getComponents() { | ||
try { | return getServerClasses(Component.class::isAssignableFrom) | ||
return com.vaadin.tests.VaadinClasses.findClasses(Component.class, | .map(VaadinClasses::castComponentClass) | ||
"com.vaadin.v7.ui"); | .collect(Collectors.toList()); | ||
} catch (IOException e) { | } | ||
throw new RuntimeException( |
|
||
"Could not find all Vaadin component classes", e); | private static Class<? extends Field> castFieldClass(Class<?> clazz) { | ||
} | return (Class<? extends Field>) clazz; | ||
} | |||
|
|||
private static Class<? extends Component> castComponentClass( | |||
Class<?> clazz) { | |||
return (Class<? extends Component>) clazz; | |||
} | |||
|
|||
protected static Set<String> getWhiteListFqns() { | |||
return WHITE_LIST_FQNS; | |||
} | } | ||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.