diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2016-12-18 08:45:05 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2016-12-18 08:45:05 +0200 |
commit | 6b51788ee7c2a8b147744bc11d220fb3ed896672 (patch) | |
tree | 4f310c85f2e5d77179a6aa218c3740c29e3410f7 | |
parent | 52decf5e2b32116deb5de32b7706cda198c52347 (diff) | |
download | vaadin-framework-6b51788ee7c2a8b147744bc11d220fb3ed896672.tar.gz vaadin-framework-6b51788ee7c2a8b147744bc11d220fb3ed896672.zip |
Add CDI dependency version to vaadin-bom (#8020)
Unify test UIs and test code for Spring and CDI.
-rw-r--r-- | bom/pom.xml | 6 | ||||
-rw-r--r-- | test/cdi/pom.xml | 76 | ||||
-rw-r--r-- | test/cdi/src/main/java/com/vaadin/test/cdi/MyVaadinUI.java | 26 | ||||
-rw-r--r-- | test/cdi/src/main/java/com/vaadin/test/cdi/ThankYouService.java | 7 | ||||
-rw-r--r-- | test/cdi/src/main/java/com/vaadin/test/cdi/ThankYouServiceImpl.java | 14 | ||||
-rw-r--r-- | test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java | 36 | ||||
-rw-r--r-- | test/pom.xml | 9 | ||||
-rw-r--r-- | test/spring-boot/src/main/java/com/example/DemoApplication.java | 7 | ||||
-rw-r--r-- | test/spring-boot/src/main/java/com/example/ThankYouService.java | 13 | ||||
-rw-r--r-- | test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java (renamed from test/spring-boot/src/test/java/com/example/SpringBootSmokeTest.java) | 4 |
10 files changed, 192 insertions, 6 deletions
diff --git a/bom/pom.xml b/bom/pom.xml index 4788c99576..c9b7178305 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -18,6 +18,7 @@ <properties> <vaadin.spring.version>2.0-SNAPSHOT</vaadin.spring.version> <vaadin.testbench.version>5.0.0.alpha2</vaadin.testbench.version> + <vaadin.cdi.version>2.0-SNAPSHOT</vaadin.cdi.version> </properties> <repositories> @@ -111,6 +112,11 @@ <artifactId>vaadin-testbench</artifactId> <version>${vaadin.testbench.version}</version> </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-cdi</artifactId> + <version>${vaadin.cdi.version}</version> + </dependency> </dependencies> </dependencyManagement> diff --git a/test/cdi/pom.xml b/test/cdi/pom.xml new file mode 100644 index 0000000000..30398c656e --- /dev/null +++ b/test/cdi/pom.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-test</artifactId> + <version>8.0-SNAPSHOT</version> + </parent> + <artifactId>vaadin-test-cdi</artifactId> + <packaging>war</packaging> + + + <dependencies> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-cdi</artifactId> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-client-compiled</artifactId> + </dependency> + + <!-- CDI API dependency --> + <dependency> + <groupId>javax.enterprise</groupId> + <artifactId>cdi-api</artifactId> + <version>1.2</version> + </dependency> + </dependencies> + + <build> + <finalName>ROOT</finalName> + <plugins> + <!-- Disable jetty-plugin --> + <plugin> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>${jetty.version}</version> + <executions> + <execution> + <id>start-jetty</id> + <phase /> + </execution> + <execution> + <id>stop-jetty</id> + <phase /> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.wildfly.plugins</groupId> + <artifactId>wildfly-maven-plugin</artifactId> + <version>1.0.2.Final</version> + <executions> + <execution> + <id>start-wildfly</id> + <phase>pre-integration-test</phase> + <goals> + <goal>start</goal> + <goal>deploy</goal> + </goals> + </execution> + <execution> + <id>stop-wildfly</id> + <phase>post-integration-test</phase> + <goals> + <goal>shutdown</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/test/cdi/src/main/java/com/vaadin/test/cdi/MyVaadinUI.java b/test/cdi/src/main/java/com/vaadin/test/cdi/MyVaadinUI.java new file mode 100644 index 0000000000..58b479b2b1 --- /dev/null +++ b/test/cdi/src/main/java/com/vaadin/test/cdi/MyVaadinUI.java @@ -0,0 +1,26 @@ +package com.vaadin.test.cdi; + +import javax.inject.Inject; + +import com.vaadin.annotations.Theme; +import com.vaadin.cdi.CDIUI; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Notification; +import com.vaadin.ui.UI; + +@Theme("valo") +@CDIUI("") +@SuppressWarnings("serial") +public class MyVaadinUI extends UI { + + @Inject + private ThankYouService service; + + @Override + protected void init(VaadinRequest request) { + setContent(new Button("Click Me", + e -> Notification.show(service.getText()))); + } + +} diff --git a/test/cdi/src/main/java/com/vaadin/test/cdi/ThankYouService.java b/test/cdi/src/main/java/com/vaadin/test/cdi/ThankYouService.java new file mode 100644 index 0000000000..abdcc3bab5 --- /dev/null +++ b/test/cdi/src/main/java/com/vaadin/test/cdi/ThankYouService.java @@ -0,0 +1,7 @@ +package com.vaadin.test.cdi; + +public interface ThankYouService { + + String getText(); + +} diff --git a/test/cdi/src/main/java/com/vaadin/test/cdi/ThankYouServiceImpl.java b/test/cdi/src/main/java/com/vaadin/test/cdi/ThankYouServiceImpl.java new file mode 100644 index 0000000000..fd22f5833a --- /dev/null +++ b/test/cdi/src/main/java/com/vaadin/test/cdi/ThankYouServiceImpl.java @@ -0,0 +1,14 @@ +package com.vaadin.test.cdi; + +import javax.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class ThankYouServiceImpl implements ThankYouService { + + public static final String THANK_YOU_TEXT = "Thank you for clicking!"; + + @Override + public String getText() { + return THANK_YOU_TEXT; + } +} diff --git a/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java b/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java new file mode 100644 index 0000000000..d3244417db --- /dev/null +++ b/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java @@ -0,0 +1,36 @@ +package com.vaadin.test.cdi; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.openqa.selenium.phantomjs.PhantomJSDriver; + +import com.vaadin.testbench.ScreenshotOnFailureRule; +import com.vaadin.testbench.TestBenchTestCase; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.NotificationElement; + +public class VaadinCDISmokeIT extends TestBenchTestCase { + + @Rule + public ScreenshotOnFailureRule rule = new ScreenshotOnFailureRule(this, + true); + + @Before + public void setup() { + // Screenshot rule tears down the driver + setDriver(new PhantomJSDriver()); + } + + @Test + public void testPageLoadsAndCanBeInterractedWith() { + getDriver().navigate().to("http://localhost:8080/"); + + $(ButtonElement.class).first().click(); + + Assert.assertTrue($(NotificationElement.class).exists()); + Assert.assertEquals(ThankYouServiceImpl.THANK_YOU_TEXT, + $(NotificationElement.class).first().getText()); + } +} diff --git a/test/pom.xml b/test/pom.xml index 6215d61112..f9a38d0592 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -15,7 +15,6 @@ <phantomjs.version>2.1.1</phantomjs.version> <vaadin.version>8.0-SNAPSHOT</vaadin.version> <failOnMissingWebXml>false</failOnMissingWebXml> - <vaadin.testbench.version>5.0.0.alpha1</vaadin.testbench.version> </properties> <repositories> @@ -40,6 +39,12 @@ <dependencies> <!-- API DEPENDENCIES --> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.0.1</version> + </dependency> + <!-- Project modules --> <dependency> <groupId>com.vaadin</groupId> @@ -60,7 +65,6 @@ <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-testbench</artifactId> - <version>${vaadin.testbench.version}</version> <scope>test</scope> </dependency> </dependencies> @@ -75,6 +79,7 @@ <module>space in directory</module> <module>vaadinservletconfiguration-widget-set</module> <module>spring-boot</module> + <module>cdi</module> </modules> <build> diff --git a/test/spring-boot/src/main/java/com/example/DemoApplication.java b/test/spring-boot/src/main/java/com/example/DemoApplication.java index 9a4edd8769..62e6a76a36 100644 --- a/test/spring-boot/src/main/java/com/example/DemoApplication.java +++ b/test/spring-boot/src/main/java/com/example/DemoApplication.java @@ -1,5 +1,6 @@ package com.example; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -19,11 +20,13 @@ public class DemoApplication { @SpringUI class MyUI extends UI { - public static final String NOTIFICATION_TEXT = "Thank you for clicking."; + + @Autowired + ThankYouService service; @Override protected void init(VaadinRequest request) { setContent(new Button("Click Me!", - e -> Notification.show(NOTIFICATION_TEXT))); + e -> Notification.show(service.getText()))); } } diff --git a/test/spring-boot/src/main/java/com/example/ThankYouService.java b/test/spring-boot/src/main/java/com/example/ThankYouService.java new file mode 100644 index 0000000000..b387046659 --- /dev/null +++ b/test/spring-boot/src/main/java/com/example/ThankYouService.java @@ -0,0 +1,13 @@ +package com.example; + +import org.springframework.stereotype.Service; + +@Service +public class ThankYouService { + + public static final String THANK_YOU_TEXT = "Thank you for clicking."; + + public String getText() { + return THANK_YOU_TEXT; + } +} diff --git a/test/spring-boot/src/test/java/com/example/SpringBootSmokeTest.java b/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java index fe5357579b..2f1cb545d8 100644 --- a/test/spring-boot/src/test/java/com/example/SpringBootSmokeTest.java +++ b/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java @@ -22,7 +22,7 @@ import com.vaadin.testbench.parallel.Browser; */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class SpringBootSmokeTest extends TestBenchTestCase { +public class VaadinSpringBootSmokeIT extends TestBenchTestCase { @LocalServerPort Integer port; @@ -38,7 +38,7 @@ public class SpringBootSmokeTest extends TestBenchTestCase { getDriver().navigate().to("http://localhost:" + port + ""); $(ButtonElement.class).first().click(); Assert.assertTrue($(NotificationElement.class).exists()); - Assert.assertEquals(MyUI.NOTIFICATION_TEXT, + Assert.assertEquals(ThankYouService.THANK_YOU_TEXT, $(NotificationElement.class).first().getText()); } } |