2 * Copyright 2000-2018 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.tests.integration.push;
18 import static org.junit.Assert.assertEquals;
20 import java.util.ArrayList;
21 import java.util.List;
23 import org.junit.Assume;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.junit.runners.Parameterized;
28 import org.junit.runners.Parameterized.Parameter;
29 import org.junit.runners.Parameterized.Parameters;
30 import org.openqa.selenium.By;
31 import org.openqa.selenium.WebElement;
33 import com.vaadin.tests.integration.AbstractIntegrationTest;
35 @RunWith(Parameterized.class)
36 public class LongPollingProxyServerIT extends AbstractIntegrationTest {
38 @Parameters(name = "{0}")
39 public static List<String[]> getTestParameters() {
40 List<String[]> parameters = new ArrayList<>();
41 addTestParams(parameters, "Buffering+Timeout", "buffering-timeout");
42 addTestParams(parameters, "NonBuffering+Timeout",
43 "nonbuffering-timeout");
44 addTestParams(parameters, "Buffering", "buffering");
45 addTestParams(parameters, "NonBuffering", "nonbuffering");
49 private static void addTestParams(List<String[]> parameters,
62 public void setup() throws Exception {
64 "wildfly9-nginx".equals(System.getProperty("server-name")));
70 public void actionAfterFirstTimeout() throws Exception {
71 // The wildfly9-nginx server has a configured timeout of 10s for
74 assertEquals(0, getClientCounter());
75 getIncrementButton().click();
76 assertEquals(1, getClientCounter());
80 public void basicPush() {
81 assertEquals(0, getServerCounter());
82 getServerCounterStartButton().click();
83 waitUntil(e -> getServerCounter() > 1, 10);
87 protected String getContextPath() {
88 // Prefix with the context path with the parameter
89 return "/" + path + super.getContextPath();
93 protected String getTestPath() {
97 private int getClientCounter() {
98 WebElement clientCounterElem = findElement(
99 By.id(BasicPush.CLIENT_COUNTER_ID));
100 return Integer.parseInt(clientCounterElem.getText());
103 private int getServerCounter() {
104 WebElement serverCounterElem = findElement(
105 By.id(BasicPush.SERVER_COUNTER_ID));
106 return Integer.parseInt(serverCounterElem.getText());
109 private WebElement getServerCounterStartButton() {
110 return findElement(By.id(BasicPush.START_TIMER_ID));
113 private WebElement getIncrementButton() {
114 return findElement(By.id(BasicPush.INCREMENT_BUTTON_ID));