summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-02-20 15:28:28 +0200
committerVaadin Code Review <review@vaadin.com>2015-02-24 07:43:59 +0000
commit8199bff426d397a9254cebd9e2f3de6744e87e84 (patch)
tree255d73aeed6b1e892a2a90b8dac3fe0b0d43bc1f
parent06a7d69c88157e41a8420f4c77efb91a7e1ad997 (diff)
downloadvaadin-framework-8199bff426d397a9254cebd9e2f3de6744e87e84.tar.gz
vaadin-framework-8199bff426d397a9254cebd9e2f3de6744e87e84.zip
Migrate TB2 tests from package applicationservlet to TB4
MultipleServeletConfigurationTest SystemMessagesTest Change-Id: I85f0bc2daed4d9ef2a4a341f4614c8a501256565
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/MultipleServletConfigurationTest.java29
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java24
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/SystemMessages.java81
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java103
-rw-r--r--uitest/tb2/com/vaadin/tests/applicationservlet/MultipleServletConfiguration.html47
-rw-r--r--uitest/tb2/com/vaadin/tests/applicationservlet/SystemMessagesTest.html52
6 files changed, 145 insertions, 191 deletions
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/MultipleServletConfigurationTest.java b/uitest/src/com/vaadin/tests/applicationservlet/MultipleServletConfigurationTest.java
new file mode 100644
index 0000000000..39e8d04ffc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/applicationservlet/MultipleServletConfigurationTest.java
@@ -0,0 +1,29 @@
+package com.vaadin.tests.applicationservlet;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class MultipleServletConfigurationTest extends MultiBrowserTest {
+
+ @Override
+ protected void closeApplication() {
+ }
+
+ @Test
+ public void testMultipleServletConfiguration() throws Exception {
+ getDriver().get(getBaseURL() + "/embed1");
+ assertLabelText("A generic test for Buttons in different configurations");
+ getDriver().get(getBaseURL() + "/embed2");
+ assertLabelText("Margins inside labels should not be allowed to collapse out of the label as it causes problems with layotus measuring the label.");
+ getDriver().get(getBaseURL() + "/embed1");
+ assertLabelText("A generic test for Buttons in different configurations");
+ }
+
+ private void assertLabelText(String expected) {
+ Assert.assertEquals("Unexpected label text,", expected,
+ $(LabelElement.class).first().getText());
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java
index 8020870bdc..3faf5bde72 100644
--- a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java
+++ b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java
@@ -15,34 +15,34 @@
*/
package com.vaadin.tests.applicationservlet;
-import java.util.List;
-
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.remote.DesiredCapabilities;
-import com.vaadin.testbench.parallel.Browser;
-import com.vaadin.tests.tb3.MultiBrowserTest;
+import com.vaadin.tests.tb3.SingleBrowserTest;
-public class NoApplicationClassTest extends MultiBrowserTest {
+public class NoApplicationClassTest extends SingleBrowserTest {
@Test
public void testInvalidApplicationClass() {
openTestURL();
String exceptionMessage = getDriver().findElement(By.xpath("//pre[2]"))
.getText();
- Assert.assertTrue(exceptionMessage
- .contains("ServletException: java.lang.ClassNotFoundException: ClassThatIsNotPresent"));
+ String expected = "ServletException: java.lang.ClassNotFoundException: ClassThatIsNotPresent";
+ Assert.assertTrue(
+ String.format(
+ "Unexpected error message.\n expected to contain: '%s'\n was: %s",
+ expected, exceptionMessage), exceptionMessage
+ .contains(expected));
}
@Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- return getBrowserCapabilities(Browser.CHROME);
+ protected String getDeploymentPath() {
+ return "/run/ClassThatIsNotPresent";
}
@Override
- protected String getDeploymentPath() {
- return "/run/ClassThatIsNotPresent";
+ protected void openTestURL(String... parameters) {
+ driver.get(getTestUrl());
}
}
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/SystemMessages.java b/uitest/src/com/vaadin/tests/applicationservlet/SystemMessages.java
new file mode 100644
index 0000000000..00547aa2d2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/applicationservlet/SystemMessages.java
@@ -0,0 +1,81 @@
+package com.vaadin.tests.applicationservlet;
+
+import java.util.Locale;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.launcher.ApplicationRunnerServlet;
+import com.vaadin.server.CustomizedSystemMessages;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinService;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.NativeSelect;
+
+public class SystemMessages extends AbstractTestUI {
+
+ public class MyButton extends Button {
+ private boolean fail = false;
+
+ @Override
+ public void beforeClientResponse(boolean initial) {
+ // Set the error message to contain the current locale.
+ VaadinService.getCurrentRequest().setAttribute(
+ ApplicationRunnerServlet.CUSTOM_SYSTEM_MESSAGES_PROPERTY,
+ new CustomizedSystemMessages() {
+ @Override
+ public String getInternalErrorMessage() {
+ return "MessagesInfo locale: " + getLocale();
+ }
+ });
+ super.beforeClientResponse(initial);
+ if (fail) {
+ throw new RuntimeException("Failed on purpose");
+ }
+ }
+ }
+
+ @Override
+ protected void setup(final VaadinRequest request) {
+ final NativeSelect localeSelect = new NativeSelect("UI locale");
+ localeSelect.setImmediate(true);
+ localeSelect.addItem(new Locale("en", "US"));
+ localeSelect.addItem(new Locale("fi", "FI"));
+ localeSelect.addItem(Locale.GERMANY);
+ localeSelect.addValueChangeListener(new ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Locale locale = (Locale) localeSelect.getValue();
+ setLocale(locale);
+ }
+ });
+ localeSelect.setValue(new Locale("fi", "FI"));
+ addComponent(localeSelect);
+ final MyButton failButton = new MyButton();
+ failButton.setCaption("Generate server side error");
+ failButton.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ failButton.fail = true;
+ failButton.markAsDirty();
+ }
+ });
+ addComponent(failButton);
+
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "SystemMessagesProvider.getSystemMessages should get an event object";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10226;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java b/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java
index 047e465722..bbbb49b39c 100644
--- a/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java
+++ b/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java
@@ -1,91 +1,34 @@
package com.vaadin.tests.applicationservlet;
-import java.util.Locale;
+import org.junit.Assert;
+import org.junit.Test;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-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;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.NativeSelect;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.NativeSelectElement;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
-public class SystemMessagesTest extends AbstractTestUI {
-
- public class MyButton extends Button {
- private boolean fail = false;
-
- @Override
- public void beforeClientResponse(boolean initial) {
- super.beforeClientResponse(initial);
- if (fail) {
- throw new RuntimeException("Failed on purpose");
- }
- }
-
- }
-
- @Override
- protected void setup(VaadinRequest request) {
- final NativeSelect localeSelect = new NativeSelect("UI locale");
- localeSelect.setImmediate(true);
- localeSelect.addItem(new Locale("en", "US"));
- localeSelect.addItem(new Locale("fi", "FI"));
- localeSelect.addItem(Locale.GERMANY);
- localeSelect.addValueChangeListener(new ValueChangeListener() {
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- setLocale((Locale) localeSelect.getValue());
- getSession().getService().setSystemMessagesProvider(
- new SystemMessagesProvider() {
-
- @Override
- public SystemMessages getSystemMessages(
- SystemMessagesInfo systemMessagesInfo) {
- CustomizedSystemMessages csm = new CustomizedSystemMessages();
- // csm.setInternalErrorCaption("Request query string: "
- // + ((VaadinServletRequest) systemMessagesInfo
- // .getRequest()).getQueryString());
- csm.setInternalErrorMessage("MessagesInfo locale: "
- + systemMessagesInfo.getLocale());
- return csm;
-
- }
- });
- }
- });
- localeSelect.setValue(new Locale("fi", "FI"));
- addComponent(localeSelect);
- final MyButton failButton = new MyButton();
- failButton.setCaption("Generate server side error");
- failButton.addClickListener(new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- failButton.fail = true;
- failButton.markAsDirty();
- }
- });
- addComponent(failButton);
+public class SystemMessagesTest extends MultiBrowserTest {
+ @Test
+ public void testFinnishLocaleInSystemErrorMessage() throws Exception {
+ openTestURL();
+ verifyError("fi_FI");
}
- @Override
- protected String getTestDescription() {
- // TODO Auto-generated method stub
- return null;
+ @Test
+ public void testGermanLocaleInSystemErrorMessage() throws Exception {
+ openTestURL();
+ $(NativeSelectElement.class).first().selectByText("de_DE");
+ verifyError("de_DE");
}
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
+ private void verifyError(String locale) {
+ $(ButtonElement.class).first().click();
+ NotificationElement notification = $(NotificationElement.class).first();
+ Assert.assertEquals("Incorrect notification caption,",
+ notification.getCaption(), "Internal error");
+ Assert.assertEquals("Incorrect notification description,",
+ notification.getDescription(), "MessagesInfo locale: " + locale);
}
-
}
diff --git a/uitest/tb2/com/vaadin/tests/applicationservlet/MultipleServletConfiguration.html b/uitest/tb2/com/vaadin/tests/applicationservlet/MultipleServletConfiguration.html
deleted file mode 100644
index 3b4452cc8d..0000000000
--- a/uitest/tb2/com/vaadin/tests/applicationservlet/MultipleServletConfiguration.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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>/embed1</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=embed1::/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]</td>
- <td>A generic test for Buttons in different configurations</td>
-</tr>
-<tr>
- <td>open</td>
- <td>/embed2</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=embed2::/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]</td>
- <td>Margins inside labels should not be allowed to collapse out of the label as it causes problems with layotus measuring the label.</td>
-</tr>
-<tr>
- <td>open</td>
- <td>/embed1</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=embed1::/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]</td>
- <td>A generic test for Buttons in different configurations</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/tb2/com/vaadin/tests/applicationservlet/SystemMessagesTest.html b/uitest/tb2/com/vaadin/tests/applicationservlet/SystemMessagesTest.html
deleted file mode 100644
index a764255b5b..0000000000
--- a/uitest/tb2/com/vaadin/tests/applicationservlet/SystemMessagesTest.html
+++ /dev/null
@@ -1,52 +0,0 @@
-<?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: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.applicationservlet.SystemMessagesTest?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestsapplicationservletSystemMessagesTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationservletSystemMessagesTest::Root/VNotification[0]/domChild[0]</td>
- <td>Internal error*MessagesInfo locale: fi_FI</td>
-</tr>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.applicationservlet.SystemMessagesTest?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>select</td>
- <td>vaadin=runcomvaadintestsapplicationservletSystemMessagesTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VNativeSelect[0]/domChild[0]</td>
- <td>label=de_DE</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestsapplicationservletSystemMessagesTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationservletSystemMessagesTest::Root/VNotification[0]/domChild[0]</td>
- <td>Internal error*MessagesInfo locale: de_DE</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>