From a2d315550fb0fc8f557698ef60cd1c1b7631a42e Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 15 Feb 2017 10:45:06 +0200 Subject: Remove vaadin-uitest-common dependency from server tests (#8551) Uses custom reference and error files in test project. --- test/servlet-containers/generic/pom.xml | 22 ++- .../reference-screenshots/finland-phantomjs.png | Bin 0 -> 11577 bytes .../reference-screenshots/initial-phantomjs.png | Bin 0 -> 10740 bytes .../tests/integration/AbstractIntegrationTest.java | 159 ++++++++++++++++----- .../AbstractServletIntegrationTest.java | 66 +-------- .../tests/integration/CustomBrowserFactory.java | 21 +++ .../ServletIntegrationDefaultPushIT.java | 26 ++++ .../ServletIntegrationDefaultPushUITest.java | 21 --- .../tests/integration/ServletIntegrationIT.java | 25 ++++ .../ServletIntegrationJSR356WebsocketUITest.java | 32 ----- .../ServletIntegrationLongPollingIT.java | 26 ++++ .../ServletIntegrationLongPollingUITest.java | 21 --- .../integration/ServletIntegrationStreamingIT.java | 26 ++++ .../ServletIntegrationStreamingUITest.java | 21 --- .../tests/integration/ServletIntegrationTests.java | 65 +++------ .../integration/ServletIntegrationUITest.java | 20 --- .../ServletIntegrationWebsocketUITest.java | 21 --- .../tests/integration/push/BasicPushTest.java | 109 -------------- .../integration/push/LongPollingProxyServerIT.java | 106 ++++++++++++++ .../push/LongPollingProxyServerTest.java | 105 -------------- .../websocket/ServletIntegrationWebsocketIT.java | 28 ++++ .../ServletIntegrationJSR356WebsocketIT.java | 28 ++++ 22 files changed, 448 insertions(+), 500 deletions(-) create mode 100644 test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png create mode 100644 test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png create mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/CustomBrowserFactory.java create mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushIT.java delete mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUITest.java create mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationIT.java delete mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationJSR356WebsocketUITest.java create mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingIT.java delete mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java create mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingIT.java delete mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java delete mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationUITest.java delete mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java delete mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/BasicPushTest.java create mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java delete mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerTest.java create mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/websocket/ServletIntegrationWebsocketIT.java create mode 100644 test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/websocket/jsr356/ServletIntegrationJSR356WebsocketIT.java diff --git a/test/servlet-containers/generic/pom.xml b/test/servlet-containers/generic/pom.xml index 4c1c9b8292..e68e6be2fa 100644 --- a/test/servlet-containers/generic/pom.xml +++ b/test/servlet-containers/generic/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.vaadin @@ -13,6 +13,7 @@ war 8.0.0 + true @@ -41,8 +42,7 @@ com.vaadin - vaadin-uitest-common - ${project.version} + vaadin-testbench-api test @@ -51,13 +51,15 @@ - + org.eclipse.jetty jetty-maven-plugin ${jetty.version} - true + + /demo + @@ -72,6 +74,13 @@ true + + maven-failsafe-plugin + + + true + + maven-war-plugin @@ -79,7 +88,8 @@ ${project.build.outputDirectory}/META-INF/MANIFEST.MF - + jboss6-war diff --git a/test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png b/test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png new file mode 100644 index 0000000000..e372c198e2 Binary files /dev/null and b/test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png differ diff --git a/test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png b/test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png new file mode 100644 index 0000000000..642759734e Binary files /dev/null and b/test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png differ diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractIntegrationTest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractIntegrationTest.java index da0d6cb08e..6a948f63d8 100644 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractIntegrationTest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractIntegrationTest.java @@ -1,37 +1,91 @@ -/* - * 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.integration; -import com.vaadin.testbench.By; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.imageio.ImageIO; + +import org.junit.After; +import org.junit.runner.RunWith; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.support.ui.ExpectedCondition; +import org.openqa.selenium.support.ui.WebDriverWait; + +import com.vaadin.testbench.annotations.BrowserConfiguration; +import com.vaadin.testbench.annotations.BrowserFactory; +import com.vaadin.testbench.annotations.RunOnHub; import com.vaadin.testbench.elements.UIElement; +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.testbench.parallel.BrowserUtil; +import com.vaadin.testbench.parallel.ParallelRunner; +import com.vaadin.testbench.parallel.ParallelTest; import com.vaadin.testbench.parallel.TestNameSuffix; -import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; - -/** - * Base class for integration tests. Integration tests use the - * {@literal deployment.url} parameter to determine the base deployment url - * (http://hostname:123) - * - * @author Vaadin Ltd - */ +import com.vaadin.testbench.screenshot.ImageFileUtil; + +@RunOnHub("tb3-hub.intra.itmill.com") +@RunWith(ParallelRunner.class) +@BrowserFactory(CustomBrowserFactory.class) @TestNameSuffix(property = "server-name") -public abstract class AbstractIntegrationTest - extends SingleBrowserTestPhantomJS2 { +public abstract class AbstractIntegrationTest extends ParallelTest { + + /** + * Height of the screenshots we want to capture + */ + private static final int SCREENSHOT_HEIGHT = 850; + + /** + * Width of the screenshots we want to capture + */ + private static final int SCREENSHOT_WIDTH = 1500; + + private boolean screenshotErrors; + + @BrowserConfiguration + public final List getBrowsersToTest() { + return getBrowsers().map(BrowserUtil.getBrowserFactory()::create) + .collect(Collectors.toList()); + } + + protected Stream getBrowsers() { + return Stream.of(Browser.PHANTOMJS); + } + @Override - protected String getBaseURL() { + public void setup() throws Exception { + super.setup(); + + testBench().resizeViewPortTo(SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT); + + openTestURL(); + } + + private void openTestURL() { + String url = getDeploymentURL() + getContextPath() + getTestPath() + "?" + + getParameters().collect(Collectors.joining("&")); + driver.get(url); + + if (!isElementPresent(UIElement.class)) { + waitUntil(e -> isElementPresent(UIElement.class), 10); + } + } + + protected Stream getParameters() { + return Stream.of("restartApplication"); + } + + /** + * Returns a path where the test UI is found. + * + * @return path for test + */ + protected abstract String getTestPath(); + + private String getDeploymentURL() { String deploymentUrl = System.getProperty("deployment.url"); if (deploymentUrl == null || deploymentUrl.equals("")) { throw new RuntimeException( @@ -40,17 +94,48 @@ public abstract class AbstractIntegrationTest return deploymentUrl; } - @Override - protected void openTestURL() { - super.openTestURL(); - - waitForApplication(); + protected void compareScreen(String identifier) throws IOException { + String refFileName = identifier + "-" + + getDesiredCapabilities().getBrowserName().toLowerCase() + + ".png"; + String errorFileName = identifier + "-" + + getDesiredCapabilities().getBrowserName().toLowerCase() + "-" + + System.getProperty("server-name") + ".png"; + File referenceFile = ImageFileUtil + .getReferenceScreenshotFile(refFileName); + try { + BufferedImage reference = ImageIO.read(referenceFile); + if (testBench().compareScreen(reference, errorFileName)) { + return; + } + } catch (IOException e) { + Logger.getLogger(getClass().getName()).warning( + "Missing screenshot reference: " + referenceFile.getPath()); + } + screenshotErrors = true; } - protected void waitForApplication() { - if (!isElementPresent(UIElement.class)) { - // Wait for UI element. - waitForElementPresent(By.vaadin("//com.vaadin.ui.UI")); + @After + public void teardown() { + if (screenshotErrors) { + throw new RuntimeException("Screenshots failed."); } } + + /** + * Waits the given number of seconds for the given condition to become true. + * Use e.g. as + * {@link #waitUntil(ExpectedConditions.textToBePresentInElement(by, text))} + * + * @param condition + * the condition to wait for to become true + */ + protected void waitUntil(ExpectedCondition condition, + long timeoutInSeconds) { + new WebDriverWait(driver, timeoutInSeconds).until(condition); + } + + protected String getContextPath() { + return "/demo"; + } } diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java index a8f291d79d..fd3600df38 100644 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java @@ -1,81 +1,21 @@ -/* - * 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.integration; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized.Parameters; import com.vaadin.testbench.elements.TableElement; -import com.vaadin.tests.tb3.ParameterizedTB3Runner; -/** - * Base class for servlet integration tests. Automatically prepends "/demo" to - * the deployment path - * - * @author Vaadin Ltd - */ -@RunWith(ParameterizedTB3Runner.class) public abstract class AbstractServletIntegrationTest extends AbstractIntegrationTest { - private String contextPath = "/demo"; - @Test - public void runTest() throws IOException, AssertionError { - openTestURL(); + public void runTest() throws Exception { // make sure no fading progress indicator from table update is lingering - sleep(2000); + Thread.sleep(2000); compareScreen("initial"); $(TableElement.class).first().getCell(0, 1).click(); // without this, table fetch might have a fading progress indicator - sleep(2000); + Thread.sleep(2000); compareScreen("finland"); } - @Override - protected String getDeploymentPath(Class uiClass) { - return contextPath + super.getDeploymentPath(uiClass); - } - - public void setContextPath(String contextPath) { - this.contextPath = contextPath; - } - - @Parameters - public static Collection getContextPaths() { - if (getServerName().equals("wildfly9-nginx")) { - ArrayList paths = new ArrayList<>(); - paths.add("/buffering/demo"); - paths.add("/nonbuffering/demo"); - paths.add("/buffering-timeout/demo"); - paths.add("/nonbuffering-timeout/demo"); - return paths; - } else { - return Collections.emptyList(); - } - } - - protected static String getServerName() { - return System.getProperty("server-name"); - } - } diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/CustomBrowserFactory.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/CustomBrowserFactory.java new file mode 100644 index 0000000000..e66d4b6df5 --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/CustomBrowserFactory.java @@ -0,0 +1,21 @@ +package com.vaadin.tests.integration; + +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.testbench.parallel.BrowserUtil; +import com.vaadin.testbench.parallel.DefaultBrowserFactory; + +public class CustomBrowserFactory extends DefaultBrowserFactory { + + @Override + public DesiredCapabilities create(Browser browser) { + DesiredCapabilities capabilities = super.create(browser); + if (BrowserUtil.isPhantomJS(capabilities)) { + capabilities.setVersion("2"); + capabilities.setCapability("phantomjs.binary.path", + "/usr/bin/phantomjs2"); + } + return capabilities; + } +} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushIT.java new file mode 100644 index 0000000000..68b8f36205 --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushIT.java @@ -0,0 +1,26 @@ +/* + * 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.integration; + +public class ServletIntegrationDefaultPushIT + extends AbstractServletIntegrationTest { + // Uses the test method declared in the super class + + @Override + protected String getTestPath() { + return "/run/ServletIntegrationDefaultPushUI"; + } +} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUITest.java deleted file mode 100644 index 20c17a3424..0000000000 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUITest.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.integration; - -public class ServletIntegrationDefaultPushUITest - extends AbstractServletIntegrationTest { - // Uses the test method declared in the super class -} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationIT.java new file mode 100644 index 0000000000..2d37779eb7 --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationIT.java @@ -0,0 +1,25 @@ +/* + * 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.integration; + +public class ServletIntegrationIT extends AbstractServletIntegrationTest { + // Uses the test method declared in the super class + + @Override + protected String getTestPath() { + return "/run/ServletIntegrationUI"; + } +} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationJSR356WebsocketUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationJSR356WebsocketUITest.java deleted file mode 100644 index 32338e2c37..0000000000 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationJSR356WebsocketUITest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.integration; - -public class ServletIntegrationJSR356WebsocketUITest - extends AbstractServletIntegrationTest { - // Uses the test method declared in the super class - - @Override - protected String getDeploymentPath(Class uiClass) { - return super.getDeploymentPath(uiClass).replace("/run/", - "/run-jsr356/"); - } - - @Override - protected Class getUIClass() { - return ServletIntegrationWebsocketUI.class; - } -} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingIT.java new file mode 100644 index 0000000000..10e36d87bb --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingIT.java @@ -0,0 +1,26 @@ +/* + * 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.integration; + +public class ServletIntegrationLongPollingIT + extends AbstractServletIntegrationTest { + // Uses the test method declared in the super class + + @Override + protected String getTestPath() { + return "/run/ServletIntegrationLongPollingUI"; + } +} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java deleted file mode 100644 index 06f51de57d..0000000000 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.integration; - -public class ServletIntegrationLongPollingUITest - extends AbstractServletIntegrationTest { - // Uses the test method declared in the super class -} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingIT.java new file mode 100644 index 0000000000..5aad9899f7 --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingIT.java @@ -0,0 +1,26 @@ +/* + * 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.integration; + +public class ServletIntegrationStreamingIT + extends AbstractServletIntegrationTest { + // Uses the test method declared in the super class + + @Override + protected String getTestPath() { + return "/run/ServletIntegrationStreamingUI"; + } +} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java deleted file mode 100644 index 29d5afc06f..0000000000 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.integration; - -public class ServletIntegrationStreamingUITest - extends AbstractServletIntegrationTest { - // Uses the test method declared in the super class -} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationTests.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationTests.java index ff30d645bf..3f9fdd78de 100644 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationTests.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationTests.java @@ -1,31 +1,15 @@ -/* - * 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.integration; import java.io.IOException; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -import com.vaadin.tests.tb3.TB3TestLocator; -import com.vaadin.tests.tb3.TB3TestSuite; import org.junit.runner.RunWith; import org.junit.runners.model.InitializationError; +import com.vaadin.testbench.parallel.ParallelTestSuite; import com.vaadin.tests.integration.ServletIntegrationTests.ServletIntegrationTestSuite; @RunWith(ServletIntegrationTestSuite.class) @@ -33,12 +17,8 @@ public class ServletIntegrationTests { public static Set notJSR356Compatible = new HashSet<>(); public static Set notWebsocketCompatible = new HashSet<>(); - static { - - notJSR356Compatible.add("jetty8"); - notJSR356Compatible.add("tomcat7"); - notJSR356Compatible.add("tomcat7apacheproxy"); + static { notWebsocketCompatible.add("tomcat7apacheproxy"); notWebsocketCompatible.add("weblogic10"); notWebsocketCompatible.add("wildfly9-nginx"); @@ -46,38 +26,35 @@ public class ServletIntegrationTests { // Jetty 9 but no ws support by default notWebsocketCompatible.add("karaf4"); - // If a server does not support any kind of websockets it does not - // support JSR-356 either.. - notJSR356Compatible.addAll(notWebsocketCompatible); + notJSR356Compatible.add("jetty8"); + notJSR356Compatible.add("tomcat7"); } - public static class ServletIntegrationTestSuite extends TB3TestSuite { + public static class ServletIntegrationTestSuite extends ParallelTestSuite { + public ServletIntegrationTestSuite(Class klass) throws InitializationError, IOException { super(klass, AbstractIntegrationTest.class, - "com.vaadin.tests.integration", new String[] {}, - new ServletTestLocator()); + "com.vaadin.tests.integration", getIgnoredPackages()); } - } - public static class ServletTestLocator extends TB3TestLocator { - @Override - protected List> findClasses(Class baseClass, - String basePackage, String[] ignoredPackages) - throws IOException { - List> allClasses = super.findClasses(baseClass, - basePackage, ignoredPackages); + private static String[] getIgnoredPackages() { + List ignoredPackages = new ArrayList<>(); String serverName = System.getProperty("server-name"); - - if (notJSR356Compatible.contains(serverName)) { - allClasses - .remove(ServletIntegrationJSR356WebsocketUITest.class); + if (serverName == null) { + serverName = ""; + } + if (!serverName.equals("widfly9-nginx")) { + ignoredPackages.add("com.vaadin.tests.integration.push"); } - if (notWebsocketCompatible.contains(serverName)) { - allClasses.remove(ServletIntegrationWebsocketUITest.class); + ignoredPackages.add("com.vaadin.tests.integration.websocket"); + } else if (notJSR356Compatible.contains(serverName)) { + ignoredPackages + .add("com.vaadin.tests.integration.websocket.jsr356"); } - return allClasses; + + return ignoredPackages.toArray(new String[ignoredPackages.size()]); } } } diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationUITest.java deleted file mode 100644 index 16c3c24685..0000000000 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationUITest.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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.integration; - -public class ServletIntegrationUITest extends AbstractServletIntegrationTest { - // Uses the test method declared in the super class -} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java deleted file mode 100644 index 204b1e29b3..0000000000 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.integration; - -public class ServletIntegrationWebsocketUITest - extends AbstractServletIntegrationTest { - // Uses the test method declared in the super class -} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/BasicPushTest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/BasicPushTest.java deleted file mode 100644 index 082710992b..0000000000 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/BasicPushTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.integration.push; - -import com.vaadin.testbench.parallel.TestCategory; -import com.vaadin.tests.tb3.AbstractTB3Test; -import com.vaadin.tests.tb3.MultiBrowserTest; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -@TestCategory("push") -public abstract class BasicPushTest extends MultiBrowserTest { - - @Override - public void setup() throws Exception { - super.setup(); - } - - @Test - public void testPush() throws InterruptedException { - openTestURL(); - - getIncrementButton().click(); - testBench().disableWaitForVaadin(); - - waitUntilClientCounterChanges(1); - - getIncrementButton().click(); - getIncrementButton().click(); - getIncrementButton().click(); - waitUntilClientCounterChanges(4); - - // Test server initiated push - getServerCounterStartButton().click(); - waitUntilServerCounterChanges(); - } - - public static int getClientCounter(AbstractTB3Test t) { - WebElement clientCounterElem = t - .findElement(By.id(BasicPush.CLIENT_COUNTER_ID)); - return Integer.parseInt(clientCounterElem.getText()); - } - - protected WebElement getIncrementButton() { - return getIncrementButton(this); - } - - protected WebElement getServerCounterStartButton() { - return getServerCounterStartButton(this); - } - - public static int getServerCounter(AbstractTB3Test t) { - WebElement serverCounterElem = t - .findElement(By.id(BasicPush.SERVER_COUNTER_ID)); - return Integer.parseInt(serverCounterElem.getText()); - } - - public static WebElement getServerCounterStartButton(AbstractTB3Test t) { - return t.findElement(By.id(BasicPush.START_TIMER_ID)); - } - - public static WebElement getServerCounterStopButton(AbstractTB3Test t) { - return t.findElement(By.id(BasicPush.STOP_TIMER_ID)); - } - - public static WebElement getIncrementButton(AbstractTB3Test t) { - return t.findElement(By.id(BasicPush.INCREMENT_BUTTON_ID)); - } - - protected void waitUntilClientCounterChanges(final int expectedValue) { - waitUntil(new ExpectedCondition() { - - @Override - public Boolean apply(WebDriver input) { - return BasicPushTest - .getClientCounter(BasicPushTest.this) == expectedValue; - } - }, 10); - } - - protected void waitUntilServerCounterChanges() { - final int counter = BasicPushTest.getServerCounter(this); - waitUntil(new ExpectedCondition() { - - @Override - public Boolean apply(WebDriver input) { - return BasicPushTest - .getServerCounter(BasicPushTest.this) > counter; - } - }, 10); - } - -} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java new file mode 100644 index 0000000000..dc1fe4e6a8 --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java @@ -0,0 +1,106 @@ +/* + * 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.integration.push; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.tests.integration.AbstractIntegrationTest; + +@RunWith(Parameterized.class) +public class LongPollingProxyServerIT extends AbstractIntegrationTest { + + @Parameters(name = "{0}") + public static List getTestParameters() { + List parameters = new ArrayList<>(); + addTestParams(parameters, "Buffering+Timeout", "buffering-timeout"); + addTestParams(parameters, "NonBuffering+Timeout", + "nonbuffering-timeout"); + addTestParams(parameters, "Buffering", "buffering"); + addTestParams(parameters, "NonBuffering", "nonbuffering"); + return parameters; + } + + private static void addTestParams(List parameters, + String... pair) { + parameters.add(pair); + } + + @Parameter(0) + public String name; + + @Parameter(1) + public String path; + + @Override + public void setup() throws Exception { + setDesiredCapabilities(Browser.PHANTOMJS.getDesiredCapabilities()); + + super.setup(); + } + + @Test + public void actionAfterFirstTimeout() throws Exception { + // The wildfly9-nginx server has a configured timeout of 10s for + // *-timeout urls + Thread.sleep(15000); + Assert.assertEquals(0, getClientCounter()); + getIncrementButton().click(); + Assert.assertEquals(1, getClientCounter()); + } + + @Test + public void basicPush() { + Assert.assertEquals(0, getServerCounter()); + getServerCounterStartButton().click(); + waitUntil(e -> getServerCounter() > 1, 10); + } + + @Override + protected String getTestPath() { + return "/" + path + "/demo"; + } + + private int getClientCounter() { + WebElement clientCounterElem = findElement( + By.id(BasicPush.CLIENT_COUNTER_ID)); + return Integer.parseInt(clientCounterElem.getText()); + } + + private int getServerCounter() { + WebElement serverCounterElem = findElement( + By.id(BasicPush.SERVER_COUNTER_ID)); + return Integer.parseInt(serverCounterElem.getText()); + } + + private WebElement getServerCounterStartButton() { + return findElement(By.id(BasicPush.START_TIMER_ID)); + } + + private WebElement getIncrementButton() { + return findElement(By.id(BasicPush.INCREMENT_BUTTON_ID)); + } +} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerTest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerTest.java deleted file mode 100644 index 3357b143a5..0000000000 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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.integration.push; - -import com.vaadin.testbench.parallel.Browser; -import com.vaadin.tests.integration.AbstractIntegrationTest; -import com.vaadin.tests.tb3.IncludeIfProperty; -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedCondition; - -import java.util.Collections; -import java.util.List; - -@IncludeIfProperty(property = "server-name", value = "wildfly9-nginx") -public class LongPollingProxyServerTest extends AbstractIntegrationTest { - - @Override - protected Class getUIClass() { - return BasicPushLongPolling.class; - } - - @Test - public void bufferingTimeoutBasicPush() throws Exception { - basicPush("buffering-timeout"); - } - - @Test - public void nonbufferingTimeoutBasicPush() throws Exception { - basicPush("nonbuffering-timeout"); - } - - @Test - public void bufferingBasicPush() throws Exception { - basicPush("buffering"); - } - - @Test - public void nonbufferingBasicPush() throws Exception { - basicPush("nonbuffering"); - } - - @Test - public void bufferingTimeoutActionAfterFirstTimeout() throws Exception { - actionAfterFirstTimeout("buffering-timeout"); - } - - @Test - public void nonbufferingTimeoutActionAfterFirstTimeout() throws Exception { - actionAfterFirstTimeout("nonbuffering-timeout"); - } - - private String getUrl(String bufferingOrNot) { - return getBaseURL() + "/" + bufferingOrNot + "/demo" - + getDeploymentPath(); - } - - private void actionAfterFirstTimeout(String bufferingOrNot) - throws Exception { - String url = getUrl(bufferingOrNot); - getDriver().get(url); - // The wildfly9-nginx server has a configured timeout of 10s for - // *-timeout urls - Thread.sleep(15000); - Assert.assertEquals(0, BasicPushTest.getClientCounter(this)); - BasicPushTest.getIncrementButton(this).click(); - Assert.assertEquals(1, BasicPushTest.getClientCounter(this)); - } - - private void basicPush(String bufferingOrNot) throws Exception { - String url = getUrl(bufferingOrNot); - getDriver().get(url); - - Assert.assertEquals(0, BasicPushTest.getServerCounter(this)); - BasicPushTest.getServerCounterStartButton(this).click(); - waitUntil(new ExpectedCondition() { - @Override - public Boolean apply(WebDriver input) { - return BasicPushTest - .getServerCounter(LongPollingProxyServerTest.this) > 1; - } - }); - } - - @Override - public List getBrowsersToTest() { - return Collections - .singletonList(Browser.PHANTOMJS.getDesiredCapabilities()); - } -} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/websocket/ServletIntegrationWebsocketIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/websocket/ServletIntegrationWebsocketIT.java new file mode 100644 index 0000000000..525e4545e4 --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/websocket/ServletIntegrationWebsocketIT.java @@ -0,0 +1,28 @@ +/* + * 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.integration.websocket; + +import com.vaadin.tests.integration.AbstractServletIntegrationTest; + +public class ServletIntegrationWebsocketIT + extends AbstractServletIntegrationTest { + // Uses the test method declared in the super class + + @Override + protected String getTestPath() { + return "/run/ServletIntegrationWebsocketUI"; + } +} diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/websocket/jsr356/ServletIntegrationJSR356WebsocketIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/websocket/jsr356/ServletIntegrationJSR356WebsocketIT.java new file mode 100644 index 0000000000..f49d3656db --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/websocket/jsr356/ServletIntegrationJSR356WebsocketIT.java @@ -0,0 +1,28 @@ +/* + * 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.integration.websocket.jsr356; + +import com.vaadin.tests.integration.websocket.ServletIntegrationWebsocketIT; + +public class ServletIntegrationJSR356WebsocketIT + extends ServletIntegrationWebsocketIT { + // Uses the test method declared in the super class + + @Override + protected String getTestPath() { + return super.getTestPath().replace("/run/", "/run-jsr356/"); + } +} -- cgit v1.2.3