diff options
44 files changed, 1088 insertions, 273 deletions
diff --git a/test/pom.xml b/test/pom.xml index e44986ffb1..f8cefa468c 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -101,6 +101,7 @@ <module>space in directory</module> <module>vaadinservletconfiguration-widget-set</module> <module>spring-boot</module> + <module>servlet-containers/generic</module> <module>cdi</module> <module>servlet-containers/jsp-integration</module> <module>bean-api-validation</module> diff --git a/test/servlet-containers/generic/.gitignore b/test/servlet-containers/generic/.gitignore new file mode 100644 index 0000000000..e2f5dd2eb2 --- /dev/null +++ b/test/servlet-containers/generic/.gitignore @@ -0,0 +1 @@ +result
\ No newline at end of file diff --git a/build.properties b/test/servlet-containers/generic/build.properties index 2148fc00e6..1c2293f06a 100644 --- a/build.properties +++ b/test/servlet-containers/generic/build.properties @@ -1,10 +1,8 @@ -javadoc.doctitle=<h1>Vaadin</h1> -javadoc.bottom=<i>Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.</i> ivy.organisation=com.vaadin vaadin.vendor=Vaadin Ltd vaadin.url=http://vaadin.com vaadin.java.version=1.6 -vaadin.version=7.7.0-SNAPSHOT +vaadin.version=8.0-SNAPSHOT vaadin.sass.version=0.9.13 gwt.version=2.7.0.vaadin3 commons-io.version=2.4 diff --git a/test/servlet-containers/generic/build.xml b/test/servlet-containers/generic/build.xml new file mode 100644 index 0000000000..ee16b2c0e1 --- /dev/null +++ b/test/servlet-containers/generic/build.xml @@ -0,0 +1,49 @@ +<?xml version="1.0"?> + +<project name="vaadin-uitest" basedir="." default="test-server" + xmlns:ivy="antlib:org.apache.ivy.ant"> + <description> + Provides a uitest WAR containing Vaadin UI tests + </description> + <include file="./common.xml" as="common" /> + + <!-- global properties --> + <property name="module.name" value="vaadin-test-generic-integration" /> + <property name="uitest.dir" location="${common.basedir}" /><!-- todo rename--> + <property name="result.dir" value="result" /> + <property name="result.war" + location="${uitest.dir}/target/${module.name}-${vaadin.version}.war" /> + + <!-- Need to give a default value to keep Ivy happy --> + <property name="vaadin.build.repository" value="http://maven.vaadin.com/vaadin-prereleases"/> + + <target name="clean"> + <fail unless="result.dir" message="No result.dir parameter given" /> + <delete dir="${result.dir}" /> + </target> + + <target name="test-server" depends="clean-testbench-errors"> + <property name="war.file" location="${result.war}" /> + <mkdir dir="${vaadin.basedir}/result" /> + <ant antfile="integration_tests.xml" + target="integration-test-all" inheritall="false" + inheritrefs="false"> + <property name="demo.war" value="${war.file}" /> + </ant> + </target> + + + <target name="clean-testbench-errors"><!--todo remove when have got rid of screenshots--> + <fail unless="com.vaadin.testbench.screenshot.directory" + message="Define screenshot directory using -Dcom.vaadin.testbench.screenshot.directory" /> + <mkdir dir="${com.vaadin.testbench.screenshot.directory}/errors" /> + <delete> + <fileset + dir="${com.vaadin.testbench.screenshot.directory}/errors"> + <include name="*" /> + </fileset> + </delete> + </target> + + +</project> diff --git a/common.xml b/test/servlet-containers/generic/common.xml index 0c817afa1c..7a105ca8bc 100644 --- a/common.xml +++ b/test/servlet-containers/generic/common.xml @@ -5,12 +5,13 @@ <format property="build.date" pattern="yyyy-MM-dd" /> </tstamp> - <dirname property="vaadin.basedir" file="${ant.file.common}" /> - <property file="${vaadin.basedir}/build.properties" /> + <dirname property="vaadin.basedir" file="${ant.file.common}/../../../" /> + <dirname property="common.basedir" file="${ant.file.common}" /> + <property file="${common.basedir}/build.properties" /> - <ivy:settings file="${vaadin.basedir}/ivysettings.xml" /> - <ivy:settings file="${vaadin.basedir}/ivysettings.xml" id="ivysettings" /> - <ivy:resolve log="download-only" file="${vaadin.basedir}/ivy-taskdefs.xml" conf="taskdefs" /> + <ivy:settings file="${common.basedir}/ivysettings.xml" /> + <ivy:settings file="${common.basedir}/ivysettings.xml" id="ivysettings" /> + <ivy:resolve log="download-only" file="${common.basedir}/ivy-taskdefs.xml" conf="taskdefs" /> <ivy:cachepath pathid="taskdefs.classpath" conf="taskdefs" /> <taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml" classpathref="taskdefs.classpath" /> diff --git a/uitest/integration_base_files/base.xml b/test/servlet-containers/generic/integration_base_files/base.xml index f2064c3007..74ea41ac06 100644 --- a/uitest/integration_base_files/base.xml +++ b/test/servlet-containers/generic/integration_base_files/base.xml @@ -10,7 +10,7 @@ <property name="JAVA_HOME" value="/usr/lib/jvm/default-java" /> <property name="waitMinutes" value="3" /> <property name="waitUrl" - value="http://localhost:${serverPort}/demo/VAADIN/themes/reindeer/styles.css" /> + value="http://localhost:${serverPort}/demo/VAADIN/themes/valo/styles.css" /> <property name="shutdownWait" value="10" /> diff --git a/uitest/integration_base_files/cleanup.sh b/test/servlet-containers/generic/integration_base_files/cleanup.sh index 42fb5a434d..42fb5a434d 100644 --- a/uitest/integration_base_files/cleanup.sh +++ b/test/servlet-containers/generic/integration_base_files/cleanup.sh diff --git a/uitest/integration_base_files/lock_age.sh b/test/servlet-containers/generic/integration_base_files/lock_age.sh index 115a8fef79..115a8fef79 100644 --- a/uitest/integration_base_files/lock_age.sh +++ b/test/servlet-containers/generic/integration_base_files/lock_age.sh diff --git a/uitest/integration_tests.xml b/test/servlet-containers/generic/integration_tests.xml index 818c0095b6..a46670b6a3 100644 --- a/uitest/integration_tests.xml +++ b/test/servlet-containers/generic/integration_tests.xml @@ -3,7 +3,7 @@ <project xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:ivy="antlib:org.apache.ivy.ant" name="Vaadin Integration Tests" basedir="." default="integration-test-all"> <!-- Import common targets --> - <import file="../common.xml" /> + <import file="common.xml" /> <dirname file="${ant.file.Vaadin Integration Tests}" property="integration_test.dir" /> <!-- Target deploying demo.war --> @@ -30,7 +30,7 @@ <!-- TestBench license parameter --> <property name="vaadin.testbench.developer.license" value="" /> - <property name="report.dir" location="${integration_test.dir}/result/reports-integration" /> + <property name="report.dir" location="${vaadin.basedir}/result/reports-integration" /> <!-- ssh host values --> <property name="ant.hub" value="${test.integration.antfile}" /> @@ -52,7 +52,7 @@ <target name="run-tb3-servlet-test"> <antcall target="run-tb3-test" inheritall="true"> - <param name="junit.test.suite" value="com.vaadin.tests.tb3.ServletIntegrationTests" /> + <param name="junit.test.suite" value="com.vaadin.tests.integration.ServletIntegrationTests" /> </antcall> </target> <target name="run-tb3-test"> diff --git a/ivy-taskdefs.xml b/test/servlet-containers/generic/ivy-taskdefs.xml index 95dca014dc..95dca014dc 100644 --- a/ivy-taskdefs.xml +++ b/test/servlet-containers/generic/ivy-taskdefs.xml diff --git a/uitest/ivy.xml b/test/servlet-containers/generic/ivy.xml index 33ac7c7c04..33ac7c7c04 100644 --- a/uitest/ivy.xml +++ b/test/servlet-containers/generic/ivy.xml diff --git a/ivysettings.xml b/test/servlet-containers/generic/ivysettings.xml index f28250c3c1..f28250c3c1 100644 --- a/ivysettings.xml +++ b/test/servlet-containers/generic/ivysettings.xml diff --git a/test/servlet-containers/generic/pom.xml b/test/servlet-containers/generic/pom.xml new file mode 100644 index 0000000000..545ef8b52e --- /dev/null +++ b/test/servlet-containers/generic/pom.xml @@ -0,0 +1,100 @@ +<?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-generic-integration</artifactId> + <name>vaadin-test-generic-integration</name> + <packaging>war</packaging> + + <dependencies> + + <!-- LIBRARY DEPENDENCIES (compile time) --> + <!-- Project modules --> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vaadin-compatibility-server</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vaadin-compatibility-client-compiled</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vaadin-client-compiled</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vaadin-themes</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vaadin-push</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vaadin-uitest-common</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + + <build> + + <plugins> + <!--TODO run this on different servers--> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-maven-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>nexus-staging-maven-plugin</artifactId> + <configuration> + <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo> + </configuration> + </plugin> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/IntegrationTestUIProvider.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/IntegrationTestUIProvider.java new file mode 100644 index 0000000000..ce64c22577 --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/IntegrationTestUIProvider.java @@ -0,0 +1,77 @@ +package com.vaadin.tests; + +import javax.servlet.annotation.WebInitParam; +import javax.servlet.annotation.WebServlet; + +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.server.UIClassSelectionEvent; +import com.vaadin.server.UIProvider; +import com.vaadin.server.VaadinServlet; +import com.vaadin.tests.integration.ServletIntegrationUI; +import com.vaadin.tests.integration.ServletIntegrationWebsocketUI; +import com.vaadin.tests.integration.push.BasicPush; +import com.vaadin.ui.UI; + +public class IntegrationTestUIProvider extends UIProvider { + + public static final String[] defaultPackages = { + "com.vaadin.tests.integration", + "com.vaadin.tests.integration.push" }; + + @Override + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + Class<? extends UI> uiClass = findUIClassFromPath(event); + return uiClass != null ? uiClass : BasicPush.class; + } + + private Class<? extends UI> findUIClassFromPath( + UIClassSelectionEvent event) { + String pathInfo = event.getRequest().getPathInfo(); + if (pathInfo != null) { + String className = pathInfo.substring(1); + if (className.startsWith("run/")) { + className = className.substring(4); + } + + if (className.contains(".")) { + return getUIClass(className); + } else { + return getUIClassFromDefaultPackage(className); + } + } + return null; + } + + private Class<? extends UI> getUIClassFromDefaultPackage(String className) { + for (String pkgName : defaultPackages) { + Class<? extends UI> uiClass = getUIClass(pkgName + "." + className); + if (uiClass != null) { + return uiClass; + } + } + return null; + } + + private Class<? extends UI> getUIClass(String className) { + try { + Class<?> loadClass = getClass().getClassLoader() + .loadClass(className.replace("/", ".")); + return (Class<? extends UI>) loadClass; + } catch (ClassNotFoundException e) { + return null; + } + } + + @WebServlet(urlPatterns = "/*", name = "IntegrationTestUIProvider", asyncSupported = true, initParams = { + @WebInitParam(name = "UIProvider", value = "com.vaadin.tests.IntegrationTestUIProvider") }) + @VaadinServletConfiguration(ui = ServletIntegrationUI.class, productionMode = false) + public static class MyServlet extends VaadinServlet { + } + + @WebServlet(urlPatterns = "/run-jsr356/*", name = "IntegrationUIProvider-Jsr356", asyncSupported = false, initParams = { + @WebInitParam(name = "org.atmosphere.cpr.asyncSupport", value = "org.atmosphere.container.JSR356AsyncSupport") }) + @VaadinServletConfiguration(ui = ServletIntegrationWebsocketUI.class, productionMode = false) + public static class JSR356Servlet extends VaadinServlet { + + } +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/FlagSeResource.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/FlagSeResource.java new file mode 100644 index 0000000000..8f8fce77c2 --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/FlagSeResource.java @@ -0,0 +1,13 @@ +package com.vaadin.tests.integration; + +import com.vaadin.server.ClassResource; + +public class FlagSeResource extends ClassResource { + + public FlagSeResource() { + super("/" + + FlagSeResource.class.getName().replace('.', '/').replaceAll( + FlagSeResource.class.getSimpleName() + "$", "") + + "se.gif"); + } +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUI.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUI.java new file mode 100644 index 0000000000..530e093d8e --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUI.java @@ -0,0 +1,29 @@ +/* + * 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.annotations.Push; + +/** + * Server test which uses the default push mechanisms + * + * @since 7.1.12 + * @author Vaadin Ltd + */ +@Push +public class ServletIntegrationDefaultPushUI extends ServletIntegrationUI { + +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUI.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUI.java new file mode 100644 index 0000000000..be74683026 --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUI.java @@ -0,0 +1,30 @@ +/* + * 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.annotations.Push; +import com.vaadin.shared.ui.ui.Transport; + +/** + * Server test which uses long polling + * + * @since 7.1 + * @author Vaadin Ltd + */ +@Push(transport = Transport.LONG_POLLING) +public class ServletIntegrationLongPollingUI extends ServletIntegrationUI { + +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationStreamingUI.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationStreamingUI.java new file mode 100644 index 0000000000..540fd70df5 --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationStreamingUI.java @@ -0,0 +1,30 @@ +/* + * 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.annotations.Push; +import com.vaadin.shared.ui.ui.Transport; + +/** + * Server test which uses streaming + * + * @since 7.1 + * @author Vaadin Ltd + */ +@Push(transport = Transport.STREAMING) +public class ServletIntegrationStreamingUI extends ServletIntegrationUI { + +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java new file mode 100644 index 0000000000..03a24fbc4c --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java @@ -0,0 +1,59 @@ +package com.vaadin.tests.integration; + +import com.vaadin.annotations.DesignRoot; +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.ClassResource; +import com.vaadin.server.Resource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.declarative.Design; +import com.vaadin.v7.data.Item; +import com.vaadin.v7.data.Property.ValueChangeEvent; +import com.vaadin.v7.data.Property.ValueChangeListener; +import com.vaadin.v7.ui.Table; + +@Widgetset("com.vaadin.v7.Vaadin7WidgetSet") +public class ServletIntegrationUI extends UI { + + @Override + protected void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + final Table table = new Table(); + table.addContainerProperty("icon", Resource.class, null); + table.setItemIconPropertyId("icon"); + table.addContainerProperty("country", String.class, null); + table.setRowHeaderMode(Table.RowHeaderMode.ICON_ONLY); + table.setImmediate(true); + table.setSelectable(true); + table.setVisibleColumns(new Object[] { "country" }); + layout.addComponent(table); + + Item item = table.addItem("FI"); + item.getItemProperty("icon").setValue(new ClassResource("fi.gif")); + item.getItemProperty("country").setValue("Finland"); + item = table.addItem("SE"); + item.getItemProperty("icon").setValue(new FlagSeResource()); + item.getItemProperty("country").setValue("Sweden"); + + final Label selectedLabel = new LabelFromDesign(); + table.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + selectedLabel.setValue(String.valueOf(table.getValue())); + } + }); + layout.addComponent(selectedLabel); + } + + @DesignRoot + public static class LabelFromDesign extends Label { + public LabelFromDesign() { + Design.read(this); + } + } +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUI.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUI.java new file mode 100644 index 0000000000..cfffa04c11 --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUI.java @@ -0,0 +1,48 @@ +/* + * 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.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +/** + * Server test which uses websockets + * + * @since 7.1 + * @author Vaadin Ltd + */ +@Push(transport = Transport.WEBSOCKET) +public class ServletIntegrationWebsocketUI extends ServletIntegrationUI { + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.tests.integration.IntegrationTestUI#init(com.vaadin.server + * .VaadinRequest) + */ + @Override + protected void init(VaadinRequest request) { + super.init(request); + // Ensure no fallback is used + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + + } + +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/AbstractTestUI.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/AbstractTestUI.java new file mode 100644 index 0000000000..c9ef1b82b0 --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/AbstractTestUI.java @@ -0,0 +1,226 @@ +package com.vaadin.tests.integration.push; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.server.WebBrowser; +import com.vaadin.shared.communication.PushMode; +import com.vaadin.shared.ui.ContentMode; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; +import com.vaadin.ui.Button; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Notification.Type; +import com.vaadin.ui.PushConfiguration; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +import java.io.File; + +public abstract class AbstractTestUI extends UI { + + @Override + public void init(VaadinRequest request) { + getPage().setTitle(getClass().getName()); + + Label label = new Label(getTestDescription(), ContentMode.HTML); + label.setWidth("100%"); + + VerticalLayout rootLayout = new VerticalLayout(); + rootLayout.setSpacing(false); + setContent(rootLayout); + + layout = new VerticalLayout(); + layout.setSpacing(false); + layout.setMargin(false); + + rootLayout.addComponent(label); + rootLayout.addComponent(layout); + ((VerticalLayout) getContent()).setExpandRatio(layout, 1); + + warnIfWidgetsetMaybeNotCompiled(); + + setTransport(request); + + setup(request); + } + + protected void warnIfWidgetsetMaybeNotCompiled() { + // Can't check location if sendUrlAsParameters is disabled + if (!getSession().getConfiguration().isSendUrlsAsParameters()) { + return; + } + + // Ignore if using debug mode + String query = getPage().getLocation().getQuery(); + if (query != null && query.matches(".*[&?]gwt\\.codesvr.*")) { + return; + } + + // Find out the widgetset of this UI based on @Widgetset annotation + Class<?> currentType = getClass(); + String usedWidgetset = VaadinServlet.DEFAULT_WIDGETSET; + while (currentType != Object.class) { + Widgetset annotation = currentType.getAnnotation(Widgetset.class); + if (annotation != null) { + usedWidgetset = annotation.value(); + break; + } else { + currentType = currentType.getSuperclass(); + } + } + + // Assuming the same folder structure as in git repo + // Assuming project root is the working dir of this process + File widgetsetsFolder = new File("WebContent/VAADIN/widgetsets"); + if (!widgetsetsFolder.isDirectory()) { + return; + } + + // Find the most newly compiled widgetset + long newestWidgetsetTimestamp = -1; + String newestWidgetsetName = null; + File[] children = widgetsetsFolder.listFiles(); + for (File child : children) { + if (!child.isDirectory() || child.getName().equals("WEB-INF")) { + continue; + } + long lastModified = child.lastModified(); + if (lastModified > newestWidgetsetTimestamp) { + newestWidgetsetTimestamp = lastModified; + newestWidgetsetName = child.getName(); + } + } + + // Compare to currently used widgetset, with a 30 minute grace period + File currentWidgetsetFolder = new File(widgetsetsFolder, usedWidgetset); + long currentWidgetsetTimestamp = currentWidgetsetFolder.lastModified(); + int halfHour = 30 * 60 * 1000; + if (currentWidgetsetTimestamp + halfHour < newestWidgetsetTimestamp) { + Notification.show( + "The currently used widgetset (" + usedWidgetset + + ") was compiled long before the most recently compiled one (" + + newestWidgetsetName + + "). Are you sure you have compiled the right widgetset?", + Type.WARNING_MESSAGE); + } + } + + /** + * Sets the push transport according to the transport= URL parameter if such + * is given. Supports transport=xhr (disables push), transport=websocket + * (forces websocket into use), transport=streaming (forces streaming into + * use). Using ?transport=xyz disables the fallback transport. + * + * @param request + * The UI init request + */ + protected void setTransport(VaadinRequest request) { + String transport = request.getParameter("transport"); + PushConfiguration config = getPushConfiguration(); + + if ("xhr".equals(transport)) { + config.setPushMode(PushMode.DISABLED); + } else if ("websocket".equals(transport)) { + enablePush(Transport.WEBSOCKET); + } else if ("websocket-xhr".equals(transport)) { + enablePush(Transport.WEBSOCKET_XHR); + } else if ("streaming".equals(transport)) { + enablePush(Transport.STREAMING); + } else if ("long-polling".equals(transport)) { + enablePush(Transport.LONG_POLLING); + } else if (transport != null) { + throw new IllegalArgumentException("Unknown transport value '" + + transport + + "'. Supported are xhr,websocket,streaming,long-polling"); + } + } + + protected void enablePush(Transport transport) { + PushConfiguration config = getPushConfiguration(); + if (!config.getPushMode().isEnabled()) { + config.setPushMode(PushMode.AUTOMATIC); + } + config.setTransport(transport); + // Ensure no fallback is used + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } + + /** + * This method is inherited from the super class, but it should generally + * not be used. If you want to just add components to your test, use e.g. + * {@link #addComponent(Component)} instead to add the component to the + * layout used by this UI. If you don't want to use the top-level layout + * used by this class, you instead inherit directly from UI. + * + * @deprecated Use {@link #addComponent(Component)} or inherit from UI + * instead. + */ + @Override + @Deprecated + public void setContent(Component content) { + // Overridden just to deprecate + super.setContent(content); + } + + private VerticalLayout layout; + + protected VerticalLayout getLayout() { + return layout; + } + + protected abstract void setup(VaadinRequest request); + + public void addComponent(Component c) { + getLayout().addComponent(c); + } + + public void addComponents(Component... c) { + getLayout().addComponents(c); + } + + public void removeComponent(Component c) { + getLayout().removeComponent(c); + } + + public void replaceComponent(Component oldComponent, + Component newComponent) { + getLayout().replaceComponent(oldComponent, newComponent); + } + + protected void addButton(String caption, Button.ClickListener listener) { + Button button = new Button(caption); + button.addClickListener(listener); + addComponent(button); + } + + protected String getTestDescription() { + return null; + }; + + protected Integer getTicketNumber() { + return null; + }; + + protected WebBrowser getBrowser() { + return getSession().getBrowser(); + } + + /** + * Execute the provided runnable on the UI thread as soon as the current + * request has been sent. + */ + protected void runAfterResponse(final Runnable runnable) { + // Immediately start a thread that will start waiting for the session to + // get unlocked. + new Thread() { + @Override + public void run() { + accessSynchronously(runnable); + } + }.start(); + } +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/BasicPush.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/BasicPush.java new file mode 100644 index 0000000000..a3f2dd1c47 --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/BasicPush.java @@ -0,0 +1,146 @@ +/* + * 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.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ContentMode; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; + +import java.util.Timer; +import java.util.TimerTask; + +@Push +public class BasicPush extends AbstractTestUI { + + public static final String CLIENT_COUNTER_ID = "clientCounter"; + + public static final String STOP_TIMER_ID = "stopTimer"; + + public static final String START_TIMER_ID = "startTimer"; + + public static final String SERVER_COUNTER_ID = "serverCounter"; + + public static final String INCREMENT_BUTTON_ID = "incrementCounter"; + + private int clientCounter = 0; + private int serverCounter = 0; + private final Timer timer = new Timer(true); + + private TimerTask task; + + @Override + protected void setup(VaadinRequest request) { + getReconnectDialogConfiguration().setDialogModal(false); + spacer(); + + /* + * Client initiated push. + */ + Label lbl = new Label("0"); + lbl.setCaption("Client counter (click 'increment' to update):"); + lbl.setId(CLIENT_COUNTER_ID); + addComponent(lbl); + + Button incrementButton = new Button("Increment", + new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + clientCounter++; + lbl.setValue(String.valueOf(clientCounter)); + } + }); + incrementButton.setId(INCREMENT_BUTTON_ID); + addComponent(incrementButton); + + spacer(); + + /* + * Server initiated push. + */ + Label serverCounterLabel = new Label("0"); + serverCounterLabel.setCaption( + "Server counter (updates each 3s by server thread) :"); + serverCounterLabel.setId(SERVER_COUNTER_ID); + addComponent(serverCounterLabel); + + Button startTimer = new Button("Start timer", (ClickListener) event -> { + serverCounter = 0; + serverCounterLabel.setValue(String.valueOf(serverCounter)); + if (task != null) { + task.cancel(); + } + task = new TimerTask() { + + @Override + public void run() { + access(() -> { + serverCounter++; + serverCounterLabel + .setValue(String.valueOf(serverCounter)); + }); + } + }; + timer.scheduleAtFixedRate(task, 3000, 3000); + }); + startTimer.setId(START_TIMER_ID); + addComponent(startTimer); + + Button stopTimer = new Button("Stop timer", new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + if (task != null) { + task.cancel(); + task = null; + } + } + }); + stopTimer.setId(STOP_TIMER_ID); + addComponent(stopTimer); + } + + @Override + protected String getTestDescription() { + return "This test tests the very basic operations of push. " + + "It tests that client initiated changes are " + + "recieved back to the client as well as server " + + "initiated changes are correctly updated to the client."; + } + + @Override + protected Integer getTicketNumber() { + return 11494; + } + + private void spacer() { + addComponent(new Label("<hr/>", ContentMode.HTML)); + } + + @Override + public void attach() { + super.attach(); + } + + @Override + public void detach() { + super.detach(); + timer.cancel(); + } +} diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/BasicPushLongPolling.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/BasicPushLongPolling.java new file mode 100644 index 0000000000..1ed7848a12 --- /dev/null +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/push/BasicPushLongPolling.java @@ -0,0 +1,34 @@ +/* + * 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.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.LONG_POLLING) +public class BasicPushLongPolling extends BasicPush { + + @Override + public void init(VaadinRequest request) { + super.init(request); + // Don't use fallback so we can easier detect if long polling fails + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } + +} diff --git a/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/LabelFromDesign.html b/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/LabelFromDesign.html new file mode 100644 index 0000000000..56329d7d19 --- /dev/null +++ b/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/LabelFromDesign.html @@ -0,0 +1 @@ +<vaadin-label /> diff --git a/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/fi.gif b/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/fi.gif Binary files differnew file mode 100644 index 0000000000..8d3a191828 --- /dev/null +++ b/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/fi.gif diff --git a/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/se.gif b/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/se.gif Binary files differnew file mode 100644 index 0000000000..80f6285228 --- /dev/null +++ b/test/servlet-containers/generic/src/main/resources/com/vaadin/tests/integration/se.gif diff --git a/uitest/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..da0d6cb08e 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/AbstractIntegrationTest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractIntegrationTest.java diff --git a/uitest/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..a8f291d79d 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java diff --git a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUITest.java index 20c17a3424..20c17a3424 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUITest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationDefaultPushUITest.java diff --git a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationJSR356WebsocketUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationJSR356WebsocketUITest.java index 32338e2c37..32338e2c37 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationJSR356WebsocketUITest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationJSR356WebsocketUITest.java diff --git a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java index 06f51de57d..06f51de57d 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java diff --git a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java index 29d5afc06f..29d5afc06f 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/ServletIntegrationTests.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationTests.java index 9698068621..ff30d645bf 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/ServletIntegrationTests.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationTests.java @@ -14,20 +14,19 @@ * the License. */ -package com.vaadin.tests.tb3; +package com.vaadin.tests.integration; import java.io.IOException; 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.tests.integration.AbstractIntegrationTest; -import com.vaadin.tests.integration.ServletIntegrationJSR356WebsocketUITest; -import com.vaadin.tests.integration.ServletIntegrationWebsocketUITest; -import com.vaadin.tests.tb3.ServletIntegrationTests.ServletIntegrationTestSuite; +import com.vaadin.tests.integration.ServletIntegrationTests.ServletIntegrationTestSuite; @RunWith(ServletIntegrationTestSuite.class) public class ServletIntegrationTests { diff --git a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationUITest.java index 16c3c24685..16c3c24685 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationUITest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationUITest.java diff --git a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java index 204b1e29b3..204b1e29b3 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java 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 new file mode 100644 index 0000000000..082710992b --- /dev/null +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/BasicPushTest.java @@ -0,0 +1,109 @@ +/* + * 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<Boolean>() { + + @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<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return BasicPushTest + .getServerCounter(BasicPushTest.this) > counter; + } + }, 10); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/integration/LongPollingProxyServerTest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerTest.java index 7a86ff4cba..3357b143a5 100644 --- a/uitest/src/test/java/com/vaadin/tests/integration/LongPollingProxyServerTest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerTest.java @@ -13,21 +13,19 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.tests.integration; - -import java.util.Collections; -import java.util.List; +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 com.vaadin.testbench.parallel.Browser; -import com.vaadin.tests.push.BasicPushLongPolling; -import com.vaadin.tests.push.BasicPushTest; -import com.vaadin.tests.tb3.IncludeIfProperty; +import java.util.Collections; +import java.util.List; @IncludeIfProperty(property = "server-name", value = "wildfly9-nginx") public class LongPollingProxyServerTest extends AbstractIntegrationTest { diff --git a/tests/screenshots b/tests/screenshots -Subproject e8a1a198f0c42b2780edc75d9e45993bcebb482 +Subproject 1163ee1b0d2523d39b326592e1a5918a27f8618 diff --git a/uitest/build.xml b/uitest/build.xml index 6a40f8e539..8dbf659383 100644 --- a/uitest/build.xml +++ b/uitest/build.xml @@ -1,97 +1,7 @@ -<?xml version="1.0"?> +<project> -<project name="vaadin-uitest" basedir="." default="test-tb3" - xmlns:ivy="antlib:org.apache.ivy.ant"> - <description> - Provides a uitest WAR containing Vaadin UI tests - </description> - <include file="../common.xml" as="common" /> - - <!-- global properties --> - <property name="module.name" value="vaadin-uitest" /> - <property name="uitest.dir" location="${vaadin.basedir}/uitest" /> - <property name="result.dir" value="result" /> - <property name="theme.result.dir" value="${result.dir}/VAADIN/themes" /> - <property name="result.war" - location="${result.dir}/lib/${module.name}-${vaadin.version}.war" /> - - <!-- Need to give a default value to keep Ivy happy --> - <property name="vaadin.build.repository" value="http://maven.vaadin.com/vaadin-prereleases"/> - - <target name="clean"> - <fail unless="result.dir" message="No result.dir parameter given" /> - <delete dir="${result.dir}" /> - </target> - - <target name="fetch-war"> - <mkdir dir="${vaadin.basedir}/uitest/target"/> - <get src="${vaadin.build.repository}/com/vaadin/vaadin-uitest/${vaadin.version}/vaadin-uitest-${vaadin.version}.war" dest="${vaadin.basedir}/uitest/target/vaadin-uitest-${vaadin.version}.war"/> - </target> - - <!-- run both normal and server tests --> - <target name="test-all" depends="clean-testbench-errors"> - <property name="war.file" - location="${vaadin.basedir}/uitest/target/vaadin-uitest-${vaadin.version}.war" /> - <mkdir dir="${vaadin.basedir}/result" /> - <parallel> - <daemons> - <ant antfile="${uitest.dir}/vaadin-server.xml" - inheritall="true" inheritrefs="true" target="deploy-and-start" /> - </daemons> - <sequential> - <ant antfile="${uitest.dir}/vaadin-server.xml" - target="wait-for-startup" /> - <ant antfile="${uitest.dir}/tb3test.xml" target="run-all-tb3-tests" - inheritall="true" /> - <!-- within sequential for now not to cause problems with result parsing in CI --> - <ant antfile="${uitest.dir}/integration_tests.xml" - target="integration-test-all" inheritall="false" - inheritrefs="false"> - <property name="demo.war" value="${war.file}" /> - </ant> - </sequential> - </parallel> + <target name="test-tb3"> + <echo>This Ant script is no longer used to test the framework. Run `mvn verify -P test` to execute browser tests.</echo> </target> - <target name="test-server" depends="clean-testbench-errors"> - <property name="war.file" - location="${vaadin.basedir}/uitest/target/vaadin-uitest-${vaadin.version}.war" /> - <ant antfile="${uitest.dir}/integration_tests.xml" - target="integration-test-all" inheritall="false" - inheritrefs="false"> - <property name="demo.war" value="${war.file}" /> - </ant> - </target> - - <target name="test-tb3" depends="clean-testbench-errors"> - <property name="war.file" - location="${vaadin.basedir}/uitest/target/vaadin-uitest-${vaadin.version}.war" /> - <mkdir dir="${vaadin.basedir}/result" /> - <parallel> - <daemons> - <ant antfile="${uitest.dir}/vaadin-server.xml" - inheritall="true" inheritrefs="true" target="deploy-and-start" /> - </daemons> - <sequential> - <ant antfile="${uitest.dir}/vaadin-server.xml" - target="wait-for-startup" /> - <ant antfile="${uitest.dir}/tb3test.xml" target="run-all-tb3-tests" - inheritall="true" /> - </sequential> - </parallel> - </target> - - <target name="clean-testbench-errors"> - <fail unless="com.vaadin.testbench.screenshot.directory" - message="Define screenshot directory using -Dcom.vaadin.testbench.screenshot.directory" /> - <mkdir dir="${com.vaadin.testbench.screenshot.directory}/errors" /> - <delete> - <fileset - dir="${com.vaadin.testbench.screenshot.directory}/errors"> - <include name="*" /> - </fileset> - </delete> - </target> - - </project> diff --git a/uitest/pom.xml b/uitest/pom.xml index 84eeb9566d..ac7fe17758 100644 --- a/uitest/pom.xml +++ b/uitest/pom.xml @@ -12,6 +12,7 @@ <packaging>war</packaging> <properties> <skip.uitest.deployment>true</skip.uitest.deployment> + <skip.uitest.failsafe>true</skip.uitest.failsafe> <!-- Don't care about coding style for tests --> <sonar.skip>true</sonar.skip> </properties> @@ -260,6 +261,24 @@ </plugin> <plugin> + <groupId>com.github.klieber</groupId> + <artifactId>phantomjs-maven-plugin</artifactId> + <configuration> + <skip>${skip.uitest.failsafe}</skip> + </configuration> + <executions> + <execution> + <goals> + <goal>install</goal> + </goals> + <configuration> + <version>${phantomjs.version}</version> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.version}</version> @@ -267,6 +286,10 @@ <httpConnector> <port>8888</port> </httpConnector> + <scanIntervalSeconds>-1</scanIntervalSeconds> + <stopPort>8889</stopPort> + <stopWait>5</stopWait> + <stopKey>foo</stopKey> </configuration> </plugin> @@ -283,18 +306,39 @@ </configuration> </plugin> <plugin> - <artifactId>maven-surefire-plugin</artifactId> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-maven-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>animal-sniffer-maven-plugin</artifactId> + <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <configuration> + <skip>${skip.uitest.failsafe}</skip> + <includes> + <include>**/AllTB3Tests.java</include> + </includes> + <systemPropertyVariables> + <com.vaadin.testbench.screenshot.directory>${project.parent.basedir}/tests/screenshots</com.vaadin.testbench.screenshot.directory> + <com.vaadin.testbench.max.retries>2</com.vaadin.testbench.max.retries> + </systemPropertyVariables> + </configuration> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> <pluginManagement> <plugins> @@ -327,20 +371,43 @@ </properties> </profile> <profile> - <id>default</id> + <id>test</id> <activation> - <activeByDefault>true</activeByDefault> + <activeByDefault>false</activeByDefault> </activation> + <properties> + <skip.uitest.failsafe>false</skip.uitest.failsafe> + </properties> <build> - <plugins> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <excludedGroups>com.vaadin.testcategory.MeasurementTest</excludedGroups> - </configuration> - </plugin> - </plugins> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + + <executions> + <!-- start and stop jetty (running our app) + when running integration tests --> + <execution> + <id>start-jetty</id> + <phase>pre-integration-test</phase> + <goals> + <goal>start</goal> + </goals> + </execution> + <execution> + <id>stop-jetty</id> + <phase>post-integration-test</phase> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> </build> + </profile> <profile> <id>measurements</id> @@ -369,54 +436,39 @@ </systemPropertyVariables> </configuration> </plugin> - <plugin> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-maven-plugin</artifactId> - <configuration> - <httpConnector> - <port>8888</port> - </httpConnector> - <scanIntervalSeconds>-1</scanIntervalSeconds> - <stopPort>8081</stopPort> - <stopWait>5</stopWait> - <stopKey>foo</stopKey> - </configuration> - <executions> - <!-- start and stop jetty (running our app) when - running integration tests --> - <execution> - <id>start-jetty</id> - <phase>pre-integration-test</phase> - <goals> - <goal>start</goal> - </goals> - </execution> - <execution> - <id>stop-jetty</id> - <phase>post-integration-test</phase> - <goals> - <goal>stop</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>com.github.klieber</groupId> - <artifactId>phantomjs-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>install</goal> - </goals> - <configuration> - <version>${phantomjs.version}</version> - </configuration> - </execution> - </executions> - </plugin> </plugins> </build> </profile> + <profile> + <id>validation</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <useLocalWebDriver>true</useLocalWebDriver> + <browsers.include>phantomjs1</browsers.include> + <categories.exclude>push,needs-ssh</categories.exclude> + </systemPropertyVariables> + </configuration> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> + </build> + </profile> </profiles> </project> diff --git a/uitest/src/main/webapp/WEB-INF/jboss-web.xml b/uitest/src/main/webapp/WEB-INF/jboss-web.xml deleted file mode 100644 index 12548b7c5c..0000000000 --- a/uitest/src/main/webapp/WEB-INF/jboss-web.xml +++ /dev/null @@ -1,7 +0,0 @@ -<jboss-web version="7.2" xmlns="http://www.jboss.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee - schema/jboss-web_7_2.xsd"> - <!-- Enable websockets on JBoss EAP 6.4 --> - <enable-websockets>true</enable-websockets> -</jboss-web> diff --git a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java index e733bf0d2e..3cbf8c38c7 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java @@ -27,7 +27,7 @@ import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; -@TestCategory("communication") +@TestCategory("needs-ssh") public class ReconnectDialogUITest extends MultiBrowserTestWithProxy { @Test diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml deleted file mode 100644 index 1e4eb02d4e..0000000000 --- a/uitest/tb3test.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0"?> -<project name="tb3test" xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:ivy="antlib:org.apache.ivy.ant" basedir="."> - - <dirname property="tb3test.dir" file="${ant.file.tb3test}" /> - <property name="report.dir" location="${tb3test.dir}/result/reports-tb3" /> - <property name="browsers.include" value="" /> - <property name="browsers.exclude" value="" /> - <property name="browser.factory" value="" /> - <property name="categories.include" value="" /> - <property name="categories.exclude" value="" /> - <property name="useLocalWebDriver" value="false" /> - <property name="com.vaadin.testbench.max.retries" value="0" /> - <property name="com.vaadin.testbench.hub.url" value="" /> - <property name="vaadin.testbench.developer.license" value="" /> - <property name="junit.test.suite" value="com.vaadin.tests.tb3.AllTB3Tests" /> - - <ivy:resolve file="${tb3test.dir}/ivy.xml" conf="build, build-provided" /> - <ivy:cachepath pathid="classpath.tb3.lib" conf="build, build-provided" /> - <path id="classpath.tb3"> - <path location="${tb3test.dir}/target/test-classes" /> - <path refid="classpath.tb3.lib" /> - <path location="${tb3test.dir}/target/classes" /> - </path> - - <target name="run-all-tb3-tests" unless="tests.tb3.skip" - description="Run all the TB3 tests (except server tests) in the project"> - <antcall target="run-tb3-suite" /> - </target> - - <target name="run-tb3-suite"> - <fail unless="com.vaadin.testbench.screenshot.directory" message="Define screenshot directory using -Dcom.vaadin.testbench.screenshot.directory" /> - <delete dir="${report.dir}" /> - <mkdir dir="${report.dir}" /> - - <junit showoutput="no" printsummary="no" fork="yes"> - <formatter type="xml" /> - <classpath refid="classpath.tb3" /> - - <jvmarg value="-Dcom.vaadin.testbench.screenshot.directory=${com.vaadin.testbench.screenshot.directory}" /> - <jvmarg value="-Djava.awt.headless=true" /> - <jvmarg value="-Dbrowsers.include=${browsers.include}" /> - <jvmarg value="-Dbrowsers.exclude=${browsers.exclude}" /> - <jvmarg value="-Dbrowser.factory=${browser.factory}" /> - <jvmarg value="-Dcategories.include=${categories.include}" /> - <jvmarg value="-Dcategories.exclude=${categories.exclude}" /> - <jvmarg value="-DuseLocalWebDriver=${useLocalWebDriver}" /> - <jvmarg value="-Dcom.vaadin.testbench.max.retries=${com.vaadin.testbench.max.retries}" /> - <jvmarg value="-Dcom.vaadin.testbench.hub.url=${com.vaadin.testbench.hub.url}" /> - <jvmarg value="-Dvaadin.testbench.developer.license=${vaadin.testbench.developer.license}" /> - <test name="${junit.test.suite}" todir="${report.dir}" /> - </junit> - - </target> - -</project> diff --git a/uitest/vaadin-server.xml b/uitest/vaadin-server.xml deleted file mode 100644 index 5e9090a536..0000000000 --- a/uitest/vaadin-server.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<project xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:ivy="antlib:org.apache.ivy.ant" name="vaadin-server" default="deploy-and-start" basedir="."> - <include file="../common.xml" /> - <dirname property="dir" file="${ant.file.vaadin-server}" /> - - <target name="deploy-and-start"> - <fail unless="war.file" message="No war file given in 'war.file'" /> - - <ivy:resolve log="download-only" file="${dir}/ivy.xml" /> - <ivy:cachepath pathid="classpath.jetty" conf="jetty-run" /> - <java classname="org.mortbay.jetty.runner.Runner" fork="yes" output="${vaadin.basedir}/result/jetty.java.out" resultproperty="resultCode" maxmemory="1024m"> - <arg value="--port" /> - <arg value="8888" /> - <arg value="--out" /> - <arg value="${vaadin.basedir}/result/jetty.out" /> - <arg value="--log" /> - <arg value="${vaadin.basedir}/result/jetty.log" /> - <arg value="${war.file}" /> - <classpath refid="classpath.jetty" /> - <jvmarg value="-ea" /> - </java> - <echo message="Jetty process ended with result code ${resultCode}" /> - - </target> - - <target name="wait-for-startup"> - <echo>Waiting for Servlet Container to start up.</echo> - <waitfor maxwait="60" maxwaitunit="second" checkevery="5" checkeveryunit="second" timeoutproperty="server.start.failed"> - <http url="http://localhost:8888" /> - </waitfor> - <fail if="server.start.failed" message="Server startup failed" /> - </target> - -</project> |