myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r939107 - in /myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src: main/java/org/apache/myfaces/extensions/cdi/message/impl/ test/java/org/apache/myfaces/extensions/cdi/message/test/
Date Wed, 28 Apr 2010 21:53:51 GMT
Author: gpetracek
Date: Wed Apr 28 21:53:51 2010
New Revision: 939107

URL: http://svn.apache.org/viewvc?rev=939107&view=rev
Log:
[EXTCDI-21] additional test-cases

Added:
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java
Modified:
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessage.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/PayloadTest.java

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessage.java?rev=939107&r1=939106&r2=939107&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessage.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessage.java
Wed Apr 28 21:53:51 2010
@@ -76,7 +76,11 @@ public class DefaultMessage extends Abst
 
     public String toString(MessageContext messageContext)
     {
-        return messageContext.message().text(getTemplate()).argument(getArguments()).payload(getMessagePayload()).toText();
+        return messageContext.message()
+                .text(getTemplate())
+                .argument(getArguments())
+                .payload(getMessagePayload())
+                .toText();
     }
 
     private Class<? extends MessagePayload>[] getMessagePayload()

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/PayloadTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/PayloadTest.java?rev=939107&r1=939106&r2=939107&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/PayloadTest.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/PayloadTest.java
Wed Apr 28 21:53:51 2010
@@ -20,8 +20,11 @@ package org.apache.myfaces.extensions.cd
 
 import org.apache.myfaces.extensions.cdi.message.api.Message;
 import org.apache.myfaces.extensions.cdi.message.api.payload.InternalMessage;
+import org.apache.myfaces.extensions.cdi.message.api.payload.MessageSeverity;
 import org.apache.myfaces.extensions.cdi.message.impl.DefaultInternalMessage;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 import org.junit.Test;
 
 /**
@@ -56,4 +59,31 @@ public class PayloadTest extends Abstrac
         assertEquals(this.messageContext.message().text("test msg 1").create(),
                 this.messageContext.getMessages().iterator().next());
     }
+
+    @Test
+    public void forwardedPayloadTest1()
+    {
+        TestPayloadAwareMessageResolver testResolver = new TestPayloadAwareMessageResolver();
+        this.messageContext.config().change().messageResolver(testResolver);
+
+        assertFalse(testResolver.isPayloadAvailable());
+
+        this.messageContext.message().text("test msg").payload(MessageSeverity.Warn.class).toText();
+
+        assertTrue(testResolver.isPayloadAvailable());
+    }
+
+    @Test
+    public void forwardedPayloadTest2()
+    {
+        TestPayloadAwareMessageResolver testResolver = new TestPayloadAwareMessageResolver();
+        this.messageContext.config().change().messageResolver(testResolver);
+
+        assertFalse(testResolver.isPayloadAvailable());
+
+        Message message = this.messageContext.message().text("test msg").payload(MessageSeverity.Warn.class).create();
+        this.messageContext.getMessageText(message);
+
+        assertTrue(testResolver.isPayloadAvailable());
+    }
 }
\ No newline at end of file

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java?rev=939107&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestPayloadAwareMessageResolver.java
Wed Apr 28 21:53:51 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.cdi.message.test;
+
+import org.apache.myfaces.extensions.cdi.message.api.MessageResolver;
+import org.apache.myfaces.extensions.cdi.message.api.payload.MessagePayload;
+import org.apache.myfaces.extensions.cdi.message.api.payload.MessageSeverity;
+
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ */
+class TestPayloadAwareMessageResolver implements MessageResolver
+{
+    private boolean isPayloadAvailable = false; 
+
+    public String getMessage(String key, Locale locale, Map<Class, Class<? extends
MessagePayload>> payload)
+    {
+        if(MessageSeverity.Warn.class.equals(payload.get(MessageSeverity.class)))
+        {
+            isPayloadAvailable = true;
+        }
+        return key;
+    }
+
+    public boolean isPayloadAvailable()
+    {
+        return isPayloadAvailable;
+    }
+}



Mime
View raw message