Part of vaadin/framework8-issues#539tags/8.0.0.beta2
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version> | <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version> | ||||
<failOnMissingWebXml>false</failOnMissingWebXml> | <failOnMissingWebXml>false</failOnMissingWebXml> | ||||
<contextmenu.version>2.0-SNAPSHOT</contextmenu.version> | <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 --> | <!-- Don't care about coding style for tests --> | ||||
<sonar.skip>true</sonar.skip> | <sonar.skip>true</sonar.skip> | ||||
</properties> | </properties> | ||||
<module>vaadinservletconfiguration-widget-set</module> | <module>vaadinservletconfiguration-widget-set</module> | ||||
<module>spring-boot</module> | <module>spring-boot</module> | ||||
<module>cdi</module> | <module>cdi</module> | ||||
<module>servlet-containers/jsp-integration</module> | |||||
<module>bean-api-validation</module> | <module>bean-api-validation</module> | ||||
<module>bean-impl-validation</module> | <module>bean-impl-validation</module> | ||||
</modules> | </modules> |
<?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> |
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")); | |||||
} | |||||
} |
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")); | |||||
} | |||||
} |
<?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> |
package com.vaadin.tests.integration; | |||||
/* | /* | ||||
* Copyright 2000-2016 Vaadin Ltd. | |||||
* Copyright 2000-2017 Vaadin Ltd. | |||||
* | * | ||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | * 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 | * use this file except in compliance with the License. You may obtain a copy of | ||||
* License for the specific language governing permissions and limitations under | * License for the specific language governing permissions and limitations under | ||||
* the License. | * the License. | ||||
*/ | */ | ||||
package com.vaadin.tests.integration; | |||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertNotEquals; | |||||
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.ArrayList; | ||||
import java.util.HashSet; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Set; | |||||
import org.junit.Test; | |||||
import org.openqa.selenium.By; | |||||
import org.openqa.selenium.WebElement; | |||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertNotEquals; | |||||
import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; | |||||
public class JSPIntegrationIT extends TestBenchTestCase { | |||||
public class JSPIntegrationTest extends SingleBrowserTestPhantomJS2 { | |||||
private static final String URL_PREFIX = "http://localhost:8080/"; | |||||
final String appRunnerTestUrl = getBaseURL() + "/run/Buttons"; | |||||
final String jspUrl = getBaseURL() + "/statictestfiles/vaadinsessions.jsp"; | |||||
final String integrationUrl = getBaseURL() + "/integration"; | |||||
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 | @Test | ||||
public void listVaadinSessions() { | public void listVaadinSessions() { | ||||
assertUICount(0); | assertUICount(0); | ||||
// Open a new UI | // Open a new UI | ||||
getDriver().get(integrationUrl); | |||||
getDriver().navigate().to(primaryUIUrl); | |||||
assertUICount(1); | assertUICount(1); | ||||
UIData firstUI = getUIs().get(0); | |||||
// Open a new UI | // Open a new UI | ||||
getDriver().get(integrationUrl); | |||||
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); | |||||
// Should now have two UIs for the same service with different uiIds | |||||
getDriver().navigate().to(secondaryUIUrl); | |||||
// Should now have another services | |||||
List<UIData> twoUIs = getUIs(); | List<UIData> twoUIs = getUIs(); | ||||
assertEquals(2, twoUIs.size()); | assertEquals(2, twoUIs.size()); | ||||
assertNotEquals(twoUIs.get(0).uiId, twoUIs.get(1).uiId); | |||||
assertEquals(twoUIs.get(0).serviceName, twoUIs.get(1).serviceName); | |||||
getDriver().get(appRunnerTestUrl); | |||||
// Should now have two services with 2 + 1 UIs | |||||
List<UIData> threeUIs = getUIs(); | |||||
assertEquals(3, threeUIs.size()); | |||||
Set<String> serviceNames = new HashSet<>(); | |||||
Set<Integer> uiIds = new HashSet<>(); | |||||
for (UIData uiData : threeUIs) { | |||||
serviceNames.add(uiData.serviceName); | |||||
uiIds.add(uiData.uiId); | |||||
} | |||||
assertGreaterOrEqual( | |||||
"There should be at least two unique service names", | |||||
serviceNames.size(), 2); | |||||
assertGreaterOrEqual("There should be at least two unique ui ids", | |||||
uiIds.size(), 2); | |||||
assertNotEquals(twoUIs.get(0).serviceName, twoUIs.get(1).serviceName); | |||||
} | } | ||||
private static class UIData { | private static class UIData { | ||||
private void assertUICount(int i) { | private void assertUICount(int i) { | ||||
assertEquals(i, getUIs().size()); | assertEquals(i, getUIs().size()); | ||||
} | } | ||||
@Before | |||||
public void setup() { | |||||
setDriver(new PhantomJSDriver()); | |||||
} | |||||
@After | |||||
public void teardown() { | |||||
getDriver().quit(); | |||||
} | |||||
} | } |
<url-pattern>/run-jsr356/*</url-pattern> | <url-pattern>/run-jsr356/*</url-pattern> | ||||
</servlet-mapping> | </servlet-mapping> | ||||
<servlet-mapping> | |||||
<servlet-name>IntegrationTest</servlet-name> | |||||
<url-pattern>/integration/*</url-pattern> | |||||
</servlet-mapping> | |||||
<servlet-mapping> | <servlet-mapping> | ||||
<servlet-name>CommErrorEmulator</servlet-name> | <servlet-name>CommErrorEmulator</servlet-name> | ||||
<url-pattern>/commerror/*</url-pattern> | <url-pattern>/commerror/*</url-pattern> |