From 4852034df2cad35489eb5d358a8ddc0b356d8568 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 14 Dec 2016 13:10:39 +0200 Subject: Add Vaadin Spring dependency version to BOM (#112) * Add Vaadin Spring dependency version to BOM This patch adds a smoke test that check that a basic Vaadin UI loads and communication works. * Remove Maven wrapper from Spring Boot test * Remove .gitignore, add missing newlines * Minor fixes to pom.xml files * Separate vaadin-test from vaadin-root * Fix whitespace --- test/pom.xml | 58 +++++++++------ test/spring-boot/pom.xml | 82 ++++++++++++++++++++++ .../src/main/java/com/example/DemoApplication.java | 29 ++++++++ .../src/main/resources/application.properties | 0 .../test/java/com/example/SpringBootSmokeTest.java | 44 ++++++++++++ 5 files changed, 191 insertions(+), 22 deletions(-) create mode 100644 test/spring-boot/pom.xml create mode 100644 test/spring-boot/src/main/java/com/example/DemoApplication.java create mode 100644 test/spring-boot/src/main/resources/application.properties create mode 100644 test/spring-boot/src/test/java/com/example/SpringBootSmokeTest.java (limited to 'test') diff --git a/test/pom.xml b/test/pom.xml index b1ee2fb074..6a4ce4f7ee 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -2,16 +2,20 @@ 4.0.0 - - com.vaadin - vaadin-root - 8.0-SNAPSHOT - + com.vaadin vaadin-test vaadin-test + 1.0-SNAPSHOT + pom + 1.8 + 1.8 + 9.3.7.v20160115 + 2.1.1 + 8.0-SNAPSHOT false + 5.0.0.alpha1 @@ -21,6 +25,18 @@ + + + + com.vaadin + vaadin-bom + ${vaadin.version} + pom + import + + + + @@ -28,36 +44,23 @@ com.vaadin vaadin-server - ${project.version} com.vaadin vaadin-themes - ${project.version} - - - - - javax.servlet - javax.servlet-api - provided - junit junit - test - - - org.hamcrest - hamcrest-all + 4.12 test com.vaadin vaadin-testbench + ${vaadin.testbench.version} test @@ -71,6 +74,7 @@ addon-using-init-param-widget-set space in directory vaadinservletconfiguration-widget-set + spring-boot @@ -107,6 +111,7 @@ com.github.klieber phantomjs-maven-plugin + 0.7 @@ -118,12 +123,13 @@ - maven-surefire-plugin + 2.19.1 maven-failsafe-plugin + 2.19.1 @@ -138,6 +144,14 @@ + + + maven-install-plugin + 2.5.2 + + true + + - \ No newline at end of file + diff --git a/test/spring-boot/pom.xml b/test/spring-boot/pom.xml new file mode 100644 index 0000000000..8cdde7ec98 --- /dev/null +++ b/test/spring-boot/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + + com.vaadin + vaadin-test + 1.0-SNAPSHOT + + vaadin-test-spring-boot + jar + + vaadin-test-spring-boot + Demo project for Vaadin Spring Boot + + + UTF-8 + UTF-8 + 1.8 + 1.4.2.RELEASE + + + + + com.vaadin + vaadin-spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + com.vaadin + vaadin-bom + ${vaadin.version} + pom + import + + + org.springframework.boot + spring-boot-starter-parent + pom + import + ${spring.boot.version} + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + + start-jetty + + + + stop-jetty + + + + + + + + diff --git a/test/spring-boot/src/main/java/com/example/DemoApplication.java b/test/spring-boot/src/main/java/com/example/DemoApplication.java new file mode 100644 index 0000000000..9a4edd8769 --- /dev/null +++ b/test/spring-boot/src/main/java/com/example/DemoApplication.java @@ -0,0 +1,29 @@ +package com.example; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.spring.annotation.SpringUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Notification; +import com.vaadin.ui.UI; + +@SpringBootApplication +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } +} + +@SpringUI +class MyUI extends UI { + public static final String NOTIFICATION_TEXT = "Thank you for clicking."; + + @Override + protected void init(VaadinRequest request) { + setContent(new Button("Click Me!", + e -> Notification.show(NOTIFICATION_TEXT))); + } +} diff --git a/test/spring-boot/src/main/resources/application.properties b/test/spring-boot/src/main/resources/application.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/spring-boot/src/test/java/com/example/SpringBootSmokeTest.java b/test/spring-boot/src/test/java/com/example/SpringBootSmokeTest.java new file mode 100644 index 0000000000..fe5357579b --- /dev/null +++ b/test/spring-boot/src/test/java/com/example/SpringBootSmokeTest.java @@ -0,0 +1,44 @@ +package com.example; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openqa.selenium.phantomjs.PhantomJSDriver; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.vaadin.testbench.TestBench; +import com.vaadin.testbench.TestBenchTestCase; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.NotificationElement; +import com.vaadin.testbench.parallel.Browser; + +/** + * @author Vaadin Ltd + * + */ +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class SpringBootSmokeTest extends TestBenchTestCase { + + @LocalServerPort + Integer port; + + @Before + public void setUp() { + setDriver(TestBench.createDriver(new PhantomJSDriver( + Browser.PHANTOMJS.getDesiredCapabilities()))); + } + + @Test + public void testPageLoadsAndButtonWorks() { + getDriver().navigate().to("http://localhost:" + port + ""); + $(ButtonElement.class).first().click(); + Assert.assertTrue($(NotificationElement.class).exists()); + Assert.assertEquals(MyUI.NOTIFICATION_TEXT, + $(NotificationElement.class).first().getText()); + } +} -- cgit v1.2.3