summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2013-11-26 14:49:12 +0200
committerVaadin Code Review <review@vaadin.com>2013-12-03 13:35:56 +0000
commit26b5b672df0aa3bdefdced81ed4619c11f3e945a (patch)
tree2a82389c617d0ba8715a695f3aa95b143c73cb5d /uitest/src/com
parent25fc48c52067237faa208cea849a775a7aa1668c (diff)
downloadvaadin-framework-26b5b672df0aa3bdefdced81ed4619c11f3e945a.tar.gz
vaadin-framework-26b5b672df0aa3bdefdced81ed4619c11f3e945a.zip
Timeout redirect timer is reset on server activity (#12446)
Change-Id: Iec2e3de627bc1cf5c7d39bf98715b1bf343e7519
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java74
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java85
2 files changed, 159 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java
new file mode 100644
index 0000000000..2c649c9ca8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java
@@ -0,0 +1,74 @@
+/*
+ * 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.components.ui;
+
+import com.vaadin.server.CustomizedSystemMessages;
+import com.vaadin.server.SystemMessages;
+import com.vaadin.server.SystemMessagesInfo;
+import com.vaadin.server.SystemMessagesProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class TimeoutRedirectResetsOnActivity extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ setupTimout(request);
+
+ addComponent(new Button("clicky", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ // NOOP
+ }
+ }));
+ }
+
+ private void setupTimout(VaadinRequest request) {
+ request.getService().setSystemMessagesProvider(
+ new SystemMessagesProvider() {
+ @Override
+ public SystemMessages getSystemMessages(
+ SystemMessagesInfo systemMessagesInfo) {
+ CustomizedSystemMessages msgs = new CustomizedSystemMessages();
+ msgs.setSessionExpiredMessage(null);
+ msgs.setSessionExpiredCaption(null);
+ msgs.setSessionExpiredNotificationEnabled(true);
+ msgs.setSessionExpiredURL("http://example.com/");
+ return msgs;
+ }
+ });
+ /*
+ * NOTE: in practice, this means a timeout after 25 seconds, because of
+ * implementation details in
+ * com.vaadin.server.communication.MetadataWriter
+ */
+ getSession().getSession().setMaxInactiveInterval(10);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "The timeout redirect timer should reset if there's activity between the client and server.";
+ }
+
+ @Override
+ @SuppressWarnings("boxing")
+ protected Integer getTicketNumber() {
+ return 12446;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java
new file mode 100644
index 0000000000..272bacb8d5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.components.ui;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TimeoutRedirectResetsOnActivityTest extends MultiBrowserTest {
+ @Test
+ public void verifyRedirectWorks() throws Exception {
+ setDebug(true);
+ openTestURL();
+
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() - startTime < 30000) {
+ clickTheButton();
+ Thread.sleep(1000);
+ }
+
+ assertTrue("button disappeared before timeout", buttonIsStillThere());
+
+ Thread.sleep(30000);
+ assertTrue("no redirection occurred within 30 seconds",
+ !buttonIsStillThere());
+ }
+
+ private boolean buttonIsStillThere() {
+ try {
+ return getButton() != null;
+ } catch (NoSuchElementException e) {
+ return false;
+ }
+ }
+
+ private void clickTheButton() {
+ getButton().click();
+ }
+
+ private WebElement getButton() {
+ /*
+ * For some reason, the vaadinElement() method doesn't work when tests
+ * are run outside of "/run/" and "/run-push/" contexts. The given error
+ * message says that the generated Vaadin path doesn't match any
+ * elements, but when that selector is put into the recorder, the
+ * recorder finds it.
+ *
+ * XPath works fine.
+ */
+ /*-
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]");
+ */
+ return getDriver().findElement(
+ By.xpath("//div[contains(@class,'v-button')]"));
+ }
+
+ @Override
+ protected String getDeploymentPath() {
+ /*
+ * AbstractTB3Test assumes only /run/ and /run-push/ contexts, so this
+ * method needs some overriding.
+ */
+ return "/12446/"
+ + TimeoutRedirectResetsOnActivity.class.getCanonicalName()
+ + "?restartApplication&debug";
+ }
+}