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 /test/cdi | |
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.
Diffstat (limited to 'test/cdi')
5 files changed, 159 insertions, 0 deletions
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()); + } +} |