state = State.CONNECT_PENDING;
}
+ protected void onClientTimeout(AtmosphereResponse response) {
+ state = State.DISCONNECTED;
+ errorHandler
+ .onError(
+ "Client unexpectedly disconnected. Ensure client timeout is disabled.",
+ -1);
+ }
+
protected void onReconnect(JavaScriptObject request,
final AtmosphereResponse response) {
if (state == State.CONNECTED) {
fallbackTransport: 'streaming',
contentType: 'application/json; charset=UTF-8',
reconnectInterval: 5000,
+ timeout: -1,
maxReconnectOnClose: 10000000,
trackMessageLength: true,
enableProtocol: false,
config.onReconnect = $entry(function(request, response) {
self.@com.vaadin.client.communication.AtmospherePushConnection::onReconnect(*)(request, response);
});
+ config.onClientTimeout = $entry(function(request) {
+ self.@com.vaadin.client.communication.AtmospherePushConnection::onClientTimeout(*)(request);
+ });
return $wnd.jQueryVaadin.atmosphere.subscribe(config);
}-*/;
*/
package com.vaadin.tests.components.window;
-import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
}
@Test
- public void verifyNoTextSelectionOnMove() throws MalformedURLException {
+ public void verifyNoTextSelectionOnMove() throws Exception {
openTestURL();
public abstract class BasicPushTest extends MultiBrowserTest {
@Test
- public void testPush() {
+ public void testPush() throws InterruptedException {
openTestURL();
// Test client initiated push
--- /dev/null
+/*
+ * Copyright 2000-2013 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.push;
+
+public class IdlePushChannelStreamingTest extends IdlePushChannelTest {
+ @Override
+ protected Class<?> getUIClass() {
+ return BasicPushStreaming.class;
+ }
+}
--- /dev/null
+/*
+ * Copyright 2000-2013 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.push;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public abstract class IdlePushChannelTest extends MultiBrowserTest {
+
+ private static final int SEVEN_MINUTES_IN_MS = 7 * 60 * 1000;
+
+ @Test
+ public void longWaitBetweenActions() throws Exception {
+ openTestURL();
+ BasicPushTest.getIncrementButton(this).click();
+ Assert.assertEquals(1, BasicPushTest.getClientCounter(this));
+ sleep(SEVEN_MINUTES_IN_MS);
+ BasicPushTest.getIncrementButton(this).click();
+ Assert.assertEquals(2, BasicPushTest.getClientCounter(this));
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2013 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.push;
+
+import java.util.List;
+
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.WebsocketTest;
+
+public class IdlePushChannelWebsocketTest extends IdlePushChannelTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return BasicPushWebsocket.class;
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ return WebsocketTest.getWebsocketBrowsers();
+ }
+}
public class PushLargeDataStreamingTest extends MultiBrowserTest {
@Test
- public void testStreamingLargeData() {
+ public void testStreamingLargeData() throws InterruptedException {
openTestURL();
// Without this there is a large chance that we will wait for all pushes
}
- private void push() {
+ private void push() throws InterruptedException {
// Wait for startButton to be present
waitForElementToBePresent(vaadinLocatorById("startButton"));
public class PushLargeDataWebsocketTest extends WebsocketTest {
@Test
- public void testWebsocketLargeData() {
+ public void testWebsocketLargeData() throws Exception {
openTestURL();
// Without this timing will be completly off as pushing "start" can
}
- private void push() {
+ private void push() throws Exception {
// Wait for startButton to be present
waitForElementToBePresent(vaadinLocatorById("startButton"));
public class TogglePushTest extends MultiBrowserTest {
@Test
- public void togglePushInInit() {
+ public void togglePushInInit() throws Exception {
setPush(true);
String url = getTestUrl();
}
@Test
- public void togglePush() {
+ public void togglePush() throws InterruptedException {
setPush(true);
openTestURL();
getDelayedCounterUpdateButton().click();
*/
private static final int SCREENSHOT_WIDTH = 1500;
+ /**
+ * Timeout used by the TB grid
+ */
+ private static final int BROWSER_TIMEOUT_IN_MS = 30 * 1000;
+
private DesiredCapabilities desiredCapabilities;
private boolean debug = false;
}
/**
- * Helper method for sleeping X ms in a test. Catches and ignores
- * InterruptedExceptions
+ * Sleeps for the given number of ms but ensures that the browser connection
+ * does not time out.
*
* @param timeoutMillis
* Number of ms to wait
+ * @throws InterruptedException
*/
- protected void sleep(int timeoutMillis) {
- try {
- Thread.sleep(timeoutMillis);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
+ protected void sleep(int timeoutMillis) throws InterruptedException {
+ while (timeoutMillis > 0) {
+ int d = Math.min(BROWSER_TIMEOUT_IN_MS, timeoutMillis);
+ Thread.sleep(d);
+ timeoutMillis -= d;
+
+ // Do something to keep the connection alive
+ getDriver().getTitle();
}
}