123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package com.vaadin.server;
-
- import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.assertNotNull;
-
- import java.lang.annotation.ElementType;
- import java.lang.annotation.Retention;
- import java.lang.annotation.RetentionPolicy;
- import java.lang.annotation.Target;
-
- import org.junit.Test;
-
- import com.vaadin.annotations.Theme;
- import com.vaadin.annotations.Widgetset;
-
- /**
- * Tests for {@link UIProvider} class.
- *
- * @author Vaadin Ltd
- */
- public class UIProviderTest {
-
- @Test
- public void getAnnotationFor_widgetsetAnnotationForSubclass_annotationFound() {
- assertNotNull("Widgetset annotation is not found for subclass",
- UIProvider.getAnnotationFor(TestClass.class, Widgetset.class));
- }
-
- @Test
- public void getAnnotationFor_themeAnnotationForSubclass_annotationFound() {
- assertNotNull("Theme annotation is not found for subclass",
- UIProvider.getAnnotationFor(TestClass.class, Theme.class));
- }
-
- @Test
- public void getAnnotationFor_themeAnnotationForSubclass_annotationOverridden() {
- assertEquals("Theme annotation is not overridden correctly in subclass",
- "c", UIProvider.getAnnotationFor(TestClass.class, Theme.class)
- .value());
- }
-
- @Test
- public void getAnnotationFor_notInheritedAnnotationForSubclass_annotationFound() {
- assertNotNull("TestAnnotation annotation is not found for subclass",
- UIProvider.getAnnotationFor(TestClass.class,
- TestAnnotation.class));
- }
-
- @Test
- public void getAnnotationFor_directAnnotationForSubclass_annotationFound() {
- assertNotNull("TestAnnotation1 annotation is not found for subclass",
- UIProvider.getAnnotationFor(TestClass.class,
- TestAnnotation1.class));
- }
-
- @Test
- public void getAnnotationFor_annotationInheritedFromInterface_annotationFound() {
- assertNotNull("Theme annotation is not inherited from interface",
- UIProvider.getAnnotationFor(ClassImplementingInterface.class,
- Theme.class));
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- public @interface TestAnnotation {
-
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- public @interface TestAnnotation1 {
-
- }
-
- @Widgetset("a")
- @Theme("b")
- @TestAnnotation
- public static class TestSuperClass {
-
- }
-
- @TestAnnotation1
- @Theme("c")
- public static class TestClass extends TestSuperClass {
-
- }
-
- @Theme("d")
- public interface InterfaceWithAnnotation {
- }
-
- public static class ClassImplementingInterface
- implements InterfaceWithAnnotation {
- }
-
- }
|