summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java4
-rw-r--r--server/src/com/vaadin/server/VaadinService.java15
-rw-r--r--server/tests/src/com/vaadin/server/VaadinServiceTest.java45
-rw-r--r--uitest/src/com/vaadin/tests/application/CriticalNotifications.java28
4 files changed, 51 insertions, 41 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 64511059d9..90fc9b2668 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -63,6 +63,7 @@ import com.google.gwt.user.client.Window.ClosingHandler;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConfiguration.ErrorMessage;
+import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadListener;
import com.vaadin.client.communication.HasJavaScriptConnectorHelper;
@@ -1768,7 +1769,8 @@ public class ApplicationConnection implements HasHandlers {
if (meta.containsKey("appError")) {
ValueMap error = meta.getValueMap("appError");
- showError(null, error.getString("caption"),
+ showError(error.getString("details"),
+ error.getString("caption"),
error.getString("message"),
error.getString("url"));
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 74f0051e30..bff71fedee 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -1574,8 +1574,8 @@ public abstract class VaadinService implements Serializable {
JsonObject appError = Json.createObject();
putValueOrJsonNull(appError, "caption", caption);
putValueOrJsonNull(appError, "url", url);
- putValueOrJsonNull(appError, "message",
- createCriticalNotificationMessage(message, details));
+ putValueOrJsonNull(appError, "message", message);
+ putValueOrJsonNull(appError, "details", details);
JsonObject meta = Json.createObject();
meta.put("appError", appError);
@@ -1595,17 +1595,6 @@ public abstract class VaadinService implements Serializable {
return "for(;;);[" + returnString + "]";
}
- private static String createCriticalNotificationMessage(String message,
- String details) {
- if (message == null) {
- return details;
- } else if (details != null) {
- return message + "<br/><br/>" + details;
- }
-
- return message;
- }
-
private static void putValueOrJsonNull(JsonObject json, String key,
String value) {
if (value == null) {
diff --git a/server/tests/src/com/vaadin/server/VaadinServiceTest.java b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
index 4b655e7855..bd3da6277a 100644
--- a/server/tests/src/com/vaadin/server/VaadinServiceTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
@@ -42,9 +42,10 @@ public class VaadinServiceTest {
}
}
- private String createCriticalNotification(String caption, String message, String details, String url) {
- return VaadinService
- .createCriticalNotificationJSON(caption, message, details, url);
+ private String createCriticalNotification(String caption, String message,
+ String details, String url) {
+ return VaadinService.createCriticalNotificationJSON(caption, message,
+ details, url);
}
@Test
@@ -77,64 +78,64 @@ public class VaadinServiceTest {
@Test
public void captionIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("foobar", "message", "details", "url");
+ String notification = createCriticalNotification("foobar", "message",
+ "details", "url");
assertThat(notification, containsString("\"caption\":\"foobar\""));
}
@Test
public void nullCaptionIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification(null, "message", "details", "url");
+ String notification = createCriticalNotification(null, "message",
+ "details", "url");
assertThat(notification, containsString("\"caption\":null"));
}
@Test
public void messageWithDetailsIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", "foo", "bar", "url");
+ String notification = createCriticalNotification("caption", "foo",
+ "bar", "url");
- assertThat(notification, containsString("\"message\":\"foo<br/><br/>bar\""));
+ assertThat(notification, containsString("\"details\":\"bar\""));
}
@Test
- public void nullMessageIsReplacedByDetailsInACriticalNotification() {
- String notification =
- createCriticalNotification("caption", null, "foobar", "url");
+ public void nullMessageSentAsNullInACriticalNotification() {
+ String notification = createCriticalNotification("caption", null,
+ "foobar", "url");
- assertThat(notification, containsString("\"message\":\"foobar\""));
+ assertThat(notification, containsString("\"message\":null"));
}
@Test
public void nullMessageIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", null, null, "url");
+ String notification = createCriticalNotification("caption", null, null,
+ "url");
assertThat(notification, containsString("\"message\":null"));
}
@Test
public void messageSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", "foobar", null, "url");
+ String notification = createCriticalNotification("caption", "foobar",
+ null, "url");
assertThat(notification, containsString("\"message\":\"foobar\""));
}
@Test
public void urlIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", "message", "details", "foobar");
+ String notification = createCriticalNotification("caption", "message",
+ "details", "foobar");
assertThat(notification, containsString("\"url\":\"foobar\""));
}
@Test
public void nullUrlIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", "message", "details", null);
+ String notification = createCriticalNotification("caption", "message",
+ "details", null);
assertThat(notification, containsString("\"url\":null"));
}
diff --git a/uitest/src/com/vaadin/tests/application/CriticalNotifications.java b/uitest/src/com/vaadin/tests/application/CriticalNotifications.java
index bde3fbaf6f..14b4cb62e9 100644
--- a/uitest/src/com/vaadin/tests/application/CriticalNotifications.java
+++ b/uitest/src/com/vaadin/tests/application/CriticalNotifications.java
@@ -26,16 +26,21 @@ 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.CheckBox;
public class CriticalNotifications extends AbstractTestUI {
private SystemMessages systemMessages;
+ private CheckBox includeDetails;
@Override
protected void setup(VaadinRequest request) {
systemMessages = VaadinService.getCurrent().getSystemMessages(
getLocale(), request);
+ includeDetails = new CheckBox("Include details");
+ addComponent(includeDetails);
+
Button sessionExpired = new Button("Session expired");
addComponent(sessionExpired);
sessionExpired.addClickListener(new ClickListener() {
@@ -43,7 +48,8 @@ public class CriticalNotifications extends AbstractTestUI {
public void buttonClick(ClickEvent event) {
showCriticalNotification(
systemMessages.getSessionExpiredCaption(),
- systemMessages.getSessionExpiredMessage(), null,
+ systemMessages.getSessionExpiredMessage(),
+ getDetailsMessage(),
systemMessages.getSessionExpiredURL());
}
@@ -56,7 +62,8 @@ public class CriticalNotifications extends AbstractTestUI {
public void buttonClick(ClickEvent event) {
showCriticalNotification(
systemMessages.getAuthenticationErrorCaption(),
- systemMessages.getAuthenticationErrorMessage(), null,
+ systemMessages.getAuthenticationErrorMessage(),
+ getDetailsMessage(),
systemMessages.getAuthenticationErrorURL());
}
@@ -69,7 +76,8 @@ public class CriticalNotifications extends AbstractTestUI {
public void buttonClick(ClickEvent event) {
showCriticalNotification(
systemMessages.getCommunicationErrorCaption(),
- systemMessages.getCommunicationErrorMessage(), null,
+ systemMessages.getCommunicationErrorMessage(),
+ getDetailsMessage(),
systemMessages.getCommunicationErrorURL());
}
@@ -82,7 +90,8 @@ public class CriticalNotifications extends AbstractTestUI {
public void buttonClick(ClickEvent event) {
showCriticalNotification(
systemMessages.getInternalErrorCaption(),
- systemMessages.getInternalErrorMessage(), null,
+ systemMessages.getInternalErrorMessage(),
+ getDetailsMessage(),
systemMessages.getInternalErrorURL());
}
@@ -95,7 +104,8 @@ public class CriticalNotifications extends AbstractTestUI {
public void buttonClick(ClickEvent event) {
showCriticalNotification(
systemMessages.getCookiesDisabledCaption(),
- systemMessages.getCookiesDisabledMessage(), null,
+ systemMessages.getCookiesDisabledMessage(),
+ getDetailsMessage(),
systemMessages.getCookiesDisabledURL());
}
@@ -112,6 +122,14 @@ public class CriticalNotifications extends AbstractTestUI {
});
}
+ protected String getDetailsMessage() {
+ if (includeDetails.getValue()) {
+ return "Some details for the error";
+ } else {
+ return null;
+ }
+ }
+
protected void showCriticalNotification(String caption, String message,
String details, String url) {
VaadinService service = VaadinService.getCurrent();