--- /dev/null
+package com.vaadin.tests.application;
+
+import java.util.Properties;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.MarginInfo;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+
+public class DeploymentConfiguration extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Properties params = getSession().getConfiguration().getInitParameters();
+ getLayout().setMargin(new MarginInfo(true, false, false, false));
+
+ for (Object key : params.keySet()) {
+ addComponent(new Label(key + ": "
+ + params.getProperty((String) key)));
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Init parameters:";
+ }
+}
+/*
+ * 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.util.Properties;
+import static org.junit.Assert.assertTrue;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
-public class DeploymentConfigurationTest extends UI {
+import org.junit.Test;
- @Override
- protected void init(VaadinRequest request) {
- VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
- setContent(layout);
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
- Properties params = getSession().getConfiguration().getInitParameters();
+public class DeploymentConfigurationTest extends MultiBrowserTest {
- for (Object key : params.keySet()) {
- layout.addComponent(new Label(key + ": "
- + params.getProperty((String) key)));
+ @Test
+ public void testParameters() {
+ openTestURL();
+ List<String> texts = new ArrayList<String>(Arrays.asList(
+ "Init parameters:", "legacyPropertyToString: false",
+ "closeIdleSessions: true", "productionMode: false",
+ "testParam: 42", "heartbeatInterval: 301",
+ "resourceCacheTime: 3601"));
+
+ for (LabelElement label : $(LabelElement.class).all()) {
+ assertTrue(label.getText() + " not found",
+ texts.contains(label.getText()));
+ texts.remove(label.getText());
}
+ assertTrue(texts.isEmpty());
}
+
}
}
private List<String> getSessionMessages(boolean storeIfNeeded) {
+ @SuppressWarnings("unchecked")
List<String> messages = (List<String>) getSession().getAttribute(
PERSISTENT_MESSAGES_ATTRIBUTE);
if (messages == null) {
--- /dev/null
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.List;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DetachOldUIOnReloadTest extends MultiBrowserTest {
+
+ private static final String RELOAD = "Reload page";
+ private static final String READ_LOG = "Read log messages from session";
+
+ @Test
+ public void testDetachesUIOnReload() throws InterruptedException {
+ openTestURL();
+ List<LabelElement> labels = $(LabelElement.class).all();
+ assertEquals("initial label incorrect", "This is UI 0",
+ lastLabelText(labels));
+
+ assertFalse("reloading button not found", $(ButtonElement.class)
+ .caption(RELOAD).all().isEmpty());
+
+ openTestURL();
+ click(READ_LOG);
+
+ checkLabels("first", 1);
+
+ click(RELOAD);
+ click(READ_LOG);
+
+ checkLabels("second", 2);
+
+ openTestURL();
+ click(READ_LOG);
+
+ checkLabels("third", 3);
+
+ // restarting reverts to 0
+ openTestURL("restartApplication");
+
+ checkLabels("final", 0);
+ }
+
+ private void checkLabels(String descriptor, int index) {
+ List<LabelElement> labels = $(LabelElement.class).all();
+ assertEquals(
+ String.format("label incorrect after %s reload", descriptor),
+ String.format("This is UI %s", index), lastLabelText(labels));
+ if (!"final".equals(descriptor)) {
+ assertEquals(String.format("log message incorrect after %s reload",
+ descriptor), String.format("%s. UI %s has been detached",
+ index, index - 1), labels.get(0).getText());
+ }
+ }
+
+ private String lastLabelText(List<LabelElement> labels) {
+ return labels.get(labels.size() - 1).getText();
+ }
+
+ private void click(String caption) {
+ $(ButtonElement.class).caption(caption).first().click();
+ }
+
+}
--- /dev/null
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.PasswordFieldElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class ErrorInUnloadEventTest extends MultiBrowserTest {
+
+ @Test
+ public void testError() {
+ openTestURL();
+ TextFieldElement user = $(TextFieldElement.class).id("user");
+ user.focus();
+ user.sendKeys("a");
+ PasswordFieldElement pass = $(PasswordFieldElement.class).id("pwd");
+ pass.focus();
+ pass.sendKeys("d");
+ ButtonElement button = $(ButtonElement.class).id("loginButton");
+ button.click();
+
+ assertEquals("label is incorrect, error while loading page",
+ "...Title...", $(LabelElement.class).first().getText());
+
+ openTestURL();
+ // no errors and page fully reloaded
+ assertTrue($(LabelElement.class).all().isEmpty());
+ }
+
+}
--- /dev/null
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import com.vaadin.tests.tb3.newelements.FixedNotificationElement;
+
+public class VaadinSessionAttributeTest extends MultiBrowserTest {
+
+ @Test
+ public void testSessionAttribute() {
+ openTestURL();
+ $(ButtonElement.class).first().click();
+ assertEquals("notification does not contain suitable text", "42 & 84",
+ $(FixedNotificationElement.class).first().getCaption());
+ }
+
+}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://localhost:8070/" />
-<title>DeploymentConfigurationTest</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">DeploymentConfigurationTest</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.DeploymentConfigurationTest?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>exact:closeIdleSessions: true</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>exact:productionMode: false</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>exact:testParam: 42</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>exact:heartbeatInterval: 301</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>exact:resourceCacheTime: 3601</td>
- <td></td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.DetachOldUIOnReload?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>This is UI 0</td>
-</tr>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.DetachOldUIOnReload</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td>
- <td>1. UI 0 has been detached</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>This is UI 1</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td>
- <td>2. UI 1 has been detached</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>This is UI 2</td>
-</tr>
-<tr>
- <td>open</td>
- <td>/</td>
- <td></td>
-</tr>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.DetachOldUIOnReload</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td>
- <td>3. UI 2 has been detached</td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
- <td>This is UI 3</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://arturwin.office.itmill.com:8888/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.ErrorInUnloadEvent?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Suser</td>
- <td>66,14</td>
-</tr>
-<tr>
- <td>enterCharacter</td>
- <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Suser</td>
- <td>a</td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwd</td>
- <td>73,16</td>
-</tr>
-<tr>
- <td>enterCharacter</td>
- <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwd</td>
- <td>d</td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwd</td>
- <td>enter</td>
-</tr>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.ErrorInUnloadEvent</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
- <td>...Title...</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.VaadinSessionAttribute?restartApplication&attachMainFirst</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestsapplicationVaadinSessionAttribute::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>//body/div[2]//h1</td>
- <td>42 & 84</td>
-</tr>
-</tbody></table>
-</body>
-</html>