summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java')
-rw-r--r--uitest/src/com/vaadin/tests/applicationservlet/SystemMessagesTest.java103
1 files changed, 23 insertions, 80 deletions
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);
}
-
}