diff --git a/org.springframework.context/src/main/java/org/springframework/ui/alert/Alerts.java b/org.springframework.context/src/main/java/org/springframework/ui/alert/Alerts.java index 22aa1eee0de..931d1febf0b 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/alert/Alerts.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/alert/Alerts.java @@ -19,7 +19,7 @@ package org.springframework.ui.alert; * A static factory for conveniently constructing Alerts. * Usage example: *
- *    static import org.springframework.ui.alert.Alerts;
+ *    import static org.springframework.ui.alert.Alerts;
  *    
  *    public void example() {
  *        info("An info alert");
@@ -40,7 +40,7 @@ public final class Alerts {
 	 * @see Severity#INFO
 	 */
 	public static Alert info(String message) {
-		return new GenericAlert(Severity.INFO, null, message);
+		return new GenericAlert(Severity.INFO, message);
 	}
 
 	/**
@@ -50,7 +50,7 @@ public final class Alerts {
 	 * @see Severity#WARNING
 	 */
 	public static Alert warning(String message) {
-		return new GenericAlert(Severity.WARNING, null, message);
+		return new GenericAlert(Severity.WARNING, message);
 	}
 
 	/**
@@ -60,7 +60,7 @@ public final class Alerts {
 	 * @see Severity#ERROR
 	 */
 	public static Alert error(String message) {
-		return new GenericAlert(Severity.ERROR, null, message);
+		return new GenericAlert(Severity.ERROR, message);
 	}
 
 	/**
@@ -70,41 +70,34 @@ public final class Alerts {
 	 * @see Severity#ERROR
 	 */
 	public static Alert fatal(String message) {
-		return new GenericAlert(Severity.FATAL, null, message);
+		return new GenericAlert(Severity.FATAL, message);
 	}
 
 	private static class GenericAlert implements Alert {
 
 		private Severity severity;
 		
-		private String code;
-		
 		private String message;
 
-		public GenericAlert(Severity severity, String code, String message) {
+		public GenericAlert(Severity severity, String message) {
 			this.severity = severity;
-			this.code = code;
 			this.message = message;
 		}
 
+		public String getCode() {
+			return null;
+		}
+
 		public Severity getSeverity() {
 			return severity;
 		}
 		
-		public String getCode() {
-			return code;
-		}
-
 		public String getMessage() {
 			return message;
 		}
 		
 		public String toString() {
-			if (getCode() != null) {
-				return getCode() + " - " + getMessage();
-			} else {
-				return getMessage();
-			}
+			return getSeverity() + ":" + getMessage();
 		}
 	}
 
diff --git a/org.springframework.context/src/test/java/org/springframework/ui/alert/AlertsTests.java b/org.springframework.context/src/test/java/org/springframework/ui/alert/AlertsTests.java
new file mode 100644
index 00000000000..8915c9d3788
--- /dev/null
+++ b/org.springframework.context/src/test/java/org/springframework/ui/alert/AlertsTests.java
@@ -0,0 +1,32 @@
+package org.springframework.ui.alert;
+
+import static org.junit.Assert.assertEquals;
+import static org.springframework.ui.alert.Alerts.error;
+import static org.springframework.ui.alert.Alerts.fatal;
+import static org.springframework.ui.alert.Alerts.info;
+import static org.springframework.ui.alert.Alerts.warning;
+
+import org.junit.Test;
+
+public class AlertsTests {
+	
+	@Test
+	public void testFactoryMethods() {
+		Alert a1 = info("alert 1");
+		assertEquals(Severity.INFO, a1.getSeverity());
+		assertEquals("alert 1", a1.getMessage());
+
+		Alert a2 = warning("alert 2");
+		assertEquals(Severity.WARNING, a2.getSeverity());
+		assertEquals("alert 2", a2.getMessage());
+
+		Alert a3 = error("alert 3");
+		assertEquals(Severity.ERROR, a3.getSeverity());
+		assertEquals("alert 3", a3.getMessage());
+
+		Alert a4 = fatal("alert 4");
+		assertEquals(Severity.FATAL, a4.getSeverity());
+		assertEquals("alert 4", a4.getMessage());
+
+	}
+}
diff --git a/org.springframework.context/src/test/java/org/springframework/ui/alert/DefaultMessageContextTests.java b/org.springframework.context/src/test/java/org/springframework/ui/alert/support/DefaultAlertContextTests.java
similarity index 82%
rename from org.springframework.context/src/test/java/org/springframework/ui/alert/DefaultMessageContextTests.java
rename to org.springframework.context/src/test/java/org/springframework/ui/alert/support/DefaultAlertContextTests.java
index 41ced47d0f2..d4c9977566b 100644
--- a/org.springframework.context/src/test/java/org/springframework/ui/alert/DefaultMessageContextTests.java
+++ b/org.springframework.context/src/test/java/org/springframework/ui/alert/support/DefaultAlertContextTests.java
@@ -1,4 +1,4 @@
-package org.springframework.ui.alert;
+package org.springframework.ui.alert.support;
 
 import static org.junit.Assert.assertEquals;
 
@@ -8,7 +8,7 @@ import org.springframework.ui.alert.Alert;
 import org.springframework.ui.alert.Severity;
 import org.springframework.ui.alert.support.DefaultAlertContext;
 
-public class DefaultMessageContextTests {
+public class DefaultAlertContextTests {
 	
 	private DefaultAlertContext context;
 
@@ -20,10 +20,6 @@ public class DefaultMessageContextTests {
 	@Test
 	public void addAlert() {
 		Alert alert = new Alert() {
-			public String getElement() {
-				return "form.property";
-			}
-
 			public String getCode() {
 				return "invalidFormat";
 			}
@@ -36,7 +32,7 @@ public class DefaultMessageContextTests {
 				return Severity.ERROR;
 			}
 		};
-		context.add(alert);
+		context.add("form.property", alert);
 		assertEquals(1, context.getAlerts().size());
 		assertEquals("invalidFormat", context.getAlerts("form.property").get(0).getCode());
 	}
diff --git a/org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java b/org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java
index 8d199bf8b28..0e3a4113e0f 100644
--- a/org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java
+++ b/org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java
@@ -103,9 +103,7 @@ public class GenericBinderTests {
 
 	@Test
 	public void bindSingleValueWithFormatterRegistedByType() throws ParseException {
-		GenericFormatterRegistry registry = new GenericFormatterRegistry();
-		registry.add(Date.class, new DateFormatter());
-		binder.setFormatterRegistry(registry);
+		binder.registerFormatter(Date.class, new DateFormatter());
 		binder.bind(Collections.singletonMap("date", "2009-06-01"));
 		assertEquals(new DateFormatter().parse("2009-06-01", Locale.US), bean.getDate());
 	}
@@ -121,9 +119,7 @@ public class GenericBinderTests {
 	
 	@Test
 	public void bindSingleValueWithnAnnotationFormatterFactoryRegistered() throws ParseException {
-		GenericFormatterRegistry registry = new GenericFormatterRegistry();
-		registry.add(new CurrencyAnnotationFormatterFactory());
-		binder.setFormatterRegistry(registry);
+		binder.registerFormatterFactory(new CurrencyAnnotationFormatterFactory());
 		binder.bind(Collections.singletonMap("currency", "$23.56"));
 		assertEquals(new BigDecimal("23.56"), bean.getCurrency());
 	}