myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r935183 [4/4] - in /myfaces/extensions/cdi/trunk: ./ jse-modules/ jse-modules/message-module/ jse-modules/message-module/api/ jse-modules/message-module/api/src/ jse-modules/message-module/api/src/main/ jse-modules/message-module/api/src/ma...
Date Sat, 17 Apr 2010 14:53:43 GMT
Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestELProvider.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/TestELProvider.java?rev=935183&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestELProvider.java
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestELProvider.java
Sat Apr 17 14:53:40 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 de.odysseus.el.ExpressionFactoryImpl;
+import de.odysseus.el.util.SimpleResolver;
+import org.apache.myfaces.extensions.cdi.message.impl.spi.ELProvider;
+import org.apache.myfaces.extensions.cdi.message.impl.spi.SimpleELContext;
+
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+
+/**
+ * @author Manfred Geiler
+ */
+class TestELProvider implements ELProvider
+{
+    public ExpressionFactory createExpressionFactory()
+    {
+        return new ExpressionFactoryImpl();
+    }
+
+    public SimpleELContext createELContext(ELResolver elResolver)
+    {
+        return new TestELContext(elResolver);
+    }
+
+    public ELResolver createELResolver()
+    {
+        return new SimpleResolver(true /*readonly*/);
+    }
+}

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestInMemoryMessageHandler.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/TestInMemoryMessageHandler.java?rev=935183&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestInMemoryMessageHandler.java
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestInMemoryMessageHandler.java
Sat Apr 17 14:53:40 2010
@@ -0,0 +1,55 @@
+/*
+ * 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.AbstractMessageHandler;
+import org.apache.myfaces.extensions.cdi.message.api.Message;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ */
+class TestInMemoryMessageHandler extends AbstractMessageHandler
+{
+    private List<Message> messages = new ArrayList<Message>();
+
+    protected void processMessage(MessageContext messageContext, Message message)
+    {
+        this.messages.add(message);
+    }
+
+    public void removeMessage(Message message)
+    {
+        this.messages.remove(message);
+    }
+
+    public void removeAllMessages()
+    {
+        this.messages.clear();
+    }
+
+    public List<Message> getMessages()
+    {
+        return Collections.unmodifiableList(this.messages);
+    }
+}

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestInternalMessageAwareMessageHandler.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/TestInternalMessageAwareMessageHandler.java?rev=935183&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestInternalMessageAwareMessageHandler.java
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestInternalMessageAwareMessageHandler.java
Sat Apr 17 14:53:40 2010
@@ -0,0 +1,37 @@
+/*
+ * 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.Message;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
+import org.apache.myfaces.extensions.cdi.message.api.payload.InternalMessage;
+
+/**
+ * @author Gerhard Petracek
+ */
+class TestInternalMessageAwareMessageHandler extends TestInMemoryMessageHandler
+{
+    public void addMessage(MessageContext messageContext, Message message)
+    {
+        if (!message.getPayload().containsKey(InternalMessage.class))
+        {
+            super.addMessage(messageContext, message);
+        }
+    }
+}
\ 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/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=935183&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestMessageResolver.java
Sat Apr 17 14:53:40 2010
@@ -0,0 +1,73 @@
+/*
+ * 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 java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author Gerhard Petracek
+ */
+class TestMessageResolver implements MessageResolver
+{
+    private static final String TEST_MESSAGES = "org.apache.myfaces.extensions.cdi.message.test.messages";
+
+    public String getMessage(String key, Locale locale, Map<Class, Class<? extends
MessagePayload>> messagePayload)
+    {
+        if (!isKey(key))
+        {
+            return key;
+        }
+
+        try
+        {
+            key = extractKey(key);
+            return ResourceBundle.getBundle(TEST_MESSAGES, locale, getClassLoader()).getString(key);
+        }
+        catch (MissingResourceException e)
+        {
+            return key;
+        }
+    }
+
+    private boolean isKey(String key)
+    {
+        return key.startsWith("{") && key.endsWith("}");
+    }
+
+    private String extractKey(String key)
+    {
+        return key.substring(1, key.length() - 1);
+    }
+
+    private ClassLoader getClassLoader()
+    {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        if (classLoader == null)
+        {
+            classLoader = TestMessageResolver.class.getClassLoader();
+        }
+        return classLoader;
+    }
+}

Added: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/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/messages_de.properties?rev=935183&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_de.properties
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_de.properties
Sat Apr 17 14:53:40 2010
@@ -0,0 +1,2 @@
+hello=Test Nachricht
+formatted_number=value: {0}
\ 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/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/messages_en.properties?rev=935183&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_en.properties
(added)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_en.properties
Sat Apr 17 14:53:40 2010
@@ -0,0 +1,2 @@
+hello=test message
+formatted_number=value: {0}
\ No newline at end of file

Modified: myfaces/extensions/cdi/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/parent/pom.xml?rev=935183&r1=935182&r2=935183&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/parent/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/parent/pom.xml Sat Apr 17 14:53:40 2010
@@ -163,6 +163,18 @@
                 <version>1.0.0-SNAPSHOT</version>
             </dependency>
 
+            <!-- CODI-I18N Message Module -->
+            <dependency>
+                <groupId>org.apache.myfaces.extensions.cdi.jse-modules</groupId>
+                <artifactId>myfaces-extcdi-message-module-api</artifactId>
+                <version>1.0.0-SNAPSHOT</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.myfaces.extensions.cdi.jse-modules</groupId>
+                <artifactId>myfaces-extcdi-message-module-impl</artifactId>
+                <version>1.0.0-SNAPSHOT</version>
+            </dependency>
+
             <!--
                 We currently need this for the CDI test container to emulate the @SessionScoped.
                 TODO: Finally this should not be necessary anymore.

Modified: myfaces/extensions/cdi/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/pom.xml?rev=935183&r1=935182&r2=935183&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/pom.xml Sat Apr 17 14:53:40 2010
@@ -68,6 +68,7 @@
         <module>parent</module>
         <module>core</module>
         <module>jee-modules</module>
+        <module>jse-modules</module>
         <!--module>test-modules</module-->
         <module>examples</module>
     </modules>



Mime
View raw message