From 5519bacd3c97fa0e9e84f35151c0a0f13e3a1df9 Mon Sep 17 00:00:00 2001 From: Johannes Eriksson Date: Fri, 13 Nov 2020 07:35:29 +0200 Subject: [PATCH] chore: remove test module test-subcontext (#9394) This module is subsumed by test-router-custom-context. (cherry picked from commit ea7d5c6ace26628da706bf335ec5bfef5e37df44) --- flow-tests/README.md | 3 - flow-tests/pom.xml | 1 - ...est Development Server (subcontext).launch | 18 --- flow-tests/test-subcontext/pom.xml | 105 ------------------ .../flow/contexttest/ui/DependencyUI.java | 101 ----------------- .../flow/contexttest/ui/NoRouterServlet.java | 55 --------- .../flow/contexttest/ui/RootContextUI.java | 42 ------- .../flow/contexttest/ui/SubContextUI.java | 28 ----- .../contexttest/ui/AbstractContextIT.java | 71 ------------ .../flow/contexttest/ui/RootContextIT.java | 18 --- .../flow/contexttest/ui/SubContextIT.java | 18 --- .../ui/SubContextNoEndingSlashIT.java | 18 --- .../contexttest/ui/SubContextSubPathIT.java | 18 --- 13 files changed, 496 deletions(-) delete mode 100644 flow-tests/test-subcontext/eclipse/UI Test Development Server (subcontext).launch delete mode 100644 flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/DependencyUI.java delete mode 100644 flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/NoRouterServlet.java delete mode 100644 flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/RootContextUI.java delete mode 100644 flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/SubContextUI.java delete mode 100644 flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/AbstractContextIT.java delete mode 100644 flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/RootContextIT.java delete mode 100644 flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextIT.java delete mode 100644 flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextNoEndingSlashIT.java delete mode 100644 flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextSubPathIT.java diff --git a/flow-tests/README.md b/flow-tests/README.md index 5ffa7789e21..15944b050c3 100644 --- a/flow-tests/README.md +++ b/flow-tests/README.md @@ -72,8 +72,6 @@ * Gattling scalability tests. Compatibility mode only. * test-servlet * Automatic servlet registration test -* test-subcontext - * `context://` tests for Compatibility mode * test-themes * Custom Theme tests for NPM and Compatibility modes * test-live-reload @@ -100,7 +98,6 @@ * Public resources used in test modules: * test-dev-mode * test-root-ui-context - * test-subcontext * test-scalability * test-servlet * test-pwa diff --git a/flow-tests/pom.xml b/flow-tests/pom.xml index 7faf900f4af..b604f16d19a 100644 --- a/flow-tests/pom.xml +++ b/flow-tests/pom.xml @@ -295,7 +295,6 @@ test-mixed/pom-npm.xml test-dev-mode test-pwa - test-subcontext test-root-ui-context test-router-custom-context test-live-reload diff --git a/flow-tests/test-subcontext/eclipse/UI Test Development Server (subcontext).launch b/flow-tests/test-subcontext/eclipse/UI Test Development Server (subcontext).launch deleted file mode 100644 index e6b66617deb..00000000000 --- a/flow-tests/test-subcontext/eclipse/UI Test Development Server (subcontext).launch +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/flow-tests/test-subcontext/pom.xml b/flow-tests/test-subcontext/pom.xml index 76ddb841c30..e69de29bb2d 100644 --- a/flow-tests/test-subcontext/pom.xml +++ b/flow-tests/test-subcontext/pom.xml @@ -1,105 +0,0 @@ - - - 4.0.0 - - com.vaadin - flow-tests - 4.0-SNAPSHOT - - flow-test-subcontext - Flow tests mapped for /context - war - - - true - 9999 - 9998 - - true - ${maven.test.skip} - - - - - com.vaadin - flow-test-resources - ${project.version} - - - - - - - - com.vaadin - flow-maven-plugin - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} - - - - start-jetty - pre-integration-test - - start - - - - stop-jetty - post-integration-test - - stop - - - - - - /context - - - - - - - - - local-run - - - !test.use.hub - - - - - - com.lazerycode.selenium - driver-binary-downloader-maven-plugin - ${driver.binary.downloader.maven.plugin.version} - - true - ${project.rootdir}/driver - ${project.rootdir}/driver_zips - ${project.rootdir}/drivers.xml - - - - pre-integration-test - - selenium - - - - - - - - - - diff --git a/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/DependencyUI.java b/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/DependencyUI.java deleted file mode 100644 index 0fdbf0f0d9d..00000000000 --- a/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/DependencyUI.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2000-2020 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.flow.contexttest.ui; - -import java.io.ByteArrayInputStream; -import java.nio.charset.StandardCharsets; - -import com.vaadin.flow.component.AttachEvent; -import com.vaadin.flow.component.UI; -import com.vaadin.flow.component.dependency.StyleSheet; -import com.vaadin.flow.component.html.Div; -import com.vaadin.flow.dom.Element; -import com.vaadin.flow.dom.ElementFactory; -import com.vaadin.flow.server.StreamRegistration; -import com.vaadin.flow.server.StreamResource; -import com.vaadin.flow.server.VaadinRequest; - -@StyleSheet("context://test-files/css/allred.css") -public class DependencyUI extends UI { - - @StyleSheet("context://test-files/css/allblueimportant.css") - public static class AllBlueImportantComponent extends Div { - - public AllBlueImportantComponent() { - setText("allblueimportant.css component"); - } - - } - - public static class JsResourceComponent extends Div { - - public JsResourceComponent() { - setText("Hello, click the body please"); - setId("hello"); - } - - @Override - protected void onAttach(AttachEvent attachEvent) { - attachEvent.getUI().getPage().addJavaScript( - "context://frontend/test-files/js/body-click-listener.js"); - } - } - - @Override - protected void init(VaadinRequest request) { - getElement().appendChild(ElementFactory.createDiv( - "This test initially loads a stylesheet which makes all text red and a JavaScript which listens to body clicks")); - getElement().appendChild(ElementFactory.createHr()); - add(new JsResourceComponent()); - - Element jsOrder = ElementFactory.createButton("Load js") - .setAttribute("id", "loadJs"); - StreamRegistration jsStreamRegistration = getSession() - .getResourceRegistry().registerResource(getJsResource()); - jsOrder.addEventListener("click", e -> { - getPage().addJavaScript("base://" - + jsStreamRegistration.getResourceUri().toString()); - }); - Element allBlue = ElementFactory - .createButton("Load 'everything blue' stylesheet") - .setAttribute("id", "loadBlue"); - allBlue.addEventListener("click", e -> { - add(new AllBlueImportantComponent()); - - }); - getElement().appendChild(jsOrder, allBlue, ElementFactory.createHr()); - } - - private StreamResource getJsResource() { - StreamResource jsRes = new StreamResource("element-appender.js", () -> { - String js = "var div = document.createElement('div');" - + "div.id = 'appended-element';" - + "div.textContent = 'Added by script';" - + "document.body.appendChild(div, null);"; - - // Wait to ensure that client side will stop until the JavaScript is - // loaded - try { - Thread.sleep(500); - } catch (Exception e1) { - } - return new ByteArrayInputStream( - js.getBytes(StandardCharsets.UTF_8)); - }); - return jsRes; - } - -} diff --git a/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/NoRouterServlet.java b/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/NoRouterServlet.java deleted file mode 100644 index e60ca30eed9..00000000000 --- a/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/NoRouterServlet.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2000-2020 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.flow.contexttest.ui; - -import javax.servlet.http.HttpServletResponse; - -import com.vaadin.flow.component.UI; -import com.vaadin.flow.function.DeploymentConfiguration; -import com.vaadin.flow.router.Location; -import com.vaadin.flow.router.NavigationTrigger; -import com.vaadin.flow.router.Router; -import com.vaadin.flow.server.ServiceException; -import com.vaadin.flow.server.VaadinServlet; -import com.vaadin.flow.server.VaadinServletService; - -public class NoRouterServlet extends VaadinServlet { - - @SuppressWarnings("serial") - @Override - protected VaadinServletService createServletService( - DeploymentConfiguration deploymentConfiguration) - throws ServiceException { - // service doesn't use router actually. UI class is responsible to - // show and update the content by itself with only root route available - VaadinServletService service = new VaadinServletService(this, - deploymentConfiguration) { - @Override - public Router getRouter() { - Router router = new Router(getRouteRegistry()) { - @Override - public int navigate(UI ui, Location location, - NavigationTrigger trigger) { - return HttpServletResponse.SC_OK; - } - }; - return router; - } - }; - service.init(); - return service; - } -} diff --git a/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/RootContextUI.java b/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/RootContextUI.java deleted file mode 100644 index 27efa18f022..00000000000 --- a/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/RootContextUI.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2020 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.flow.contexttest.ui; - -import javax.servlet.annotation.WebServlet; - -import com.vaadin.flow.dom.ElementFactory; -import com.vaadin.flow.server.VaadinRequest; -import com.vaadin.flow.server.VaadinServletConfiguration; - -public class RootContextUI extends DependencyUI { - - /** - * The main servlet for the application. - */ - @WebServlet(urlPatterns = { - "/*" }, name = "UIServlet", asyncSupported = true) - @VaadinServletConfiguration(ui = RootContextUI.class, productionMode = false) - public static class Servlet extends NoRouterServlet { - } - - @Override - protected void init(VaadinRequest request) { - getElement().appendChild(ElementFactory.createDiv("Root Context UI") - .setAttribute("id", "root")); - super.init(request); - } - -} diff --git a/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/SubContextUI.java b/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/SubContextUI.java deleted file mode 100644 index af7f4496ee3..00000000000 --- a/flow-tests/test-subcontext/src/main/java/com/vaadin/flow/contexttest/ui/SubContextUI.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.vaadin.flow.contexttest.ui; - -import javax.servlet.annotation.WebServlet; - -import com.vaadin.flow.dom.ElementFactory; -import com.vaadin.flow.server.VaadinRequest; -import com.vaadin.flow.server.VaadinServletConfiguration; - -public class SubContextUI extends DependencyUI { - - /** - * The main servlet for the application. - */ - @WebServlet(urlPatterns = { - "/SubContext/*" }, name = "AnotherServlet", asyncSupported = true) - @VaadinServletConfiguration(ui = SubContextUI.class, productionMode = false) - public static class SubContextServlet extends NoRouterServlet { - - } - - @Override - protected void init(VaadinRequest request) { - getElement().appendChild(ElementFactory.createDiv("Sub Context UI") - .setAttribute("id", "sub")); - super.init(request); - } - -} diff --git a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/AbstractContextIT.java b/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/AbstractContextIT.java deleted file mode 100644 index f2a5c1bf487..00000000000 --- a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/AbstractContextIT.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.vaadin.flow.contexttest.ui; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.flow.testutil.ChromeBrowserTest; - -public abstract class AbstractContextIT extends ChromeBrowserTest { - - private static final String JETTY_CONTEXT = "/context"; - - private static final String RED = "rgba(255, 0, 0, 1)"; - private static final String BLUE = "rgba(0, 0, 255, 1)"; - - protected abstract String getAppContext(); - - protected abstract void verifyCorrectUI(); - - @Override - protected String getTestPath() { - return JETTY_CONTEXT + getAppContext(); - } - - @Test - public void testStyleInjection() { - open(); - verifyCorrectUI(); - styleInjection(); - } - - @Test - public void testScriptInjection() { - open(); - verifyCorrectUI(); - scriptInjection(); - } - - private void styleInjection() { - // Initial stylesheet makes all text red - Assert.assertEquals(RED, findElementById("hello").getCssValue("color")); - - // Inject stylesheet which makes text blue - findElementById("loadBlue").click(); - - // Wait as the framework will not stop until the stylesheet is loaded - waitUntil(input -> findElementById("hello").getCssValue("color") - .equals(BLUE)); - } - - private void scriptInjection() { - // Initial JS registers a body click handler - findElement(By.cssSelector("body")).click(); - String addedBodyText = findElement(By.cssSelector(".body-click-added")) - .getText(); - Assert.assertEquals( - "Click on body, reported by JavaScript click handler", - addedBodyText); - - // Inject scripts - findElementById("loadJs").click(); - String addedJsText = findElementById("appended-element").getText(); - Assert.assertEquals("Added by script", addedJsText); - } - - protected WebElement findElementById(String id) { - return findElement(By.id(id)); - } - -} diff --git a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/RootContextIT.java b/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/RootContextIT.java deleted file mode 100644 index 1574c1d96df..00000000000 --- a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/RootContextIT.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vaadin.flow.contexttest.ui; - -import org.junit.Assert; -import org.openqa.selenium.By; - -public class RootContextIT extends AbstractContextIT { - - @Override - protected String getAppContext() { - return ""; - } - - @Override - protected void verifyCorrectUI() { - Assert.assertNotNull(findElement(By.id("root"))); - } - -} diff --git a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextIT.java b/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextIT.java deleted file mode 100644 index 2a186032956..00000000000 --- a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextIT.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vaadin.flow.contexttest.ui; - -import org.junit.Assert; -import org.openqa.selenium.By; - -public class SubContextIT extends AbstractContextIT { - - @Override - protected String getAppContext() { - return "/SubContext/"; - } - - @Override - protected void verifyCorrectUI() { - Assert.assertNotNull(findElement(By.id("sub"))); - } - -} diff --git a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextNoEndingSlashIT.java b/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextNoEndingSlashIT.java deleted file mode 100644 index 624a249c283..00000000000 --- a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextNoEndingSlashIT.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vaadin.flow.contexttest.ui; - -import org.junit.Assert; -import org.openqa.selenium.By; - -public class SubContextNoEndingSlashIT extends AbstractContextIT { - - @Override - protected String getAppContext() { - return "/SubContext"; - } - - @Override - protected void verifyCorrectUI() { - Assert.assertNotNull(findElement(By.id("sub"))); - } - -} diff --git a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextSubPathIT.java b/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextSubPathIT.java deleted file mode 100644 index 74ea925f668..00000000000 --- a/flow-tests/test-subcontext/src/test/java/com/vaadin/flow/contexttest/ui/SubContextSubPathIT.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vaadin.flow.contexttest.ui; - -import org.junit.Assert; -import org.openqa.selenium.By; - -public class SubContextSubPathIT extends AbstractContextIT { - - @Override - protected String getAppContext() { - return "/SubContext/foo/bar"; - } - - @Override - protected void verifyCorrectUI() { - Assert.assertNotNull(findElement(By.id("sub"))); - } - -}