diff options
author | Artur Signell <artur@vaadin.com> | 2015-09-01 14:19:50 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-09-03 11:43:27 +0300 |
commit | 379c6679879cf69ef4253da97f7d557bc33673e4 (patch) | |
tree | b773fc2cdce5d2b0f90f3b1ac4922505c063f676 /uitest/src/com/vaadin | |
parent | 29175d10b275a6e87dbbec8fe703a640f5f6a37f (diff) | |
download | vaadin-framework-379c6679879cf69ef4253da97f7d557bc33673e4.tar.gz vaadin-framework-379c6679879cf69ef4253da97f7d557bc33673e4.zip |
Nginx + Wildfly 9 test for various proxy configurations (#11733)
* /nonbuffering a proxy without any buffering
* /buffering tests a buffering proxy
* /nonbuffering-timeout tests a proxy without any buffering but with a 10s timeout set
* /buffering-timeout tests a buffering proxy with a 10s timeout set
Change-Id: I5d99cc29364e3ed888371fa18ee404f912d73223
Diffstat (limited to 'uitest/src/com/vaadin')
6 files changed, 195 insertions, 10 deletions
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..58c4198ec0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/LongPollingProxyServerTest.java @@ -0,0 +1,109 @@ +/* + * 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 void actionAfterFirstTimeout(String bufferingOrNot) + throws Exception { + String url = getBaseURL() + "/" + bufferingOrNot + "/demo" + + getDeploymentPath(); + getDriver().get(url); + Thread.sleep(15000); // Server Timeout is 10s + 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 = getBaseURL() + "/" + bufferingOrNot + "/demo" + + getDeploymentPath(); + 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) > 0; + } + }); + 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/push/BasicPushTest.java b/uitest/src/com/vaadin/tests/push/BasicPushTest.java index 5bac54f0f7..0e86902b50 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)); } private void waitUntilClientCounterChanges(final int expectedValue) { 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..cb04b4f2e8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/IncludeIfProperty.java @@ -0,0 +1,33 @@ +/* + * 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; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Inherited +public @interface IncludeIfProperty { + + String property(); + + String value(); + +} 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/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 |