tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r499892 - in /tapestry/tapestry5/tapestry-ioc/trunk/src: main/java/org/apache/tapestry/ioc/test/IOCTestCase.java main/java/org/apache/tapestry/ioc/util/AbstractMessages.java test/java/org/apache/tapestry/ioc/internal/util/MessagesImplTest.java
Date Thu, 25 Jan 2007 18:46:13 GMT
Author: hlship
Date: Thu Jan 25 10:46:13 2007
New Revision: 499892

URL: http://svn.apache.org/viewvc?view=rev&rev=499892
Log:
Tweak the behavior of AbstractMessages when a key is missing.

Modified:
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/MessagesImplTest.java

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java?view=diff&rev=499892&r1=499891&r2=499892
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java
(original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java
Thu Jan 25 10:46:13 2007
@@ -23,6 +23,7 @@
 import org.apache.tapestry.ioc.Location;
 import org.apache.tapestry.ioc.LogSource;
 import org.apache.tapestry.ioc.MappedConfiguration;
+import org.apache.tapestry.ioc.MessageFormatter;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.ioc.ObjectCreator;
 import org.apache.tapestry.ioc.ObjectProvider;
@@ -308,5 +309,27 @@
     protected final void train_isDebugEnabled(Log log, boolean debugEnabled)
     {
         expect(log.isDebugEnabled()).andReturn(debugEnabled);
+    }
+
+    protected final void train_contains(Messages messages, String key, boolean result)
+    {
+        expect(messages.contains(key)).andReturn(result).atLeastOnce();
+    }
+
+    protected final void train_getMessageFormatter(Messages messages, String key,
+            MessageFormatter formatter)
+    {
+        expect(messages.getFormatter(key)).andReturn(formatter).atLeastOnce();
+    }
+
+    protected final MessageFormatter newMessageFormatter()
+    {
+        return newMock(MessageFormatter.class);
+    }
+
+    /** Have to put the result before the varargs. */
+    protected void train_format(MessageFormatter formatter, String result, Object... arguments)
+    {
+        expect(formatter.format(arguments)).andReturn(result);
     }
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java?view=diff&rev=499892&r1=499891&r2=499892
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java
(original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/AbstractMessages.java
Thu Jan 25 10:46:13 2007
@@ -50,7 +50,7 @@
     {
         if (contains(key)) return valueForKey(key);
 
-        return "[" + key.toUpperCase() + "]";
+        return String.format("[[missing key: %s]]", key);
     }
 
     public MessageFormatter getFormatter(String key)

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/MessagesImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/MessagesImplTest.java?view=diff&rev=499892&r1=499891&r2=499892
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/MessagesImplTest.java
(original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/MessagesImplTest.java
Thu Jan 25 10:46:13 2007
@@ -40,7 +40,7 @@
     @Test
     public void get_unknown_message_from_catalog()
     {
-        assertEquals(_messages.get("does-not-exist"), "[DOES-NOT-EXIST]");
+        assertEquals(_messages.get("does-not-exist"), "[[missing key: does-not-exist]]");
     }
 
     @Test
@@ -69,6 +69,6 @@
     @Test
     public void format_unknown_key()
     {
-        assertEquals(_messages.format("rezult", "good"), "[REZULT]");
+        assertEquals(_messages.format("rezult", "good"), "[[missing key: rezult]]");
     }
 }



Mime
View raw message