myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdebussc...@apache.org
Subject svn commit: r1068865 - in /myfaces/test/trunk: test12/src/main/java/org/apache/myfaces/test/base/ test12/src/main/java/org/apache/myfaces/test/base/junit4/ test12/src/main/java/org/apache/myfaces/test/config/ test12/src/main/java/org/apache/myfaces/tes...
Date Wed, 09 Feb 2011 12:38:54 GMT
Author: rdebusscher
Date: Wed Feb  9 12:38:53 2011
New Revision: 1068865

URL: http://svn.apache.org/viewvc?rev=1068865&view=rev
Log:
MYFACESTEST-41

Added:
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/config/ResourceBundleVarNames.java
    myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ResourceBundleTest.java
    myfaces/test/trunk/test12/src/test/resources/org/apache/myfaces/test/config/test.properties
Modified:
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
    myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
    myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
    myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
    myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java

Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
(original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
Wed Feb  9 12:38:53 2011
@@ -28,6 +28,7 @@ import javax.faces.render.RenderKitFacto
 
 import junit.framework.TestCase;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.mock.MockApplication;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
@@ -296,6 +297,7 @@ public abstract class AbstractJsfTestCas
         servletContext = null;
         session = null;
         FactoryFinder.releaseFactories();
+        ResourceBundleVarNames.resetNames();
 
         Thread.currentThread().setContextClassLoader(threadContextClassLoader);
         threadContextClassLoader = null;

Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
(original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
Wed Feb  9 12:38:53 2011
@@ -32,6 +32,7 @@ import javax.faces.lifecycle.LifecycleFa
 import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
 import org.apache.myfaces.test.mock.MockHttpServletRequest;
@@ -298,6 +299,7 @@ public abstract class AbstractJsfConfigu
         servletContext = null;
         session = null;
         FactoryFinder.releaseFactories();
+        ResourceBundleVarNames.resetNames();
 
         Thread.currentThread().setContextClassLoader(threadContextClassLoader);
         threadContextClassLoader = null;

Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
(original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
Wed Feb  9 12:38:53 2011
@@ -26,6 +26,7 @@ import javax.faces.component.UIViewRoot;
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.RenderKitFactory;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.mock.MockApplication;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
@@ -297,6 +298,7 @@ public abstract class AbstractJsfTestCas
         servletContext = null;
         session = null;
         FactoryFinder.releaseFactories();
+        ResourceBundleVarNames.resetNames();
 
         Thread.currentThread().setContextClassLoader(threadContextClassLoader);
         threadContextClassLoader = null;

Added: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/config/ResourceBundleVarNames.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/config/ResourceBundleVarNames.java?rev=1068865&view=auto
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/config/ResourceBundleVarNames.java
(added)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/config/ResourceBundleVarNames.java
Wed Feb  9 12:38:53 2011
@@ -0,0 +1,45 @@
+/*
+ * 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.test.config;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Rudy De Busscher
+ */
+public final class ResourceBundleVarNames
+{
+
+    private static Map<String, String> varNames = new HashMap<String, String>();
+
+    private ResourceBundleVarNames()
+    {
+    }
+
+    public static void addVarName(String varName, String fullyQualifiedBaseName) {
+        varNames.put(varName, fullyQualifiedBaseName);
+    }
+
+    public static String getVarName(String varName) {
+        return varNames.get(varName);
+    }
+
+    public static void resetNames() {
+        varNames.clear();
+    }
+}

Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
(original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
Wed Feb  9 12:38:53 2011
@@ -26,6 +26,7 @@ import javax.faces.component.UIViewRoot;
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.RenderKitFactory;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.mock.MockApplication;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
@@ -294,6 +295,7 @@ public abstract class AbstractJmockJsfTe
         servletContext = null;
         session = null;
         FactoryFinder.releaseFactories();
+        ResourceBundleVarNames.resetNames();
 
         Thread.currentThread().setContextClassLoader(threadContextClassLoader);
         threadContextClassLoader = null;

Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
(original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/mock/MockApplication12.java
Wed Feb  9 12:38:53 2011
@@ -41,6 +41,7 @@ import javax.faces.component.UIComponent
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.el.FacesImplicitObjectELResolver;
 import org.apache.myfaces.test.el.FacesPropertyResolverChainWrapper;
 import org.apache.myfaces.test.el.FacesResourceBundleELResolver;
@@ -277,7 +278,21 @@ public class MockApplication12 extends M
         }
         catch (MissingResourceException e)
         {
-            return null;
+
+            String newName = ResourceBundleVarNames.getVarName(name);
+            if (newName == null) {
+                return null;
+            }
+
+            try
+            {
+                return ResourceBundle.getBundle(newName, locale);
+            }
+            catch (MissingResourceException exc)
+            {
+                return null;
+            }
+
         }
     }
 

Added: myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ResourceBundleTest.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ResourceBundleTest.java?rev=1068865&view=auto
==============================================================================
--- myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ResourceBundleTest.java
(added)
+++ myfaces/test/trunk/test12/src/test/java/org/apache/myfaces/test/mock/ResourceBundleTest.java
Wed Feb  9 12:38:53 2011
@@ -0,0 +1,79 @@
+/*
+ * 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.test.mock;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.test.base.AbstractJsfTestCase;
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
+
+import javax.faces.application.Application;
+import javax.faces.context.FacesContext;
+import java.util.ResourceBundle;
+
+/**
+ * @author Rudy De Busscher
+ */
+public class ResourceBundleTest extends AbstractJsfTestCase
+{
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        ResourceBundleVarNames.addVarName("msg", "org.apache.myfaces.test.config.test");
+    }
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of this test case
+     */
+    public ResourceBundleTest(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite()
+    {
+        return (new TestSuite(ResourceBundleTest.class));
+    }
+
+    public void testResourceBundleNonExistent() {
+        FacesContext context = FacesContext.getCurrentInstance();
+        Application application = context.getApplication();
+        ResourceBundle rb = application.getResourceBundle(context, "xx");
+        Assert.assertNull(rb);
+
+    }
+
+    public void testResourceBundleExistent() {
+        FacesContext context = FacesContext.getCurrentInstance();
+        Application application = context.getApplication();
+        ResourceBundle rb = application.getResourceBundle(context, "msg");
+        Assert.assertNotNull(rb);
+
+    }
+}

Added: myfaces/test/trunk/test12/src/test/resources/org/apache/myfaces/test/config/test.properties
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/test/resources/org/apache/myfaces/test/config/test.properties?rev=1068865&view=auto
==============================================================================
--- myfaces/test/trunk/test12/src/test/resources/org/apache/myfaces/test/config/test.properties
(added)
+++ myfaces/test/trunk/test12/src/test/resources/org/apache/myfaces/test/config/test.properties
Wed Feb  9 12:38:53 2011
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+JUnit.test=Test
\ No newline at end of file

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
(original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
Wed Feb  9 12:38:53 2011
@@ -28,6 +28,7 @@ import javax.faces.render.RenderKitFacto
 
 import junit.framework.TestCase;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.mock.MockApplication;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
@@ -302,6 +303,7 @@ public abstract class AbstractJsfTestCas
         servletContext = null;
         session = null;
         FactoryFinder.releaseFactories();
+        ResourceBundleVarNames.resetNames();
 
         Thread.currentThread().setContextClassLoader(threadContextClassLoader);
         threadContextClassLoader = null;

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
(original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
Wed Feb  9 12:38:53 2011
@@ -32,6 +32,7 @@ import javax.faces.lifecycle.LifecycleFa
 import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
 import org.apache.myfaces.test.mock.MockHttpServletRequest;
@@ -304,6 +305,7 @@ public abstract class AbstractJsfConfigu
         servletContext = null;
         session = null;
         FactoryFinder.releaseFactories();
+        ResourceBundleVarNames.resetNames();
 
         Thread.currentThread().setContextClassLoader(threadContextClassLoader);
         threadContextClassLoader = null;

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
(original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
Wed Feb  9 12:38:53 2011
@@ -26,6 +26,7 @@ import javax.faces.component.UIViewRoot;
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.RenderKitFactory;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.mock.MockApplication;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
@@ -303,6 +304,7 @@ public abstract class AbstractJsfTestCas
         servletContext = null;
         session = null;
         FactoryFinder.releaseFactories();
+        ResourceBundleVarNames.resetNames();
 
         Thread.currentThread().setContextClassLoader(threadContextClassLoader);
         threadContextClassLoader = null;

Modified: myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java?rev=1068865&r1=1068864&r2=1068865&view=diff
==============================================================================
--- myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
(original)
+++ myfaces/test/trunk/test20/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
Wed Feb  9 12:38:53 2011
@@ -26,6 +26,7 @@ import javax.faces.component.UIViewRoot;
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.RenderKitFactory;
 
+import org.apache.myfaces.test.config.ResourceBundleVarNames;
 import org.apache.myfaces.test.mock.MockApplication;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
@@ -301,6 +302,7 @@ public abstract class AbstractJmockJsfTe
         servletContext = null;
         session = null;
         FactoryFinder.releaseFactories();
+        ResourceBundleVarNames.resetNames();
 
         Thread.currentThread().setContextClassLoader(threadContextClassLoader);
         threadContextClassLoader = null;



Mime
View raw message