myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r940383 - 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 Mon, 03 May 2010 07:24:45 GMT
Author: gpetracek
Date: Mon May  3 07:24:44 2010
New Revision: 940383

URL: http://svn.apache.org/viewvc?rev=940383&view=rev
Log:
[EXTCDI-21] added tests

Added:
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/Label.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TechnicalMessage.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/labels_de.properties
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/labels_en.properties
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/t_messages_de.properties
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/t_messages_en.properties
Modified:
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultLocaleResolver.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/AbstractTest.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ExtensibilityTest.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageBuilder.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultLocaleResolver.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/DefaultLocaleResolver.java?rev=940383&r1=940382&r2=940383&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultLocaleResolver.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultLocaleResolver.java
Mon May  3 07:24:44 2010
@@ -32,7 +32,6 @@ class DefaultLocaleResolver implements L
 
     public Locale getLocale()
     {
-        return Locale.ENGLISH;
-        //return Locale.getDefault();
+        return Locale.getDefault();
     }
 }

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/AbstractTest.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/AbstractTest.java?rev=940383&r1=940382&r2=940383&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/AbstractTest.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/AbstractTest.java
Mon May  3 07:24:44 2010
@@ -19,9 +19,12 @@
 package org.apache.myfaces.extensions.cdi.message.test;
 
 import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
+import org.apache.myfaces.extensions.cdi.message.api.LocaleResolver;
 import org.apache.myfaces.extensions.cdi.message.impl.DefaultMessageContext;
 import org.junit.Before;
 
+import java.util.Locale;
+
 /**
  * @author Gerhard Petracek
  */
@@ -34,6 +37,13 @@ public abstract class AbstractTest
     {
         this.messageContext = new DefaultMessageContext().config().use()
                 .messageResolver(new TestMessageResolver())
+                .localeResolver(new LocaleResolver()
+                {
+                    public Locale getLocale()
+                    {
+                        return Locale.ENGLISH;
+                    }
+                })
                 .create();
     }
 }

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ExtensibilityTest.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/ExtensibilityTest.java?rev=940383&r1=940382&r2=940383&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ExtensibilityTest.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ExtensibilityTest.java
Mon May  3 07:24:44 2010
@@ -46,6 +46,30 @@ public class ExtensibilityTest extends A
     }
 
     @Test
+    public void customMessageTypeViaCustomMessageBuilder1Test()
+    {
+        Message message = TestMessageBuilder.label().text("{hello}").create();
+
+        assertEquals("test label", message.toString(this.messageContext));
+    }
+
+    @Test
+    public void customMessageTypeViaCustomMessageBuilder2Test()
+    {
+        Message message = TestMessageBuilder.technicalMessage().text("{hello}").create();
+
+        assertEquals("hello codi", message.toString(this.messageContext));
+    }
+
+    @Test
+    public void customMessageTypeTest()
+    {
+        String messageText = this.messageContext.message().text("{hello}").payload(Label.class).toText();
+
+        assertEquals("test label", messageText);
+    }
+
+    @Test
     public void newMessageFactoryTestViaMessageContext()
     {
         Message message = new DefaultMessageContext(new TestMessageFactory()).message().text("{hello}").create();

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/Label.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/Label.java?rev=940383&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/Label.java
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/Label.java
Mon May  3 07:24:44 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.payload.MessagePayload;
+
+/**
+ * @author Gerhard Petracek
+ */
+interface Label extends MessagePayload
+{
+}

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TechnicalMessage.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/TechnicalMessage.java?rev=940383&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TechnicalMessage.java
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TechnicalMessage.java
Mon May  3 07:24:44 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.payload.MessagePayload;
+
+/**
+ * @author Gerhard Petracek
+ */
+interface TechnicalMessage extends MessagePayload
+{
+}
\ No newline at end of file

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageBuilder.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/TestMessageBuilder.java?rev=940383&r1=940382&r2=940383&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageBuilder.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageBuilder.java
Mon May  3 07:24:44 2010
@@ -19,6 +19,7 @@
 package org.apache.myfaces.extensions.cdi.message.test;
 
 import org.apache.myfaces.extensions.cdi.message.impl.SimpleMessageBuilder;
+import org.apache.myfaces.extensions.cdi.message.api.MessageBuilder;
 
 /**
  * @author Gerhard Petracek
@@ -30,4 +31,19 @@ class TestMessageBuilder extends SimpleM
     public TestMessageBuilder()
     {
     }
+
+    public static MessageBuilder message()
+    {
+        return new TestMessageBuilder();
+    }
+
+    public static MessageBuilder technicalMessage()
+    {
+        return new TestMessageBuilder().payload(TechnicalMessage.class);
+    }
+
+    public static MessageBuilder label()
+    {
+        return new TestMessageBuilder().payload(Label.class);
+    }
 }

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.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/TestMessageResolver.java?rev=940383&r1=940382&r2=940383&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java
Mon May  3 07:24:44 2010
@@ -32,6 +32,8 @@ import java.util.ResourceBundle;
 class TestMessageResolver implements MessageResolver
 {
     private static final String TEST_MESSAGES = "org.apache.myfaces.extensions.cdi.message.test.messages";
+    private static final String TEST_TECHNICAL_MESSAGES = "org.apache.myfaces.extensions.cdi.message.test.t_messages";
+    private static final String TEST_LABELS = "org.apache.myfaces.extensions.cdi.message.test.labels";
 
     public String getMessage(String key, Locale locale, Map<Class, Class<? extends
MessagePayload>> messagePayload)
     {
@@ -43,6 +45,15 @@ class TestMessageResolver implements Mes
         try
         {
             key = extractKey(key);
+
+            if(messagePayload.containsKey(Label.class))
+            {
+                return ResourceBundle.getBundle(TEST_LABELS, locale, getClassLoader()).getString(key);
+            }
+            else if(messagePayload.containsKey(TechnicalMessage.class))
+            {
+                return ResourceBundle.getBundle(TEST_TECHNICAL_MESSAGES, locale, getClassLoader()).getString(key);
+            }
             return ResourceBundle.getBundle(TEST_MESSAGES, locale, getClassLoader()).getString(key);
         }
         catch (MissingResourceException e)

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/labels_de.properties
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/labels_de.properties?rev=940383&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/labels_de.properties
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/labels_de.properties
Mon May  3 07:24:44 2010
@@ -0,0 +1 @@
+hello=Test Label
\ 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/labels_en.properties
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/labels_en.properties?rev=940383&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/labels_en.properties
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/labels_en.properties
Mon May  3 07:24:44 2010
@@ -0,0 +1 @@
+hello=test label
\ 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/t_messages_de.properties
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/t_messages_de.properties?rev=940383&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/t_messages_de.properties
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/t_messages_de.properties
Mon May  3 07:24:44 2010
@@ -0,0 +1 @@
+hello=Hallo CODI
\ 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/t_messages_en.properties
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/t_messages_en.properties?rev=940383&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/t_messages_en.properties
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/t_messages_en.properties
Mon May  3 07:24:44 2010
@@ -0,0 +1 @@
+hello=hello codi
\ No newline at end of file



Mime
View raw message