You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2018/05/08 12:49:16 UTC
[myfaces] 17/29: MYFACES-3140 FacesMessage.VALUES is not ordered
properly (merge changes in 1.1.x branch)
This is an automated email from the ASF dual-hosted git repository.
deki pushed a commit to branch 1.1.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git
commit 7076262b5c52e5b67c4191cf28829c5ac29c3d57
Author: Jakob Korherr <ja...@apache.org>
AuthorDate: Wed May 18 19:16:56 2011 +0000
MYFACES-3140 FacesMessage.VALUES is not ordered properly (merge changes in 1.1.x branch)
---
.../java/javax/faces/application/FacesMessage.java | 5 +++-
.../javax/faces/application/FacesMessageTest.java | 28 ++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/api/src/main/java/javax/faces/application/FacesMessage.java b/api/src/main/java/javax/faces/application/FacesMessage.java
index f7fd150..6c017d8 100755
--- a/api/src/main/java/javax/faces/application/FacesMessage.java
+++ b/api/src/main/java/javax/faces/application/FacesMessage.java
@@ -55,8 +55,11 @@ public class FacesMessage
map.put(SEVERITY_WARN.toString(), SEVERITY_WARN);
map.put(SEVERITY_ERROR.toString(), SEVERITY_ERROR);
map.put(SEVERITY_FATAL.toString(), SEVERITY_FATAL);
- VALUES = Collections.unmodifiableList(new ArrayList(map.values()));
VALUES_MAP = Collections.unmodifiableMap(map);
+
+ List severityList = new ArrayList(map.values());
+ Collections.sort(severityList); // the JSF spec requires it to be sorted
+ VALUES = Collections.unmodifiableList(severityList);
}
private FacesMessage.Severity _severity;
diff --git a/api/src/test/java/javax/faces/application/FacesMessageTest.java b/api/src/test/java/javax/faces/application/FacesMessageTest.java
index 781080e..73f28c3 100644
--- a/api/src/test/java/javax/faces/application/FacesMessageTest.java
+++ b/api/src/test/java/javax/faces/application/FacesMessageTest.java
@@ -21,6 +21,10 @@ package javax.faces.application;
import junit.framework.TestCase;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
public class FacesMessageTest extends TestCase {
public static void main(String[] args) {
@@ -168,4 +172,28 @@ public class FacesMessageTest extends TestCase {
assertEquals(0, FacesMessage.SEVERITY_ERROR.compareTo(FacesMessage.SEVERITY_ERROR));
assertEquals(0, FacesMessage.SEVERITY_FATAL.compareTo(FacesMessage.SEVERITY_FATAL));
}
+
+ public void testSeverityValues()
+ {
+ // JSF spec requires this list to be sorted by ordinal
+ for (int i = 0, sz = FacesMessage.VALUES.size(); i < sz; i++)
+ {
+ FacesMessage.Severity severity = (FacesMessage.Severity) FacesMessage.VALUES.get(i);
+ assertEquals(i + 1, severity.getOrdinal());
+ }
+ }
+
+ public void testSeverityValuesMap()
+ {
+ Map severityMap = FacesMessage.VALUES_MAP;
+ Set entrySet = severityMap.entrySet();
+
+ for (Iterator it = entrySet.iterator(); it.hasNext(); )
+ {
+ Map.Entry e = (Map.Entry) it.next();
+
+ assertEquals(e.getKey(), e.getValue().toString());
+ }
+ }
+
}
--
To stop receiving notification emails like this one, please contact
deki@apache.org.