diff options
Diffstat (limited to 'uitest')
38 files changed, 1283 insertions, 230 deletions
diff --git a/uitest/integration_tests.xml b/uitest/integration_tests.xml index bdbf1f2e5b..20d0d2147d 100644 --- a/uitest/integration_tests.xml +++ b/uitest/integration_tests.xml @@ -230,6 +230,13 @@ <param name="target-server" value="wildfly9" /> </antcall> </target> + <target name="integration-test-wildfly9-nginx"> + <antcall target="run-generic-integration-test"> + <param name="startDelay" value="10" /> + <param name="target-server" value="wildfly9-nginx" /> + <param name="target-port" value="80" /> + </antcall> + </target> <target name="integration-test-glassfish3"> <antcall target="run-generic-integration-test"> <param name="startDelay" value="10" /> diff --git a/uitest/ivy.xml b/uitest/ivy.xml index 281ba1ecdf..e17e094f79 100644 --- a/uitest/ivy.xml +++ b/uitest/ivy.xml @@ -78,15 +78,19 @@ <exclude org="org.eclipse.jetty.orbit"></exclude> </dependency> <dependency org="org.eclipse.jetty" name="jetty-websocket" - rev="&jetty.version;" conf="ide, jetty-run->default"> + rev="&jetty.version;" conf="ide, build-provided, jetty-run->default"> <exclude org="org.eclipse.jetty.orbit"></exclude> </dependency> <dependency org="org.eclipse.jetty" name="jetty-webapp" rev="&jetty.version;" conf="ide, build-provided, jetty-run->default"> <exclude org="org.eclipse.jetty.orbit"></exclude> </dependency> + <dependency org="org.eclipse.jetty" name="jetty-util" + rev="&jetty.version;" conf="ide, build-provided, jetty-run->default"> + <exclude org="org.eclipse.jetty.orbit"></exclude> + </dependency> <dependency org="org.mortbay.jetty" name="jetty-runner" - rev="&jetty.version;" conf="ide, jetty-run->default"> + rev="&jetty.version;" conf="ide, build-provided, jetty-run->default"> <exclude org="org.eclipse.jetty.orbit"></exclude> </dependency> @@ -104,7 +108,7 @@ <dependency org="org.hsqldb" name="hsqldb" rev="2.2.6" conf="build,ide -> default" /> <dependency org="com.vaadin" name="vaadin-testbench" - rev="4.0.2" conf="build-provided,ide -> default" /> + rev="4.0.3" conf="build-provided,ide -> default" /> <!-- This should be removed once tests have been updated to use lang3 --> <dependency org="commons-lang" name="commons-lang" rev="2.6" conf="build,ide -> default" /> @@ -114,7 +118,6 @@ <dependency org="com.vaadin" name="vaadin-buildhelpers" rev="${vaadin.version}" conf="compile-theme->build" /> - <dependency org="org.eclipse.jgit" name="org.eclipse.jgit" rev="3.5.1.201410131835-r" conf="ide,build->default"> <exclude org="org.apache.httpcomponents"></exclude> diff --git a/uitest/src/com/vaadin/tests/application/CommErrorEmulatorServlet.java b/uitest/src/com/vaadin/tests/application/CommErrorEmulatorServlet.java new file mode 100644 index 0000000000..116ef1c1f2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/CommErrorEmulatorServlet.java @@ -0,0 +1,151 @@ +/* + * Copyright 2000-2014 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.application; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.vaadin.server.DeploymentConfiguration; +import com.vaadin.server.RequestHandler; +import com.vaadin.server.ServiceException; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinResponse; +import com.vaadin.server.VaadinServlet; +import com.vaadin.server.VaadinServletService; +import com.vaadin.server.VaadinSession; +import com.vaadin.server.communication.HeartbeatHandler; +import com.vaadin.server.communication.UidlRequestHandler; +import com.vaadin.ui.UI; + +public class CommErrorEmulatorServlet extends VaadinServlet { + + private Map<UI, Integer> uidlResponseCode = Collections + .synchronizedMap(new HashMap<UI, Integer>()); + private Map<UI, Integer> heartbeatResponseCode = Collections + .synchronizedMap(new HashMap<UI, Integer>()); + + private final CommErrorUIDLRequestHandler uidlHandler = new CommErrorUIDLRequestHandler(); + private final CommErrorHeartbeatHandler heartbeatHandler = new CommErrorHeartbeatHandler(); + + public class CommErrorUIDLRequestHandler extends UidlRequestHandler { + @Override + public boolean synchronizedHandleRequest(VaadinSession session, + VaadinRequest request, VaadinResponse response) + throws IOException { + UI ui = session.getService().findUI(request); + if (ui != null && uidlResponseCode.containsKey(ui)) { + response.sendError(uidlResponseCode.get(ui), "Error set in UI"); + return true; + } + + return super.synchronizedHandleRequest(session, request, response); + } + } + + public class CommErrorHeartbeatHandler extends HeartbeatHandler { + @Override + public boolean synchronizedHandleRequest(VaadinSession session, + VaadinRequest request, VaadinResponse response) + throws IOException { + UI ui = session.getService().findUI(request); + if (ui != null && heartbeatResponseCode.containsKey(ui)) { + response.sendError(heartbeatResponseCode.get(ui), + "Error set in UI"); + return true; + } + + return super.synchronizedHandleRequest(session, request, response); + } + + } + + public class CommErrorEmulatorService extends VaadinServletService { + + public CommErrorEmulatorService(VaadinServlet servlet, + DeploymentConfiguration deploymentConfiguration) + throws ServiceException { + super(servlet, deploymentConfiguration); + } + + @Override + protected List<RequestHandler> createRequestHandlers() + throws ServiceException { + List<RequestHandler> handlers = super.createRequestHandlers(); + handlers.add(uidlHandler); + handlers.add(heartbeatHandler); + return handlers; + } + } + + @Override + protected VaadinServletService createServletService( + DeploymentConfiguration deploymentConfiguration) + throws ServiceException { + CommErrorEmulatorService s = new CommErrorEmulatorService(this, + deploymentConfiguration); + s.init(); + return s; + } + + public void setUIDLResponseCode(final UI ui, int responseCode, + final int delay) { + uidlResponseCode.put(ui, responseCode); + System.out.println("Responding with " + responseCode + + " to UIDL requests for " + ui + " for the next " + delay + + "s"); + + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(delay * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("Handing UIDL requests normally again"); + + uidlResponseCode.remove(ui); + } + }).start(); + } + + public void setHeartbeatResponseCode(final UI ui, int responseCode, + final int delay) { + heartbeatResponseCode.put(ui, responseCode); + + System.out.println("Responding with " + responseCode + + " to heartbeat requests for " + ui + " for the next " + delay + + "s"); + + new Thread(new Runnable() { + + @Override + public void run() { + try { + Thread.sleep(delay * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("Handing heartbeat requests normally again"); + heartbeatResponseCode.remove(ui); + } + }).start(); + } + +} diff --git a/uitest/src/com/vaadin/tests/application/CommErrorEmulatorUI.java b/uitest/src/com/vaadin/tests/application/CommErrorEmulatorUI.java new file mode 100644 index 0000000000..080d36fa48 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/CommErrorEmulatorUI.java @@ -0,0 +1,270 @@ +/* + * Copyright 2000-2014 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.application; + +import com.vaadin.annotations.Theme; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Panel; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +@Theme("valo") +public class CommErrorEmulatorUI extends AbstractTestUIWithLog { + + private static class Response { + private Integer code; + private Integer time; + + /** + * @param code + * @param time + */ + public Response(Integer code, Integer time) { + super(); + this.code = code; + this.time = time; + } + + } + + private Response uidlResponse = new Response(503, 10); + private Response heartbeatResponse = new Response(200, 10); + + // Server exceptions will occur in this test as we are writing the response + // here and not letting the servlet write it + @Override + protected void setup(VaadinRequest request) { + String transport = request.getParameter("transport"); + + if ("websocket".equalsIgnoreCase(transport)) { + log("Using websocket"); + } else if ("websocket-xhr".equalsIgnoreCase(transport)) { + log("Using websocket for push only"); + } else if ("long-polling".equalsIgnoreCase(transport)) { + log("Using long-polling"); + } else { + log("Using XHR"); + } + getLayout().setSpacing(true); + addComponent(createConfigPanel()); + addComponent(createServerConfigPanel()); + + addComponent(new Button("Say hello", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log("Hello"); + } + })); + } + + /** + * @since + * @return + */ + private Component createServerConfigPanel() { + Panel p = new Panel("Server config (NOTE: affects all users)"); + VerticalLayout vl = new VerticalLayout(); + vl.setSpacing(true); + vl.setMargin(true); + p.setContent(vl); + vl.addComponent(createTemporaryResponseCodeSetters("UIDL", uidlResponse)); + vl.addComponent(createTemporaryResponseCodeSetters("Heartbeat", + heartbeatResponse)); + vl.addComponent(new Button("Activate", new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + if (uidlResponse.code != null && uidlResponse.code != 200) { + getServlet().setUIDLResponseCode(CommErrorEmulatorUI.this, + uidlResponse.code, uidlResponse.time); + log("Responding with " + uidlResponse.code + + " to UIDL requests for " + uidlResponse.time + + "s"); + } + if (heartbeatResponse.code != null + && heartbeatResponse.code != 200) { + getServlet().setHeartbeatResponseCode( + CommErrorEmulatorUI.this, heartbeatResponse.code, + heartbeatResponse.time); + log("Responding with " + heartbeatResponse.code + + " to heartbeat requests for " + + heartbeatResponse.time + "s"); + } + } + })); + + return p; + } + + private Component createConfigPanel() { + Panel p = new Panel("Reconnect dialog configuration"); + p.setSizeUndefined(); + final TextField reconnectDialogMessage = new TextField( + "Reconnect message"); + reconnectDialogMessage.setWidth("50em"); + reconnectDialogMessage.setValue(getReconnectDialogConfiguration() + .getDialogText()); + reconnectDialogMessage + .addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getReconnectDialogConfiguration().setDialogText( + reconnectDialogMessage.getValue()); + } + }); + + final TextField reconnectDialogGaveUpMessage = new TextField( + "Reconnect gave up message"); + reconnectDialogGaveUpMessage.setWidth("50em"); + + reconnectDialogGaveUpMessage.setValue(getReconnectDialogConfiguration() + .getDialogTextGaveUp()); + reconnectDialogGaveUpMessage + .addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getReconnectDialogConfiguration().setDialogTextGaveUp( + reconnectDialogGaveUpMessage.getValue()); + } + }); + final TextField reconnectDialogReconnectAttempts = new TextField( + "Reconnect attempts"); + reconnectDialogReconnectAttempts.setConverter(Integer.class); + reconnectDialogReconnectAttempts + .setConvertedValue(getReconnectDialogConfiguration() + .getReconnectAttempts()); + reconnectDialogReconnectAttempts + .addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getReconnectDialogConfiguration().setReconnectAttempts( + (Integer) reconnectDialogReconnectAttempts + .getConvertedValue()); + } + }); + final TextField reconnectDialogReconnectInterval = new TextField( + "Reconnect interval (ms)"); + reconnectDialogReconnectInterval.setConverter(Integer.class); + reconnectDialogReconnectInterval + .setConvertedValue(getReconnectDialogConfiguration() + .getReconnectInterval()); + reconnectDialogReconnectInterval + .addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getReconnectDialogConfiguration().setReconnectInterval( + (Integer) reconnectDialogReconnectInterval + .getConvertedValue()); + } + }); + + final TextField reconnectDialogGracePeriod = new TextField( + "Reconnect dialog grace period (ms)"); + reconnectDialogGracePeriod.setConverter(Integer.class); + reconnectDialogGracePeriod + .setConvertedValue(getReconnectDialogConfiguration() + .getDialogGracePeriod()); + reconnectDialogGracePeriod + .addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getReconnectDialogConfiguration().setDialogGracePeriod( + (Integer) reconnectDialogGracePeriod + .getConvertedValue()); + } + }); + + final CheckBox reconnectDialogModal = new CheckBox( + "Reconnect dialog modality"); + reconnectDialogModal.setValue(getReconnectDialogConfiguration() + .isDialogModal()); + reconnectDialogModal.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getReconnectDialogConfiguration().setDialogModal( + reconnectDialogModal.getValue()); + } + }); + + VerticalLayout vl = new VerticalLayout(); + vl.setMargin(true); + vl.setSpacing(true); + p.setContent(vl); + vl.addComponents(reconnectDialogMessage, reconnectDialogGaveUpMessage, + reconnectDialogGracePeriod, reconnectDialogModal, + reconnectDialogReconnectAttempts, + reconnectDialogReconnectInterval); + return p; + } + + private Component createTemporaryResponseCodeSetters(String type, + final Response response) { + + HorizontalLayout hl = new HorizontalLayout(); + hl.setSpacing(true); + hl.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); + Label l1 = new Label("Respond to " + type + " requests with code"); + final TextField responseCode = new TextField(null, "" + response.code); + responseCode.setConverter(Integer.class); + responseCode.setWidth("5em"); + Label l2 = new Label("for the following"); + final TextField timeField = new TextField(null, "" + response.time); + timeField.setConverter(Integer.class); + timeField.setWidth("5em"); + Label l3 = new Label("seconds"); + + responseCode.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + Integer code = (Integer) responseCode.getConvertedValue(); + response.code = code; + } + }); + + timeField.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + Integer time = (Integer) timeField.getConvertedValue(); + response.time = time; + } + }); + + hl.addComponents(l1, responseCode, l2, timeField, l3); + return hl; + } + + protected CommErrorEmulatorServlet getServlet() { + return (CommErrorEmulatorServlet) VaadinServlet.getCurrent(); + } + +} diff --git a/uitest/src/com/vaadin/tests/application/CriticalNotificationsTestBase.java b/uitest/src/com/vaadin/tests/application/CriticalNotificationsTest.java index f3813fce50..03564cbaf7 100644 --- a/uitest/src/com/vaadin/tests/application/CriticalNotificationsTestBase.java +++ b/uitest/src/com/vaadin/tests/application/CriticalNotificationsTest.java @@ -22,48 +22,7 @@ import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.tests.tb3.MultiBrowserThemeTest; -public abstract class CriticalNotificationsTestBase extends - MultiBrowserThemeTest { - - public static class ValoCriticalNotificationsTest extends - CriticalNotificationsTestBase { - @Override - protected String getTheme() { - return "valo"; - } - } - - public static class ReindeerCriticalNotificationsTest extends - CriticalNotificationsTestBase { - @Override - protected String getTheme() { - return "reindeer"; - } - } - - public static class RunoCriticalNotificationsTest extends - CriticalNotificationsTestBase { - @Override - protected String getTheme() { - return "runo"; - } - } - - public static class ChameleonCriticalNotificationsTest extends - CriticalNotificationsTestBase { - @Override - protected String getTheme() { - return "chameleon"; - } - } - - public static class BaseCriticalNotificationsTest extends - CriticalNotificationsTestBase { - @Override - protected String getTheme() { - return "base"; - } - } +public class CriticalNotificationsTest extends MultiBrowserThemeTest { @Test public void internalError() throws Exception { diff --git a/uitest/src/com/vaadin/tests/application/ReconnectDialogThemeTest.java b/uitest/src/com/vaadin/tests/application/ReconnectDialogThemeTest.java new file mode 100644 index 0000000000..b9e57d39e8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/ReconnectDialogThemeTest.java @@ -0,0 +1,101 @@ +/* + * Copyright 2000-2014 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.application; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TakesScreenshot; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.parallel.BrowserUtil; +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.CustomTestBenchCommandExecutor; +import com.vaadin.tests.tb3.MultiBrowserThemeTestWithProxy; + +@TestCategory("") +public class ReconnectDialogThemeTest extends MultiBrowserThemeTestWithProxy { + + static By reconnectDialogBy = By.className("v-reconnect-dialog"); + + @Test + public void reconnectDialogTheme() throws IOException { + openTestURL(); + ButtonElement helloButton = $(ButtonElement.class).caption("Say hello") + .first(); + helloButton.click(); + Assert.assertEquals("1. Hello from the server", getLogRow(0)); + disconnectProxy(); + helloButton.click(); + testBench().disableWaitForVaadin(); + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + boolean present = isElementPresent(reconnectDialogBy); + return present; + } + }); + + WebElement dialog = findElement(reconnectDialogBy); + WebElement spinner = dialog.findElement(By.className("spinner")); + + // Hide spinner to make screenshot stable + executeScript("arguments[0].style.visibility='hidden';", spinner); + compareScreen("onscreen-without-spinner"); + + // Show spinner and make sure it is shown by comparing to the screenshot + // without a spinner + executeScript("arguments[0].style.visibility='visible';", spinner); + BufferedImage fullScreen = ImageIO.read(new ByteArrayInputStream( + ((TakesScreenshot) getDriver()) + .getScreenshotAs(OutputType.BYTES))); + BufferedImage spinnerImage = CustomTestBenchCommandExecutor + .cropToElement(spinner, fullScreen, + BrowserUtil.isIE8(getDesiredCapabilities())); + assertHasManyColors("Spinner is not shown", spinnerImage); + + } + + private void assertHasManyColors(String message, BufferedImage spinnerImage) { + int backgroundColor = spinnerImage.getRGB(0, 0); + for (int x = 0; x < spinnerImage.getWidth(); x++) { + for (int y = 0; y < spinnerImage.getHeight(); y++) { + if (Math.abs(spinnerImage.getRGB(x, y) - backgroundColor) > 50) { + return; + } + } + } + Assert.fail(message); + + } + + @Override + protected Class<?> getUIClass() { + return ReconnectDialogUI.class; + } + +} diff --git a/uitest/src/com/vaadin/tests/application/ReconnectDialogUI.java b/uitest/src/com/vaadin/tests/application/ReconnectDialogUI.java new file mode 100644 index 0000000000..62de2d49c5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/ReconnectDialogUI.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2014 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.application; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; + +public class ReconnectDialogUI extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + if (request.getParameter("reconnectAttempts") != null) { + getReconnectDialogConfiguration() + .setReconnectAttempts( + Integer.parseInt(request + .getParameter("reconnectAttempts"))); + } + Button b = new Button("Say hello"); + b.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log("Hello from the server"); + } + }); + + addComponent(b); + } + +} diff --git a/uitest/src/com/vaadin/tests/application/ReconnectDialogUITest.java b/uitest/src/com/vaadin/tests/application/ReconnectDialogUITest.java new file mode 100644 index 0000000000..0a31402c13 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/ReconnectDialogUITest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2000-2014 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.application; + +import org.junit.Assert; +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; + +import com.jcraft.jsch.JSchException; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; + +public class ReconnectDialogUITest extends MultiBrowserTestWithProxy { + + @Test + public void reconnectDialogShownAndDisappears() throws JSchException { + openTestURL(); + getButton().click(); + Assert.assertEquals("1. Hello from the server", getLogRow(0)); + disconnectProxy(); + getButton().click(); + waitForReconnectDialogWithText("Server connection lost, trying to reconnect..."); + connectProxy(); + waitForReconnectDialogToDisappear(); + Assert.assertEquals("2. Hello from the server", getLogRow(0)); + } + + @Test + public void gaveUpMessageShown() { + openTestURL("reconnectAttempts=3"); + getButton().click(); + Assert.assertEquals("1. Hello from the server", getLogRow(0)); + + disconnectProxy(); + getButton().click(); + + waitForReconnectDialogWithText("Server connection lost."); + } + + private void waitForReconnectDialogWithText(final String text) { + waitForReconnectDialogPresent(); + final WebElement reconnectDialog = findElement(ReconnectDialogThemeTest.reconnectDialogBy); + waitUntil(new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver input) { + return reconnectDialog.findElement(By.className("text")) + .getText().equals(text); + } + }, 10); + + } + + private void waitForReconnectDialogToDisappear() { + waitForElementNotPresent(ReconnectDialogThemeTest.reconnectDialogBy); + + } + + private void waitForReconnectDialogPresent() { + waitForElementPresent(ReconnectDialogThemeTest.reconnectDialogBy); + } + + private WebElement getButton() { + return $(ButtonElement.class).first(); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index 98b0f63ce1..33ff504d8d 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -124,6 +124,8 @@ public abstract class AbstractTestUI extends UI { 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)) { diff --git a/uitest/src/com/vaadin/tests/components/grid/GridThemeChangeTest.java b/uitest/src/com/vaadin/tests/components/grid/GridThemeChangeTest.java index 182bec04c9..1e2b8f4335 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridThemeChangeTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridThemeChangeTest.java @@ -36,7 +36,7 @@ public class GridThemeChangeTest extends MultiBrowserTest { @Test public void testThemeChange() { - openTestURL(); + openTestURL("debug"); GridElement grid = $(GridElement.class).first(); @@ -44,6 +44,7 @@ public class GridThemeChangeTest extends MultiBrowserTest { grid.getCell(0, 0).click(); + grid = $(GridElement.class).first(); int valoHeight = grid.getRow(0).getSize().getHeight(); Assert.assertTrue( diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java index cff8ade054..cbd0857bd1 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java @@ -376,9 +376,10 @@ public class GridSortingTest extends GridBasicFeaturesTest { } private void assertLastSortIsUserOriginated(boolean isUserOriginated) { + // Find a message in the log List<WebElement> userOriginatedMessages = getDriver() .findElements( - By.xpath("//*[contains(text(),'SortOrderChangeEvent: isUserOriginated')]")); + By.xpath("//div[@id='Log']//*[contains(text(),'SortOrderChangeEvent: isUserOriginated')]")); Collections.sort(userOriginatedMessages, new Comparator<WebElement>() { @Override diff --git a/uitest/src/com/vaadin/tests/components/uitest/LiferayThemeTest.java b/uitest/src/com/vaadin/tests/components/uitest/LiferayThemeTest.java deleted file mode 100644 index 47c4c1baae..0000000000 --- a/uitest/src/com/vaadin/tests/components/uitest/LiferayThemeTest.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2000-2014 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.components.uitest; - -public class LiferayThemeTest extends ThemeTest { - @Override - protected String getTheme() { - return "liferay"; - } -} diff --git a/uitest/src/com/vaadin/tests/components/uitest/ThemeTest.java b/uitest/src/com/vaadin/tests/components/uitest/ThemeTest.java index 86847fc28e..f6d680de87 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/ThemeTest.java +++ b/uitest/src/com/vaadin/tests/components/uitest/ThemeTest.java @@ -13,11 +13,11 @@ import com.vaadin.testbench.elements.ComboBoxElement; import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elementsbase.ServerClass; import com.vaadin.testbench.parallel.BrowserUtil; -import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.MultiBrowserThemeTest; import com.vaadin.tests.tb3.newelements.FixedNotificationElement; import com.vaadin.tests.tb3.newelements.WindowElement; -public abstract class ThemeTest extends MultiBrowserTest { +public class ThemeTest extends MultiBrowserThemeTest { @ServerClass("com.vaadin.ui.DateField") public static class DateFieldElement extends @@ -51,15 +51,9 @@ public abstract class ThemeTest extends MultiBrowserTest { return ThemeTestUI.class; } - protected abstract String getTheme(); - @Test public void testTheme() throws Exception { - openTestURL("theme=" + getTheme()); - runThemeTest(); - } - - private void runThemeTest() throws IOException { + openTestURL(); TabSheetElement themeTabSheet = $(TabSheetElement.class).first(); // Labels tab @@ -161,12 +155,26 @@ public abstract class ThemeTest extends MultiBrowserTest { } private void testTables() throws IOException { + compareScreen("tables"); - TableElement table = $(TableElement.class).first(); - new Actions(driver).moveToElement(table.getCell(0, 1), 5, 5) - .contextClick().perform(); - compareScreen("tables-contextmenu"); - table.findElement(By.className("v-table-column-selector")).click(); + final TableElement table = $(TableElement.class).first(); + if (!BrowserUtil.isPhantomJS(getDesiredCapabilities())) { + // Context click does not work in phantom js + new Actions(driver).moveToElement(table.getCell(0, 1), 5, 5) + .contextClick().perform(); + compareScreen("tables-contextmenu"); + + // Close context menu before opening collapsemenu + // (https://dev.vaadin.com/ticket/18770) + WebElement cm = findElement(By.className("v-contextmenu")); + cm.findElement(By.xpath("//div[text()='Save']")).click(); + } + + WebElement columnSelector = table.findElement(By + .className("v-table-column-selector")); + new Actions(driver).moveToElement(columnSelector, 5, 5).click() + .perform(); + compareScreen("tables-collapsemenu"); } diff --git a/uitest/src/com/vaadin/tests/integration/AbstractServletIntegrationTest.java b/uitest/src/com/vaadin/tests/integration/AbstractServletIntegrationTest.java index 7e9a2138e4..eb1b714776 100644 --- a/uitest/src/com/vaadin/tests/integration/AbstractServletIntegrationTest.java +++ b/uitest/src/com/vaadin/tests/integration/AbstractServletIntegrationTest.java @@ -16,8 +16,13 @@ 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; @@ -27,9 +32,12 @@ import com.vaadin.testbench.elements.TableElement; * * @author Vaadin Ltd */ +@RunWith(ParameterizedTB3Runner.class) public abstract class AbstractServletIntegrationTest extends AbstractIntegrationTest { + private String contextPath = "/demo"; + @Test public void runTest() throws IOException, AssertionError { openTestURL(); @@ -40,7 +48,29 @@ public abstract class AbstractServletIntegrationTest extends @Override protected String getDeploymentPath(Class<?> uiClass) { - return "/demo" + super.getDeploymentPath(uiClass); + return contextPath + super.getDeploymentPath(uiClass); + } + + public void setContextPath(String contextPath) { + this.contextPath = contextPath; + } + + @Parameters + public static Collection<String> getContextPaths() { + if (getServerName().equals("wildfly9-nginx")) { + ArrayList<String> paths = new ArrayList<String>(); + 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/uitest/src/com/vaadin/tests/integration/LongPollingProxyServerTest.java b/uitest/src/com/vaadin/tests/integration/LongPollingProxyServerTest.java new file mode 100644 index 0000000000..16c599641b --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/LongPollingProxyServerTest.java @@ -0,0 +1,107 @@ +/* + * Copyright 2000-2014 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.util.Collections; +import java.util.List; + +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; + +@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<Boolean>() { + @Override + public Boolean apply(WebDriver input) { + return BasicPushTest + .getServerCounter(LongPollingProxyServerTest.this) > 1; + } + }); + } + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return Collections.singletonList(Browser.PHANTOMJS + .getDesiredCapabilities()); + } +} diff --git a/uitest/src/com/vaadin/tests/integration/ParameterizedTB3Runner.java b/uitest/src/com/vaadin/tests/integration/ParameterizedTB3Runner.java new file mode 100644 index 0000000000..b051fb51db --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/ParameterizedTB3Runner.java @@ -0,0 +1,170 @@ +/* + * Copyright 2000-2014 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.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.junit.runners.Parameterized.Parameters; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; + +import com.vaadin.tests.tb3.TB3Runner; + +/** + * TestBench test runner which supports static @Parameters annotated methods + * providing parameters for the corresponding setter. + * <p> + * {@code @Parameters public static Collection<String> getThemes() } creates one + * permutation for each value returned by {@code getThemes()}. The value is + * automatically assigned to the test instance using {@code setTheme(String)} + * before invoking the test method + * + * @author Vaadin Ltd + */ +public class ParameterizedTB3Runner extends TB3Runner { + + public ParameterizedTB3Runner(Class<?> klass) throws InitializationError { + super(klass); + } + + @Override + protected List<FrameworkMethod> computeTestMethods() { + List<FrameworkMethod> methods = super.computeTestMethods(); + + Map<Method, Collection<String>> parameters = new LinkedHashMap<Method, Collection<String>>(); + + // Find all @Parameters methods and invoke them to find out permutations + + for (Method m : getTestClass().getJavaClass().getMethods()) { + Parameters p = m.getAnnotation(Parameters.class); + if (p == null) { + continue; + } + + if (!m.getName().startsWith("get") || !m.getName().endsWith("s")) { + throw new IllegalStateException( + "Method " + + m.getName() + + " is annotated with @Parameter but is not named getSomeThings() as it should"); + } + + if (m.getParameterTypes().length != 0) { + throw new IllegalStateException( + "Method " + + m.getName() + + " annotated with @Parameter should not have any arguments"); + } + + if (!Modifier.isStatic(m.getModifiers())) { + throw new IllegalStateException("Method " + m.getName() + + " annotated with @Parameter must be static"); + } + + // getThemes -> setTheme + String setter = "set" + m.getName().substring("get".length()); + setter = setter.substring(0, setter.length() - 1); + // property = property.substring(0, 1).toLowerCase() + // + property.substring(1); + + Method setterMethod; + try { + setterMethod = getTestClass().getJavaClass().getMethod(setter, + String.class); + } catch (Exception e) { + throw new IllegalStateException("No setter " + setter + + " found in " + + getTestClass().getJavaClass().getName(), e); + } + + Collection<String> values; + try { + values = (Collection<String>) m.invoke(null); + if (!values.isEmpty()) { + // Ignore any empty collections to allow e.g. integration + // tests to use "/demo" path by default without adding that + // to the screenshot name + parameters.put(setterMethod, values); + } + } catch (Exception e) { + throw new IllegalStateException("The setter " + m.getName() + + " could not be invoked", e); + } + } + + // Add method permutations for all @Parameters + for (Method setter : parameters.keySet()) { + List<FrameworkMethod> newMethods = new ArrayList<FrameworkMethod>(); + for (FrameworkMethod m : methods) { + + if (!(m instanceof TBMethod)) { + System.err.println("Unknown method type: " + + m.getClass().getName()); + newMethods.add(m); + continue; + } + + // testFoo + // testBar + // -> + // testFoo[valo] + // testFoo[runo] + // testBar[valo] + // testBar[runo] + + for (final String value : parameters.get(setter)) { + newMethods.add(new TBMethodWithBefore((TBMethod) m, setter, + value)); + } + } + // Update methods so next parameters will use all expanded methods + methods = newMethods; + } + return methods; + } + + public static class TBMethodWithBefore extends TBMethod { + + private Method setter; + private String value; + private TBMethod parent; + + public TBMethodWithBefore(TBMethod m, Method setter, String value) { + super(m.getMethod(), m.getCapabilities()); + parent = m; + this.setter = setter; + this.value = value; + } + + @Override + public Object invokeExplosively(Object target, Object... params) + throws Throwable { + setter.invoke(target, value); + return parent.invokeExplosively(target, params); + } + + @Override + public String getName() { + return parent.getName() + "[" + value + "]"; + }; + + } +} diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java index ffc5395c2c..7379b08f5b 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPush.java +++ b/uitest/src/com/vaadin/tests/push/BasicPush.java @@ -50,7 +50,7 @@ public class BasicPush extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { - + getReconnectDialogConfiguration().setDialogModal(false); spacer(); /* diff --git a/uitest/src/com/vaadin/tests/push/BasicPushTest.java b/uitest/src/com/vaadin/tests/push/BasicPushTest.java index f176008eb0..157e3f74ae 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPushTest.java +++ b/uitest/src/com/vaadin/tests/push/BasicPushTest.java @@ -16,6 +16,7 @@ package com.vaadin.tests.push; 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; @@ -52,8 +53,8 @@ public abstract class BasicPushTest extends MultiBrowserTest { } public static int getClientCounter(AbstractTB3Test t) { - WebElement clientCounterElem = t - .vaadinElementById(BasicPush.CLIENT_COUNTER_ID); + WebElement clientCounterElem = t.findElement(By + .id(BasicPush.CLIENT_COUNTER_ID)); return Integer.parseInt(clientCounterElem.getText()); } @@ -66,21 +67,21 @@ public abstract class BasicPushTest extends MultiBrowserTest { } public static int getServerCounter(AbstractTB3Test t) { - WebElement serverCounterElem = t - .vaadinElementById(BasicPush.SERVER_COUNTER_ID); + WebElement serverCounterElem = t.findElement(By + .id(BasicPush.SERVER_COUNTER_ID)); return Integer.parseInt(serverCounterElem.getText()); } public static WebElement getServerCounterStartButton(AbstractTB3Test t) { - return t.vaadinElementById(BasicPush.START_TIMER_ID); + return t.findElement(By.id(BasicPush.START_TIMER_ID)); } public static WebElement getServerCounterStopButton(AbstractTB3Test t) { - return t.vaadinElementById(BasicPush.STOP_TIMER_ID); + return t.findElement(By.id(BasicPush.STOP_TIMER_ID)); } public static WebElement getIncrementButton(AbstractTB3Test t) { - return t.vaadinElementById(BasicPush.INCREMENT_BUTTON_ID); + return t.findElement(By.id(BasicPush.INCREMENT_BUTTON_ID)); } protected void waitUntilClientCounterChanges(final int expectedValue) { diff --git a/uitest/src/com/vaadin/tests/components/uitest/ChameleonThemeTest.java b/uitest/src/com/vaadin/tests/push/BasicPushWebsocketXhr.java index 8c4349ad5f..e31eb2a369 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/ChameleonThemeTest.java +++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocketXhr.java @@ -13,21 +13,22 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.tests.components.uitest; +package com.vaadin.tests.push; -import java.io.IOException; +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; -public class ChameleonThemeTest extends ThemeTest { - @Override - protected String getTheme() { - return "chameleon"; - } +@Push(transport = Transport.WEBSOCKET_XHR) +public class BasicPushWebsocketXhr extends BasicPush { @Override - protected void testWindows() throws IOException { - super.testWindows(); - - // chameleon theme only - testWindow(4, "subwindow-opaque"); + public void init(VaadinRequest request) { + super.init(request); + // Don't use fallback so we can easier detect if websocket fails + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); } + } diff --git a/uitest/src/com/vaadin/tests/components/uitest/BaseThemeTest.java b/uitest/src/com/vaadin/tests/push/BasicPushWebsocketXhrTest.java index 6a7174bf99..430246d66a 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/BaseThemeTest.java +++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocketXhrTest.java @@ -13,11 +13,17 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.tests.components.uitest; +package com.vaadin.tests.push; -public class BaseThemeTest extends ThemeTest { +import java.util.List; + +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.WebsocketTest; + +public class BasicPushWebsocketXhrTest extends BasicPushTest { @Override - protected String getTheme() { - return "base"; + public List<DesiredCapabilities> getBrowsersToTest() { + return getBrowsersSupportingWebSocket(); } } diff --git a/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersTest.java b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersTest.java index 69e5de960a..95c03d9959 100644 --- a/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersTest.java +++ b/uitest/src/com/vaadin/tests/push/SendMultibyteCharactersTest.java @@ -36,7 +36,7 @@ public abstract class SendMultibyteCharactersTest extends MultiBrowserTest { findElement(By.tagName("body")).click(); - waitForDebugMessage("Variable burst to be sent to server:", 5); + waitForDebugMessage("RPC invocations to be sent to the server:", 5); waitForDebugMessage("Handling message from server", 10); } diff --git a/uitest/src/com/vaadin/tests/requesthandlers/CommunicationError.java b/uitest/src/com/vaadin/tests/requesthandlers/CommunicationError.java index 31ec7658ee..26f3dff1a2 100644 --- a/uitest/src/com/vaadin/tests/requesthandlers/CommunicationError.java +++ b/uitest/src/com/vaadin/tests/requesthandlers/CommunicationError.java @@ -15,6 +15,9 @@ */ package com.vaadin.tests.requesthandlers; +import java.io.IOException; +import java.io.PrintWriter; + import com.vaadin.launcher.ApplicationRunnerServlet; import com.vaadin.server.CustomizedSystemMessages; import com.vaadin.server.SystemMessages; @@ -69,7 +72,17 @@ public class CommunicationError extends UIProvider { @Override public void buttonClick(ClickEvent event) { - VaadinService.getCurrentResponse().setStatus(400); + try { + // An unparseable response will cause + // communication error + PrintWriter writer = VaadinService + .getCurrentResponse().getWriter(); + writer.write("for(;;)[{FOOBAR}]"); + writer.flush(); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } } }); addComponent(button); diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index d76cd616b1..a58575890e 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -37,6 +37,7 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicHttpEntityEnclosingRequest; import org.junit.Assert; import org.junit.Rule; +import org.junit.rules.TestName; import org.junit.runner.RunWith; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -98,6 +99,9 @@ import elemental.json.impl.JsonUtil; public abstract class AbstractTB3Test extends ParallelTest { @Rule + public TestName testName = new TestName(); + + @Rule public RetryOnFail retry = new RetryOnFail(); /** @@ -465,6 +469,15 @@ public abstract class AbstractTB3Test extends ParallelTest { waitUntil(ExpectedConditions.presenceOfElementLocated(by)); } + protected void waitForElementNotPresent(final By by) { + waitUntil(new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver input) { + return input.findElements(by).isEmpty(); + } + }); + } + protected void waitForElementVisible(final By by) { waitUntil(ExpectedConditions.visibilityOfElementLocated(by)); } diff --git a/uitest/src/com/vaadin/tests/tb3/CustomTestBenchCommandExecutor.java b/uitest/src/com/vaadin/tests/tb3/CustomTestBenchCommandExecutor.java index a70eeeeb49..00d7788f8b 100644 --- a/uitest/src/com/vaadin/tests/tb3/CustomTestBenchCommandExecutor.java +++ b/uitest/src/com/vaadin/tests/tb3/CustomTestBenchCommandExecutor.java @@ -118,7 +118,7 @@ public class CustomTestBenchCommandExecutor { * @return * @throws IOException */ - private BufferedImage cropToElement(WebElement element, + public static BufferedImage cropToElement(WebElement element, BufferedImage fullScreen, boolean isIE8) throws IOException { Point loc = element.getLocation(); Dimension size = element.getSize(); diff --git a/uitest/src/com/vaadin/tests/tb3/IncludeIfProperty.java b/uitest/src/com/vaadin/tests/tb3/IncludeIfProperty.java new file mode 100644 index 0000000000..789422c0c6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/IncludeIfProperty.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 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.tb3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation to control inclusion of a test into a test suite. + * <p> + * The test will be included in the suite only if the given System property + * {@code property} has the given {@code value}. + * <p> + * Used by {@link TB3TestLocator} + * + * @since + * @author Vaadin Ltd + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Inherited +public @interface IncludeIfProperty { + + String property(); + + String value(); + +} diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index c53209d1dc..23ead80fce 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -20,8 +20,6 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; -import org.junit.Rule; -import org.junit.rules.TestName; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.remote.DesiredCapabilities; @@ -46,9 +44,6 @@ import com.vaadin.testbench.parallel.BrowserUtil; */ public abstract class MultiBrowserTest extends PrivateTB3Configuration { - @Rule - public TestName testName = new TestName(); - protected List<DesiredCapabilities> getBrowsersSupportingWebSocket() { // No WebSocket support in IE8-9 and PhantomJS return getBrowserCapabilities(Browser.IE10, Browser.IE11, diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTest.java index 0964e6eb65..bab4c3e80a 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTest.java @@ -16,18 +16,38 @@ package com.vaadin.tests.tb3; import java.util.Arrays; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized.Parameters; import org.openqa.selenium.remote.DesiredCapabilities; +import com.vaadin.tests.integration.ParameterizedTB3Runner; + /** * Test which uses theme returned by {@link #getTheme()} for running the test */ +@RunWith(ParameterizedTB3Runner.class) public abstract class MultiBrowserThemeTest extends MultiBrowserTest { - protected abstract String getTheme(); + private String theme; + + public void setTheme(String theme) { + this.theme = theme; + } + + protected String getTheme() { + return theme; + } + + @Parameters + public static Collection<String> getThemes() { + return Arrays.asList(new String[] { "valo", "reindeer", "runo", + "chameleon", "base" }); + } @Override protected boolean requireWindowFocusForIE() { @@ -37,7 +57,7 @@ public abstract class MultiBrowserThemeTest extends MultiBrowserTest { @Override protected void openTestURL(Class<?> uiClass, String... parameters) { Set<String> params = new HashSet<String>(Arrays.asList(parameters)); - params.add("theme=" + getTheme()); + params.add("theme=" + theme); super.openTestURL(uiClass, params.toArray(new String[params.size()])); } diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTestWithProxy.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTestWithProxy.java new file mode 100644 index 0000000000..26ed8288d1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTestWithProxy.java @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2014 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.tb3; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized.Parameters; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.integration.ParameterizedTB3Runner; + +@RunWith(ParameterizedTB3Runner.class) +public abstract class MultiBrowserThemeTestWithProxy extends + MultiBrowserTestWithProxy { + + private String theme; + + public void setTheme(String theme) { + this.theme = theme; + } + + @Parameters + public static Collection<String> getThemes() { + return Arrays.asList(new String[] { "valo", "reindeer", "runo", + "chameleon", "base" }); + } + + @Override + protected boolean requireWindowFocusForIE() { + return true; + } + + @Override + protected void openTestURL(Class<?> uiClass, String... parameters) { + Set<String> params = new HashSet<String>(Arrays.asList(parameters)); + params.add("theme=" + theme); + super.openTestURL(uiClass, params.toArray(new String[params.size()])); + } + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + List<DesiredCapabilities> browsersToTest = getBrowsersExcludingPhantomJS(); + browsersToTest.add(PHANTOMJS2()); + return browsersToTest; + } +} diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java index 6b8fb1741b..1c24720075 100644 --- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java @@ -381,8 +381,7 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { * fails */ private String getScreenshotFailureName() { - return getScreenshotBaseName() + "_" - + getUniqueIdentifier(getDesiredCapabilities()) + return getScreenshotBaseName() + "_" + getUniqueIdentifier(null) + "-failure.png"; } @@ -418,52 +417,34 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { */ private String getScreenshotReferenceName(String identifier, Integer versionOverride) { - String uniqueBrowserIdentifier; - if (versionOverride == null) { - uniqueBrowserIdentifier = getUniqueIdentifier(getDesiredCapabilities()); - } else { - uniqueBrowserIdentifier = getUniqueIdentifier( - getDesiredCapabilities(), "" + versionOverride); - } - - // WindowMaximizeRestoreTest_Windows_InternetExplorer_8_window-1-moved-maximized-restored.png return getScreenshotReferenceDirectory() + File.separator - + getScreenshotBaseName() + "_" + uniqueBrowserIdentifier + "_" - + identifier + ".png"; + + getScreenshotBaseName() + "_" + + getUniqueIdentifier(versionOverride) + "_" + identifier + + ".png"; } - /** - * Returns a string which uniquely (enough) identifies this browser. Used - * mainly in screenshot names. - * - * @param capabilities - * @param versionOverride - * - * @return a unique string for each browser - */ - private String getUniqueIdentifier(DesiredCapabilities capabilities, - String versionOverride) { - return getUniqueIdentifier(BrowserUtil.getPlatform(capabilities), - BrowserUtil.getBrowserIdentifier(capabilities), versionOverride); - } + private String getUniqueIdentifier(Integer versionOverride) { + String testNameAndParameters = testName.getMethodName(); + // runTest-wildfly9-nginx[Windows_Firefox_24][/buffering/demo][valo] - /** - * Returns a string which uniquely (enough) identifies this browser. Used - * mainly in screenshot names. - * - * @param capabilities - * - * @return a unique string for each browser - */ - private String getUniqueIdentifier(DesiredCapabilities capabilities) { - return getUniqueIdentifier(BrowserUtil.getPlatform(capabilities), - BrowserUtil.getBrowserIdentifier(capabilities), - capabilities.getVersion()); - } + String parameters = testNameAndParameters.substring( + testNameAndParameters.indexOf("[") + 1, + testNameAndParameters.length() - 1); + // Windows_Firefox_24][/buffering/demo][valo + + parameters = parameters.replace("][", "_"); + // Windows_Firefox_24_/buffering/demo_valo - private String getUniqueIdentifier(String platform, String browser, - String version) { - return platform + "_" + browser + "_" + version; + parameters = parameters.replace("/", ""); + // Windows_Firefox_24_bufferingdemo_valo + + if (versionOverride != null) { + // Windows_Firefox_17_bufferingdemo_valo + parameters = parameters.replaceFirst("_" + + getDesiredCapabilities().getVersion(), "_" + + versionOverride); + } + return parameters; } /** diff --git a/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java index 885d3521b7..b06044446e 100644 --- a/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java +++ b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java @@ -24,7 +24,7 @@ import java.util.Set; import org.junit.runner.RunWith; import org.junit.runners.model.InitializationError; -import com.vaadin.tests.integration.AbstractServletIntegrationTest; +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; @@ -51,6 +51,7 @@ public class ServletIntegrationTests { notWebsocketCompatible.add("tomcat6"); notWebsocketCompatible.add("tomcat7apacheproxy"); notWebsocketCompatible.add("weblogic10"); + notWebsocketCompatible.add("wildfly9-nginx"); // Requires an update to 8.5.5 and a fix for // https://dev.vaadin.com/ticket/16354 @@ -65,7 +66,7 @@ public class ServletIntegrationTests { public static class ServletIntegrationTestSuite extends TB3TestSuite { public ServletIntegrationTestSuite(Class<?> klass) throws InitializationError, IOException { - super(klass, AbstractServletIntegrationTest.class, + super(klass, AbstractIntegrationTest.class, "com.vaadin.tests.integration", new String[] {}, new ServletTestLocator()); } diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java index acdef54492..4917e398cf 100644 --- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java +++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java @@ -22,7 +22,7 @@ import java.lang.reflect.Modifier; import org.apache.http.client.HttpClient; import org.junit.runners.Parameterized; import org.junit.runners.model.InitializationError; -import org.openqa.selenium.remote.HttpCommandExecutor; +import org.openqa.selenium.remote.internal.ApacheHttpClient; import org.openqa.selenium.remote.internal.HttpClientFactory; import com.vaadin.testbench.parallel.ParallelRunner; @@ -48,8 +48,8 @@ public class TB3Runner extends ParallelRunner { // reduce socket timeout to avoid tests hanging for three hours try { - Field field = HttpCommandExecutor.class - .getDeclaredField("httpClientFactory"); + Field field = ApacheHttpClient.Factory.class + .getDeclaredField("defaultClientFactory"); assert (Modifier.isStatic(field.getModifiers())); field.setAccessible(true); field.set(null, new HttpClientFactory() { diff --git a/uitest/src/com/vaadin/tests/tb3/TB3TestLocator.java b/uitest/src/com/vaadin/tests/tb3/TB3TestLocator.java index a0fbf51195..eb0861757e 100644 --- a/uitest/src/com/vaadin/tests/tb3/TB3TestLocator.java +++ b/uitest/src/com/vaadin/tests/tb3/TB3TestLocator.java @@ -213,6 +213,17 @@ public class TB3TestLocator { return false; } + IncludeIfProperty includeIfProperty = c + .getAnnotation(IncludeIfProperty.class); + if (includeIfProperty != null) { + String includeValue = includeIfProperty.value(); + String systemPropertyValue = System.getProperty(includeIfProperty + .property()); + if (!includeValue.equals(systemPropertyValue)) { + return false; + } + } + return true; } }
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java index 79da9f902d..211a908ccb 100644 --- a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java +++ b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java @@ -71,7 +71,7 @@ public class ThemeChangeOnTheFlyTest extends MultiBrowserTest { public void reindeerToNullToReindeer() throws IOException { openTestURL(); - changeThemeAndCompare("null"); + changeTheme("null"); changeThemeAndCompare("reindeer"); } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java b/uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java index 0da1c6c775..8237d75c6c 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/MockApplicationConnection.java @@ -15,17 +15,9 @@ */ package com.vaadin.tests.widgetset.client; -import java.util.Date; -import java.util.logging.Logger; - import com.vaadin.client.ApplicationConnection; -import com.vaadin.client.ValueMap; -import com.vaadin.shared.ApplicationConstants; import com.vaadin.tests.widgetset.server.csrf.ui.CsrfTokenDisabled; -import elemental.json.JsonObject; -import elemental.json.JsonValue; - /** * Mock ApplicationConnection for several issues where we need to hack it. * @@ -34,14 +26,24 @@ import elemental.json.JsonValue; */ public class MockApplicationConnection extends ApplicationConnection { - private static final Logger LOGGER = Logger - .getLogger(MockApplicationConnection.class.getName()); + public MockApplicationConnection() { + super(); + messageHandler = new MockServerMessageHandler(); + messageHandler.setConnection(this); + messageSender = new MockServerCommunicationHandler(); + messageSender.setConnection(this); + } - // The last token received from the server. - private String lastCsrfTokenReceiver; + @Override + public MockServerMessageHandler getMessageHandler() { + return (MockServerMessageHandler) super.getMessageHandler(); + } - // The last token sent to the server. - private String lastCsrfTokenSent; + @Override + public MockServerCommunicationHandler getMessageSender() { + return (MockServerCommunicationHandler) super + .getMessageSender(); + } /** * Provide the last token received from the server. <br/> @@ -50,7 +52,7 @@ public class MockApplicationConnection extends ApplicationConnection { * @see CsrfTokenDisabled */ public String getLastCsrfTokenReceiver() { - return lastCsrfTokenReceiver; + return getMessageHandler().lastCsrfTokenReceiver; } /** @@ -60,23 +62,7 @@ public class MockApplicationConnection extends ApplicationConnection { * @see CsrfTokenDisabled */ public String getLastCsrfTokenSent() { - return lastCsrfTokenSent; - } - - @Override - protected void handleUIDLMessage(Date start, String jsonText, ValueMap json) { - lastCsrfTokenReceiver = json - .getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID); - - super.handleUIDLMessage(start, jsonText, json); - } - - @Override - protected void doUidlRequest(String uri, JsonObject payload) { - JsonValue jsonValue = payload.get(ApplicationConstants.CSRF_TOKEN); - lastCsrfTokenSent = jsonValue != null ? jsonValue.toJson() : null; - - super.doUidlRequest(uri, payload); + return getMessageSender().lastCsrfTokenSent; } } diff --git a/uitest/src/com/vaadin/tests/components/uitest/RunoThemeTest.java b/uitest/src/com/vaadin/tests/widgetset/client/MockServerCommunicationHandler.java index 073ab27566..14b5671181 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/RunoThemeTest.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/MockServerCommunicationHandler.java @@ -13,21 +13,24 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.tests.components.uitest; +package com.vaadin.tests.widgetset.client; -import java.io.IOException; +import com.vaadin.client.communication.MessageSender; +import com.vaadin.shared.ApplicationConstants; -public class RunoThemeTest extends ThemeTest { - @Override - protected String getTheme() { - return "runo"; - } +import elemental.json.JsonObject; +import elemental.json.JsonValue; + +public class MockServerCommunicationHandler extends MessageSender { + + // The last token sent to the server. + String lastCsrfTokenSent; @Override - protected void testWindows() throws IOException { - super.testWindows(); + public void send(JsonObject payload) { + JsonValue jsonValue = payload.get(ApplicationConstants.CSRF_TOKEN); + lastCsrfTokenSent = jsonValue != null ? jsonValue.toJson() : null; - // runo theme only - testWindow(3, "subwindow-dialog"); + super.send(payload); } } diff --git a/uitest/src/com/vaadin/tests/components/uitest/ReindeerThemeTest.java b/uitest/src/com/vaadin/tests/widgetset/client/MockServerMessageHandler.java index cdeb4b0606..39b89b55ca 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/ReindeerThemeTest.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/MockServerMessageHandler.java @@ -13,22 +13,23 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.tests.components.uitest; +package com.vaadin.tests.widgetset.client; -import java.io.IOException; +import com.vaadin.client.ValueMap; +import com.vaadin.client.communication.MessageHandler; +import com.vaadin.shared.ApplicationConstants; -public class ReindeerThemeTest extends ThemeTest { - @Override - protected String getTheme() { - return "reindeer"; - } +public class MockServerMessageHandler extends MessageHandler { + + // The last token received from the server. + protected String lastCsrfTokenReceiver; @Override - protected void testWindows() throws IOException { - super.testWindows(); + public void handleJSON(ValueMap json) { + lastCsrfTokenReceiver = json + .getString(ApplicationConstants.UIDL_SECURITY_TOKEN_ID); - // reindeer theme only - testWindow(1, "subwindow-light"); - testWindow(2, "subwindow-black"); + super.handleJSON(json); } + } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java b/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java index 4dae8892e7..c9a5a93332 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/TestingPushConnection.java @@ -2,7 +2,6 @@ package com.vaadin.tests.widgetset.client; import com.google.gwt.user.client.Window; import com.vaadin.client.ApplicationConnection; -import com.vaadin.client.ApplicationConnection.CommunicationErrorHandler; import com.vaadin.client.communication.AtmospherePushConnection; import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; @@ -12,9 +11,8 @@ public class TestingPushConnection extends AtmospherePushConnection { @Override public void init(ApplicationConnection connection, - PushConfigurationState pushConfiguration, - CommunicationErrorHandler errorHandler) { - super.init(connection, pushConfiguration, errorHandler); + PushConfigurationState pushConfiguration) { + super.init(connection, pushConfiguration); transport = Window.Location.getParameter("transport"); } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java index cf24ed6921..39dca8d799 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/csrf/CsrfButtonConnector.java @@ -70,8 +70,8 @@ public class CsrfButtonConnector extends AbstractComponentConnector { } private String csrfTokenInfo() { - return getMockConnection().getCsrfToken() + ", " - + getMockConnection().getLastCsrfTokenReceiver() + ", " + return getMockConnection().getMessageHandler().getCsrfToken() + + ", " + getMockConnection().getLastCsrfTokenReceiver() + ", " + getMockConnection().getLastCsrfTokenSent(); } |