aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-10-26 22:35:23 +0300
committerVaadin Code Review <review@vaadin.com>2016-10-29 07:34:54 +0000
commit1e978a6ba0924c240803543a31d024b7c649f4ce (patch)
tree4ebe5a576e2b4c05417b0822c8becb91bd091130 /uitest/src
parent334b3f0a4b393f274d171dddc359be605c2cd1b1 (diff)
downloadvaadin-framework-1e978a6ba0924c240803543a31d024b7c649f4ce.tar.gz
vaadin-framework-1e978a6ba0924c240803543a31d024b7c649f4ce.zip
Serve static files also in servletPath/VAADIN (#14398)
Change-Id: I6891827a1fb99216d4e286c761d1384a88000604
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/webapp/WEB-INF/web.xml14
-rw-r--r--uitest/src/test/java/com/vaadin/tests/applicationservlet/ServletWithResourcesTest.java68
2 files changed, 82 insertions, 0 deletions
diff --git a/uitest/src/main/webapp/WEB-INF/web.xml b/uitest/src/main/webapp/WEB-INF/web.xml
index b96257b1e0..31f535e383 100644
--- a/uitest/src/main/webapp/WEB-INF/web.xml
+++ b/uitest/src/main/webapp/WEB-INF/web.xml
@@ -146,6 +146,15 @@
</init-param>
<async-supported>true</async-supported>
</servlet>
+ <servlet>
+ <servlet-name>ResourcesFromServlet</servlet-name>
+ <servlet-class>com.vaadin.launcher.ApplicationRunnerServlet</servlet-class>
+ <init-param>
+ <param-name>resources</param-name>
+ <param-value>/servlet-with-resources</param-value>
+ </init-param>
+ <async-supported>true</async-supported>
+ </servlet>
<!-- For testing GAE - the deployment script changes this to use GAEVaadinServlet -->
<servlet>
@@ -221,6 +230,11 @@
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>ResourcesFromServlet</servlet-name>
+ <url-pattern>/servlet-with-resources/*</url-pattern>
+ </servlet-mapping>
+
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServletWithResourcesTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServletWithResourcesTest.java
new file mode 100644
index 0000000000..92d5795eee
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServletWithResourcesTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2000-2016 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.
+ */
+package com.vaadin.tests.applicationservlet;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.tests.components.label.LabelModes;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class ServletWithResourcesTest extends SingleBrowserTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return LabelModes.class;
+ }
+
+ @Override
+ protected String getDeploymentPath(Class<?> uiClass) {
+ return super.getDeploymentPath(uiClass).replaceAll("/run/",
+ "/servlet-with-resources/");
+ }
+
+ @Test
+ public void servletServesResources() {
+ openTestURL();
+ Assert.assertEquals("Enabled",
+ $(CheckBoxElement.class).first().getCaption());
+
+ List<WebElement> links = findElements(By.xpath("//head/link"));
+ for (WebElement link : links) {
+ String href = link.getAttribute("href");
+ Assert.assertTrue(
+ "href '" + href
+ + "' should contain '/servlet-with-resources/VAADIN'",
+ href.contains("/servlet-with-resources/VAADIN"));
+ }
+
+ List<WebElement> scripts = findElements(By.xpath("//head/script"));
+ for (WebElement script : scripts) {
+ String src = script.getAttribute("src");
+ Assert.assertTrue(
+ "src '" + src
+ + "' should contain '/servlet-with-resources/VAADIN'",
+ src.contains("/servlet-with-resources/VAADIN"));
+ }
+
+ }
+
+}