summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorIlia Motornyi <elmot@vaadin.com>2017-01-26 16:27:54 +0200
committerAleksi Hietanen <aleksi@vaadin.com>2017-01-26 16:27:54 +0200
commitddbb619651a9073666274592359124ce271725ed (patch)
tree15f79b7c13f673c5fce05d5f0ab742ddfa8823a6 /test
parent9abf1eeab7196c0ac75a23101c262bfa404d1c84 (diff)
downloadvaadin-framework-ddbb619651a9073666274592359124ce271725ed.tar.gz
vaadin-framework-ddbb619651a9073666274592359124ce271725ed.zip
JspIntegrationTest as a separate module (#8228)
Part of vaadin/framework8-issues#539
Diffstat (limited to 'test')
-rw-r--r--test/pom.xml3
-rw-r--r--test/servlet-containers/jsp-integration/pom.xml30
-rw-r--r--test/servlet-containers/jsp-integration/src/main/java/com/vaadin/tests/integration/AnotherTrivialUI.java28
-rw-r--r--test/servlet-containers/jsp-integration/src/main/java/com/vaadin/tests/integration/TrivialUI.java30
-rw-r--r--test/servlet-containers/jsp-integration/src/main/webapp/WEB-INF/web.xml57
-rw-r--r--test/servlet-containers/jsp-integration/src/main/webapp/staticfiles/vaadinsessions.jsp54
-rw-r--r--test/servlet-containers/jsp-integration/src/test/java/com/vaadin/tests/integration/JSPIntegrationIT.java105
7 files changed, 307 insertions, 0 deletions
diff --git a/test/pom.xml b/test/pom.xml
index d0a148cbfa..b9493fcb55 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -17,6 +17,8 @@
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<failOnMissingWebXml>false</failOnMissingWebXml>
<contextmenu.version>2.0-SNAPSHOT</contextmenu.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Don't care about coding style for tests -->
<sonar.skip>true</sonar.skip>
</properties>
@@ -99,6 +101,7 @@
<module>vaadinservletconfiguration-widget-set</module>
<module>spring-boot</module>
<module>cdi</module>
+ <module>servlet-containers/jsp-integration</module>
<module>bean-api-validation</module>
<module>bean-impl-validation</module>
</modules>
diff --git a/test/servlet-containers/jsp-integration/pom.xml b/test/servlet-containers/jsp-integration/pom.xml
new file mode 100644
index 0000000000..c32914c3c0
--- /dev/null
+++ b/test/servlet-containers/jsp-integration/pom.xml
@@ -0,0 +1,30 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-test</artifactId>
+ <version>8.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <artifactId>vaadin-test-jsp-integration</artifactId>
+ <name>vaadin-test-jsp-integration</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-client-compiled</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-uitest-common</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/test/servlet-containers/jsp-integration/src/main/java/com/vaadin/tests/integration/AnotherTrivialUI.java b/test/servlet-containers/jsp-integration/src/main/java/com/vaadin/tests/integration/AnotherTrivialUI.java
new file mode 100644
index 0000000000..a165b81282
--- /dev/null
+++ b/test/servlet-containers/jsp-integration/src/main/java/com/vaadin/tests/integration/AnotherTrivialUI.java
@@ -0,0 +1,28 @@
+package com.vaadin.tests.integration;
+/*
+ * Copyright 2000-2017 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.UI;
+
+public class AnotherTrivialUI extends UI {
+ @Override
+ protected void init(VaadinRequest request) {
+ setContent(new Label("Another Trivial UI"));
+ }
+
+}
diff --git a/test/servlet-containers/jsp-integration/src/main/java/com/vaadin/tests/integration/TrivialUI.java b/test/servlet-containers/jsp-integration/src/main/java/com/vaadin/tests/integration/TrivialUI.java
new file mode 100644
index 0000000000..b7c7a56b52
--- /dev/null
+++ b/test/servlet-containers/jsp-integration/src/main/java/com/vaadin/tests/integration/TrivialUI.java
@@ -0,0 +1,30 @@
+package com.vaadin.tests.integration;
+/*
+ * Copyright 2000-2017 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import com.vaadin.annotations.VaadinServletConfiguration;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinServlet;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.UI;
+
+public class TrivialUI extends UI {
+ @Override
+ protected void init(VaadinRequest request) {
+ setContent(new Label("Trivial UI"));
+ }
+
+}
diff --git a/test/servlet-containers/jsp-integration/src/main/webapp/WEB-INF/web.xml b/test/servlet-containers/jsp-integration/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..1d0326bd19
--- /dev/null
+++ b/test/servlet-containers/jsp-integration/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app id="vaadin-uitest" version="3.0"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+
+ <!-- THIS IS A DEVELOPMENT AND TESTING web.xml . -->
+
+ <display-name>Vaadin</display-name>
+ <description>Vaadin JSP Integration Test</description>
+
+ <context-param>
+ <param-name>productionMode</param-name>
+ <param-value>false</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>VaadinStaticFiles</servlet-name>
+ <servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
+ <async-supported>false</async-supported>
+ </servlet>
+
+ <servlet>
+ <servlet-name>PrimaryUIServlet</servlet-name>
+ <servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
+ <init-param>
+ <param-name>UI</param-name>
+ <param-value>com.vaadin.tests.integration.TrivialUI</param-value>
+ </init-param>
+ <async-supported>true</async-supported>
+ </servlet>
+
+ <servlet>
+ <servlet-name>SecondaryUIServlet</servlet-name>
+ <servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
+ <init-param>
+ <param-name>UI</param-name>
+ <param-value>com.vaadin.tests.integration.AnotherTrivialUI</param-value>
+ </init-param>
+ <async-supported>true</async-supported>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>PrimaryUIServlet</servlet-name>
+ <url-pattern>/primaryui/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>SecondaryUIServlet</servlet-name>
+ <url-pattern>/secondaryui/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>VaadinStaticFiles</servlet-name>
+ <url-pattern>/VAADIN/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/test/servlet-containers/jsp-integration/src/main/webapp/staticfiles/vaadinsessions.jsp b/test/servlet-containers/jsp-integration/src/main/webapp/staticfiles/vaadinsessions.jsp
new file mode 100644
index 0000000000..b22787a203
--- /dev/null
+++ b/test/servlet-containers/jsp-integration/src/main/webapp/staticfiles/vaadinsessions.jsp
@@ -0,0 +1,54 @@
+<!DOCTYPE>
+<%@page import="com.vaadin.ui.UI"%>
+<%@page import="com.vaadin.server.VaadinSession"%>
+<HTML>
+<HEAD>
+<TITLE>JSP integration</TITLE>
+<style>
+table {
+ background: #fff;
+}
+
+td {
+ border: 1px solid black;
+ padding: .5em;
+}
+</style>
+</HEAD>
+<BODY>
+ <table>
+ <tr>
+ <th align="left" colspan=4>Available UIs:</th>
+ </tr>
+ <tr>
+ <th>Service Name</th>
+ <th>CSRF token</th>
+ <th>UI id</th>
+ <th>UI type</th>
+ <th>Main content</th>
+ </tr>
+ <%
+ HttpSession httpSession = request.getSession(false);
+ for (VaadinSession vs : VaadinSession.getAllSessions(httpSession)) {
+ try {
+ vs.lock();
+ for (UI ui : vs.getUIs()) {
+ out.append("<tr class='uirow'>");
+ out.append("<td>" + vs.getService().getServiceName()
+ + "</td>");
+ out.append("<td>" + vs.getCsrfToken() + "</td>");
+ out.append("<td>" + ui.getUIId() + "</td>");
+ out.append("<td>" + ui.getClass().getName() + "</td>");
+ out.append("<td>" + ui.getContent().getClass().getName() + "</td>");
+ out.append("</tr>");
+
+ }
+ } finally {
+ vs.unlock();
+ }
+
+ }
+ %>
+ </table>
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/test/servlet-containers/jsp-integration/src/test/java/com/vaadin/tests/integration/JSPIntegrationIT.java b/test/servlet-containers/jsp-integration/src/test/java/com/vaadin/tests/integration/JSPIntegrationIT.java
new file mode 100644
index 0000000000..5a6c62724e
--- /dev/null
+++ b/test/servlet-containers/jsp-integration/src/test/java/com/vaadin/tests/integration/JSPIntegrationIT.java
@@ -0,0 +1,105 @@
+package com.vaadin.tests.integration;
+/*
+ * Copyright 2000-2017 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import com.vaadin.testbench.TestBenchTestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.phantomjs.PhantomJSDriver;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+public class JSPIntegrationIT extends TestBenchTestCase {
+
+ private static final String URL_PREFIX = "http://localhost:8080/";
+
+ private static final String primaryUIUrl = URL_PREFIX + "primaryui";
+ private static final String jspUrl = URL_PREFIX + "staticfiles/vaadinsessions.jsp";
+ private static final String secondaryUIUrl = URL_PREFIX + "secondaryui";
+
+ @Test
+ public void listVaadinSessions() {
+
+ assertUICount(0);
+
+ // Open a new UI
+ getDriver().navigate().to(primaryUIUrl);
+
+
+ assertUICount(1);
+ UIData firstUI = getUIs().get(0);
+
+ // Open a new UI
+ getDriver().navigate().to(primaryUIUrl);
+ UIData secondUI = getUIs().get(0);
+
+ // Should now have UI for the same service with different uiId
+ assertUICount(1);
+ assertNotEquals(firstUI.uiId, secondUI.uiId);
+ assertEquals(firstUI.serviceName, secondUI.serviceName);
+
+ getDriver().navigate().to(secondaryUIUrl);
+ // Should now have another services
+ List<UIData> twoUIs = getUIs();
+ assertEquals(2, twoUIs.size());
+ assertNotEquals(twoUIs.get(0).serviceName, twoUIs.get(1).serviceName);
+ }
+
+ private static class UIData {
+ private String serviceName;
+ private int uiId;
+ }
+
+ private List<UIData> getUIs() {
+ List<UIData> uis = new ArrayList<>();
+
+ getDriver().get(jspUrl);
+ List<WebElement> rows = getDriver()
+ .findElements(By.xpath("//tr[@class='uirow']"));
+ for (WebElement row : rows) {
+ UIData data = new UIData();
+ List<WebElement> tds = row.findElements(By.xpath("./td"));
+
+ data.serviceName = tds.get(0).getText();
+ data.uiId = Integer.parseInt(tds.get(2).getText());
+
+ uis.add(data);
+ }
+
+ return uis;
+ }
+
+ private void assertUICount(int i) {
+ assertEquals(i, getUIs().size());
+ }
+
+ @Before
+ public void setup() {
+ setDriver(new PhantomJSDriver());
+ }
+
+ @After
+ public void teardown() {
+ getDriver().quit();
+ }
+}