You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2018/05/03 18:26:28 UTC

[myfaces-test] branch 1_0_0_beta_4 created (now b4499bb)

This is an automated email from the ASF dual-hosted git repository.

deki pushed a change to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git.


      at b4499bb  move to branch for release procedure

This branch includes the following new commits:

     new 1767909  folder for the test framework
     new 2c106d1  copy shale test to myfaces
     new 11eb777  moved one level up...
     new e020e3a  
     new 706afbb  create test12 module
     new 1688cfc  Create test20 module
     new 79b6982  move to test12 module
     new 7d34029  remove moved src
     new f08b599  copy pom.xml
     new 8c00c4b  Create initial layout for myfaces test
     new 49e6d15  Create test20 branch
     new 5971ef1  MYFACES-2327 Move facelets test code to myfaces
     new 5bf67ba  small fixes (add _processingEvents and redirect getMimeType)
     new fc865e1  MYFACES-2345 Add View Parameters feature
     new c85bfc4  small fix on MockApplication20
     new 5ad5cb6  use getDigester instead local var
     new 021af1e  add Application.getProjectStage()
     new 7971bcf  set jdk to 1.5
     new 774b61a  MYFACES-2422 Change package name to org.apache.myfaces.test in myfaces-test project
     new f5081c8  MYFACES-2492 Update and create Mock classes in myfaces-test20 (Thanks to Ingo Hofmann for this patch)
     new c063fa6  update dependency versions
     new 6e25395  [maven-release-plugin] prepare release 1_0_0_beta
     new 5b15eed  [maven-release-plugin] prepare for next development iteration
     new 14e2610  MYFACESTEST-3 Add configuration resource for Myfaces 1.2 to ConfigParser (Thanks to Rudy De Busscher for this patch)
     new 706198f  MYFACESTEST-5 Implementation of MockHttpSession.invalidate() (Thanks to Christoph Göldner for this patch) + test case
     new 869f785  MYFACESTEST-4 Unable to call setValue of ValueExpression in test (Thanks to Christoph Göldner for the patch)
     new e6e3324  [maven-release-plugin] prepare release 1_0_0_beta_2
     new 9e17d54  [maven-release-plugin] prepare for next development iteration
     new a3d2939  MYFACESTEST-7 MockResource needs to override setResourceName and setLibraryName
     new 3c3e81a  [maven-release-plugin] prepare release 1_0_0_beta_3
     new f6dd68e  [maven-release-plugin] prepare for next development iteration
     new e55dcae  MYFACESTEST-8 Implement ViewHandler.getBookmarkableURL() for MyFaces test 2.0
     new c2f7f09  MYFACESTEST-9 MockExternalContext20 should implement encodePartialActionURL()
     new c75ed26  when object is null return null
     new 3698953  [maven-release-plugin] prepare release 1_0_0_beta_4
     new 158cdfc  [maven-release-plugin]  copy for tag 1_0_0_beta_4
     new c724ce2  [maven-release-plugin] prepare for next development iteration
     new 7c3ff98  move to branches for release procedure
     new cc3d9a0  MYFACESTEST-11 Update ConfigParser to jsf 2
     new cf6b9f5  MYFACESTEST-15 Add new MockResponseStateManager
     new 7e066e8  MYFACESTEST-15 Add new MockResponseStateManager
     new a205961  MYFACESTEST-16 Update license and notice for myfaces test
     new bc199b5  remove unused directory
     new 16a03f3  MYFACESTEST-17 Update MockExternalContext so it delegate to mock request and response objects and add new methods present on facelets mocks
     new 7dfcc08  MYFACESTEST-18 Include in AbstractJsfTestCase and AbstractJmockTestCase protected methods for setup elements and allow better customization
     new 1651f0a  IOException(Exception e) does not exists in jdk 1.5
     new 8f57f6a  fix typo errors
     new be6fa62  MYFACESTEST-14 Update myfaces-test to use JUnit 4.x
     new fa01e0f  MYFACESTEST-14 Update myfaces-test to use JUnit 4.x (don't cast to mock)
     new a06f745  MYFACESTEST-19 JUnit4 Runner that runs each Test method in a seperate classloader (thanks to Rudy De Busscher for this patch)
     new 9e585ca  MYFACESTEST-13 MockResource must implement all its methods
     new 747a119  [maven-release-plugin]  copy for tag 1_0_0_beta_4
     new b4499bb  move to branch for release procedure

The 53 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 07/24: [maven-release-plugin] copy for tag 1_0_0_beta_4

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 158cdfc69074ed175e9d85dae86ef2d853ad5d60
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Fri Jun 11 02:32:56 2010 +0000

    [maven-release-plugin]  copy for tag 1_0_0_beta_4
---
 pom.xml        | 8 ++++----
 test12/pom.xml | 2 +-
 test20/pom.xml | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index af3cfaf..0eea5db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,16 +30,16 @@
     <artifactId>myfaces-test-project</artifactId>
     <packaging>pom</packaging>
     <name>Myfaces Test Framework</name>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0-beta-4</version>
     <url>http://myfaces.apache.org/test</url>
     <issueManagement>
       <system>jira</system>
       <url>http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10600</url>
     </issueManagement>
     <scm>
-      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/trunk</connection>
-      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/trunk</developerConnection>
-      <url>http://svn.apache.org/repos/asf/myfaces/test/trunk</url>
+      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</connection>
+      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</developerConnection>
+      <url>http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</url>
     </scm>
     <modules>
       <module>test12</module>
diff --git a/test12/pom.xml b/test12/pom.xml
index 3ffa3bb..90ef95d 100644
--- a/test12/pom.xml
+++ b/test12/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0-beta-4</version>
     </parent>
 
     <artifactId>myfaces-test12</artifactId>
diff --git a/test20/pom.xml b/test20/pom.xml
index 8021996..60fe388 100644
--- a/test20/pom.xml
+++ b/test20/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0-beta-4</version>
     </parent>
 
     <artifactId>myfaces-test20</artifactId>

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 03/24: MYFACESTEST-8 Implement ViewHandler.getBookmarkableURL() for MyFaces test 2.0

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit e55dcae34ae69267f14d62945c8db1f25991a0c5
Author: Jakob Korherr <ja...@apache.org>
AuthorDate: Mon Apr 19 19:39:39 2010 +0000

    MYFACESTEST-8 Implement ViewHandler.getBookmarkableURL() for MyFaces test 2.0
---
 .../myfaces/test/mock/MockApplication20.java       |  3 ++
 .../myfaces/test/mock/MockViewHandler20.java       | 50 ++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java b/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
index b1d6080..72dce99 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
@@ -47,6 +47,9 @@ public class MockApplication20 extends MockApplication12
     public MockApplication20()
     {
         super();
+        
+        // install the 2.0-ViewHandler-Mock
+        this.setViewHandler(new MockViewHandler20());
     }
 
     private static class SystemListenerEntry
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/MockViewHandler20.java b/test20/src/main/java/org/apache/myfaces/test/mock/MockViewHandler20.java
new file mode 100644
index 0000000..0663440
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/MockViewHandler20.java
@@ -0,0 +1,50 @@
+/*
+ * 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 java.util.List;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+/**
+ * Mock for a JSF 2.0 ViewHandler.
+ * This ViewHandler is used by MockApplication20.
+ * 
+ * @author Jakob Korherr (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class MockViewHandler20 extends MockViewHandler
+{
+
+    @Override
+    public String getBookmarkableURL(FacesContext context, String viewId,
+            Map<String, List<String>> parameters, boolean includeViewParams)
+    {
+        // the standard impl only calls getActionURL(context, viewId)
+        // but we want to include the parameters too
+        
+        String actionEncodedViewId = getActionURL(context, viewId);
+        ExternalContext externalContext = context.getExternalContext();
+        String bookmarkEncodedURL = externalContext.encodeBookmarkableURL(actionEncodedViewId, parameters);
+        return externalContext.encodeActionURL(bookmarkEncodedURL);
+    }
+    
+}

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 22/24: MYFACESTEST-13 MockResource must implement all its methods

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 9e585ca8850586bb6456a7f4877f7bed06e0e788
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Tue Jul 13 22:31:58 2010 +0000

    MYFACESTEST-13 MockResource must implement all its methods
---
 .../myfaces/test/mock/MockApplication20.java       |   2 +
 .../resource/MockClassLoaderResourceLoader.java    | 122 ++++
 .../MockExternalContextResourceLoader.java         | 208 ++++++
 .../myfaces/test/mock/resource/MockResource.java   | 161 ++---
 .../test/mock/resource/MockResourceHandler.java    | 378 +++++------
 .../mock/resource/MockResourceHandlerSupport.java  | 115 ++++
 .../test/mock/resource/MockResourceLoader.java     | 155 +++++
 .../test/mock/resource/MockResourceMeta.java       | 110 ++++
 .../{MockResource.java => MockSimpleResource.java} | 361 +++++------
 ...Handler.java => MockSimpleResourceHandler.java} | 703 +++++++++++----------
 .../myfaces/test/mock/MockResourceTestCase.java    |  28 +-
 11 files changed, 1495 insertions(+), 848 deletions(-)

diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java b/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
index 72dce99..242d475 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/MockApplication20.java
@@ -19,6 +19,7 @@ package org.apache.myfaces.test.mock;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.test.mock.resource.MockResourceHandler;
 
 import javax.faces.FacesException;
 import javax.faces.application.ProjectStage;
@@ -50,6 +51,7 @@ public class MockApplication20 extends MockApplication12
         
         // install the 2.0-ViewHandler-Mock
         this.setViewHandler(new MockViewHandler20());
+        this.setResourceHandler(new MockResourceHandler());
     }
 
     private static class SystemListenerEntry
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockClassLoaderResourceLoader.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockClassLoaderResourceLoader.java
new file mode 100644
index 0000000..5064789
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockClassLoaderResourceLoader.java
@@ -0,0 +1,122 @@
+/*
+ * 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.resource;
+
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * A resource loader implementation which loads resources from the thread ClassLoader.
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 882702 $ $Date: 2009-11-20 15:16:07 -0500 (Vie, 20 Nov 2009) $
+ */
+public class MockClassLoaderResourceLoader extends MockResourceLoader
+{
+    private ClassLoader _classLoader;
+    
+    public MockClassLoaderResourceLoader(ClassLoader loader, String prefix)
+    {
+        super(prefix);
+        _classLoader = loader;
+    }
+
+    @Override
+    public String getLibraryVersion(String path)
+    {
+        return null;
+    }
+
+    @Override
+    public InputStream getResourceInputStream(MockResourceMeta resourceMeta)
+    {
+        if (getPrefix() != null && !"".equals(getPrefix()))
+        {
+            return getClassLoader().getResourceAsStream(getPrefix() + '/' + resourceMeta.getResourceIdentifier());
+        }
+        else
+        {
+            return getClassLoader().getResourceAsStream(resourceMeta.getResourceIdentifier());
+        }
+    }
+
+    @Override
+    public URL getResourceURL(MockResourceMeta resourceMeta)
+    {
+        if (getPrefix() != null && !"".equals(getPrefix()))
+        {
+            return getClassLoader().getResource(getPrefix() + '/' + resourceMeta.getResourceIdentifier());
+        }
+        else
+        {
+            return getClassLoader().getResource(resourceMeta.getResourceIdentifier());
+        }
+    }
+
+    @Override
+    public String getResourceVersion(String path)
+    {
+        return null;
+    }
+
+    @Override
+    public MockResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
+                                           String resourceName, String resourceVersion)
+    {
+        return new MockResourceMeta(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
+    }
+
+    /**
+     * Returns the ClassLoader to use when looking up resources under the top level package. By default, this is the
+     * context class loader.
+     * 
+     * @return the ClassLoader used to lookup resources
+     */
+    public ClassLoader getClassLoader()
+    {
+        return _classLoader;
+    }
+    
+    public void setClassLoader(ClassLoader loader)
+    {
+        _classLoader = loader;
+    }
+
+    @Override
+    public boolean libraryExists(String libraryName)
+    {
+        if (getPrefix() != null && !"".equals(getPrefix()))
+        {
+            URL url = getClassLoader().getResource(getPrefix() + '/' + libraryName);
+            if (url != null)
+            {
+                return true;
+            }
+        }
+        else
+        {
+            URL url = getClassLoader().getResource(libraryName);
+            if (url != null)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockExternalContextResourceLoader.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockExternalContextResourceLoader.java
new file mode 100644
index 0000000..f32372e
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockExternalContextResourceLoader.java
@@ -0,0 +1,208 @@
+/*
+ * 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.resource;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * A resource loader implementation which loads resources from the webapp root. 
+ * It uses the methods on ExternalContext for handle resources.
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 882702 $ $Date: 2009-11-20 15:16:07 -0500 (Vie, 20 Nov 2009) $
+ */
+public class MockExternalContextResourceLoader extends MockResourceLoader
+{
+    /**
+     * It checks version like this: /1/, /1_0/, /1_0_0/, /100_100/
+     * 
+     * Used on getLibraryVersion to filter resource directories
+     **/
+    protected static Pattern VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*/");
+
+    /**
+     * It checks version like this: /1.js, /1_0.js, /1_0_0.js, /100_100.js
+     * 
+     * Used on getResourceVersion to filter resources
+     **/
+    protected static Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*\\..*");
+
+    public MockExternalContextResourceLoader(String prefix)
+    {
+        super(prefix);
+    }
+
+    protected Set<String> getResourcePaths(String path)
+    {
+        return FacesContext.getCurrentInstance().getExternalContext().getResourcePaths(getPrefix() + '/' + path);
+    }
+
+    @Override
+    public String getResourceVersion(String path)
+    {
+        String resourceVersion = null;
+        Set<String> resourcePaths = this.getResourcePaths(path);
+        if (getPrefix() != null)
+            path = getPrefix() + '/' + path;
+
+        if (null != resourcePaths && !resourcePaths.isEmpty())
+        {
+            // resourceVersion = // execute the comment
+            // Look in the resourcePaths for versioned resources.
+            // If one or more versioned resources are found, take
+            // the one with the "highest" version number as the value
+            // of resourceVersion. If no versioned libraries
+            // are found, let resourceVersion remain null.
+            for (String resourcePath : resourcePaths)
+            {
+                String version = resourcePath.substring(path.length());
+
+                if (RESOURCE_VERSION_CHECKER.matcher(version).matches())
+                {
+                    version = version.substring(1, version.lastIndexOf('.'));
+                    if (resourceVersion == null)
+                    {
+                        resourceVersion = version;
+                    }
+                    else if (getVersionComparator().compare(resourceVersion, version) < 0)
+                    {
+                        resourceVersion = version;
+                    }
+                }
+            }
+            //Since it is a directory and no version was found, set as invalid
+            if (resourceVersion == null)
+            {
+                resourceVersion = VERSION_INVALID;
+            }
+        }
+        return resourceVersion;
+    }
+
+    @Override
+    public String getLibraryVersion(String path)
+    {
+        String libraryVersion = null;
+        Set<String> libraryPaths = this.getResourcePaths(path);
+        path = getPrefix() + '/' + path;
+        if (null != libraryPaths && !libraryPaths.isEmpty())
+        {
+            // Look in the libraryPaths for versioned libraries.
+            // If one or more versioned libraries are found, take
+            // the one with the "highest" version number as the value
+            // of libraryVersion. If no versioned libraries
+            // are found, let libraryVersion remain null.
+
+            for (Iterator<String> it = libraryPaths.iterator(); it.hasNext();)
+            {
+                String libraryPath = it.next();
+                String version = libraryPath.substring(path.length());
+
+                if (VERSION_CHECKER.matcher(version).matches())
+                {
+                    version = version.substring(1, version.length() - 1);
+                    if (libraryVersion == null)
+                    {
+                        libraryVersion = version;
+                    }
+                    else if (getVersionComparator().compare(libraryVersion, version) < 0)
+                    {
+                        libraryVersion = version;
+                    }
+                }
+            }
+        }
+        return libraryVersion;
+    }
+
+    @Override
+    public URL getResourceURL(MockResourceMeta resourceMeta)
+    {
+        try
+        {
+            return FacesContext.getCurrentInstance().getExternalContext().getResource(
+                getPrefix() + '/' + resourceMeta.getResourceIdentifier());
+        }
+        catch (MalformedURLException e)
+        {
+            return null;
+        }
+    }
+
+    @Override
+    public InputStream getResourceInputStream(MockResourceMeta resourceMeta)
+    {
+        return FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream(
+            getPrefix() + '/' + resourceMeta.getResourceIdentifier());
+    }
+
+    @Override
+    public MockResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
+                                           String resourceName, String resourceVersion)
+    {
+        return new MockResourceMeta(prefix, libraryName, libraryVersion, resourceName, resourceVersion);
+    }
+
+    @Override
+    public boolean libraryExists(String libraryName)
+    {
+        if (getPrefix() != null && !"".equals(getPrefix()))
+        {
+            try
+            {
+                URL url =
+                    FacesContext.getCurrentInstance().getExternalContext().getResource(
+                        getPrefix() + '/' + libraryName);
+                if (url != null)
+                {
+                    return true;
+                }
+            }
+            catch (MalformedURLException e)
+            {
+                return false;
+            }
+        }
+        else
+        {
+            try
+            {
+
+                URL url = FacesContext.getCurrentInstance().getExternalContext().getResource(libraryName);
+
+                if (url != null)
+                {
+                    return true;
+                }
+            }
+            catch (MalformedURLException e)
+            {
+                return false;
+            }
+        }
+        return false;
+    }
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResource.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResource.java
index f1d02b7..9c1fc94 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResource.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResource.java
@@ -17,115 +17,79 @@
 
 package org.apache.myfaces.test.mock.resource;
 
-import org.apache.myfaces.test.mock.MockServletContext;
-
-import javax.faces.application.Resource;
-import javax.faces.context.FacesContext;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Collections;
 import java.util.Map;
 
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+
 /**
  * <p>Mock implementation of <code>Resource</code>.</p>
  * <p/>
- * $Id$
- *
- * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
  */
 public class MockResource extends Resource
 {
-
-    private String _prefix;
-    private String _libraryName;
-    private String _libraryVersion;
-    private String _resourceName;
-    private String _resourceVersion;
-    private File _documentRoot;
-
-    /**
-     * Creates new resource object
-     *
-     * @param prefix          locale prefix if any
-     * @param libraryName     resource library name
-     * @param libraryVersion  resource library version if any
-     * @param resourceName    resource file name
-     * @param resourceVersion resource version if any
-     * @param documentRoot    parent folder of resource directories. Must not be <code>null</code>
-     */
-    public MockResource(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion, File documentRoot)
-    {
-        _prefix = prefix;
-        _libraryName = libraryName;
-        _libraryVersion = libraryVersion;
-        _resourceName = resourceName;
-        _resourceVersion = resourceVersion;
-        _documentRoot = documentRoot;
-
-        if (_documentRoot == null) {
-            throw new IllegalArgumentException("documentRoot must not be null");
-        }
-    }
-
-    @Override
-    public String getResourceName()
-    {
-        return _resourceName;
-    }
-
-    @Override
-    public void setResourceName(String resourceName)
-    {
-        _resourceName = resourceName;
-    }
-
-    @Override
-    public String getLibraryName()
+    private MockResourceMeta _resourceMeta;
+    private MockResourceLoader _resourceLoader;
+    private MockResourceHandlerSupport _resourceHandlerSupport;
+    
+    public MockResource(MockResourceMeta resourceMeta, 
+            MockResourceLoader resourceLoader, MockResourceHandlerSupport support, String contentType)
     {
-        return _libraryName;
+        _resourceMeta = resourceMeta;
+        _resourceLoader = resourceLoader;
+        _resourceHandlerSupport = support;
+        setLibraryName(resourceMeta.getLibraryName());
+        setResourceName(resourceMeta.getResourceName());
+        setContentType(contentType);
     }
     
-    @Override
-    public void setLibraryName(String libraryName)
+    public MockResourceLoader getResourceLoader()
     {
-        _libraryName = libraryName;
-    }
-
+        return _resourceLoader;
+    }    
+    
     @Override
     public InputStream getInputStream() throws IOException
     {
-        MockServletContext servletContext = (MockServletContext)
-            FacesContext.getCurrentInstance().getExternalContext().getContext();
-        servletContext.setDocumentRoot(_documentRoot);
-        return servletContext.getResourceAsStream(buildResourcePath());
+        return getResourceLoader().getResourceInputStream(_resourceMeta);            
     }
 
     @Override
     public String getRequestPath()
     {
-        throw new UnsupportedOperationException();
+        String path;
+        if (_resourceHandlerSupport.isExtensionMapping())
+        {
+            path = ResourceHandler.RESOURCE_IDENTIFIER + '/' + 
+                getResourceName() + _resourceHandlerSupport.getMapping();
+        }
+        else
+        {
+            String mapping = _resourceHandlerSupport.getMapping(); 
+            path = ResourceHandler.RESOURCE_IDENTIFIER + '/' + getResourceName();
+            path = (mapping == null) ? path : mapping + path;
+        }
+        
+        return path;
     }
 
     @Override
     public Map<String, String> getResponseHeaders()
     {
-        throw new UnsupportedOperationException();
+        return Collections.emptyMap();
     }
 
     @Override
     public URL getURL()
     {
-        MockServletContext servletContext = (MockServletContext)
-            FacesContext.getCurrentInstance().getExternalContext().getContext();
-        servletContext.setDocumentRoot(_documentRoot);
-
-        try {
-            return servletContext.getResource(buildResourcePath());
-        } catch (MalformedURLException e) {
-            return null;
-        }
+        return getResourceLoader().getResourceURL(_resourceMeta);
     }
 
     @Override
@@ -133,47 +97,4 @@ public class MockResource extends Resource
     {
         return true;
     }
-
-    private String buildResourcePath()
-    {
-        StringBuilder builder = new StringBuilder();
-        builder.append('/');
-        boolean firstSlashAdded = false;
-        if (_prefix != null && _prefix.length() > 0) {
-            builder.append(_prefix);
-            firstSlashAdded = true;
-        }
-        if (_libraryName != null) {
-            if (firstSlashAdded) {
-                builder.append('/');
-            }
-            builder.append(_libraryName);
-            firstSlashAdded = true;
-        }
-        if (_libraryVersion != null) {
-            if (firstSlashAdded) {
-                builder.append('/');
-            }
-            builder.append(_libraryVersion);
-            firstSlashAdded = true;
-        }
-        if (_resourceName != null) {
-            if (firstSlashAdded) {
-                builder.append('/');
-            }
-            builder.append(_resourceName);
-            firstSlashAdded = true;
-        }
-        if (_resourceVersion != null) {
-            if (firstSlashAdded) {
-                builder.append('/');
-            }
-            builder.append(_resourceVersion);
-            builder.append(
-                _resourceName.substring(_resourceName.lastIndexOf('.')));
-        }
-
-        return builder.toString();
-    }
-
-}
+}
\ No newline at end of file
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandler.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandler.java
index 75addb5..e3d6243 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandler.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandler.java
@@ -17,64 +17,64 @@
 
 package org.apache.myfaces.test.mock.resource;
 
-import org.apache.myfaces.test.mock.MockServletContext;
-
-import javax.faces.FacesException;
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
-import java.util.*;
-import java.util.regex.Pattern;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.faces.FacesException;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
 
 /**
  * <p>Mock implementation of <code>ResourceHandler</code>.</p>
- * <p/>
- * $Id$
+ * <p>This ResourceHandler implementation try to follow the default algorithm
+ * defined by the spec, so it try to load resources using the current 
+ * ExternalContext and the specified ClassLoader, in the same locations
+ * it is expected ("resources" and "META-INF/resources").</p>
  * 
- * @since 2.0
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
  */
 public class MockResourceHandler extends ResourceHandler
 {
 
-    private static final String IS_RESOURCE_REQUEST = "org.apache.myfaces.IS_RESOURCE_REQUEST";
+    private boolean _resourceRequest;
 
-    /**
-     * It checks version like this: /1/, /1_0/, /1_0_0/, /100_100/
-     * <p/>
-     * Used on getLibraryVersion to filter resource directories
-     */
-    protected static Pattern VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*/");
+    private MockResourceHandlerSupport resourceHandlerSupport;
+    
+    private ClassLoader _classLoader;
 
-    /**
-     * It checks version like this: /1.js, /1_0.js, /1_0_0.js, /100_100.js
-     * <p/>
-     * Used on getResourceVersion to filter resources
-     */
-    protected static Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*\\..*");
-
-    private File _documentRoot;
-
-    /**
-     * @param documentRoot parent folder of resource directories. Must not be <code>null</code>
-     */
-    public MockResourceHandler(File documentRoot)
+    public MockResourceHandler()
     {
-        if (documentRoot == null) {
-            throw new NullPointerException("documentRoot must not be null");
-        }
-
-        _documentRoot = documentRoot;
-
-        ((MockServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
-            .setDocumentRoot(_documentRoot);
+        _classLoader = getContextClassLoader();
+        resourceHandlerSupport = new MockResourceHandlerSupport(true, ".jsf",_classLoader);
+    }
+    
+    public MockResourceHandler(ClassLoader classLoader)
+    {
+        if (classLoader == null)
+            _classLoader = getContextClassLoader();
+        else
+            _classLoader = classLoader;
+        
+        resourceHandlerSupport = new MockResourceHandlerSupport(true, ".jsf",_classLoader);
+    }
+    
+    public MockResourceHandler(boolean extensionMapping, String mapping, ClassLoader classLoader)
+    {
+        if (classLoader == null)
+            _classLoader = getContextClassLoader();
+        else
+            _classLoader = classLoader;
+        
+        resourceHandlerSupport = new MockResourceHandlerSupport(extensionMapping, mapping,_classLoader);
     }
 
     @Override
@@ -92,22 +92,147 @@ public class MockResourceHandler extends ResourceHandler
     @Override
     public Resource createResource(String resourceName, String libraryName, String contentType)
     {
-        String prefix = getLocalePrefixForLocateResource();
-        String libraryVersion = getLibraryVersion(prefix + "/" + libraryName);
-
-        String pathToResource;
-        if (null != libraryVersion) {
-            pathToResource = prefix + '/'
-                + libraryName + '/' + libraryVersion + '/'
-                + resourceName;
-        }
-        else {
-            pathToResource = prefix + '/'
-                + libraryName + '/' + resourceName;
+        Resource resource = null;
+        
+        if (contentType == null)
+        {
+            //Resolve contentType using ExternalContext.getMimeType
+            contentType = FacesContext.getCurrentInstance().getExternalContext().getMimeType(resourceName);
         }
 
-        return new MockResource(prefix, libraryName, libraryVersion, resourceName, getResourceVersion(pathToResource), _documentRoot);
+        for (MockResourceLoader loader : getResourceHandlerSupport()
+                .getResourceLoaders())
+        {
+            MockResourceMeta resourceMeta = deriveResourceMeta(loader,
+                    resourceName, libraryName);
+
+            if (resourceMeta != null)
+            {
+                resource = new MockResource(resourceMeta, loader,
+                        getResourceHandlerSupport(), contentType);
+                break;
+            }
+        }
+        return resource;
     }
+    
+    /**
+     * This method try to create a ResourceMeta for a specific resource
+     * loader. If no library, or resource is found, just return null,
+     * so the algorithm in createResource can continue checking with the 
+     * next registered ResourceLoader. 
+     */
+    protected MockResourceMeta deriveResourceMeta(MockResourceLoader resourceLoader,
+            String resourceName, String libraryName)
+    {
+        String localePrefix = getLocalePrefixForLocateResource();
+        String resourceVersion = null;
+        String libraryVersion = null;
+        MockResourceMeta resourceId = null;
+        
+        //1. Try to locate resource in a localized path
+        if (localePrefix != null)
+        {
+            if (null != libraryName)
+            {
+                String pathToLib = localePrefix + '/' + libraryName;
+                libraryVersion = resourceLoader.getLibraryVersion(pathToLib);
+
+                if (null != libraryVersion)
+                {
+                    String pathToResource = localePrefix + '/'
+                            + libraryName + '/' + libraryVersion + '/'
+                            + resourceName;
+                    resourceVersion = resourceLoader
+                            .getResourceVersion(pathToResource);
+                }
+                else
+                {
+                    String pathToResource = localePrefix + '/'
+                            + libraryName + '/' + resourceName;
+                    resourceVersion = resourceLoader
+                            .getResourceVersion(pathToResource);
+                }
+
+                if (!(resourceVersion != null && MockResourceLoader.VERSION_INVALID.equals(resourceVersion)))
+                {
+                    resourceId = resourceLoader.createResourceMeta(localePrefix, libraryName,
+                            libraryVersion, resourceName, resourceVersion);
+                }
+            }
+            else
+            {
+                resourceVersion = resourceLoader
+                        .getResourceVersion(localePrefix + '/'+ resourceName);
+                if (!(resourceVersion != null && MockResourceLoader.VERSION_INVALID.equals(resourceVersion)))
+                {               
+                    resourceId = resourceLoader.createResourceMeta(localePrefix, null, null,
+                            resourceName, resourceVersion);
+                }
+            }
+
+            if (resourceId != null)
+            {
+                URL url = resourceLoader.getResourceURL(resourceId);
+                if (url == null)
+                {
+                    resourceId = null;
+                }
+            }            
+        }
+        
+        //2. Try to localize resource in a non localized path
+        if (resourceId == null)
+        {
+            if (null != libraryName)
+            {
+                libraryVersion = resourceLoader.getLibraryVersion(libraryName);
+
+                if (null != libraryVersion)
+                {
+                    String pathToResource = (libraryName + '/' + libraryVersion
+                            + '/' + resourceName);
+                    resourceVersion = resourceLoader
+                            .getResourceVersion(pathToResource);
+                }
+                else
+                {
+                    String pathToResource = (libraryName + '/'
+                            + resourceName);
+                    resourceVersion = resourceLoader
+                            .getResourceVersion(pathToResource);
+                }
+
+                if (!(resourceVersion != null && MockResourceLoader.VERSION_INVALID.equals(resourceVersion)))
+                {               
+                    resourceId = resourceLoader.createResourceMeta(null, libraryName,
+                            libraryVersion, resourceName, resourceVersion);
+                }
+            }
+            else
+            {
+                resourceVersion = resourceLoader
+                        .getResourceVersion(resourceName);
+                
+                if (!(resourceVersion != null && MockResourceLoader.VERSION_INVALID.equals(resourceVersion)))
+                {               
+                    resourceId = resourceLoader.createResourceMeta(null, null, null,
+                            resourceName, resourceVersion);
+                }
+            }
+
+            if (resourceId != null)
+            {
+                URL url = resourceLoader.getResourceURL(resourceId);
+                if (url == null)
+                {
+                    resourceId = null;
+                }
+            }            
+        }
+        
+        return resourceId;
+    }    
 
     @Override
     public String getRendererTypeForResourceName(String resourceName)
@@ -130,33 +255,7 @@ public class MockResourceHandler extends ResourceHandler
     @Override
     public boolean isResourceRequest(FacesContext facesContext)
     {
-        // Since this method could be called many times we save it
-        //on request map so the first time is calculated it remains
-        //alive until the end of the request
-        Boolean value = (Boolean) facesContext.getExternalContext()
-            .getRequestMap().get(IS_RESOURCE_REQUEST);
-
-        if (value != null && value.booleanValue()) {
-            //return the saved value
-            return value.booleanValue();
-        }
-        else {
-            // assuming that we don't have servlet mapping
-            String resourceBasePath = facesContext.getExternalContext().getRequestPathInfo();
-
-            if (resourceBasePath != null
-                && resourceBasePath
-                .startsWith(ResourceHandler.RESOURCE_IDENTIFIER)) {
-                facesContext.getExternalContext().getRequestMap().put(
-                    IS_RESOURCE_REQUEST, Boolean.TRUE);
-                return true;
-            }
-            else {
-                facesContext.getExternalContext().getRequestMap().put(
-                    IS_RESOURCE_REQUEST, Boolean.FALSE);
-                return false;
-            }
-        }
+        return _resourceRequest;
     }
 
     @Override
@@ -214,9 +313,8 @@ public class MockResourceHandler extends ResourceHandler
      * against java2 security to ensure no security related exceptions are encountered.
      *
      * @return ClassLoader
-     * @since 3.0.6
      */
-    private static ClassLoader getContextClassLoader()
+    static ClassLoader getContextClassLoader()
     {
         if (System.getSecurityManager() != null) {
             try {
@@ -238,114 +336,24 @@ public class MockResourceHandler extends ResourceHandler
         }
     }
 
-    private String getLibraryVersion(String path)
+    public MockResourceHandlerSupport getResourceHandlerSupport()
     {
-        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
-
-        String libraryVersion = null;
-        Set<String> libraryPaths = context.getResourcePaths("/" + path);
-        if (null != libraryPaths && !libraryPaths.isEmpty()) {
-            // Look in the libraryPaths for versioned libraries.
-            // If one or more versioned libraries are found, take
-            // the one with the "highest" version number as the value
-            // of libraryVersion. If no versioned libraries
-            // are found, let libraryVersion remain null.
-
-            for (String libraryPath : libraryPaths) {
-                String version = libraryPath.substring(path.length());
-
-                if (VERSION_CHECKER.matcher(version).matches()) {
-                    version = version.substring(1, version.length() - 1);
-                    if (libraryVersion == null) {
-                        libraryVersion = version;
-                    }
-                    else if (compareVersion(libraryVersion, version) < 0) {
-                        libraryVersion = version;
-                    }
-                }
-            }
-        }
-        return libraryVersion;
+        return resourceHandlerSupport;
     }
 
-    private int compareVersion(String s1, String s2)
+    public void setResourceHandlerSupport(
+            MockResourceHandlerSupport resourceHandlerSupport)
     {
-        int n1 = 0;
-        int n2 = 0;
-        String o1 = s1;
-        String o2 = s2;
-
-        boolean p1 = true;
-        boolean p2 = true;
-
-        while (n1 == n2 && (p1 || p2)) {
-            int i1 = o1.indexOf('_');
-            int i2 = o2.indexOf('_');
-            if (i1 < 0) {
-                if (o1.length() > 0) {
-                    p1 = false;
-                    n1 = Integer.valueOf(o1);
-                    o1 = "";
-                }
-                else {
-                    p1 = false;
-                    n1 = 0;
-                }
-            }
-            else {
-                n1 = Integer.valueOf(o1.substring(0, i1));
-                o1 = o1.substring(i1 + 1);
-            }
-            if (i2 < 0) {
-                if (o2.length() > 0) {
-                    p2 = false;
-                    n2 = Integer.valueOf(o2);
-                    o2 = "";
-                }
-                else {
-                    p2 = false;
-                    n2 = 0;
-                }
-            }
-            else {
-                n2 = Integer.valueOf(o2.substring(0, i2));
-                o2 = o2.substring(i2 + 1);
-            }
-        }
+        this.resourceHandlerSupport = resourceHandlerSupport;
+    }
 
-        if (n1 == n2) {
-            return s1.length() - s2.length();
-        }
-        return n1 - n2;
+    public void setResourceRequest(boolean resourceRequest)
+    {
+        this._resourceRequest = resourceRequest;
     }
 
-    private String getResourceVersion(String path)
+    public boolean isResourceRequest()
     {
-        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
-        String resourceVersion = null;
-        Set<String> resourcePaths = context.getResourcePaths("/" + path);
-
-        if (null != resourcePaths && !resourcePaths.isEmpty()) {
-            // resourceVersion = // execute the comment
-            // Look in the resourcePaths for versioned resources.
-            // If one or more versioned resources are found, take
-            // the one with the "highest" version number as the value
-            // of resourceVersion. If no versioned libraries
-            // are found, let resourceVersion remain null.
-            for (String resourcePath : resourcePaths) {
-                String version = resourcePath.substring(path.length());
-
-                if (RESOURCE_VERSION_CHECKER.matcher(version).matches()) {
-                    version = version.substring(1, version.lastIndexOf('.'));
-                    if (resourceVersion == null) {
-                        resourceVersion = version;
-                    }
-                    else if (compareVersion(resourceVersion, version) < 0) {
-                        resourceVersion = version;
-                    }
-                }
-            }
-        }
-        return resourceVersion;
+        return _resourceRequest;
     }
-}
+}
\ No newline at end of file
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandlerSupport.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandlerSupport.java
new file mode 100644
index 0000000..fb90f43
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandlerSupport.java
@@ -0,0 +1,115 @@
+/*
+ * 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.resource;
+
+
+/**
+ * Store additional info used by MockResource and MockResourceHandler
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: jakobk $)
+ * @version $Revision: 960906 $ $Date: 2010-07-06 09:45:40 -0500 (Mar, 06 Jul 2010) $
+ */
+public class MockResourceHandlerSupport
+{
+
+    private boolean _extensionMapping;
+
+    private String _mapping;
+
+    private MockResourceLoader[] _resourceLoaders;
+
+    public MockResourceHandlerSupport()
+    {
+        _extensionMapping = true;
+        _mapping = ".jsf";
+        _resourceLoaders = new MockResourceLoader[]{ new MockExternalContextResourceLoader("/resources"),
+                new MockClassLoaderResourceLoader(MockResourceHandler.getContextClassLoader(), "META-INF/resources")};
+    }
+    
+    public MockResourceHandlerSupport(boolean extensionMapping, String mapping)
+    {
+        super();
+        _extensionMapping = extensionMapping;
+        _mapping = mapping;
+        _resourceLoaders = new MockResourceLoader[]{ new MockExternalContextResourceLoader("/resources"),
+                new MockClassLoaderResourceLoader(MockResourceHandler.getContextClassLoader(), "META-INF/resources")};
+    }
+
+    public MockResourceHandlerSupport(boolean extensionMapping, String mapping, ClassLoader classLoader)
+    {
+        _extensionMapping = extensionMapping;
+        _mapping = mapping;
+        _resourceLoaders = new MockResourceLoader[]{ new MockExternalContextResourceLoader("/resources"),
+                new MockClassLoaderResourceLoader(classLoader, "META-INF/resources")};
+    }
+
+    public MockResourceHandlerSupport(boolean extensionMapping, String mapping,
+            MockResourceLoader[] resourceLoaders)
+    {
+        super();
+        _extensionMapping = extensionMapping;
+        _mapping = mapping;
+        _resourceLoaders = resourceLoaders;
+    }
+
+    /**
+     * Check if the mapping used is done using extensions (.xhtml, .jsf)
+     * or if it is not (/faces/*)
+     * @return
+     */
+    public boolean isExtensionMapping()
+    {
+        return _extensionMapping;
+    }
+    
+    public void setExtensionMapping(boolean extensionMapping)
+    {
+        _extensionMapping = extensionMapping;
+    }
+
+    /**
+     * Get the mapping used as prefix(/faces) or sufix(.jsf)
+     * 
+     * @return
+     */
+    public String getMapping()
+    {
+        return _mapping;
+    }
+    
+    public void setMapping(String prefix)
+    {
+        _mapping = prefix;
+    }
+    
+    /**
+     * Return an array of resource loaders used to find resources
+     * using the standard. The order of ResourceLoaders define
+     * its precedence. 
+     * 
+     * @return
+     */
+    public MockResourceLoader[] getResourceLoaders()
+    {
+        return _resourceLoaders; 
+    }
+
+    public void setResourceLoaders(MockResourceLoader[] resourceLoaders)
+    {
+        _resourceLoaders = resourceLoaders;
+    }
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceLoader.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceLoader.java
new file mode 100644
index 0000000..81bf0e2
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceLoader.java
@@ -0,0 +1,155 @@
+/*
+ * 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.resource;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Comparator;
+
+/**
+ * Base class for resource loaders.  Resource loaders can lookup resources 
+ * as URLs from arbitrary locations, including JAR files.
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 882702 $ $Date: 2009-11-20 15:16:07 -0500 (Vie, 20 Nov 2009) $
+ */
+public abstract class MockResourceLoader
+{
+    
+    public static final String VERSION_INVALID = "INVALID";
+    
+    private String _prefix;
+    
+    public MockResourceLoader(String prefix)
+    {
+        _prefix = prefix;
+    }
+
+    public abstract String getResourceVersion(String path);
+
+    /**
+     * Return the max available version found (if exists) or
+     * return null if no version available. 
+     */
+    public abstract String getLibraryVersion(String path);
+
+    /**
+     * Return the max available version found (if exists) or
+     * return null if no version available. 
+     */
+    public abstract URL getResourceURL(MockResourceMeta resourceMeta);
+
+    public abstract InputStream getResourceInputStream(MockResourceMeta resourceMeta);
+    
+    public abstract MockResourceMeta createResourceMeta(String prefix, String libraryName, String libraryVersion,
+            String resourceName, String resourceVersion);
+    
+    public abstract boolean libraryExists(String libraryName);
+    
+    private Comparator<String> _versionComparator = null;
+
+    protected Comparator<String> getVersionComparator()
+    {
+        if (_versionComparator == null)
+        {
+            _versionComparator = new VersionComparator();
+        }
+        return _versionComparator;
+    }
+
+    protected void setVersionComparator(Comparator<String> versionComparator)
+    {
+        _versionComparator = versionComparator;
+    }
+
+    public class VersionComparator implements Comparator<String>
+    {
+
+        public int compare(String s1, String s2)
+        {
+            int n1 = 0;
+            int n2 = 0;
+            String o1 = s1;
+            String o2 = s2;
+
+            boolean p1 = true;
+            boolean p2 = true;
+
+            while (n1 == n2 && (p1 || p2))
+            {
+                int i1 = o1.indexOf('_');
+                int i2 = o2.indexOf('_');
+                if (i1 < 0)
+                {
+                    if (o1.length() > 0)
+                    {
+                        p1 = false;
+                        n1 = Integer.valueOf(o1);
+                        o1 = "";
+                    }
+                    else
+                    {
+                        p1 = false;
+                        n1 = 0;
+                    }
+                }
+                else
+                {
+                    n1 = Integer.valueOf(o1.substring(0, i1));
+                    o1 = o1.substring(i1 + 1);
+                }
+                if (i2 < 0)
+                {
+                    if (o2.length() > 0)
+                    {
+                        p2 = false;
+                        n2 = Integer.valueOf(o2);
+                        o2 = "";
+                    }
+                    else
+                    {
+                        p2 = false;
+                        n2 = 0;
+                    }
+                }
+                else
+                {
+                    n2 = Integer.valueOf(o2.substring(0, i2));
+                    o2 = o2.substring(i2 + 1);
+                }
+            }
+
+            if (n1 == n2)
+            {
+                return s1.length() - s2.length();
+            }
+            return n1 - n2;
+        }
+    }
+    
+    public String getPrefix()
+    {
+        return _prefix;
+    }
+
+    public void setPrefix(String prefix)
+    {
+        _prefix = prefix;
+    }
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceMeta.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceMeta.java
new file mode 100644
index 0000000..9fee22e
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceMeta.java
@@ -0,0 +1,110 @@
+/*
+ * 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.resource;
+
+/**
+ * Contains the metadata information to reference a resource 
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 946779 $ $Date: 2010-05-20 15:31:42 -0500 (Jue, 20 May 2010) $
+ */
+public class MockResourceMeta
+{
+    
+    private final String _prefix;
+    private final String _libraryName;
+    private final String _libraryVersion;
+    private final String _resourceName;
+    private final String _resourceVersion;
+    
+    public MockResourceMeta(String prefix, String libraryName, String libraryVersion,
+            String resourceName, String resourceVersion)
+    {
+        _prefix = prefix;
+        _libraryName = libraryName;
+        _libraryVersion = libraryVersion;
+        _resourceName = resourceName;
+        _resourceVersion = resourceVersion;
+    }
+
+    public String getLibraryName()
+    {
+        return _libraryName;
+    }    
+    
+    public String getResourceName()
+    {
+        return _resourceName;
+    }    
+
+    public String getLocalePrefix()
+    {
+        return _prefix;
+    }
+
+    public String getLibraryVersion()
+    {
+        return _libraryVersion;
+    }
+
+    public String getResourceVersion()
+    {
+        return _resourceVersion;
+    }
+    
+    public String getResourceIdentifier()
+    {
+        StringBuilder builder = new StringBuilder();
+        boolean firstSlashAdded = false;
+        if (_prefix != null && _prefix.length() > 0)
+        {
+            builder.append(_prefix);
+            firstSlashAdded = true;
+        }
+        if (_libraryName != null)
+        {
+            if (firstSlashAdded) builder.append('/');
+            builder.append(_libraryName);
+            firstSlashAdded = true;
+        }
+        if (_libraryVersion != null)
+        {
+            if (firstSlashAdded) builder.append('/');
+            builder.append(_libraryVersion);
+            firstSlashAdded = true;
+        }
+        if (_resourceName != null)
+        {
+            if (firstSlashAdded) builder.append('/');
+            builder.append(_resourceName);
+            firstSlashAdded = true;
+        }
+        if (_resourceVersion != null)
+        {
+            if (firstSlashAdded) builder.append('/');
+            builder.append(_resourceVersion);
+            builder.append(
+                    _resourceName.substring(_resourceName.lastIndexOf('.')));
+            firstSlashAdded = true;
+        }
+
+        return builder.toString();
+    }
+
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResource.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockSimpleResource.java
similarity index 87%
copy from test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResource.java
copy to test20/src/main/java/org/apache/myfaces/test/mock/resource/MockSimpleResource.java
index f1d02b7..56dbcc9 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResource.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockSimpleResource.java
@@ -1,179 +1,182 @@
-/*
- * 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.resource;
-
-import org.apache.myfaces.test.mock.MockServletContext;
-
-import javax.faces.application.Resource;
-import javax.faces.context.FacesContext;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
-/**
- * <p>Mock implementation of <code>Resource</code>.</p>
- * <p/>
- * $Id$
- *
- * @since 2.0
- */
-public class MockResource extends Resource
-{
-
-    private String _prefix;
-    private String _libraryName;
-    private String _libraryVersion;
-    private String _resourceName;
-    private String _resourceVersion;
-    private File _documentRoot;
-
-    /**
-     * Creates new resource object
-     *
-     * @param prefix          locale prefix if any
-     * @param libraryName     resource library name
-     * @param libraryVersion  resource library version if any
-     * @param resourceName    resource file name
-     * @param resourceVersion resource version if any
-     * @param documentRoot    parent folder of resource directories. Must not be <code>null</code>
-     */
-    public MockResource(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion, File documentRoot)
-    {
-        _prefix = prefix;
-        _libraryName = libraryName;
-        _libraryVersion = libraryVersion;
-        _resourceName = resourceName;
-        _resourceVersion = resourceVersion;
-        _documentRoot = documentRoot;
-
-        if (_documentRoot == null) {
-            throw new IllegalArgumentException("documentRoot must not be null");
-        }
-    }
-
-    @Override
-    public String getResourceName()
-    {
-        return _resourceName;
-    }
-
-    @Override
-    public void setResourceName(String resourceName)
-    {
-        _resourceName = resourceName;
-    }
-
-    @Override
-    public String getLibraryName()
-    {
-        return _libraryName;
-    }
-    
-    @Override
-    public void setLibraryName(String libraryName)
-    {
-        _libraryName = libraryName;
-    }
-
-    @Override
-    public InputStream getInputStream() throws IOException
-    {
-        MockServletContext servletContext = (MockServletContext)
-            FacesContext.getCurrentInstance().getExternalContext().getContext();
-        servletContext.setDocumentRoot(_documentRoot);
-        return servletContext.getResourceAsStream(buildResourcePath());
-    }
-
-    @Override
-    public String getRequestPath()
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, String> getResponseHeaders()
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public URL getURL()
-    {
-        MockServletContext servletContext = (MockServletContext)
-            FacesContext.getCurrentInstance().getExternalContext().getContext();
-        servletContext.setDocumentRoot(_documentRoot);
-
-        try {
-            return servletContext.getResource(buildResourcePath());
-        } catch (MalformedURLException e) {
-            return null;
-        }
-    }
-
-    @Override
-    public boolean userAgentNeedsUpdate(FacesContext context)
-    {
-        return true;
-    }
-
-    private String buildResourcePath()
-    {
-        StringBuilder builder = new StringBuilder();
-        builder.append('/');
-        boolean firstSlashAdded = false;
-        if (_prefix != null && _prefix.length() > 0) {
-            builder.append(_prefix);
-            firstSlashAdded = true;
-        }
-        if (_libraryName != null) {
-            if (firstSlashAdded) {
-                builder.append('/');
-            }
-            builder.append(_libraryName);
-            firstSlashAdded = true;
-        }
-        if (_libraryVersion != null) {
-            if (firstSlashAdded) {
-                builder.append('/');
-            }
-            builder.append(_libraryVersion);
-            firstSlashAdded = true;
-        }
-        if (_resourceName != null) {
-            if (firstSlashAdded) {
-                builder.append('/');
-            }
-            builder.append(_resourceName);
-            firstSlashAdded = true;
-        }
-        if (_resourceVersion != null) {
-            if (firstSlashAdded) {
-                builder.append('/');
-            }
-            builder.append(_resourceVersion);
-            builder.append(
-                _resourceName.substring(_resourceName.lastIndexOf('.')));
-        }
-
-        return builder.toString();
-    }
-
-}
+/*
+ * 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.resource;
+
+import org.apache.myfaces.test.mock.MockServletContext;
+
+import javax.faces.application.Resource;
+import javax.faces.context.FacesContext;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+/**
+ * <p>Mock simple implementation of <code>Resource</code>.</p>
+ * 
+ * <p>
+ * It is used by MockSimpleResourceHandler to wrap resource instances.
+ * </p>
+ * 
+ * @author Jakob Korherr (latest modification by $Author: lu4242 $)
+ * @version $Revision: 882702 $ $Date: 2009-11-20 15:16:07 -0500 (Vie, 20 Nov 2009) $
+ */
+public class MockSimpleResource extends Resource
+{
+
+    private String _prefix;
+    private String _libraryName;
+    private String _libraryVersion;
+    private String _resourceName;
+    private String _resourceVersion;
+    private File _documentRoot;
+
+    /**
+     * Creates new resource object
+     *
+     * @param prefix          locale prefix if any
+     * @param libraryName     resource library name
+     * @param libraryVersion  resource library version if any
+     * @param resourceName    resource file name
+     * @param resourceVersion resource version if any
+     * @param documentRoot    parent folder of resource directories. Must not be <code>null</code>
+     */
+    public MockSimpleResource(String prefix, String libraryName, String libraryVersion, String resourceName, String resourceVersion, File documentRoot)
+    {
+        _prefix = prefix;
+        _libraryName = libraryName;
+        _libraryVersion = libraryVersion;
+        _resourceName = resourceName;
+        _resourceVersion = resourceVersion;
+        _documentRoot = documentRoot;
+
+        if (_documentRoot == null) {
+            throw new IllegalArgumentException("documentRoot must not be null");
+        }
+    }
+
+    @Override
+    public String getResourceName()
+    {
+        return _resourceName;
+    }
+
+    @Override
+    public void setResourceName(String resourceName)
+    {
+        _resourceName = resourceName;
+    }
+
+    @Override
+    public String getLibraryName()
+    {
+        return _libraryName;
+    }
+    
+    @Override
+    public void setLibraryName(String libraryName)
+    {
+        _libraryName = libraryName;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException
+    {
+        MockServletContext servletContext = (MockServletContext)
+            FacesContext.getCurrentInstance().getExternalContext().getContext();
+        servletContext.setDocumentRoot(_documentRoot);
+        return servletContext.getResourceAsStream(buildResourcePath());
+    }
+
+    @Override
+    public String getRequestPath()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Map<String, String> getResponseHeaders()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public URL getURL()
+    {
+        MockServletContext servletContext = (MockServletContext)
+            FacesContext.getCurrentInstance().getExternalContext().getContext();
+        servletContext.setDocumentRoot(_documentRoot);
+
+        try {
+            return servletContext.getResource(buildResourcePath());
+        } catch (MalformedURLException e) {
+            return null;
+        }
+    }
+
+    @Override
+    public boolean userAgentNeedsUpdate(FacesContext context)
+    {
+        return true;
+    }
+
+    private String buildResourcePath()
+    {
+        StringBuilder builder = new StringBuilder();
+        builder.append('/');
+        boolean firstSlashAdded = false;
+        if (_prefix != null && _prefix.length() > 0) {
+            builder.append(_prefix);
+            firstSlashAdded = true;
+        }
+        if (_libraryName != null) {
+            if (firstSlashAdded) {
+                builder.append('/');
+            }
+            builder.append(_libraryName);
+            firstSlashAdded = true;
+        }
+        if (_libraryVersion != null) {
+            if (firstSlashAdded) {
+                builder.append('/');
+            }
+            builder.append(_libraryVersion);
+            firstSlashAdded = true;
+        }
+        if (_resourceName != null) {
+            if (firstSlashAdded) {
+                builder.append('/');
+            }
+            builder.append(_resourceName);
+            firstSlashAdded = true;
+        }
+        if (_resourceVersion != null) {
+            if (firstSlashAdded) {
+                builder.append('/');
+            }
+            builder.append(_resourceVersion);
+            builder.append(
+                _resourceName.substring(_resourceName.lastIndexOf('.')));
+        }
+
+        return builder.toString();
+    }
+
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandler.java b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockSimpleResourceHandler.java
similarity index 93%
copy from test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandler.java
copy to test20/src/main/java/org/apache/myfaces/test/mock/resource/MockSimpleResourceHandler.java
index 75addb5..eebf58f 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockResourceHandler.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/resource/MockSimpleResourceHandler.java
@@ -1,351 +1,352 @@
-/*
- * 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.resource;
-
-import org.apache.myfaces.test.mock.MockServletContext;
-
-import javax.faces.FacesException;
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.*;
-import java.util.regex.Pattern;
-
-/**
- * <p>Mock implementation of <code>ResourceHandler</code>.</p>
- * <p/>
- * $Id$
- * 
- * @since 2.0
- */
-public class MockResourceHandler extends ResourceHandler
-{
-
-    private static final String IS_RESOURCE_REQUEST = "org.apache.myfaces.IS_RESOURCE_REQUEST";
-
-    /**
-     * It checks version like this: /1/, /1_0/, /1_0_0/, /100_100/
-     * <p/>
-     * Used on getLibraryVersion to filter resource directories
-     */
-    protected static Pattern VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*/");
-
-    /**
-     * It checks version like this: /1.js, /1_0.js, /1_0_0.js, /100_100.js
-     * <p/>
-     * Used on getResourceVersion to filter resources
-     */
-    protected static Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*\\..*");
-
-    private File _documentRoot;
-
-    /**
-     * @param documentRoot parent folder of resource directories. Must not be <code>null</code>
-     */
-    public MockResourceHandler(File documentRoot)
-    {
-        if (documentRoot == null) {
-            throw new NullPointerException("documentRoot must not be null");
-        }
-
-        _documentRoot = documentRoot;
-
-        ((MockServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
-            .setDocumentRoot(_documentRoot);
-    }
-
-    @Override
-    public Resource createResource(String resourceName)
-    {
-        return createResource(resourceName, null);
-    }
-
-    @Override
-    public Resource createResource(String resourceName, String libraryName)
-    {
-        return createResource(resourceName, libraryName, null);
-    }
-
-    @Override
-    public Resource createResource(String resourceName, String libraryName, String contentType)
-    {
-        String prefix = getLocalePrefixForLocateResource();
-        String libraryVersion = getLibraryVersion(prefix + "/" + libraryName);
-
-        String pathToResource;
-        if (null != libraryVersion) {
-            pathToResource = prefix + '/'
-                + libraryName + '/' + libraryVersion + '/'
-                + resourceName;
-        }
-        else {
-            pathToResource = prefix + '/'
-                + libraryName + '/' + resourceName;
-        }
-
-        return new MockResource(prefix, libraryName, libraryVersion, resourceName, getResourceVersion(pathToResource), _documentRoot);
-    }
-
-    @Override
-    public String getRendererTypeForResourceName(String resourceName)
-    {
-        if (resourceName.endsWith(".js")) {
-            return "javax.faces.resource.Script";
-        }
-        else if (resourceName.endsWith(".css")) {
-            return "javax.faces.resource.Stylesheet";
-        }
-        return null;
-    }
-
-    @Override
-    public void handleResourceRequest(FacesContext context) throws IOException
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public boolean isResourceRequest(FacesContext facesContext)
-    {
-        // Since this method could be called many times we save it
-        //on request map so the first time is calculated it remains
-        //alive until the end of the request
-        Boolean value = (Boolean) facesContext.getExternalContext()
-            .getRequestMap().get(IS_RESOURCE_REQUEST);
-
-        if (value != null && value.booleanValue()) {
-            //return the saved value
-            return value.booleanValue();
-        }
-        else {
-            // assuming that we don't have servlet mapping
-            String resourceBasePath = facesContext.getExternalContext().getRequestPathInfo();
-
-            if (resourceBasePath != null
-                && resourceBasePath
-                .startsWith(ResourceHandler.RESOURCE_IDENTIFIER)) {
-                facesContext.getExternalContext().getRequestMap().put(
-                    IS_RESOURCE_REQUEST, Boolean.TRUE);
-                return true;
-            }
-            else {
-                facesContext.getExternalContext().getRequestMap().put(
-                    IS_RESOURCE_REQUEST, Boolean.FALSE);
-                return false;
-            }
-        }
-    }
-
-    @Override
-    public boolean libraryExists(String libraryName)
-    {
-        String localePrefix = getLocalePrefixForLocateResource();
-
-        String pathToLib;
-
-        if (localePrefix != null) {
-            //Check with locale
-            pathToLib = localePrefix + '/' + libraryName;
-        }
-        else {
-            pathToLib = libraryName;
-        }
-
-        try {
-            URL url = FacesContext.getCurrentInstance().getExternalContext().getResource("/" + pathToLib);
-            return (url != null);
-        }
-        catch (MalformedURLException e) {
-            return false;
-        }
-    }
-
-    protected String getLocalePrefixForLocateResource()
-    {
-        String localePrefix = null;
-        FacesContext context = FacesContext.getCurrentInstance();
-
-        String bundleName = context.getApplication().getMessageBundle();
-
-        if (null != bundleName) {
-            Locale locale = context.getApplication().getViewHandler()
-                .calculateLocale(context);
-
-            ResourceBundle bundle = ResourceBundle
-                .getBundle(bundleName, locale, getContextClassLoader());
-
-            if (bundle != null) {
-                try {
-                    localePrefix = bundle.getString(ResourceHandler.LOCALE_PREFIX);
-                }
-                catch (MissingResourceException e) {
-                    // Ignore it and return null
-                }
-            }
-        }
-        return localePrefix;
-    }
-
-    /**
-     * Gets the ClassLoader associated with the current thread.  Includes a check for priviledges
-     * against java2 security to ensure no security related exceptions are encountered.
-     *
-     * @return ClassLoader
-     * @since 3.0.6
-     */
-    private static ClassLoader getContextClassLoader()
-    {
-        if (System.getSecurityManager() != null) {
-            try {
-                ClassLoader cl = AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
-                {
-                    public ClassLoader run() throws PrivilegedActionException
-                    {
-                        return Thread.currentThread().getContextClassLoader();
-                    }
-                });
-                return cl;
-            }
-            catch (PrivilegedActionException pae) {
-                throw new FacesException(pae);
-            }
-        }
-        else {
-            return Thread.currentThread().getContextClassLoader();
-        }
-    }
-
-    private String getLibraryVersion(String path)
-    {
-        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
-
-        String libraryVersion = null;
-        Set<String> libraryPaths = context.getResourcePaths("/" + path);
-        if (null != libraryPaths && !libraryPaths.isEmpty()) {
-            // Look in the libraryPaths for versioned libraries.
-            // If one or more versioned libraries are found, take
-            // the one with the "highest" version number as the value
-            // of libraryVersion. If no versioned libraries
-            // are found, let libraryVersion remain null.
-
-            for (String libraryPath : libraryPaths) {
-                String version = libraryPath.substring(path.length());
-
-                if (VERSION_CHECKER.matcher(version).matches()) {
-                    version = version.substring(1, version.length() - 1);
-                    if (libraryVersion == null) {
-                        libraryVersion = version;
-                    }
-                    else if (compareVersion(libraryVersion, version) < 0) {
-                        libraryVersion = version;
-                    }
-                }
-            }
-        }
-        return libraryVersion;
-    }
-
-    private int compareVersion(String s1, String s2)
-    {
-        int n1 = 0;
-        int n2 = 0;
-        String o1 = s1;
-        String o2 = s2;
-
-        boolean p1 = true;
-        boolean p2 = true;
-
-        while (n1 == n2 && (p1 || p2)) {
-            int i1 = o1.indexOf('_');
-            int i2 = o2.indexOf('_');
-            if (i1 < 0) {
-                if (o1.length() > 0) {
-                    p1 = false;
-                    n1 = Integer.valueOf(o1);
-                    o1 = "";
-                }
-                else {
-                    p1 = false;
-                    n1 = 0;
-                }
-            }
-            else {
-                n1 = Integer.valueOf(o1.substring(0, i1));
-                o1 = o1.substring(i1 + 1);
-            }
-            if (i2 < 0) {
-                if (o2.length() > 0) {
-                    p2 = false;
-                    n2 = Integer.valueOf(o2);
-                    o2 = "";
-                }
-                else {
-                    p2 = false;
-                    n2 = 0;
-                }
-            }
-            else {
-                n2 = Integer.valueOf(o2.substring(0, i2));
-                o2 = o2.substring(i2 + 1);
-            }
-        }
-
-        if (n1 == n2) {
-            return s1.length() - s2.length();
-        }
-        return n1 - n2;
-    }
-
-    private String getResourceVersion(String path)
-    {
-        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
-        String resourceVersion = null;
-        Set<String> resourcePaths = context.getResourcePaths("/" + path);
-
-        if (null != resourcePaths && !resourcePaths.isEmpty()) {
-            // resourceVersion = // execute the comment
-            // Look in the resourcePaths for versioned resources.
-            // If one or more versioned resources are found, take
-            // the one with the "highest" version number as the value
-            // of resourceVersion. If no versioned libraries
-            // are found, let resourceVersion remain null.
-            for (String resourcePath : resourcePaths) {
-                String version = resourcePath.substring(path.length());
-
-                if (RESOURCE_VERSION_CHECKER.matcher(version).matches()) {
-                    version = version.substring(1, version.lastIndexOf('.'));
-                    if (resourceVersion == null) {
-                        resourceVersion = version;
-                    }
-                    else if (compareVersion(resourceVersion, version) < 0) {
-                        resourceVersion = version;
-                    }
-                }
-            }
-        }
-        return resourceVersion;
-    }
-}
+/*
+ * 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.resource;
+
+import org.apache.myfaces.test.mock.MockServletContext;
+
+import javax.faces.FacesException;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.*;
+import java.util.regex.Pattern;
+
+/**
+ * <p>Mock implementation of <code>ResourceHandler</code>.</p>
+ * <p>This Mock could be used on situations where all resources
+ * are on a specific path.</p>
+ * 
+ * @author Jakob Korherr (latest modification by $Author: lu4242 $)
+ * @version $Revision: 882702 $ $Date: 2009-11-20 15:16:07 -0500 (Vie, 20 Nov 2009) $
+ */
+public class MockSimpleResourceHandler extends ResourceHandler
+{
+
+    private static final String IS_RESOURCE_REQUEST = "org.apache.myfaces.IS_RESOURCE_REQUEST";
+
+    /**
+     * It checks version like this: /1/, /1_0/, /1_0_0/, /100_100/
+     * <p/>
+     * Used on getLibraryVersion to filter resource directories
+     */
+    protected static Pattern VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*/");
+
+    /**
+     * It checks version like this: /1.js, /1_0.js, /1_0_0.js, /100_100.js
+     * <p/>
+     * Used on getResourceVersion to filter resources
+     */
+    protected static Pattern RESOURCE_VERSION_CHECKER = Pattern.compile("/\\p{Digit}+(_\\p{Digit}*)*\\..*");
+
+    private File _documentRoot;
+
+    /**
+     * @param documentRoot parent folder of resource directories. Must not be <code>null</code>
+     */
+    public MockSimpleResourceHandler(File documentRoot)
+    {
+        if (documentRoot == null) {
+            throw new NullPointerException("documentRoot must not be null");
+        }
+
+        _documentRoot = documentRoot;
+
+        ((MockServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
+            .setDocumentRoot(_documentRoot);
+    }
+
+    @Override
+    public Resource createResource(String resourceName)
+    {
+        return createResource(resourceName, null);
+    }
+
+    @Override
+    public Resource createResource(String resourceName, String libraryName)
+    {
+        return createResource(resourceName, libraryName, null);
+    }
+
+    @Override
+    public Resource createResource(String resourceName, String libraryName, String contentType)
+    {
+        String prefix = getLocalePrefixForLocateResource();
+        String libraryVersion = getLibraryVersion(prefix + "/" + libraryName);
+
+        String pathToResource;
+        if (null != libraryVersion) {
+            pathToResource = prefix + '/'
+                + libraryName + '/' + libraryVersion + '/'
+                + resourceName;
+        }
+        else {
+            pathToResource = prefix + '/'
+                + libraryName + '/' + resourceName;
+        }
+
+        return new MockSimpleResource(prefix, libraryName, libraryVersion, resourceName, getResourceVersion(pathToResource), _documentRoot);
+    }
+
+    @Override
+    public String getRendererTypeForResourceName(String resourceName)
+    {
+        if (resourceName.endsWith(".js")) {
+            return "javax.faces.resource.Script";
+        }
+        else if (resourceName.endsWith(".css")) {
+            return "javax.faces.resource.Stylesheet";
+        }
+        return null;
+    }
+
+    @Override
+    public void handleResourceRequest(FacesContext context) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean isResourceRequest(FacesContext facesContext)
+    {
+        // Since this method could be called many times we save it
+        //on request map so the first time is calculated it remains
+        //alive until the end of the request
+        Boolean value = (Boolean) facesContext.getExternalContext()
+            .getRequestMap().get(IS_RESOURCE_REQUEST);
+
+        if (value != null && value.booleanValue()) {
+            //return the saved value
+            return value.booleanValue();
+        }
+        else {
+            // assuming that we don't have servlet mapping
+            String resourceBasePath = facesContext.getExternalContext().getRequestPathInfo();
+
+            if (resourceBasePath != null
+                && resourceBasePath
+                .startsWith(ResourceHandler.RESOURCE_IDENTIFIER)) {
+                facesContext.getExternalContext().getRequestMap().put(
+                    IS_RESOURCE_REQUEST, Boolean.TRUE);
+                return true;
+            }
+            else {
+                facesContext.getExternalContext().getRequestMap().put(
+                    IS_RESOURCE_REQUEST, Boolean.FALSE);
+                return false;
+            }
+        }
+    }
+
+    @Override
+    public boolean libraryExists(String libraryName)
+    {
+        String localePrefix = getLocalePrefixForLocateResource();
+
+        String pathToLib;
+
+        if (localePrefix != null) {
+            //Check with locale
+            pathToLib = localePrefix + '/' + libraryName;
+        }
+        else {
+            pathToLib = libraryName;
+        }
+
+        try {
+            URL url = FacesContext.getCurrentInstance().getExternalContext().getResource("/" + pathToLib);
+            return (url != null);
+        }
+        catch (MalformedURLException e) {
+            return false;
+        }
+    }
+
+    protected String getLocalePrefixForLocateResource()
+    {
+        String localePrefix = null;
+        FacesContext context = FacesContext.getCurrentInstance();
+
+        String bundleName = context.getApplication().getMessageBundle();
+
+        if (null != bundleName) {
+            Locale locale = context.getApplication().getViewHandler()
+                .calculateLocale(context);
+
+            ResourceBundle bundle = ResourceBundle
+                .getBundle(bundleName, locale, getContextClassLoader());
+
+            if (bundle != null) {
+                try {
+                    localePrefix = bundle.getString(ResourceHandler.LOCALE_PREFIX);
+                }
+                catch (MissingResourceException e) {
+                    // Ignore it and return null
+                }
+            }
+        }
+        return localePrefix;
+    }
+
+    /**
+     * Gets the ClassLoader associated with the current thread.  Includes a check for priviledges
+     * against java2 security to ensure no security related exceptions are encountered.
+     *
+     * @return ClassLoader
+     * @since 3.0.6
+     */
+    private static ClassLoader getContextClassLoader()
+    {
+        if (System.getSecurityManager() != null) {
+            try {
+                ClassLoader cl = AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
+                {
+                    public ClassLoader run() throws PrivilegedActionException
+                    {
+                        return Thread.currentThread().getContextClassLoader();
+                    }
+                });
+                return cl;
+            }
+            catch (PrivilegedActionException pae) {
+                throw new FacesException(pae);
+            }
+        }
+        else {
+            return Thread.currentThread().getContextClassLoader();
+        }
+    }
+
+    private String getLibraryVersion(String path)
+    {
+        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
+
+        String libraryVersion = null;
+        Set<String> libraryPaths = context.getResourcePaths("/" + path);
+        if (null != libraryPaths && !libraryPaths.isEmpty()) {
+            // Look in the libraryPaths for versioned libraries.
+            // If one or more versioned libraries are found, take
+            // the one with the "highest" version number as the value
+            // of libraryVersion. If no versioned libraries
+            // are found, let libraryVersion remain null.
+
+            for (String libraryPath : libraryPaths) {
+                String version = libraryPath.substring(path.length());
+
+                if (VERSION_CHECKER.matcher(version).matches()) {
+                    version = version.substring(1, version.length() - 1);
+                    if (libraryVersion == null) {
+                        libraryVersion = version;
+                    }
+                    else if (compareVersion(libraryVersion, version) < 0) {
+                        libraryVersion = version;
+                    }
+                }
+            }
+        }
+        return libraryVersion;
+    }
+
+    private int compareVersion(String s1, String s2)
+    {
+        int n1 = 0;
+        int n2 = 0;
+        String o1 = s1;
+        String o2 = s2;
+
+        boolean p1 = true;
+        boolean p2 = true;
+
+        while (n1 == n2 && (p1 || p2)) {
+            int i1 = o1.indexOf('_');
+            int i2 = o2.indexOf('_');
+            if (i1 < 0) {
+                if (o1.length() > 0) {
+                    p1 = false;
+                    n1 = Integer.valueOf(o1);
+                    o1 = "";
+                }
+                else {
+                    p1 = false;
+                    n1 = 0;
+                }
+            }
+            else {
+                n1 = Integer.valueOf(o1.substring(0, i1));
+                o1 = o1.substring(i1 + 1);
+            }
+            if (i2 < 0) {
+                if (o2.length() > 0) {
+                    p2 = false;
+                    n2 = Integer.valueOf(o2);
+                    o2 = "";
+                }
+                else {
+                    p2 = false;
+                    n2 = 0;
+                }
+            }
+            else {
+                n2 = Integer.valueOf(o2.substring(0, i2));
+                o2 = o2.substring(i2 + 1);
+            }
+        }
+
+        if (n1 == n2) {
+            return s1.length() - s2.length();
+        }
+        return n1 - n2;
+    }
+
+    private String getResourceVersion(String path)
+    {
+        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
+        String resourceVersion = null;
+        Set<String> resourcePaths = context.getResourcePaths("/" + path);
+
+        if (null != resourcePaths && !resourcePaths.isEmpty()) {
+            // resourceVersion = // execute the comment
+            // Look in the resourcePaths for versioned resources.
+            // If one or more versioned resources are found, take
+            // the one with the "highest" version number as the value
+            // of resourceVersion. If no versioned libraries
+            // are found, let resourceVersion remain null.
+            for (String resourcePath : resourcePaths) {
+                String version = resourcePath.substring(path.length());
+
+                if (RESOURCE_VERSION_CHECKER.matcher(version).matches()) {
+                    version = version.substring(1, version.lastIndexOf('.'));
+                    if (resourceVersion == null) {
+                        resourceVersion = version;
+                    }
+                    else if (compareVersion(resourceVersion, version) < 0) {
+                        resourceVersion = version;
+                    }
+                }
+            }
+        }
+        return resourceVersion;
+    }
+}
diff --git a/test20/src/test/java/org/apache/myfaces/test/mock/MockResourceTestCase.java b/test20/src/test/java/org/apache/myfaces/test/mock/MockResourceTestCase.java
index e5d9fe1..bf74832 100644
--- a/test20/src/test/java/org/apache/myfaces/test/mock/MockResourceTestCase.java
+++ b/test20/src/test/java/org/apache/myfaces/test/mock/MockResourceTestCase.java
@@ -17,18 +17,20 @@
 
 package org.apache.myfaces.test.mock;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.apache.myfaces.test.base.AbstractJsfTestCase;
-import org.apache.myfaces.test.mock.resource.MockResource;
-import org.apache.myfaces.test.mock.resource.MockResourceHandler;
-
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
 import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
 
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.test.base.AbstractJsfTestCase;
+import org.apache.myfaces.test.mock.resource.MockSimpleResource;
+import org.apache.myfaces.test.mock.resource.MockSimpleResourceHandler;
+
 /**
  * Test case for resource handling
  */
@@ -58,7 +60,7 @@ public class MockResourceTestCase extends AbstractJsfTestCase {
 
     public void testGetResource() throws Exception {
 
-        Resource resource = new MockResource(null, "testlib", null, "testfile.js", null, _documentRoot);
+        Resource resource = new MockSimpleResource(null, "testlib", null, "testfile.js", null, _documentRoot);
 
         URL resourceUrl = resource.getURL();
         assertNotNull("Could not find resource", resourceUrl);
@@ -67,27 +69,27 @@ public class MockResourceTestCase extends AbstractJsfTestCase {
 
     public void testGetNotExistingResource() throws Exception {
 
-        Resource resource = new MockResource(null, "testlib", null, "notexisting.js", null, _documentRoot);
+        Resource resource = new MockSimpleResource(null, "testlib", null, "notexisting.js", null, _documentRoot);
 
         assertNull(resource.getURL());
     }
 
     public void testGetAsStream() throws Exception {
-        Resource resource = new MockResource(null, "testlib", null, "testfile.js", null, _documentRoot);
+        Resource resource = new MockSimpleResource(null, "testlib", null, "testfile.js", null, _documentRoot);
         InputStream stream = resource.getInputStream();
         assertNotNull(stream);
         assertTrue(stream.read() != -1);
     }
 
     public void testCreateResource() throws Exception {
-        ResourceHandler handler = new MockResourceHandler(_documentRoot);
+        ResourceHandler handler = new MockSimpleResourceHandler(_documentRoot);
         Resource resource = handler.createResource("testfile.js", "testlib");
         assertNotNull("resource could not be created", resource);
         assertTrue(resource.getURL().toString().endsWith("org/apache/myfaces/test/mock/resources/testlib/testfile.js"));
     }
 
     public void testResourceHandler() throws Exception {
-       ResourceHandler handler = new MockResourceHandler(_documentRoot);
+       ResourceHandler handler = new MockSimpleResourceHandler(_documentRoot);
 
         assertTrue(handler.libraryExists("testlib"));
         assertFalse(handler.libraryExists("notexistinglib"));

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 14/24: remove unused directory

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit bc199b576a6bbf243a97cfa36f668b18be443658
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 00:10:02 2010 +0000

    remove unused directory

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 05/24: when object is null return null

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit c75ed26941b292b7adb3f0c208904ad5e00bce58
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Sat May 29 01:15:13 2010 +0000

    when object is null return null
---
 .../main/java/org/apache/myfaces/test/el/MockExpressionFactory.java   | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/test12/src/main/java/org/apache/myfaces/test/el/MockExpressionFactory.java b/test12/src/main/java/org/apache/myfaces/test/el/MockExpressionFactory.java
index a86d7b3..350848e 100644
--- a/test12/src/main/java/org/apache/myfaces/test/el/MockExpressionFactory.java
+++ b/test12/src/main/java/org/apache/myfaces/test/el/MockExpressionFactory.java
@@ -123,6 +123,10 @@ public class MockExpressionFactory extends ExpressionFactory {
         if ((object != null) && targetType.isAssignableFrom(object.getClass())) {
             return object;
         }
+        
+        // new to spec
+        if (object == null)
+            return null;
 
         // We do not know how to perform this conversion
         throw new IllegalArgumentException("Cannot convert " + object + " to " + targetType.getName());

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 23/24: [maven-release-plugin] copy for tag 1_0_0_beta_4

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 747a119d955b5f91e210d286a34bd95474af9f54
Merge: 158cdfc 9e585ca
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 15 18:11:51 2010 +0000

    [maven-release-plugin]  copy for tag 1_0_0_beta_4

 test12/pom.xml                                     |  20 +-
 .../myfaces/test/base/AbstractJsfTestCase.java     |  62 +-
 .../AbstractJsfConfigurableMockTestCase.java}      | 124 ++--
 .../base/{ => junit4}/AbstractJsfTestCase.java     |  78 ++-
 .../htmlunit/junit4/AbstractHtmlUnitTestCase.java  | 320 ++++++++++
 .../test/jmock/AbstractJmockJsfTestCase.java       |  54 +-
 .../myfaces/test/mock/MockExternalContext.java     | 431 +++++++------
 .../myfaces/test/mock/MockHttpServletRequest.java  |  85 ++-
 .../myfaces/test/mock/MockHttpServletResponse.java | 121 ++--
 .../apache/myfaces/test/mock/MockRenderKit.java    |  73 ++-
 .../myfaces/test/mock/MockRequestDispatcher.java   |  59 ++
 .../test/mock/MockResponseStateManager.java        | 280 ++++++++
 .../myfaces/test/mock/MockServletContext.java      | 433 +++++++------
 .../myfaces/test/mock/MockServletInputStream.java  |  53 ++
 .../myfaces/test/mock/_AbstractAttributeMap.java   | 351 ++++++++++
 .../apache/myfaces/test/mock/_ApplicationMap.java  |  87 +++
 .../org/apache/myfaces/test/mock/_CookieMap.java   | 173 +++++
 .../java/org/apache/myfaces/test/mock/_Hex.java    | 310 +++++++++
 .../myfaces/test/mock/_InitParameterMap.java       |  74 +++
 .../apache/myfaces/test/mock/_NullEnumeration.java |  48 ++
 .../myfaces/test/mock/_RequestHeaderMap.java       |  70 ++
 .../myfaces/test/mock/_RequestHeaderValuesMap.java |  76 +++
 .../org/apache/myfaces/test/mock/_RequestMap.java  |  61 ++
 .../myfaces/test/mock/_RequestParameterMap.java    |  68 ++
 .../test/mock/_RequestParameterValuesMap.java      |  61 ++
 .../org/apache/myfaces/test/mock/_SessionMap.java  |  88 +++
 .../apache/myfaces/test/runners/NamedRunner.java   | 123 ++++
 .../myfaces/test/runners/TestClassLoader.java      | 332 ++++++++++
 .../test/runners/TestPerClassLoaderRunner.java     | 293 +++++++++
 test12/src/main/resources/META-INF/NOTICE.txt      |  16 +-
 .../META-INF/licenses/facelets-LICENSE.txt         |  70 ++
 .../myfaces/test/runners/excluded.properties       |  12 +
 .../test/mock/{TestMockBean.java => MockBean.java} |   2 +-
 .../myfaces/test/mock/MockObjectsTestCase.java     |   4 +-
 .../runner/TestPerCLassLoaderDefaultTestCase.java  |  71 +++
 .../test/runner/TestPerClassLoaderTestCase.java    |  66 ++
 .../myfaces/test/runner/WebXmlParameter.java       |  58 +-
 .../apache/myfaces/test/runner/WebXmlUtils.java    |  68 +-
 test20/pom.xml                                     |   2 +-
 .../apache/myfaces/test/config/ConfigParser.java   | 607 ++++++++++++++++++
 .../apache/myfaces/test/config/ConfigParser20.java | 164 -----
 .../myfaces/test/mock/MockApplication20.java       |   2 +
 .../test/mock/MockResponseStateManager.java        | 353 +++++++++++
 .../resource/MockClassLoaderResourceLoader.java    | 122 ++++
 .../MockExternalContextResourceLoader.java         | 208 ++++++
 .../myfaces/test/mock/resource/MockResource.java   | 161 ++---
 .../test/mock/resource/MockResourceHandler.java    | 378 +++++------
 .../mock/resource/MockResourceHandlerSupport.java  | 115 ++++
 .../test/mock/resource/MockResourceLoader.java     | 155 +++++
 .../test/mock/resource/MockResourceMeta.java       | 110 ++++
 .../{MockResource.java => MockSimpleResource.java} | 361 +++++------
 ...Handler.java => MockSimpleResourceHandler.java} | 703 +++++++++++----------
 .../test/config/ConfigParser20TestCase.java        | 119 ----
 .../myfaces/test/config/ConfigParserTestCase.java  | 196 ++++++
 .../org/apache/myfaces/test/config/MyBehavior.java |  56 +-
 .../test/config/MyClientBehaviorRenderer.java}     |  56 +-
 .../apache/myfaces/test/config/MyConverter.java}   |  65 +-
 .../apache/myfaces/test/config/MyValidator.java}   |  62 +-
 .../myfaces/test/mock/MockResourceTestCase.java    |  28 +-
 ...ces20-faces-config-1.xml => faces-config-1.xml} | 173 ++---
 60 files changed, 7012 insertions(+), 1959 deletions(-)


-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 11/24: MYFACESTEST-15 Add new MockResponseStateManager

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit cf6b9f5ec0f4e0feb82d494467c5142df9822127
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 00:05:32 2010 +0000

    MYFACESTEST-15 Add new MockResponseStateManager
---
 .../apache/myfaces/test/mock/MockRenderKit.java    |  73 ++---
 .../test/mock/MockResponseStateManager.java        | 280 +++++++++++++++++++
 .../java/org/apache/myfaces/test/mock/_Hex.java    | 310 +++++++++++++++++++++
 3 files changed, 628 insertions(+), 35 deletions(-)

diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockRenderKit.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockRenderKit.java
index 8d505fc..2ffbbe8 100644
--- a/test12/src/main/java/org/apache/myfaces/test/mock/MockRenderKit.java
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockRenderKit.java
@@ -35,105 +35,108 @@ import javax.faces.render.ResponseStateManager;
  * $Id$
  */
 
-public class MockRenderKit extends RenderKit {
-
+public class MockRenderKit extends RenderKit
+{
 
     // ------------------------------------------------------------ Constructors
 
-
     /**
      * <p>Return a default instance.</p>
      */
-    public MockRenderKit() {
+    public MockRenderKit()
+    {
     }
 
-
     // ----------------------------------------------------- Mock Object Methods
 
+    public void setResponseStateManager(ResponseStateManager rsm)
+    {
+        this.rsm = rsm;
+    }
 
     // ------------------------------------------------------ Instance Variables
 
-
     /**
      * <p>The set of renderers registered here.</p>
      */
     private Map renderers = new HashMap();
-
+    private ResponseStateManager rsm = new MockResponseStateManager();
 
     // ------------------------------------------------------- RenderKit Methods
 
-
     /** {@inheritDoc} */
     public void addRenderer(String family, String rendererType,
-                            Renderer renderer) {
+            Renderer renderer)
+    {
 
-        if ((family == null) || (rendererType == null) || (renderer == null)) {
+        if ((family == null) || (rendererType == null) || (renderer == null))
+        {
             throw new NullPointerException();
         }
         renderers.put(family + "|" + rendererType, renderer);
 
     }
 
-
     /** {@inheritDoc} */
-    public Renderer getRenderer(String family, String rendererType) {
+    public Renderer getRenderer(String family, String rendererType)
+    {
 
-        if ((family == null) || (rendererType == null)) {
+        if ((family == null) || (rendererType == null))
+        {
             throw new NullPointerException();
         }
         return (Renderer) renderers.get(family + "|" + rendererType);
 
     }
 
-
     /** {@inheritDoc} */
     public ResponseWriter createResponseWriter(Writer writer,
-                                               String contentTypeList,
-                                               String characterEncoding) {
+            String contentTypeList, String characterEncoding)
+    {
 
-       return new MockResponseWriter(writer, contentTypeList, characterEncoding);
+        return new MockResponseWriter(writer, contentTypeList,
+                characterEncoding);
 
     }
 
-
     /** {@inheritDoc} */
-    public ResponseStream createResponseStream(OutputStream out) {
+    public ResponseStream createResponseStream(OutputStream out)
+    {
 
         final OutputStream stream = out;
-        return new ResponseStream() {
+        return new ResponseStream()
+        {
 
-            public void close() throws IOException {
+            public void close() throws IOException
+            {
                 stream.close();
             }
 
-            public void flush() throws IOException {
+            public void flush() throws IOException
+            {
                 stream.flush();
             }
 
-            public void write(byte[] b) throws IOException {
+            public void write(byte[] b) throws IOException
+            {
                 stream.write(b);
             }
 
-            public void write(byte[] b, int off, int len) throws IOException {
+            public void write(byte[] b, int off, int len) throws IOException
+            {
                 stream.write(b, off, len);
             }
 
-            public void write(int b) throws IOException {
+            public void write(int b) throws IOException
+            {
                 stream.write(b);
             }
-
         };
-
-
     }
 
-
     /** {@inheritDoc} */
-    public ResponseStateManager getResponseStateManager() {
-
-        throw new UnsupportedOperationException();
-
+    public ResponseStateManager getResponseStateManager()
+    {
+        return rsm;
     }
-
-
 }
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
new file mode 100644
index 0000000..2bb2548
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
@@ -0,0 +1,280 @@
+package org.apache.myfaces.test.mock;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.faces.application.StateManager.SerializedView;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.ResponseStateManager;
+
+/**
+ * Mock class that encode view state in hex format
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 951803 $ $Date: 2010-06-05 21:13:20 -0500 (Sáb, 05 Jun 2010) $
+ */
+public class MockResponseStateManager extends ResponseStateManager
+{
+    // ------------------------------------------------------------ Constructors
+
+    // ------------------------------------------------------ Instance Variables
+    
+    private static final int TREE_PARAM = 0;
+    private static final int STATE_PARAM = 1;
+    private static final int VIEWID_PARAM = 2;
+    private static final String ZIP_CHARSET = "ISO-8859-1";
+
+    
+    // ----------------------------------------------------- Mock Object Methods
+
+    // -------------------------------------------------- ResponseStateManager Methods
+    
+    public Object getState(FacesContext facesContext, String viewId)
+    {
+        Object[] savedState = getSavedState(facesContext);
+        if (savedState == null)
+        {
+            return null;
+        }
+
+        return new Object[] { savedState[TREE_PARAM], savedState[STATE_PARAM] };
+    }
+
+    public Object getTreeStructureToRestore(FacesContext facesContext, String viewId)
+    {
+        // Although this method won't be called anymore,
+        // it has been kept for backward compatibility.
+        Object[] savedState = getSavedState(facesContext);
+        if (savedState == null)
+        {
+            return null;
+        }
+
+        return savedState[TREE_PARAM];
+    }
+
+    public Object getComponentStateToRestore(FacesContext facesContext)
+    {
+        // Although this method won't be called anymore,
+        // it has been kept for backward compatibility.
+        Object[] savedState = getSavedState(facesContext);
+        if (savedState == null)
+        {
+            return null;
+        }
+
+        return savedState[STATE_PARAM];
+    }
+
+    public boolean isPostback(FacesContext context)
+    {
+        return context.getExternalContext().getRequestParameterMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM);
+    }
+
+    public void writeState(FacesContext facescontext, SerializedView serializedview)
+            throws IOException
+    {
+        ResponseWriter responseWriter = facescontext.getResponseWriter();
+
+        Object[] savedState = new Object[3];
+
+        if (facescontext.getApplication().getStateManager().isSavingStateInClient(facescontext))
+        {
+            Object treeStruct = serializedview.getStructure();
+            Object compStates = serializedview.getState();
+
+            if (treeStruct != null)
+            {
+                savedState[TREE_PARAM] = treeStruct;
+            }
+
+            if (compStates != null)
+            {
+                savedState[STATE_PARAM] = compStates;
+            }
+        }
+        else
+        {
+            // write viewSequence
+            Object treeStruct = serializedview.getStructure();
+            if (treeStruct != null)
+            {
+                if (treeStruct instanceof String)
+                {
+                    savedState[TREE_PARAM] = treeStruct;
+                }
+            }
+        }
+
+        savedState[VIEWID_PARAM] = facescontext.getViewRoot().getViewId();
+
+        // write the view state field
+        writeViewStateField(facescontext, responseWriter, savedState);
+
+        // renderKitId field
+        writeRenderKitIdField(facescontext, responseWriter);
+    }
+
+    private void writeViewStateField(FacesContext facesContext, ResponseWriter responseWriter, Object savedState)
+    throws IOException
+    {
+        
+        String serializedState = construct(facesContext, savedState);
+        responseWriter.startElement("input", null);
+        responseWriter.writeAttribute("type", "hidden", null);
+        responseWriter.writeAttribute("name", VIEW_STATE_PARAM, null);
+        responseWriter.writeAttribute("value", serializedState, null);
+        responseWriter.endElement("input");
+    }
+    
+
+    private void writeRenderKitIdField(FacesContext facesContext, ResponseWriter responseWriter) throws IOException
+    {
+    
+        String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
+        if (defaultRenderKitId != null && !RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(defaultRenderKitId))
+        {
+            responseWriter.startElement("input", null);
+            responseWriter.writeAttribute("type", "hidden", null);
+            responseWriter.writeAttribute("name", ResponseStateManager.RENDER_KIT_ID_PARAM, null);
+            responseWriter.writeAttribute("value", defaultRenderKitId, null);
+            responseWriter.endElement("input");
+        }
+    }
+    
+    private String construct(FacesContext facesContext, Object savedState) throws IOException
+    {
+        byte[] bytes = null;
+        ByteArrayOutputStream baos = null;
+        ObjectOutputStream oos = null;
+        try
+        {
+            baos = new ByteArrayOutputStream();
+            oos = new ObjectOutputStream(baos);
+            oos.writeObject(savedState);
+            bytes = baos.toByteArray();
+        }
+        finally
+        {
+            if (oos != null)
+            {
+                try
+                {
+                    oos.close();
+                }
+                catch(IOException e)
+                {
+                }
+                finally
+                {
+                    oos = null;
+                }
+            }
+            if (baos != null)
+            {
+                try
+                {
+                    baos.close();
+                }
+                catch(IOException e)
+                {
+                }
+                finally
+                {
+                    baos = null;
+                }
+            }
+        }
+        return new String(new _Hex().encode(bytes), ZIP_CHARSET);
+    }
+    
+    private Object reconstruct(FacesContext facesContext, String encodedState) throws IOException
+    {
+        byte[] bytes = encodedState.getBytes(ZIP_CHARSET);
+        
+        ByteArrayInputStream input = null;
+        ObjectInputStream s = null;
+        Object object = null;
+        
+        try
+        {
+            input = new ByteArrayInputStream(bytes);
+            s = new ObjectInputStream(input); 
+            object = s.readObject();
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new IOException(e);
+        }
+        finally
+        {
+            if (s != null)
+            {
+                try
+                {
+                    s.close();
+                }
+                catch(IOException e)
+                {
+                }
+                finally
+                {
+                    s = null;
+                }
+            }
+            if (input != null)
+            {
+                try
+                {
+                    input.close();
+                }
+                catch(IOException e)
+                {
+                }
+                finally
+                {
+                    input = null;
+                }
+            }
+        }
+        return object;
+    }
+
+    private Object[] getSavedState(FacesContext facesContext) {
+        Object encodedState = 
+            facesContext.getExternalContext().
+                getRequestParameterMap().get(VIEW_STATE_PARAM);
+        if(encodedState==null || (((String) encodedState).length() == 0)) { 
+            return null;
+        }
+
+        Object[] savedState = null;
+        
+        try
+        {
+            savedState = (Object[])reconstruct(facesContext, (String)encodedState);
+        }
+        catch(IOException e)
+        {
+            facesContext.getExternalContext().log("Cannot reconstruct view state", e);
+        }
+
+        if (savedState == null)
+        {
+            return null;
+        }
+        
+        String restoredViewId = (String)savedState[VIEWID_PARAM];
+
+        if (restoredViewId == null)
+        {
+            return null;
+        }
+        return savedState;
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_Hex.java b/test12/src/main/java/org/apache/myfaces/test/mock/_Hex.java
new file mode 100644
index 0000000..efecfd6
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_Hex.java
@@ -0,0 +1,310 @@
+/*
+ * 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 java.io.UnsupportedEncodingException;
+
+/**
+ * Hex encoder and decoder. The charset used for certain operation can be set, the default is set in
+ * {@link #DEFAULT_CHARSET_NAME}
+ * 
+ * @since 1.1
+ * @author Apache Software Foundation
+ * @version $Id: Hex.java 801639 2009-08-06 13:15:10Z niallp $
+ */
+class _Hex {
+
+    /**
+     * Default charset name is {@link CharEncoding#UTF_8}
+     */
+    public static final String DEFAULT_CHARSET_NAME = "UTF-8";
+
+    /**
+     * Used to build output as Hex
+     */
+    private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    /**
+     * Used to build output as Hex
+     */
+    private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+
+    /**
+     * Converts an array of characters representing hexadecimal values into an array of bytes of those same values. The
+     * returned array will be half the length of the passed array, as it takes two characters to represent any given
+     * byte. An exception is thrown if the passed char array has an odd number of elements.
+     * 
+     * @param data
+     *            An array of characters containing hexadecimal digits
+     * @return A byte array containing binary data decoded from the supplied char array.
+     * @throws DecoderException
+     *             Thrown if an odd number or illegal of characters is supplied
+     */
+    public static byte[] decodeHex(char[] data) throws Exception {
+
+        int len = data.length;
+
+        if ((len & 0x01) != 0) {
+            throw new Exception("Odd number of characters.");
+        }
+
+        byte[] out = new byte[len >> 1];
+
+        // two characters form the hex value.
+        for (int i = 0, j = 0; j < len; i++) {
+            int f = toDigit(data[j], j) << 4;
+            j++;
+            f = f | toDigit(data[j], j);
+            j++;
+            out[i] = (byte) (f & 0xFF);
+        }
+
+        return out;
+    }
+
+    /**
+     * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
+     * The returned array will be double the length of the passed array, as it takes two characters to represent any
+     * given byte.
+     * 
+     * @param data
+     *            a byte[] to convert to Hex characters
+     * @return A char[] containing hexadecimal characters
+     */
+    public static char[] encodeHex(byte[] data) {
+        return encodeHex(data, true);
+    }
+
+    /**
+     * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
+     * The returned array will be double the length of the passed array, as it takes two characters to represent any
+     * given byte.
+     * 
+     * @param data
+     *            a byte[] to convert to Hex characters
+     * @param toLowerCase
+     *            <code>true</code> converts to lowercase, <code>false</code> to uppercase
+     * @return A char[] containing hexadecimal characters
+     * @since 1.4
+     */
+    public static char[] encodeHex(byte[] data, boolean toLowerCase) {
+        return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER);
+    }
+
+    /**
+     * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
+     * The returned array will be double the length of the passed array, as it takes two characters to represent any
+     * given byte.
+     * 
+     * @param data
+     *            a byte[] to convert to Hex characters
+     * @param toDigits
+     *            the output alphabet
+     * @return A char[] containing hexadecimal characters
+     * @since 1.4
+     */
+    protected static char[] encodeHex(byte[] data, char[] toDigits) {
+        int l = data.length;
+        char[] out = new char[l << 1];
+        // two characters form the hex value.
+        for (int i = 0, j = 0; i < l; i++) {
+            out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
+            out[j++] = toDigits[0x0F & data[i]];
+        }
+        return out;
+    }
+
+    /**
+     * Converts an array of bytes into a String representing the hexadecimal values of each byte in order. The returned
+     * String will be double the length of the passed array, as it takes two characters to represent any given byte.
+     * 
+     * @param data
+     *            a byte[] to convert to Hex characters
+     * @return A String containing hexadecimal characters
+     * @since 1.4
+     */
+    public static String encodeHexString(byte[] data) {
+        return new String(encodeHex(data));
+    }
+
+    /**
+     * Converts a hexadecimal character to an integer.
+     * 
+     * @param ch
+     *            A character to convert to an integer digit
+     * @param index
+     *            The index of the character in the source
+     * @return An integer
+     * @throws DecoderException
+     *             Thrown if ch is an illegal hex character
+     */
+    protected static int toDigit(char ch, int index) throws Exception {
+        int digit = Character.digit(ch, 16);
+        if (digit == -1) {
+            throw new Exception("Illegal hexadecimal charcter " + ch + " at index " + index);
+        }
+        return digit;
+    }
+
+    private final String charsetName;
+
+    /**
+     * Creates a new codec with the default charset name {@link #DEFAULT_CHARSET_NAME}
+     */
+    public _Hex() {
+        // use default encoding
+        this.charsetName = DEFAULT_CHARSET_NAME;
+    }
+
+    /**
+     * Creates a new codec with the given charset name.
+     * 
+     * @param csName
+     *            the charset name.
+     * @since 1.4
+     */
+    public _Hex(String csName) {
+        this.charsetName = csName;
+    }
+
+    /**
+     * Converts an array of character bytes representing hexadecimal values into an array of bytes of those same values.
+     * The returned array will be half the length of the passed array, as it takes two characters to represent any given
+     * byte. An exception is thrown if the passed char array has an odd number of elements.
+     * 
+     * @param array
+     *            An array of character bytes containing hexadecimal digits
+     * @return A byte array containing binary data decoded from the supplied byte array (representing characters).
+     * @throws DecoderException
+     *             Thrown if an odd number of characters is supplied to this function
+     * @see #decodeHex(char[])
+     */
+    public byte[] decode(byte[] array) throws Exception {
+        try {
+            return decodeHex(new String(array, getCharsetName()).toCharArray());
+        } catch (UnsupportedEncodingException e) {
+            throw new Exception(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Converts a String or an array of character bytes representing hexadecimal values into an array of bytes of those
+     * same values. The returned array will be half the length of the passed String or array, as it takes two characters
+     * to represent any given byte. An exception is thrown if the passed char array has an odd number of elements.
+     * 
+     * @param object
+     *            A String or, an array of character bytes containing hexadecimal digits
+     * @return A byte array containing binary data decoded from the supplied byte array (representing characters).
+     * @throws DecoderException
+     *             Thrown if an odd number of characters is supplied to this function or the object is not a String or
+     *             char[]
+     * @see #decodeHex(char[])
+     */
+    public Object decode(Object object) throws Exception {
+        try {
+            char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object;
+            return decodeHex(charArray);
+        } catch (ClassCastException e) {
+            throw new Exception(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Converts an array of bytes into an array of bytes for the characters representing the hexadecimal values of each
+     * byte in order. The returned array will be double the length of the passed array, as it takes two characters to
+     * represent any given byte.
+     * <p>
+     * The conversion from hexadecimal characters to the returned bytes is performed with the charset named by
+     * {@link #getCharsetName()}.
+     * </p>
+     * 
+     * @param array
+     *            a byte[] to convert to Hex characters
+     * @return A byte[] containing the bytes of the hexadecimal characters
+     * @throws IllegalStateException
+     *             if the charsetName is invalid. This API throws {@link IllegalStateException} instead of
+     *             {@link UnsupportedEncodingException} for backward compatibility.
+     * @see #encodeHex(byte[])
+     */
+    public byte[] encode(byte[] array) {
+        return getBytesUnchecked(encodeHexString(array), getCharsetName());
+    }
+    
+    private static byte[] getBytesUnchecked(String string, String charsetName)
+    {
+        if (string == null)
+        {
+            return null;
+        }
+        try
+        {
+            return string.getBytes(charsetName);
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            throw new IllegalStateException(charsetName, e);
+        }
+    }
+
+
+    /**
+     * Converts a String or an array of bytes into an array of characters representing the hexadecimal values of each
+     * byte in order. The returned array will be double the length of the passed String or array, as it takes two
+     * characters to represent any given byte.
+     * <p>
+     * The conversion from hexadecimal characters to bytes to be encoded to performed with the charset named by
+     * {@link #getCharsetName()}.
+     * </p>
+     * 
+     * @param object
+     *            a String, or byte[] to convert to Hex characters
+     * @return A char[] containing hexadecimal characters
+     * @throws EncoderException
+     *             Thrown if the given object is not a String or byte[]
+     * @see #encodeHex(byte[])
+     */
+    public Object encode(Object object) throws Exception {
+        try {
+            byte[] byteArray = object instanceof String ? ((String) object).getBytes(getCharsetName()) : (byte[]) object;
+            return encodeHex(byteArray);
+        } catch (ClassCastException e) {
+            throw new Exception(e.getMessage(), e);
+        } catch (UnsupportedEncodingException e) {
+            throw new Exception(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Gets the charset name.
+     * 
+     * @return the charset name.
+     * @since 1.4
+     */
+    public String getCharsetName() {
+        return this.charsetName;
+    }
+
+    /**
+     * Returns a string representation of the object, which includes the charset name.
+     * 
+     * @return a string representation of the object.
+     */
+    public String toString() {
+        return super.toString() + "[charsetName=" + this.charsetName + "]";
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 04/24: MYFACESTEST-9 MockExternalContext20 should implement encodePartialActionURL()

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit c2f7f09785fd8bdaba1b3984335db0de44f082a3
Author: Jakob Korherr <ja...@apache.org>
AuthorDate: Mon May 3 17:01:27 2010 +0000

    MYFACESTEST-9 MockExternalContext20 should implement encodePartialActionURL()
---
 .../java/org/apache/myfaces/test/mock/MockExternalContext20.java    | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/MockExternalContext20.java b/test20/src/main/java/org/apache/myfaces/test/mock/MockExternalContext20.java
index 71e3ddc..98615c3 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/MockExternalContext20.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/MockExternalContext20.java
@@ -157,6 +157,12 @@ public class MockExternalContext20 extends MockExternalContext12
     {
         return response.encodeRedirectURL(encodeURL(baseUrl, parameters));
     }
+    
+    @Override
+    public String encodePartialActionURL(String url)
+    {
+        return ((HttpServletResponse) response).encodeURL(url);
+    }
 
     public String getContextName() {
         return context.getServletContextName();

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 20/24: MYFACESTEST-14 Update myfaces-test to use JUnit 4.x (don't cast to mock)

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit fa01e0f1f27f0262a60b9d9c7094ffc1c9197e49
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Tue Jul 13 04:03:56 2010 +0000

    MYFACESTEST-14 Update myfaces-test to use JUnit 4.x (don't cast to mock)
---
 .../junit4/AbstractJsfConfigurableMockTestCase.java | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java b/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
index f8cbe11..ba8b1e2 100644
--- a/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
@@ -34,15 +34,12 @@ import javax.faces.render.RenderKitFactory;
 
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
-import org.apache.myfaces.test.mock.MockFacesContextFactory;
 import org.apache.myfaces.test.mock.MockHttpServletRequest;
 import org.apache.myfaces.test.mock.MockHttpServletResponse;
 import org.apache.myfaces.test.mock.MockHttpSession;
 import org.apache.myfaces.test.mock.MockRenderKit;
 import org.apache.myfaces.test.mock.MockServletConfig;
 import org.apache.myfaces.test.mock.MockServletContext;
-import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
-import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
 import org.junit.After;
 import org.junit.Before;
 
@@ -52,11 +49,11 @@ import org.junit.Before;
  * protected variables are initialized in the <code>setUp()</code> method, and
  * cleaned up in the <code>tearDown()</code> method:</p>
  * <ul>
- * <li><code>application</code> (<code>MockApplication</code>)</li>
+ * <li><code>application</code> (<code>Application</code>)</li>
  * <li><code>config</code> (<code>MockServletConfig</code>)</li>
- * <li><code>externalContext</code> (<code>MockExternalContext</code>)</li>
- * <li><code>facesContext</code> (<code>MockFacesContext</code>)</li>
- * <li><code>lifecycle</code> (<code>MockLifecycle</code>)</li>
+ * <li><code>externalContext</code> (<code>ExternalContext</code>)</li>
+ * <li><code>facesContext</code> (<code>FacesContext</code>)</li>
+ * <li><code>lifecycle</code> (<code>Lifecycle</code>)</li>
  * <li><code>request</code> (<code>MockHttpServletRequest</code></li>
  * <li><code>response</code> (<code>MockHttpServletResponse</code>)</li>
  * <li><code>servletContext</code> (<code>MockServletContext</code>)</li>
@@ -158,22 +155,22 @@ public abstract class AbstractJsfConfigurableMockTestCase {
     
     protected void setUpLifecycle() throws Exception
     {
-        lifecycleFactory = (MockLifecycleFactory)
+        lifecycleFactory = (LifecycleFactory)
         FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
-        lifecycle = (MockLifecycle)
+        lifecycle = 
         lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
     }
     
     protected void setUpFacesContext() throws Exception
     {
-        facesContextFactory = (MockFacesContextFactory)
+        facesContextFactory = (FacesContextFactory)
         FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
-        facesContext = (MockFacesContext)
+        facesContext = (FacesContext)
         facesContextFactory.getFacesContext(servletContext,
                 request,
                 response,
                 lifecycle);
-        externalContext = (MockExternalContext) facesContext.getExternalContext();
+        externalContext = (ExternalContext) facesContext.getExternalContext();
     }
 
     protected void setUpView() throws Exception

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 06/24: [maven-release-plugin] prepare release 1_0_0_beta_4

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 369895341cf46d5281b2a03a3d7ce52a0d9bc228
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Fri Jun 11 02:32:44 2010 +0000

    [maven-release-plugin] prepare release 1_0_0_beta_4
---
 pom.xml        | 8 ++++----
 test12/pom.xml | 2 +-
 test20/pom.xml | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index af3cfaf..0eea5db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,16 +30,16 @@
     <artifactId>myfaces-test-project</artifactId>
     <packaging>pom</packaging>
     <name>Myfaces Test Framework</name>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0-beta-4</version>
     <url>http://myfaces.apache.org/test</url>
     <issueManagement>
       <system>jira</system>
       <url>http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10600</url>
     </issueManagement>
     <scm>
-      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/trunk</connection>
-      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/trunk</developerConnection>
-      <url>http://svn.apache.org/repos/asf/myfaces/test/trunk</url>
+      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</connection>
+      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</developerConnection>
+      <url>http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</url>
     </scm>
     <modules>
       <module>test12</module>
diff --git a/test12/pom.xml b/test12/pom.xml
index 3ffa3bb..90ef95d 100644
--- a/test12/pom.xml
+++ b/test12/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0-beta-4</version>
     </parent>
 
     <artifactId>myfaces-test12</artifactId>
diff --git a/test20/pom.xml b/test20/pom.xml
index 8021996..60fe388 100644
--- a/test20/pom.xml
+++ b/test20/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0-beta-4</version>
     </parent>
 
     <artifactId>myfaces-test20</artifactId>

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 21/24: MYFACESTEST-19 JUnit4 Runner that runs each Test method in a seperate classloader (thanks to Rudy De Busscher for this patch)

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit a06f745f3d4fd50831fe4c361069fe07fb82e68d
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Tue Jul 13 04:14:17 2010 +0000

    MYFACESTEST-19 JUnit4 Runner that runs each Test method in a seperate classloader (thanks to Rudy De Busscher for this patch)
---
 test12/pom.xml                                     |   8 +
 .../myfaces/test/base/AbstractJsfTestCase.java     |   4 +-
 .../apache/myfaces/test/runners/NamedRunner.java   | 123 ++++++++
 .../myfaces/test/runners/TestClassLoader.java      | 332 +++++++++++++++++++++
 .../test/runners/TestPerClassLoaderRunner.java     | 293 ++++++++++++++++++
 .../myfaces/test/runners/excluded.properties       |  12 +
 .../runner/TestPerCLassLoaderDefaultTestCase.java  |  71 +++++
 .../test/runner/TestPerClassLoaderTestCase.java    |  66 ++++
 .../myfaces/test/runner/WebXmlParameter.java       |  30 ++
 .../apache/myfaces/test/runner/WebXmlUtils.java    |  40 +++
 10 files changed, 978 insertions(+), 1 deletion(-)

diff --git a/test12/pom.xml b/test12/pom.xml
index 4484902..1838e31 100644
--- a/test12/pom.xml
+++ b/test12/pom.xml
@@ -95,6 +95,14 @@
     </dependencies>
 
     <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*properties</include>
+                </includes>
+            </resource>
+        </resources>
         <plugins>
             <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
diff --git a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java b/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
index fbe30cb..54e444e 100644
--- a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
@@ -202,7 +202,9 @@ public abstract class AbstractJsfTestCase extends TestCase {
         application = null;
         config = null;
         externalContext = null;
-        facesContext.release();
+        if (facesContext != null) {
+            facesContext.release();
+        }
         facesContext = null;
         lifecycle = null;
         lifecycleFactory = null;
diff --git a/test12/src/main/java/org/apache/myfaces/test/runners/NamedRunner.java b/test12/src/main/java/org/apache/myfaces/test/runners/NamedRunner.java
new file mode 100644
index 0000000..5493027
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/runners/NamedRunner.java
@@ -0,0 +1,123 @@
+/*
+ * 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.runners;
+
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+
+/**
+ * A Junit 4 runner that stores the name of the method that runs.  The methods marked with @After and @Before 
+ * (but also the Test method itself) can request this name for which it is running.
+ * 
+ * @author Rudy De Busscher
+ */
+public class NamedRunner extends BlockJUnit4ClassRunner
+{
+
+    /** The Constant PREFIX_KEY. */
+    private static final String PREFIX_KEY = "ClassLoaderRunner_TestMethodName_";
+
+    /** The Constant NO_NAME. */
+    private static final String NO_NAME = "null";
+
+    /**
+     * Instantiates a new named runner.
+     * 
+     * @param klass the klass
+     * 
+     * @throws InitializationError the initialization error
+     */
+    public NamedRunner(Class<?> klass) throws InitializationError
+    {
+        super(klass);
+    }
+
+    @Override
+    protected void runChild(FrameworkMethod method, RunNotifier notifier)
+
+    {
+        storeTestMethodName(method.getName());
+        super.runChild(method, notifier);
+        removeTestMethodName();
+    }
+
+    /**
+     * Gets the test method name.
+     * 
+     * @return the test method name
+     */
+    public static String getTestMethodName()
+    {
+        return retrieveTestMethodName();
+    }
+
+    /**
+     * Retrieve test method name.
+     * 
+     * @return the string
+     */
+    private static String retrieveTestMethodName()
+    {
+        // We can't use a ThreadLocal variable in the case the TestPerClassLoader runner is used.  Then this
+        // Method is accessed from another classloader and thus reinitialized variables.
+        String result = null;
+        String storedName = System.getProperty(getKey());
+        if (!NO_NAME.equals(storedName))
+        {
+            result = storedName;
+        }
+        return result;
+    }
+
+    /**
+     * Removes the test method name.
+     */
+    private static void removeTestMethodName()
+    {
+        // We can't use a ThreadLocal variable in the case the TestPerClassLoader runner is used.  Then this
+        // Method is accessed from another classloader and thus reinitialized variables.
+        System.setProperty(getKey(), NO_NAME);
+
+    }
+
+    /**
+     * Store test method name.
+     * 
+     * @param name the name
+     */
+    private static void storeTestMethodName(String name)
+    {
+
+        // We can't use a ThreadLocal variable in the case the TestPerClassLoader runner is used.  Then this
+        // Method is accessed from another classloader and thus reinitialized variables.
+        System.setProperty(getKey(), name);
+    }
+
+    /**
+     * Gets the key.
+     * 
+     * @return the key
+     */
+    private static String getKey()
+    {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(PREFIX_KEY).append(Thread.currentThread().getName());
+        return buffer.toString();
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/runners/TestClassLoader.java b/test12/src/main/java/org/apache/myfaces/test/runners/TestClassLoader.java
new file mode 100644
index 0000000..036f1f0
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/runners/TestClassLoader.java
@@ -0,0 +1,332 @@
+/*
+ * 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.runners;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * A Classloader that delegates the loading of the classes to the parent if it is in the 
+ * excluded list or does it itself otherwise.
+ * Useful for a system that sets up a classloader per Test system.
+ *  
+ * @author Rudy De Busscher
+ */
+public class TestClassLoader extends ClassLoader
+{
+    /** scanned class path */
+    private Vector<String> fPathItems;
+    /** default excluded paths */
+    private String[] defaultExclusions = { "junit.framework.",
+            "junit.extensions.", "junit.runner." };
+    /** name of excluded properties file */
+    static final String EXCLUDED_FILE = "excluded.properties";
+    /** excluded paths */
+    private Vector<String> fExcluded;
+
+    /**
+     * Constructs a TestCaseLoader. It scans the class path
+     * and the excluded package paths
+     */
+    public TestClassLoader()
+    {
+        this(System.getProperty("java.class.path"));
+    }
+
+    /**
+     * Constructs a TestCaseLoader. It scans the class path
+     * and the excluded package paths
+     */
+    public TestClassLoader(String classPath)
+    {
+        scanPath(classPath);
+        readExcludedPackages();
+    }
+
+    private void scanPath(String classPath)
+    {
+        String separator = System.getProperty("path.separator");
+        fPathItems = new Vector<String>(10);
+        StringTokenizer st = new StringTokenizer(classPath, separator);
+        while (st.hasMoreTokens())
+        {
+            fPathItems.addElement(st.nextToken());
+        }
+    }
+
+    @Override
+    public URL getResource(String name)
+    {
+        return ClassLoader.getSystemResource(name);
+    }
+
+    @Override
+    public InputStream getResourceAsStream(String name)
+    {
+        return ClassLoader.getSystemResourceAsStream(name);
+    }
+
+    /**
+     * Checks if path is excluded.
+     * 
+     * @param name the name
+     * 
+     * @return true, if is excluded
+     */
+    public boolean isExcluded(String name)
+    {
+        for (int i = 0; i < fExcluded.size(); i++)
+        {
+            if (name.startsWith((String) fExcluded.elementAt(i)))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public synchronized Class loadClass(String name, boolean resolve)
+            throws ClassNotFoundException
+    {
+
+        Class c = findLoadedClass(name);
+        if (c != null)
+            return c;
+        //
+        // Delegate the loading of excluded classes to the
+        // standard class loader.
+        //
+        if (isExcluded(name))
+        {
+            try
+            {
+                c = findSystemClass(name);
+                return c;
+            }
+            catch (ClassNotFoundException e)
+            {
+                // keep searching
+            }
+        }
+        if (c == null)
+        {
+            byte[] data = lookupClassData(name);
+            if (data == null)
+                throw new ClassNotFoundException();
+            c = defineClass(name, data, 0, data.length);
+        }
+        if (resolve)
+            resolveClass(c);
+        return c;
+    }
+
+    /**
+     * Lookup class data in one of the classpath elements configured.
+     * 
+     * @param className the class name
+     * 
+     * @return the bytes making up the class
+     * 
+     * @throws ClassNotFoundException when class can't be found on the classpath elements.
+     */
+    private byte[] lookupClassData(String className)
+            throws ClassNotFoundException
+    {
+        byte[] data = null;
+        for (int i = 0; i < fPathItems.size(); i++)
+        {
+            String path = (String) fPathItems.elementAt(i);
+            String fileName = className.replace('.', '/') + ".class";
+            if (isJar(path))
+            {
+                data = loadJarData(path, fileName);
+            }
+            else
+            {
+                data = loadFileData(path, fileName);
+            }
+            if (data != null)
+                return data;
+        }
+        throw new ClassNotFoundException(className);
+    }
+
+    /**
+     * Checks if is jar.
+     * 
+     * @param pathEntry the path entry
+     * 
+     * @return true, if is jar
+     */
+    boolean isJar(String pathEntry)
+    {
+        return pathEntry.endsWith(".jar") || pathEntry.endsWith(".zip");
+    }
+
+    /**
+     * Load class bytes from file.
+     * 
+     * @param path the path
+     * @param fileName the file name
+     * 
+     * @return the bytes making up the class
+     */
+    private byte[] loadFileData(String path, String fileName)
+    {
+        File file = new File(path, fileName);
+        if (file.exists())
+        {
+            return getClassData(file);
+        }
+        return null;
+    }
+
+    private byte[] getClassData(File f)
+    {
+        try
+        {
+            FileInputStream stream = new FileInputStream(f);
+            ByteArrayOutputStream out = new ByteArrayOutputStream(1000);
+            byte[] b = new byte[1000];
+            int n;
+            while ((n = stream.read(b)) != -1)
+                out.write(b, 0, n);
+            stream.close();
+            out.close();
+            return out.toByteArray();
+
+        }
+        catch (IOException e)
+        {
+        }
+        return null;
+    }
+
+    /**
+     * Load class bytes from jar.
+     * 
+     * @param path the path
+     * @param fileName the file name
+     * 
+     * @return the bytes making up the class
+     */
+    private byte[] loadJarData(String path, String fileName)
+    {
+        ZipFile zipFile = null;
+        InputStream stream = null;
+        File archive = new File(path);
+        if (!archive.exists())
+            return null;
+        try
+        {
+            zipFile = new ZipFile(archive);
+        }
+        catch (IOException io)
+        {
+            return null;
+        }
+        ZipEntry entry = zipFile.getEntry(fileName);
+        if (entry == null)
+            return null;
+        int size = (int) entry.getSize();
+        try
+        {
+            stream = zipFile.getInputStream(entry);
+            byte[] data = new byte[size];
+            int pos = 0;
+            while (pos < size)
+            {
+                int n = stream.read(data, pos, data.length - pos);
+                pos += n;
+            }
+            zipFile.close();
+            return data;
+        }
+        catch (IOException e)
+        {
+        }
+        finally
+        {
+            try
+            {
+                if (stream != null)
+                    stream.close();
+            }
+            catch (IOException e)
+            {
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Read excluded packages for which classes are read by the parent class loader.
+     */
+    private void readExcludedPackages()
+    {
+        fExcluded = new Vector<String>(10);
+        for (int i = 0; i < defaultExclusions.length; i++)
+            fExcluded.addElement(defaultExclusions[i]);
+
+        InputStream is = getClass().getResourceAsStream(EXCLUDED_FILE);
+        if (is == null)
+            return;
+        Properties p = new Properties();
+        try
+        {
+            p.load(is);
+        }
+        catch (IOException e)
+        {
+            return;
+        }
+        finally
+        {
+            try
+            {
+                is.close();
+            }
+            catch (IOException e)
+            {
+            }
+        }
+        for (Enumeration e = p.propertyNames(); e.hasMoreElements();)
+        {
+            String key = (String) e.nextElement();
+            if (key.startsWith("excluded."))
+            {
+                String path = p.getProperty(key);
+                path = path.trim();
+                if (path.endsWith("*"))
+                    path = path.substring(0, path.length() - 1);
+                if (path.length() > 0)
+                    fExcluded.addElement(path);
+            }
+        }
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/runners/TestPerClassLoaderRunner.java b/test12/src/main/java/org/apache/myfaces/test/runners/TestPerClassLoaderRunner.java
new file mode 100644
index 0000000..32e2c12
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/runners/TestPerClassLoaderRunner.java
@@ -0,0 +1,293 @@
+/*
+ * 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.runners;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import java.util.logging.Logger;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.internal.runners.statements.Fail;
+import org.junit.internal.runners.statements.RunAfters;
+import org.junit.internal.runners.statements.RunBefores;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+import org.junit.runners.model.TestClass;
+
+/**
+ * A Junit 4 runner that executes each Test method with a new Custom classloader so that all variables, 
+ * also the final ones, are reinitialized.
+ * 
+ * @author Rudy De Busscher
+
+ */
+public class TestPerClassLoaderRunner extends NamedRunner
+{
+    private static final Logger LOGGER = Logger
+            .getLogger(TestPerClassLoaderRunner.class.getName());
+
+    // The classpath is needed because the custom class loader looks there to find the classes.
+    private static String classPath;
+    private static boolean classPathDetermined = false;
+
+    // Some data related to the class from the custom class loader.
+    private TestClass testClassFromClassLoader;
+    private Object beforeFromClassLoader;
+    private Object afterFromClassLoader;
+
+    /**
+     * Instantiates a new test per class loader runner.
+     * 
+     * @param klass the klass
+     * 
+     * @throws InitializationError the initialization error
+     */
+    public TestPerClassLoaderRunner(Class<?> klass) throws InitializationError
+    {
+        super(klass);
+    }
+
+    @Override
+    protected Object createTest() throws Exception
+    {
+        // Need an instance now from the class loaded by the custom loader.
+        return testClassFromClassLoader.getJavaClass().newInstance();
+    }
+
+    /**
+     * Load classes (TestCase, @Before and @After with custom class loader.
+     * 
+     * @throws ClassNotFoundException the class not found exception
+     */
+    private void loadClassesWithCustomClassLoader()
+            throws ClassNotFoundException
+    {
+        ClassLoader classLoader;
+
+        // We need the classpath so that our custom loader can search for the requested classes.
+        String testPath = getClassPath();
+        if (testPath != null)
+        {
+            classLoader = new TestClassLoader(testPath);
+        }
+
+        else
+        {
+            classLoader = new TestClassLoader();
+
+        }
+
+        testClassFromClassLoader = new TestClass(classLoader
+                .loadClass(getTestClass().getJavaClass().getName()));
+        // See withAfters and withBefores for the reason.
+        beforeFromClassLoader = classLoader.loadClass(Before.class.getName());
+        afterFromClassLoader = classLoader.loadClass(After.class.getName());
+    }
+
+    @Override
+    protected Statement methodBlock(FrameworkMethod method)
+    {
+        FrameworkMethod newMethod = null;
+        try
+        {
+            // Need the class frmo the custom loader now, so lets load the class.
+            loadClassesWithCustomClassLoader();
+            // The method as parameter is frmo the original class and thus not found in our
+            // class loaded by the custom name (reflection is class loader sensitive)
+            // So find the same method but now in the class frmo the class Loader.
+            Method methodFromNewlyLoadedClass = testClassFromClassLoader
+                    .getJavaClass().getMethod(method.getName());
+            newMethod = new FrameworkMethod(methodFromNewlyLoadedClass);
+        }
+        catch (ClassNotFoundException e)
+        {
+            // Show any problem nicely as a JUnit Test failure.
+            return new Fail(e);
+        }
+        catch (SecurityException e)
+        {
+            return new Fail(e);
+        }
+        catch (NoSuchMethodException e)
+        {
+            return new Fail(e);
+        }
+
+        // We can carry out the normal JUnit functionality with our newly discoverd method now. 
+        return super.methodBlock(newMethod);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected Statement withAfters(FrameworkMethod method, Object target,
+            Statement statement)
+    {
+        // We now to need to search in the class from the custom loader.
+        //We also need to search with the annotation loaded by the custom class loader or otherwise we don't find any method.
+        List<FrameworkMethod> afters = testClassFromClassLoader
+                .getAnnotatedMethods((Class<? extends Annotation>) afterFromClassLoader);
+        return new RunAfters(statement, afters, target);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected Statement withBefores(FrameworkMethod method, Object target,
+            Statement statement)
+    {
+        // We now to need to search in the class from the custom loader.
+        //We also need to search with the annotation loaded by the custom class loader or otherwise we don't find any method.
+        List<FrameworkMethod> befores = testClassFromClassLoader
+                .getAnnotatedMethods((Class<? extends Annotation>) beforeFromClassLoader);
+        return new RunBefores(statement, befores, target);
+    }
+
+    /**
+     * Gets the class path. This value is cached in a static variable for performance reasons.
+     * 
+     * @return the class path
+     */
+    private static String getClassPath()
+    {
+        if (classPathDetermined)
+        {
+            return classPath;
+        }
+
+        classPathDetermined = true;
+        // running from maven, we have the classpath in this property.
+        classPath = System.getProperty("surefire.test.class.path");
+        if (classPath != null)
+        {
+            return classPath;
+        }
+
+        // For a multi module project, running it from the top we have to find it using another way.
+        // We also need to set useSystemClassLoader=true in the POM so that we gets a jar with the classpath in it.
+        String booterClassPath = System.getProperty("java.class.path");
+        Vector<String> pathItems = null;
+        if (booterClassPath != null)
+        {
+            pathItems = scanPath(booterClassPath);
+        }
+        // Do we have just 1 entry as classpath which is a jar?
+        if (pathItems != null && pathItems.size() == 1
+                && isJar((String) pathItems.get(0)))
+        {
+            classPath = loadJarManifestClassPath((String) pathItems.get(0),
+                    "META-INF/MANIFEST.MF");
+        }
+        return classPath;
+
+    }
+
+    /**
+     * Load jar manifest class path.
+     * 
+     * @param path the path
+     * @param fileName the file name
+     * 
+     * @return the string
+     */
+    private static String loadJarManifestClassPath(String path, String fileName)
+    {
+        File archive = new File(path);
+        if (!archive.exists())
+        {
+            return null;
+        }
+        ZipFile zipFile = null;
+
+        try
+        {
+            zipFile = new ZipFile(archive);
+        }
+        catch (IOException io)
+        {
+            return null;
+        }
+
+        ZipEntry entry = zipFile.getEntry(fileName);
+        if (entry == null)
+        {
+            return null;
+        }
+        try
+        {
+            Manifest mf = new Manifest();
+            mf.read(zipFile.getInputStream(entry));
+
+            return mf.getMainAttributes().getValue(Attributes.Name.CLASS_PATH)
+                    .replaceAll(" ", System.getProperty("path.separator"))
+                    .replaceAll("file:/", "");
+        }
+        catch (MalformedURLException e)
+        {
+            LOGGER.throwing("ClassLoaderTestSuite", "loadJarManifestClassPath",
+                    e);
+        }
+        catch (IOException e)
+        {
+            LOGGER.throwing("ClassLoaderTestSuite", "loadJarManifestClassPath",
+                    e);
+        }
+        return null;
+    }
+
+    /**
+     * Checks if is jar.
+     * 
+     * @param pathEntry the path entry
+     * 
+     * @return true, if is jar
+     */
+    private static boolean isJar(String pathEntry)
+    {
+        return pathEntry.endsWith(".jar") || pathEntry.endsWith(".zip");
+    }
+
+    /**
+     * Scan path for all directories.
+     * 
+     * @param classPath the class path
+     * 
+     * @return the vector< string>
+     */
+    private static Vector<String> scanPath(String classPath)
+    {
+        String separator = System.getProperty("path.separator");
+        Vector<String> pathItems = new Vector<String>(10);
+        StringTokenizer st = new StringTokenizer(classPath, separator);
+        while (st.hasMoreTokens())
+        {
+            pathItems.addElement(st.nextToken());
+        }
+        return pathItems;
+    }
+
+}
diff --git a/test12/src/main/resources/org/apache/myfaces/test/runners/excluded.properties b/test12/src/main/resources/org/apache/myfaces/test/runners/excluded.properties
new file mode 100644
index 0000000..a936e9a
--- /dev/null
+++ b/test12/src/main/resources/org/apache/myfaces/test/runners/excluded.properties
@@ -0,0 +1,12 @@
+#
+# The list of excluded package paths for the TestCaseClassLoader
+#
+excluded.0=sun.*
+excluded.1=com.sun.*
+excluded.2=org.omg.*
+excluded.3=javax.*
+excluded.4=sunw.*
+excluded.5=java.*
+excluded.6=org.w3c.dom.*
+excluded.7=org.xml.sax.*
+excluded.8=net.jini.*
diff --git a/test12/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java b/test12/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java
new file mode 100644
index 0000000..9106b8d
--- /dev/null
+++ b/test12/src/test/java/org/apache/myfaces/test/runner/TestPerCLassLoaderDefaultTestCase.java
@@ -0,0 +1,71 @@
+/*
+ * 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.runner;
+
+import junit.framework.Assert;
+
+import org.apache.myfaces.test.base.junit4.AbstractJsfConfigurableMockTestCase;
+import org.apache.myfaces.test.runners.NamedRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ */
+@RunWith(value = NamedRunner.class)
+public class TestPerCLassLoaderDefaultTestCase extends
+        AbstractJsfConfigurableMockTestCase
+{
+
+    @Override
+    protected void setUpExternalContext() throws Exception
+    {
+
+        super.setUpExternalContext();
+
+        if (needXmlParameters())
+        {
+            servletContext
+                    .addInitParameter(WebXmlParameter.PARAMETER_KEY, "60");
+        }
+
+    }
+
+    @Test
+    public void testGetParameterDefault()
+    {
+        Assert.assertNull(WebXmlParameter.PARAMETER);
+    }
+
+    @Test
+    public void testGetParameterWebXml()
+    {
+
+        Assert.assertNull(WebXmlParameter.PARAMETER);
+        // Although the parameter is set, the final variable keeps it value
+        // Since we aren't running with the TestPerClassLoader Test case.
+        Assert.assertNotNull(servletContext
+                .getInitParameter(WebXmlParameter.PARAMETER_KEY));
+    }
+
+    // These methods can be placed in a common super class.
+    protected boolean needXmlParameters()
+    {
+        return NamedRunner.getTestMethodName().contains("Xml");
+    }
+}
diff --git a/test12/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java b/test12/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java
new file mode 100644
index 0000000..86fe9ed
--- /dev/null
+++ b/test12/src/test/java/org/apache/myfaces/test/runner/TestPerClassLoaderTestCase.java
@@ -0,0 +1,66 @@
+/*
+ * 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.runner;
+
+import junit.framework.Assert;
+
+import org.apache.myfaces.test.base.junit4.AbstractJsfConfigurableMockTestCase;
+import org.apache.myfaces.test.runners.TestPerClassLoaderRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ */
+@RunWith(value = TestPerClassLoaderRunner.class)
+public class TestPerClassLoaderTestCase extends
+        AbstractJsfConfigurableMockTestCase
+{
+
+    @Override
+    protected void setUpExternalContext() throws Exception
+    {
+
+        super.setUpExternalContext();
+
+        if (needXmlParameters())
+        {
+            servletContext
+                    .addInitParameter(WebXmlParameter.PARAMETER_KEY, "60");
+        }
+
+    }
+
+    @Test
+    public void testGetParameterDefault()
+    {
+        Assert.assertNull(WebXmlParameter.PARAMETER);
+    }
+
+    @Test
+    public void testGetParameterWebXml()
+    {
+        Assert.assertEquals("60", WebXmlParameter.PARAMETER);
+    }
+
+    // These methods can be placed in a common super class.
+    protected boolean needXmlParameters()
+    {
+        return TestPerClassLoaderRunner.getTestMethodName().contains("Xml");
+    }
+}
diff --git a/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java b/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java
new file mode 100644
index 0000000..455fb58
--- /dev/null
+++ b/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlParameter.java
@@ -0,0 +1,30 @@
+/*
+ * 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.runner;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ */
+public class WebXmlParameter
+{
+    public static final String PARAMETER_KEY = "PARAMETER";
+    
+    static final String PARAMETER = WebXmlUtils
+            .getInitParameter(PARAMETER_KEY);
+
+}
diff --git a/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java b/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java
new file mode 100644
index 0000000..f122dfc
--- /dev/null
+++ b/test12/src/test/java/org/apache/myfaces/test/runner/WebXmlUtils.java
@@ -0,0 +1,40 @@
+/*
+ * 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.runner;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ */
+public final class WebXmlUtils
+{
+
+    private WebXmlUtils()
+    {
+
+    }
+
+    public static String getInitParameter(String parameterName)
+    {
+        String value = FacesContext.getCurrentInstance().getExternalContext()
+                .getInitParameter(parameterName);
+        return (value != null) ? value.replace(" ", "").trim() : null;
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 02/24: [maven-release-plugin] prepare for next development iteration

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit f6dd68e93855718ae570bc56670cbf92ce82786f
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Wed Apr 14 01:33:18 2010 +0000

    [maven-release-plugin] prepare for next development iteration
---
 pom.xml        | 8 ++++----
 test12/pom.xml | 2 +-
 test20/pom.xml | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index 817590e..af3cfaf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,16 +30,16 @@
     <artifactId>myfaces-test-project</artifactId>
     <packaging>pom</packaging>
     <name>Myfaces Test Framework</name>
-    <version>1.0.0-beta-3</version>
+    <version>1.0.0-SNAPSHOT</version>
     <url>http://myfaces.apache.org/test</url>
     <issueManagement>
       <system>jira</system>
       <url>http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10600</url>
     </issueManagement>
     <scm>
-      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_3</connection>
-      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_3</developerConnection>
-      <url>http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_3</url>
+      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/trunk</connection>
+      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/trunk</developerConnection>
+      <url>http://svn.apache.org/repos/asf/myfaces/test/trunk</url>
     </scm>
     <modules>
       <module>test12</module>
diff --git a/test12/pom.xml b/test12/pom.xml
index 132862a..3ffa3bb 100644
--- a/test12/pom.xml
+++ b/test12/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-beta-3</version>
+        <version>1.0.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>myfaces-test12</artifactId>
diff --git a/test20/pom.xml b/test20/pom.xml
index 8976be8..8021996 100644
--- a/test20/pom.xml
+++ b/test20/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-beta-3</version>
+        <version>1.0.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>myfaces-test20</artifactId>

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 18/24: fix typo errors

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 8f57f6a0acd794ae90998f794a131415f29643ac
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 02:37:54 2010 +0000

    fix typo errors
---
 .../java/org/apache/myfaces/test/mock/MockResponseStateManager.java     | 2 +-
 test20/src/test/java/org/apache/myfaces/test/config/MyValidator.java    | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java b/test20/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
index d9b9e16..c205602 100644
--- a/test20/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
@@ -210,7 +210,7 @@ public class MockResponseStateManager extends ResponseStateManager
         }
         catch (ClassNotFoundException e)
         {
-            throw new IOException(e);
+            throw new IOException(e.getMessage());
         }
         finally
         {
diff --git a/test20/src/test/java/org/apache/myfaces/test/config/MyValidator.java b/test20/src/test/java/org/apache/myfaces/test/config/MyValidator.java
index 3dbc014..d1f9f97 100644
--- a/test20/src/test/java/org/apache/myfaces/test/config/MyValidator.java
+++ b/test20/src/test/java/org/apache/myfaces/test/config/MyValidator.java
@@ -27,7 +27,6 @@ import javax.faces.validator.ValidatorException;
  */
 public class MyValidator implements Validator {
 
-    @Override
     public void validate(FacesContext context, UIComponent component,
             Object value) throws ValidatorException
     {

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 09/24: move to branches for release procedure

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 7c3ff984ee8e636ee47e2e8c0ac2845f1b25e679
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Fri Jun 11 02:35:46 2010 +0000

    move to branches for release procedure

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 15/24: MYFACESTEST-17 Update MockExternalContext so it delegate to mock request and response objects and add new methods present on facelets mocks

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 16a03f39b721e9e3129925084357963a2606a29a
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 00:15:53 2010 +0000

    MYFACESTEST-17 Update MockExternalContext so it delegate to mock request and response objects and add new methods present on facelets mocks
---
 .../myfaces/test/mock/MockExternalContext.java     | 431 ++++++++++----------
 .../myfaces/test/mock/MockHttpServletRequest.java  |  85 ++--
 .../myfaces/test/mock/MockHttpServletResponse.java | 121 +++---
 .../myfaces/test/mock/MockRequestDispatcher.java   |  59 +++
 .../myfaces/test/mock/MockServletContext.java      | 433 ++++++++++++---------
 .../myfaces/test/mock/MockServletInputStream.java  |  53 +++
 .../myfaces/test/mock/_AbstractAttributeMap.java   | 351 +++++++++++++++++
 .../apache/myfaces/test/mock/_ApplicationMap.java  |  87 +++++
 .../org/apache/myfaces/test/mock/_CookieMap.java   | 173 ++++++++
 .../myfaces/test/mock/_InitParameterMap.java       |  74 ++++
 .../apache/myfaces/test/mock/_NullEnumeration.java |  48 +++
 .../myfaces/test/mock/_RequestHeaderMap.java       |  70 ++++
 .../myfaces/test/mock/_RequestHeaderValuesMap.java |  76 ++++
 .../org/apache/myfaces/test/mock/_RequestMap.java  |  61 +++
 .../myfaces/test/mock/_RequestParameterMap.java    |  68 ++++
 .../test/mock/_RequestParameterValuesMap.java      |  61 +++
 .../org/apache/myfaces/test/mock/_SessionMap.java  |  88 +++++
 17 files changed, 1870 insertions(+), 469 deletions(-)

diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockExternalContext.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockExternalContext.java
index 8c47099..9b61d28 100644
--- a/test12/src/main/java/org/apache/myfaces/test/mock/MockExternalContext.java
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockExternalContext.java
@@ -21,9 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
@@ -31,7 +29,10 @@ import java.util.Set;
 
 import javax.faces.FacesException;
 import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -43,12 +44,11 @@ import javax.servlet.http.HttpSession;
  * $Id$
  */
 
-public class MockExternalContext extends ExternalContext {
-
+public class MockExternalContext extends ExternalContext
+{
 
     // ------------------------------------------------------------ Constructors
 
-
     /**
      * <p>Construct a wrapper instance.</p>
      *
@@ -58,74 +58,98 @@ public class MockExternalContext extends ExternalContext {
      */
     public MockExternalContext(ServletContext context,
                                HttpServletRequest request,
-                               HttpServletResponse response) {
+                               HttpServletResponse response)
+    {
 
         this.context = context;
         this.request = request;
         this.response = response;
-        applicationMap = new MockApplicationMap(context);
-        requestMap = new MockRequestMap(request);
-
+        this.applicationMap = null;
+        this.initParameterMap = null;
+        this.requestMap = null;
+        this.requestCookieMap = null;
+        this.requestHeaderMap = null;
+        this.requestParameterMap = null;
+        this.requestParameterValuesMap = null;
+        this.requestHeaderValuesMap = null;
+        this.sessionMap = null;
     }
 
-
     // ----------------------------------------------------- Mock Object Methods
 
-
     // ------------------------------------------------------ Instance Variables
 
-
-    private Map applicationMap = null;
-    protected ServletContext context = null;
-    protected HttpServletRequest request = null;
-    private Map requestMap = null;
-    protected HttpServletResponse response = null;
-    private Map sessionMap = null;
-    private Map requestCookieMap = new HashMap();
-    private Map requestHeaderMap = new HashMap();
-    private Map requestParameterMap = new HashMap();
-
+    protected ServletContext context;
+    protected HttpServletRequest request;
+    protected HttpServletResponse response;
+    private Map applicationMap;
+    private Map initParameterMap;
+    private Map requestMap;
+    private Map requestCookieMap;
+    private Map requestHeaderMap;
+    private Map requestParameterMap;
+    private Map requestParameterValuesMap;
+    private Map requestHeaderValuesMap;
+    private Map sessionMap;
 
     // ------------------------------------------------- setters for the mock object
 
-
     /**
      * <p>Add a new cookie for this request.</p>
      *
      * @param cookie The new cookie
      */
-    public void addRequestCookieMap(Cookie cookie) {
-        requestParameterMap.put(cookie.getName(), cookie);
+    public void addRequestCookieMap(Cookie cookie)
+    {
+        Map map = getRequestCookieMap();
+        if (request instanceof MockHttpServletRequest &&
+            map instanceof _CookieMap)
+        {
+            ((MockHttpServletRequest)request).addCookie(cookie);
+        }
+        else
+        {
+            map.put(cookie.getName(), cookie);
+        }
     }
 
-
     /**
      * <p>Set the request cookie map for this request.</p>
      *
      * @param map The new request cookie map
      */
-    public void setRequestCookieMap(Map map) {
-        requestParameterMap = map;
+    public void setRequestCookieMap(Map map)
+    {
+        requestCookieMap = map;
     }
 
-
     /**
      * <p>Add the specified request parameter for this request.</p>
      *
      * @param key Parameter name
      * @param value Parameter value
      */
-    public void addRequestParameterMap(String key, String value) {
-        requestParameterMap.put(key, value);
+    public void addRequestParameterMap(String key, String value)
+    {
+        Map map = getRequestParameterMap();
+        if (request instanceof MockHttpServletRequest &&
+            map instanceof _RequestParameterMap)
+        {
+            ((MockHttpServletRequest)request).addParameter(key, value);
+        }
+        else
+        {
+            map.put(key, value);
+        }
     }
 
-
     /**
      * <p>Set the request parameter map for this request.</p>
      *
      * @param map The new request parameter map
      */
-    public void setRequestParameterMap(Map map) {
+    public void setRequestParameterMap(Map map)
+    {
         requestParameterMap = map;
     }
 
@@ -135,316 +159,320 @@ public class MockExternalContext extends ExternalContext {
      * @param key Parameter name
      * @param value Parameter value
      */
-    public void addRequestHeader(String key, String value) {
-        requestHeaderMap.put(key, value);
+    public void addRequestHeader(String key, String value)
+    {
+        Map map = getRequestHeaderMap();
+        if (request instanceof MockHttpServletRequest &&
+            map instanceof _RequestHeaderMap)
+        {
+            ((MockHttpServletRequest)request).addHeader(key, value);
+        }
+        else
+        {
+            map.put(key, value);
+        }
     }
 
-
     /**
      * <p>Set the request header map for this request.</p>
      *
      * @param map The new request header map
      */
-    public void setRequestHeaderMap(Map map) {
+    public void setRequestHeaderMap(Map map)
+    {
         requestHeaderMap = map;
     }
 
-
-
-
-
     // ------------------------------------------------- ExternalContext Methods
 
-
     /** {@inheritDoc} */
-    public void dispatch(String requestURI)
-      throws IOException, FacesException {
-
-        throw new UnsupportedOperationException();
-
+    public void dispatch(String requestURI) throws IOException, FacesException
+    {
+        RequestDispatcher requestDispatcher = request
+                .getRequestDispatcher(requestURI);
+        // If there is no dispatcher, send NOT_FOUND
+        if (requestDispatcher == null)
+        {
+            ((HttpServletResponse) response)
+                    .sendError(HttpServletResponse.SC_NOT_FOUND);
+            return;
+        }
+        try
+        {
+            requestDispatcher.forward(request, response);
+        }
+        catch (ServletException e)
+        {
+            if (e.getMessage() != null)
+            {
+                throw new FacesException(e.getMessage(), e);
+            }
+            throw new FacesException(e);
+        }
     }
 
-
     /** {@inheritDoc} */
-    public String encodeActionURL(String sb) {
-
+    public String encodeActionURL(String sb)
+    {
         return sb;
-
     }
 
-
     /** {@inheritDoc} */
-    public String encodeNamespace(String aValue) {
-
+    public String encodeNamespace(String aValue)
+    {
         return aValue;
-
     }
 
-
     /** {@inheritDoc} */
-    public String encodeResourceURL(String sb) {
-
+    public String encodeResourceURL(String sb)
+    {
         return sb;
-
     }
 
-
     /** {@inheritDoc} */
-    public Map getApplicationMap() {
-
-        return this.applicationMap;
-
+    public Map getApplicationMap()
+    {
+        if (applicationMap == null)
+        {
+            applicationMap = new _ApplicationMap(context);
+        }
+        return applicationMap;
     }
 
-
     /** {@inheritDoc} */
-    public String getAuthType() {
-
+    public String getAuthType()
+    {
         return request.getAuthType();
-
     }
 
-
     /** {@inheritDoc} */
-    public Object getContext() {
-
+    public Object getContext()
+    {
         return context;
-
     }
 
-
     /** {@inheritDoc} */
-    public String getInitParameter(String name) {
-
+    public String getInitParameter(String name)
+    {
         return context.getInitParameter(name);
-
     }
 
-
     /** {@inheritDoc} */
-    public Map getInitParameterMap() {
-
-        Map parameterMap = new HashMap();
-        Enumeration names = context.getInitParameterNames();
-        while (names.hasMoreElements()) {
-            String name = (String) names.nextElement();
-            parameterMap.put(name, context.getInitParameter(name));
+    public Map getInitParameterMap()
+    {
+        if (initParameterMap == null)
+        {
+            initParameterMap = new _InitParameterMap(context);
         }
-        return Collections.unmodifiableMap(parameterMap);
-
+        return initParameterMap;
     }
 
-
     /** {@inheritDoc} */
-    public String getRemoteUser() {
-
+    public String getRemoteUser()
+    {
         return request.getRemoteUser();
-
     }
 
-
     /** {@inheritDoc} */
-    public Object getRequest() {
-
+    public Object getRequest()
+    {
         return request;
-
     }
 
-
     /** {@inheritDoc} */
-    public String getRequestContextPath() {
-
+    public String getRequestContextPath()
+    {
         return request.getContextPath();
-
     }
 
-
     /** {@inheritDoc} */
-    public Map getRequestCookieMap() {
-
+    public Map getRequestCookieMap()
+    {
+        if (requestCookieMap == null)
+        {
+            requestCookieMap = new _CookieMap(request);
+        }
         return requestCookieMap;
-
     }
 
-
     /** {@inheritDoc} */
-    public Map getRequestHeaderMap() {
-
+    public Map getRequestHeaderMap()
+    {
+        if (requestHeaderMap == null)
+        {
+            requestHeaderMap = new _RequestHeaderMap(request);
+        }
         return requestHeaderMap;
-
     }
 
-
     /** {@inheritDoc} */
-    public Map getRequestHeaderValuesMap() {
-
-        throw new UnsupportedOperationException();
-
+    public Map getRequestHeaderValuesMap()
+    {
+        if (requestHeaderValuesMap == null)
+        {
+            requestHeaderValuesMap = new _RequestHeaderValuesMap(request);
+        }
+        return requestHeaderValuesMap;
     }
 
-
     /** {@inheritDoc} */
-    public Locale getRequestLocale() {
-
+    public Locale getRequestLocale()
+    {
         return request.getLocale();
-
     }
 
-
     /** {@inheritDoc} */
-    public Iterator getRequestLocales() {
-
+    public Iterator getRequestLocales()
+    {
         return new LocalesIterator(request.getLocales());
-
     }
 
-
     /** {@inheritDoc} */
-    public Map getRequestMap() {
-
+    public Map getRequestMap()
+    {
+        if (requestMap == null)
+        {
+            requestMap = new _RequestMap(request);
+        }
         return requestMap;
-
     }
 
-
     /** {@inheritDoc} */
-    public Map getRequestParameterMap() {
-
+    public Map getRequestParameterMap()
+    {
+        if (requestParameterMap == null)
+        {
+            requestParameterMap = new _RequestParameterMap(request);
+        }
         return requestParameterMap;
-
     }
 
-
     /** {@inheritDoc} */
-    public Iterator getRequestParameterNames() {
+    public Iterator getRequestParameterNames()
+    {
+        final Enumeration enumer = request.getParameterNames();
+        Iterator it = new Iterator()
+        {
+            public boolean hasNext()
+            {
+                return enumer.hasMoreElements();
+            }
 
-        throw new UnsupportedOperationException();
+            public Object next()
+            {
+                return enumer.nextElement();
+            }
 
+            public void remove()
+            {
+                throw new UnsupportedOperationException(this.getClass()
+                        .getName()
+                        + " UnsupportedOperationException");
+            }
+        };
+        return it;
     }
 
-
     /** {@inheritDoc} */
-    public Map getRequestParameterValuesMap() {
-
-        throw new UnsupportedOperationException();
-
+    public Map getRequestParameterValuesMap()
+    {
+        if (requestParameterValuesMap == null)
+        {
+            requestParameterValuesMap = new _RequestParameterValuesMap(request);
+        }
+        return requestParameterValuesMap;
     }
 
-
     /** {@inheritDoc} */
-    public String getRequestPathInfo() {
-
+    public String getRequestPathInfo()
+    {
         return request.getPathInfo();
-
     }
 
-
     /** {@inheritDoc} */
-    public String getRequestServletPath() {
-
+    public String getRequestServletPath()
+    {
         return request.getServletPath();
-
     }
 
-
     /** {@inheritDoc} */
-    public URL getResource(String path) throws MalformedURLException {
-
+    public URL getResource(String path) throws MalformedURLException
+    {
         return context.getResource(path);
-
     }
 
-
     /** {@inheritDoc} */
-    public InputStream getResourceAsStream(String path) {
-
+    public InputStream getResourceAsStream(String path)
+    {
         return context.getResourceAsStream(path);
-
     }
 
-
     /** {@inheritDoc} */
-    public Set getResourcePaths(String path) {
-
+    public Set getResourcePaths(String path)
+    {
         return context.getResourcePaths(path);
-
     }
 
-
     /** {@inheritDoc} */
-    public Object getResponse() {
-
+    public Object getResponse()
+    {
         return response;
-
     }
 
-
     /** {@inheritDoc} */
-    public Object getSession(boolean create) {
-
+    public Object getSession(boolean create)
+    {
         return request.getSession(create);
-
     }
 
-
     /** {@inheritDoc} */
-    public Map getSessionMap() {
-
-        if (sessionMap == null) {
+    public Map getSessionMap()
+    {
+        if (sessionMap == null)
+        {
             HttpSession session = request.getSession(true);
             sessionMap = new MockSessionMap(session);
         }
         return sessionMap;
-
     }
 
-
     /** {@inheritDoc} */
-    public java.security.Principal getUserPrincipal() {
-
+    public java.security.Principal getUserPrincipal()
+    {
         return request.getUserPrincipal();
-
     }
 
-
     /** {@inheritDoc} */
-    public boolean isUserInRole(String role) {
-
+    public boolean isUserInRole(String role)
+    {
         return request.isUserInRole(role);
-
     }
 
-
     /** {@inheritDoc} */
-    public void log(String message) {
-
+    public void log(String message)
+    {
         context.log(message);
-
     }
 
-
     /** {@inheritDoc} */
-    public void log(String message, Throwable throwable) {
-
+    public void log(String message, Throwable throwable)
+    {
         context.log(message, throwable);
-
     }
 
-
     /** {@inheritDoc} */
-    public void redirect(String requestURI)
-      throws IOException {
-
-        throw new UnsupportedOperationException();
-
+    public void redirect(String requestURI) throws IOException
+    {
+        response.sendRedirect(requestURI);
+        FacesContext.getCurrentInstance().responseComplete();
     }
 
-
     /**
      * <p>Iterator implementation that wraps an enumeration
      * of Locales for the current request.</p>
      */
-    private class LocalesIterator implements Iterator {
+    private class LocalesIterator implements Iterator
+    {
 
         /**
          * <p>Construct an iterator wrapping the specified
@@ -452,7 +480,8 @@ public class MockExternalContext extends ExternalContext {
          *
          * @param locales Locales enumeration to wrap
          */
-        public LocalesIterator(Enumeration locales) {
+        public LocalesIterator(Enumeration locales)
+        {
             this.locales = locales;
         }
 
@@ -462,15 +491,23 @@ public class MockExternalContext extends ExternalContext {
         private Enumeration locales;
 
         /** {@inheritDoc} */
-        public boolean hasNext() { return locales.hasMoreElements(); }
+        public boolean hasNext()
+        {
+            return locales.hasMoreElements();
+        }
 
         /** {@inheritDoc} */
-        public Object next() { return locales.nextElement(); }
+        public Object next()
+        {
+            return locales.nextElement();
+        }
 
         /** {@inheritDoc} */
-        public void remove() { throw new UnsupportedOperationException(); }
+        public void remove()
+        {
+            throw new UnsupportedOperationException();
+        }
 
     }
 
-
 }
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java
index bec0ffb..3bee3e4 100644
--- a/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletRequest.java
@@ -18,10 +18,15 @@
 package org.apache.myfaces.test.mock;
 
 import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
 import java.security.Principal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -163,7 +168,19 @@ public class MockHttpServletRequest implements HttpServletRequest {
         parameters.put(name, results);
 
     }
-
+    
+    public void addCookie(Cookie c)
+    {
+        for (int i = 0; i < cookies.size(); i++)
+        {
+            if ( ((Cookie)cookies.get(i)).getName().equals(c.getName()) )
+            {
+                cookies.set(i, c);
+                return;
+            }
+        }
+        cookies.add(c);
+    }
 
     /**
      * <p>Return the <code>ServletContext</code> associated with
@@ -259,7 +276,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
     private String servletPath = null;
     private HttpSession session = null;
     private String characterEncoding = null;
-
+    private ServletInputStream inputStream = null;
+    private List cookies = new ArrayList();
+    private Vector locales = null; 
 
     // ---------------------------------------------- HttpServletRequest Methods
 
@@ -283,8 +302,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
     /** {@inheritDoc} */
     public Cookie[] getCookies() {
 
-        throw new UnsupportedOperationException();
-
+        Cookie[] array = new Cookie[cookies.size()];
+        for (int i = 0; i < cookies.size(); i++)
+        {
+            array[i] = (Cookie) cookies.get(i);
+        }
+        return array;
     }
 
 
@@ -474,7 +497,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
     public HttpSession getSession(boolean create) {
 
         if (create && (session == null)) {
-            throw new UnsupportedOperationException();
+            this.session = new MockHttpSession(this.servletContext);
         }
         return session;
 
@@ -573,12 +596,15 @@ public class MockHttpServletRequest implements HttpServletRequest {
 
 
     /** {@inheritDoc} */
-    public ServletInputStream getInputStream() {
-
-        throw new UnsupportedOperationException();
-
+    public ServletInputStream getInputStream()
+    {
+        return this.inputStream;
+    }
+    
+    public void setInputStream(MockServletInputStream stream)
+    {
+        this.inputStream = stream;
     }
-
 
     /** {@inheritDoc} */
     public Locale getLocale() {
@@ -589,10 +615,14 @@ public class MockHttpServletRequest implements HttpServletRequest {
 
 
     /** {@inheritDoc} */
-    public Enumeration getLocales() {
-
-        throw new UnsupportedOperationException();
-
+    public Enumeration getLocales()
+    {
+        if (this.locales == null)
+        {
+            locales = new Vector(Arrays.asList(Locale
+                    .getAvailableLocales()));
+        }
+        return this.locales.elements();
     }
 
 
@@ -666,10 +696,22 @@ public class MockHttpServletRequest implements HttpServletRequest {
 
 
     /** {@inheritDoc} */
-    public BufferedReader getReader() {
-
-        throw new UnsupportedOperationException();
-
+    public BufferedReader getReader()
+    {
+        if (this.inputStream != null) {
+            try{
+                Reader sourceReader = (this.characterEncoding != null) ? new InputStreamReader(
+                        this.inputStream, this.characterEncoding)
+                        : new InputStreamReader(this.inputStream);
+                return new BufferedReader(sourceReader);
+            }
+            catch(UnsupportedEncodingException e)
+            {
+                throw new RuntimeException(e);
+            }
+        } else {
+            return null;
+        }
     }
 
 
@@ -709,10 +751,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
 
 
     /** {@inheritDoc} */
-    public RequestDispatcher getRequestDispatcher(String path) {
-
-        throw new UnsupportedOperationException();
-
+    public RequestDispatcher getRequestDispatcher(String path)
+    {
+        return servletContext.getRequestDispatcher(path);
     }
 
 
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletResponse.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletResponse.java
index ab18d5e..9d4a7a1 100644
--- a/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletResponse.java
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockHttpServletResponse.java
@@ -23,10 +23,13 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.TimeZone;
 
 import javax.servlet.ServletOutputStream;
@@ -71,8 +74,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
         }
         return null;
     }
-
-
+    
+    public Cookie getCookie(String name)
+    {
+        return (Cookie)cookies.get(name);
+    }
+    
     /**
      * <p>Return the text message for the HTTP status that was set.</p>
      */
@@ -127,16 +134,20 @@ public class MockHttpServletResponse implements HttpServletResponse {
     private int status = HttpServletResponse.SC_OK;
     private ServletOutputStream stream = null;
     private PrintWriter writer = null;
-
+    
+    private boolean committed = false;
+    private long contentLength = 0;
+    private int bufferSize = 0;
+    private Locale locale = Locale.getDefault();
+    private Map cookies = new HashMap(4);
 
     // -------------------------------------------- HttpServletResponse Methods
 
 
     /** {@inheritDoc} */
-    public void addCookie(Cookie cookie) {
-
-        throw new UnsupportedOperationException();
-
+    public void addCookie(Cookie cookie)
+    {
+        cookies.put(cookie.getName(), cookie);
     }
 
 
@@ -205,28 +216,38 @@ public class MockHttpServletResponse implements HttpServletResponse {
 
 
     /** {@inheritDoc} */
-    public void sendError(int status) {
-
+    public void sendError(int status)
+    {
+        if (this.committed)
+        {
+            throw new IllegalStateException("Response is already committed");
+        }
         this.status = status;
-
+        this.committed = true;
     }
 
 
     /** {@inheritDoc} */
-    public void sendError(int status, String message) {
-
+    public void sendError(int status, String message)
+    {
+        if (this.committed)
+        {
+            throw new IllegalStateException("Response is already committed");
+        }
         this.status = status;
         this.message = message;
-
+        this.committed = true;
     }
 
 
     /** {@inheritDoc} */
     public void sendRedirect(String location) {
-
+        if (this.committed) {
+            throw new IllegalStateException("Response is already committed");
+        }
         this.status = HttpServletResponse.SC_MOVED_TEMPORARILY;
         this.message = location;
-
+        this.committed = true;
     }
 
 
@@ -258,18 +279,16 @@ public class MockHttpServletResponse implements HttpServletResponse {
 
 
     /** {@inheritDoc} */
-    public void setStatus(int status) {
-
-        throw new UnsupportedOperationException();
-
+    public void setStatus(int status)
+    {
+        this.status = status;
     }
 
 
     /** {@inheritDoc} */
     public void setStatus(int status, String message) {
-
-        throw new UnsupportedOperationException();
-
+        this.status = status;
+        this.message = message;
     }
 
 
@@ -277,18 +296,15 @@ public class MockHttpServletResponse implements HttpServletResponse {
 
 
     /** {@inheritDoc} */
-    public void flushBuffer() {
-
-        throw new UnsupportedOperationException();
-
+    public void flushBuffer()
+    {
+    
     }
 
 
     /** {@inheritDoc} */
     public int getBufferSize() {
-
-        throw new UnsupportedOperationException();
-
+        return bufferSize;
     }
 
 
@@ -309,10 +325,9 @@ public class MockHttpServletResponse implements HttpServletResponse {
 
 
     /** {@inheritDoc} */
-    public Locale getLocale() {
-
-        throw new UnsupportedOperationException();
-
+    public Locale getLocale()
+    {
+        return this.locale;
     }
 
 
@@ -345,34 +360,28 @@ public class MockHttpServletResponse implements HttpServletResponse {
 
 
     /** {@inheritDoc} */
-    public boolean isCommitted() {
-
-        throw new UnsupportedOperationException();
-
+    public boolean isCommitted()
+    {
+        return committed;
     }
 
 
     /** {@inheritDoc} */
-    public void reset() {
-
-        throw new UnsupportedOperationException();
-
+    public void reset()
+    {
     }
 
 
     /** {@inheritDoc} */
-    public void resetBuffer() {
-
-        throw new UnsupportedOperationException();
-
+    public void resetBuffer()
+    {
     }
 
 
     /** {@inheritDoc} */
-    public void setBufferSize(int size) {
-
-        throw new UnsupportedOperationException();
-
+    public void setBufferSize(int size)
+    {
+        this.bufferSize = size;
     }
 
 
@@ -385,10 +394,9 @@ public class MockHttpServletResponse implements HttpServletResponse {
 
 
     /** {@inheritDoc} */
-    public void setContentLength(int length) {
-
-        throw new UnsupportedOperationException();
-
+    public void setContentLength(int length)
+    {
+        this.contentLength = length;
     }
 
 
@@ -401,10 +409,9 @@ public class MockHttpServletResponse implements HttpServletResponse {
 
 
     /** {@inheritDoc} */
-    public void setLocale(Locale locale) {
-
-        throw new UnsupportedOperationException();
-
+    public void setLocale(Locale locale)
+    {
+        this.locale = locale;
     }
 
 
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockRequestDispatcher.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockRequestDispatcher.java
new file mode 100644
index 0000000..a7650a9
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockRequestDispatcher.java
@@ -0,0 +1,59 @@
+/*
+ * 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 java.io.IOException;
+import java.net.URL;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MockRequestDispatcher.java 804043 2009-08-13 22:08:44Z lu4242 $
+ */
+public class MockRequestDispatcher implements RequestDispatcher
+{
+
+    protected final URL url;
+
+    public MockRequestDispatcher(URL url)
+    {
+        this.url = url;
+    }
+
+    public void forward(ServletRequest request, ServletResponse response)
+            throws ServletException, IOException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void include(ServletRequest request, ServletResponse response)
+            throws ServletException, IOException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockServletContext.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockServletContext.java
index 5300be1..c46ea4b 100644
--- a/test12/src/main/java/org/apache/myfaces/test/mock/MockServletContext.java
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockServletContext.java
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -37,7 +38,6 @@ import javax.servlet.ServletContextAttributeEvent;
 import javax.servlet.ServletContextAttributeListener;
 import javax.servlet.ServletException;
 
-
 /**
  * <p>Mock implementation of <code>ServletContext</code>.</p>
  *
@@ -51,24 +51,11 @@ import javax.servlet.ServletException;
  * $Id$
  */
 
-public class MockServletContext implements ServletContext {
-
-
+public class MockServletContext implements ServletContext
+{
 
     // ----------------------------------------------------- Mock Object Methods
 
-
-    /**
-     * <p>Add a new listener instance that should be notified about
-     * attribute changes.</p>
-     *
-     * @param listener Listener to be added
-     */
-    public void addAttributeListener(ServletContextAttributeListener listener) {
-        attributeListeners.add(listener);
-    }
-
-
     /**
      * <p>Add a context initialization parameter to the set of
      * parameters recognized by this instance.</p>
@@ -76,11 +63,11 @@ public class MockServletContext implements ServletContext {
      * @param name Parameter name
      * @param value Parameter value
      */
-    public void addInitParameter(String name, String value) {
+    public void addInitParameter(String name, String value)
+    {
         parameters.put(name, value);
     }
 
-
     /**
      * <p>Add a new MIME type mapping to the set of mappings
      * recognized by this instance.</p>
@@ -88,11 +75,11 @@ public class MockServletContext implements ServletContext {
      * @param extension Extension to check for (without the period)
      * @param contentType Corresponding content type
      */
-    public void addMimeType(String extension, String contentType) {
+    public void addMimeType(String extension, String contentType)
+    {
         mimeTypes.put(extension, contentType);
     }
 
-
     /**
      * <p>Set the document root for <code>getRealPath()</code>
      * resolution.  This parameter <strong>MUST</strong> represent
@@ -100,84 +87,90 @@ public class MockServletContext implements ServletContext {
      *
      * @param documentRoot The new base directory
      */
-    public void setDocumentRoot(File documentRoot) {
+    public void setDocumentRoot(File documentRoot)
+    {
         this.documentRoot = documentRoot;
     }
 
+    public void setDocumentRoot(URI base)
+    {
+        File f = new File(base);
+        if (!f.exists())
+        {
+            throw new IllegalArgumentException("File: " + base.getPath()
+                    + " doesn't exist");
+        }
+        this.documentRoot = f;
+    }
 
-    // ------------------------------------------------------ Instance Variables
+    /**
+     * <p>Add a new listener instance that should be notified about
+     * attribute changes.</p>
+     *
+     * @param listener Listener to be added
+     */
+    public void addAttributeListener(ServletContextAttributeListener listener)
+    {
+        attributeListeners.add(listener);
+    }
 
+    // ------------------------------------------------------ Instance Variables
 
-    private List attributeListeners = new ArrayList();
     private Hashtable attributes = new Hashtable();
     private File documentRoot = null;
     private Hashtable mimeTypes = new Hashtable();
     private Hashtable parameters = new Hashtable();
-
+    private List attributeListeners = new ArrayList();
 
     // -------------------------------------------------- ServletContext Methods
 
-
     /** {@inheritDoc} */
-    public Object getAttribute(String name) {
+    public Object getAttribute(String name)
+    {
 
         return attributes.get(name);
 
     }
 
-
     /** {@inheritDoc} */
-    public Enumeration getAttributeNames() {
+    public Enumeration getAttributeNames()
+    {
 
         return attributes.keys();
 
     }
 
-
-    /** {@inheritDoc} */
-    public ServletContext getContext(String uripath) {
-
-        throw new UnsupportedOperationException();
-
-    }
-
-    /** {@inheritDoc} */
-    public String getContextPath() {
-
-        throw new UnsupportedOperationException();
-
-    }
-
-
     /** {@inheritDoc} */
-    public String getInitParameter(String name) {
+    public String getInitParameter(String name)
+    {
 
         return (String) parameters.get(name);
 
     }
 
-
     /** {@inheritDoc} */
-    public Enumeration getInitParameterNames() {
+    public Enumeration getInitParameterNames()
+    {
 
         return parameters.keys();
 
     }
 
-
     /** {@inheritDoc} */
-    public int getMajorVersion() {
+    public int getMajorVersion()
+    {
 
         return 2;
 
     }
 
-
     /** {@inheritDoc} */
-    public String getMimeType(String path) {
+    public String getMimeType(String path)
+    {
 
         int period = path.lastIndexOf('.');
-        if (period < 0) {
+        if (period < 0)
+        {
             return null;
         }
         String extension = path.substring(period + 1);
@@ -185,121 +178,128 @@ public class MockServletContext implements ServletContext {
 
     }
 
-
     /** {@inheritDoc} */
-    public int getMinorVersion() {
+    public int getMinorVersion()
+    {
 
         return 4;
 
     }
 
-
-    /** {@inheritDoc} */
-    public RequestDispatcher getNamedDispatcher(String name) {
-
-        throw new UnsupportedOperationException();
-
-    }
-
-
     /** {@inheritDoc} */
-    public String getRealPath(String path) {
+    public String getRealPath(String path)
+    {
 
-        if (documentRoot != null) {
-            if (!path.startsWith("/")) {
+        if (documentRoot != null)
+        {
+            if (!path.startsWith("/"))
+            {
                 throw new IllegalArgumentException("The specified path ('"
                         + path + "') does not start with a '/' character");
             }
             File resolved = new File(documentRoot, path.substring(1));
-            try {
+            try
+            {
                 return resolved.getCanonicalPath();
-            } catch (IOException e) {
+            }
+            catch (IOException e)
+            {
                 return resolved.getAbsolutePath();
             }
-        } else {
+        }
+        else
+        {
             return null;
         }
 
     }
 
-
     /** {@inheritDoc} */
-    public RequestDispatcher getRequestDispatcher(String path) {
-
-        throw new UnsupportedOperationException();
-
-    }
-
-
-    /** {@inheritDoc} */
-    public URL getResource(String path) throws MalformedURLException {
-
-        if (documentRoot != null) {
-            if (!path.startsWith("/")) {
-                throw new MalformedURLException("The specified path ('"
-                        + path + "') does not start with a '/' character");
+    public URL getResource(String path) throws MalformedURLException
+    {
+
+        if (documentRoot != null)
+        {
+            if (!path.startsWith("/"))
+            {
+                throw new MalformedURLException("The specified path ('" + path
+                        + "') does not start with a '/' character");
             }
             File resolved = new File(documentRoot, path.substring(1));
-            if (resolved.exists()) {
+            if (resolved.exists())
+            {
                 return resolved.toURL();
-            } else {
+            }
+            else
+            {
                 return null;
             }
-        } else {
+        }
+        else
+        {
             return null;
         }
 
     }
 
-
     /** {@inheritDoc} */
-    public InputStream getResourceAsStream(String path) {
-
-        try {
+    public InputStream getResourceAsStream(String path)
+    {
+        try
+        {
             URL url = getResource(path);
-            if (url != null) {
+            if (url != null)
+            {
                 return url.openStream();
             }
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             ;
         }
         return null;
-
     }
 
-
     /** {@inheritDoc} */
-    public Set getResourcePaths(String path) {
+    public Set getResourcePaths(String path)
+    {
 
-        if (documentRoot == null) {
+        if (documentRoot == null)
+        {
             return null;
         }
 
         // Enforce the leading slash restriction
-        if (!path.startsWith("/")) {
-            throw new IllegalArgumentException("The specified path ('"
-                    + path + "') does not start with a '/' character");
+        if (!path.startsWith("/"))
+        {
+            throw new IllegalArgumentException("The specified path ('" + path
+                    + "') does not start with a '/' character");
         }
 
         // Locate the File node for this path's directory (if it exists)
         File node = new File(documentRoot, path.substring(1));
-        if (!node.exists()) {
+        if (!node.exists())
+        {
             return null;
         }
-        if (!node.isDirectory()) {
+        if (!node.isDirectory())
+        {
             return null;
         }
 
         // Construct a Set containing the paths to the contents of this directory
         Set set = new HashSet();
         String[] files = node.list();
-        if (files == null) {
+        if (files == null)
+        {
             return null;
         }
-        for (int i = 0; i < files.length; i++) {
+        for (int i = 0; i < files.length; i++)
+        {
             String subfile = path + files[i];
             File subnode = new File(node, files[i]);
-            if (subnode.isDirectory()) {
+            if (subnode.isDirectory())
+            {
                 subfile += "/";
             }
             set.add(subfile);
@@ -307,111 +307,153 @@ public class MockServletContext implements ServletContext {
 
         // Return the completed set
         return set;
-
     }
 
-
     /** {@inheritDoc} */
-    public Servlet getServlet(String name) throws ServletException {
-
-        throw new UnsupportedOperationException();
-
+    public void log(String message)
+    {
+        System.out.println(message);
     }
 
-
     /** {@inheritDoc} */
-    public String getServletContextName() {
-
-        return "MockServletContext";
-
+    public void log(Exception exception, String message)
+    {
+        System.out.println(message);
+        exception.printStackTrace();
     }
 
-
     /** {@inheritDoc} */
-    public String getServerInfo() {
-
-        return "MockServletContext";
-
+    public void log(String message, Throwable exception)
+    {
+        System.out.println(message);
+        exception.printStackTrace();
     }
 
+    /** {@inheritDoc} */
+    public void removeAttribute(String name)
+    {
+        if (attributes.containsKey(name))
+        {
+            Object value = attributes.remove(name);
+            fireAttributeRemoved(name, value);
+        }
+    }
 
     /** {@inheritDoc} */
-    public Enumeration getServlets() {
+    public void setAttribute(String name, Object value)
+    {
+        if (name == null)
+        {
+            throw new IllegalArgumentException("Attribute name cannot be null");
+        }
+        if (value == null)
+        {
+            removeAttribute(name);
+            return;
+        }
+        if (attributes.containsKey(name))
+        {
+            Object oldValue = attributes.get(name);
+            attributes.put(name, value);
+            fireAttributeReplaced(name, oldValue);
+        }
+        else
+        {
+            attributes.put(name, value);
+            fireAttributeAdded(name, value);
+        }
+    }
 
+    /** {@inheritDoc} */
+    public ServletContext getContext(String uripath)
+    {
         throw new UnsupportedOperationException();
-
     }
 
-
     /** {@inheritDoc} */
-    public Enumeration getServletNames() {
-
+    public String getContextPath()
+    {
         throw new UnsupportedOperationException();
-
     }
 
-
     /** {@inheritDoc} */
-    public void log(String message) {
-
-        System.out.println(message);
-
+    public Servlet getServlet(String name) throws ServletException
+    {
+        throw new UnsupportedOperationException();
     }
 
-
     /** {@inheritDoc} */
-    public void log(Exception exception, String message) {
-
-        System.out.println(message);
-        exception.printStackTrace();
-
+    public String getServletContextName()
+    {
+        return "MockServletContext";
     }
 
-
     /** {@inheritDoc} */
-    public void log(String message, Throwable exception) {
-
-        System.out.println(message);
-        exception.printStackTrace();
-
+    public String getServerInfo()
+    {
+        return "MockServletContext";
     }
 
-
     /** {@inheritDoc} */
-    public void removeAttribute(String name) {
-
-        if (attributes.containsKey(name)) {
-            Object value = attributes.remove(name);
-            fireAttributeRemoved(name, value);
-        }
+    public Enumeration getServlets()
+    {
+        throw new UnsupportedOperationException();
+    }
 
+    /** {@inheritDoc} */
+    public Enumeration getServletNames()
+    {
+        throw new UnsupportedOperationException();
     }
 
+    /** {@inheritDoc} */
+    public RequestDispatcher getNamedDispatcher(String name)
+    {
+        throw new UnsupportedOperationException();
+    }
 
     /** {@inheritDoc} */
-    public void setAttribute(String name, Object value) {
+    public RequestDispatcher getRequestDispatcher(String path)
+    {
+        URI uri = this.resolve(path);
+        if (uri != null)
+        {
+            File f = new File(uri);
+            if (f.exists())
+            {
+                try
+                {
+                    return new MockRequestDispatcher(uri.toURL());
+                }
+                catch (MalformedURLException e)
+                {
+                    this.log(e.getMessage());
+                    return null;
+                }
+            }
 
-        if (name == null) {
-            throw new IllegalArgumentException("Attribute name cannot be null");
         }
-        if (value == null) {
-            removeAttribute(name);
-            return;
-        }
-        if (attributes.containsKey(name)) {
-            Object oldValue = attributes.get(name);
-            attributes.put(name, value);
-            fireAttributeReplaced(name, oldValue);
-        } else {
-            attributes.put(name, value);
-            fireAttributeAdded(name, value);
-        }
-
+        return null;
     }
 
-
     // --------------------------------------------------------- Private Methods
 
+    private final URI resolve(String path)
+    {
+        if (path == null)
+        {
+            throw new NullPointerException("Path cannot be null");
+        }
+        if (path.charAt(0) == '/')
+        {
+            if (path.length() > 1)
+            {
+                return documentRoot.toURI().resolve(path.substring(1));
+            }
+            return documentRoot.toURI();
+        }
+        return null;
+    }
 
     /**
      * <p>Fire an attribute added event to interested listeners.</p>
@@ -419,61 +461,66 @@ public class MockServletContext implements ServletContext {
      * @param key Attribute whose value has been added
      * @param value The new value
      */
-    private void fireAttributeAdded(String key, Object value) {
-        if (attributeListeners.size() < 1) {
+    void fireAttributeAdded(String key, Object value)
+    {
+        if (attributeListeners.size() < 1)
+        {
             return;
         }
-        ServletContextAttributeEvent event =
-                new ServletContextAttributeEvent(this, key, value);
+        ServletContextAttributeEvent event = new ServletContextAttributeEvent(
+                this, key, value);
         Iterator listeners = attributeListeners.iterator();
-        while (listeners.hasNext()) {
-            ServletContextAttributeListener listener =
-                    (ServletContextAttributeListener) listeners.next();
+        while (listeners.hasNext())
+        {
+            ServletContextAttributeListener listener = (ServletContextAttributeListener) listeners
+                    .next();
             listener.attributeAdded(event);
         }
     }
 
-
     /**
      * <p>Fire an attribute removed event to interested listeners.</p>
      *
      * @param key Attribute whose value has been removed
      * @param value The value that was removed
      */
-    private void fireAttributeRemoved(String key, Object value) {
-        if (attributeListeners.size() < 1) {
+    void fireAttributeRemoved(String key, Object value)
+    {
+        if (attributeListeners.size() < 1)
+        {
             return;
         }
-        ServletContextAttributeEvent event =
-                new ServletContextAttributeEvent(this, key, value);
+        ServletContextAttributeEvent event = new ServletContextAttributeEvent(
+                this, key, value);
         Iterator listeners = attributeListeners.iterator();
-        while (listeners.hasNext()) {
-            ServletContextAttributeListener listener =
-                    (ServletContextAttributeListener) listeners.next();
+        while (listeners.hasNext())
+        {
+            ServletContextAttributeListener listener = (ServletContextAttributeListener) listeners
+                    .next();
             listener.attributeRemoved(event);
         }
     }
 
-
     /**
      * <p>Fire an attribute replaced event to interested listeners.</p>
      *
      * @param key Attribute whose value has been replaced
      * @param value The original value
      */
-    private void fireAttributeReplaced(String key, Object value) {
-        if (attributeListeners.size() < 1) {
+    void fireAttributeReplaced(String key, Object value)
+    {
+        if (attributeListeners.size() < 1)
+        {
             return;
         }
-        ServletContextAttributeEvent event =
-                new ServletContextAttributeEvent(this, key, value);
+        ServletContextAttributeEvent event = new ServletContextAttributeEvent(
+                this, key, value);
         Iterator listeners = attributeListeners.iterator();
-        while (listeners.hasNext()) {
-            ServletContextAttributeListener listener =
-                    (ServletContextAttributeListener) listeners.next();
+        while (listeners.hasNext())
+        {
+            ServletContextAttributeListener listener = (ServletContextAttributeListener) listeners
+                    .next();
             listener.attributeReplaced(event);
         }
     }
-
-
 }
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockServletInputStream.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockServletInputStream.java
new file mode 100644
index 0000000..f8cdd5e
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockServletInputStream.java
@@ -0,0 +1,53 @@
+/*
+ * 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 java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletInputStream;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MockServletInputStream.java 804043 2009-08-13 22:08:44Z lu4242 $
+ */
+public class MockServletInputStream extends ServletInputStream
+{
+
+    private final InputStream source;
+
+    public MockServletInputStream()
+    {
+        this.source = new ByteArrayInputStream(new byte[0]);
+    }
+
+    public MockServletInputStream(InputStream source)
+    {
+        this.source = source;
+    }
+
+    public int read() throws IOException
+    {
+        return this.source.read();
+    }
+
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_AbstractAttributeMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_AbstractAttributeMap.java
new file mode 100644
index 0000000..84ff97d
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_AbstractAttributeMap.java
@@ -0,0 +1,351 @@
+/*
+ * 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 java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+
+/**
+ * Helper Map implementation for use with different Attribute Maps.
+ *
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+abstract class _AbstractAttributeMap
+    extends AbstractMap
+{
+    private Set              _keySet;
+    private Collection       _values;
+    private Set              _entrySet;
+
+    public void clear()
+    {
+        List names = new ArrayList();
+        for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+        {
+            names.add(e.nextElement());
+        }
+
+        for (Iterator it = names.iterator(); it.hasNext();)
+        {
+            removeAttribute((String) it.next());
+        }
+    }
+
+    public boolean containsKey(Object key)
+    {
+        return getAttribute(key.toString()) != null;
+    }
+
+    public boolean containsValue(Object findValue)
+    {
+        if (findValue == null)
+        {
+            return false;
+        }
+
+        for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+        {
+            Object value = getAttribute((String) e.nextElement());
+            if (findValue.equals(value))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public Set entrySet()
+    {
+        return (_entrySet != null) ? _entrySet : (_entrySet = new EntrySet());
+    }
+
+    public Object get(Object key)
+    {
+        return getAttribute(key.toString());
+    }
+
+    public boolean isEmpty()
+    {
+        return !getAttributeNames().hasMoreElements();
+    }
+
+    public Set keySet()
+    {
+        return (_keySet != null) ? _keySet : (_keySet = new KeySet());
+    }
+
+    public Object put(Object key, Object value)
+    {
+        String key_ = key.toString();
+        Object retval = getAttribute(key_);
+        setAttribute(key_, value);
+        return retval;
+    }
+
+    public void putAll(Map t)
+    {
+        for (Iterator it = t.entrySet().iterator(); it.hasNext();)
+        {
+            Entry entry = (Entry) it.next();
+            setAttribute(entry.getKey().toString(), entry.getValue());
+        }
+    }
+
+    public Object remove(Object key)
+    {
+        String key_ = key.toString();
+        Object retval = getAttribute(key_);
+        removeAttribute(key_);
+        return retval;
+    }
+
+    public int size()
+    {
+        int size = 0;
+        for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+        {
+            size++;
+            e.nextElement();
+        }
+        return size;
+    }
+
+    public Collection values()
+    {
+        return (_values != null) ? _values : (_values = new Values());
+    }
+
+
+    abstract protected Object getAttribute(String key);
+
+    abstract protected void setAttribute(String key, Object value);
+
+    abstract protected void removeAttribute(String key);
+
+    abstract protected Enumeration getAttributeNames();
+
+
+    private class KeySet extends AbstractSet
+    {
+        public Iterator iterator()
+        {
+            return new KeyIterator();
+        }
+
+        public boolean isEmpty()
+        {
+            return _AbstractAttributeMap.this.isEmpty();
+        }
+
+        public int size()
+        {
+            return _AbstractAttributeMap.this.size();
+        }
+
+        public boolean contains(Object o)
+        {
+            return _AbstractAttributeMap.this.containsKey(o);
+        }
+
+        public boolean remove(Object o)
+        {
+            return _AbstractAttributeMap.this.remove(o) != null;
+        }
+
+        public void clear()
+        {
+            _AbstractAttributeMap.this.clear();
+        }
+    }
+
+    private class KeyIterator
+        implements Iterator
+    {
+        protected final Enumeration _e = getAttributeNames();
+        protected Object            _currentKey;
+
+        public void remove()
+        {
+            // remove() may cause ConcurrentModificationException.
+            // We could throw an exception here, but not throwing an exception
+            //   allows one call to remove() to succeed
+            if (_currentKey == null)
+            {
+                throw new NoSuchElementException(
+                    "You must call next() at least once");
+            }
+            _AbstractAttributeMap.this.remove(_currentKey);
+        }
+
+        public boolean hasNext()
+        {
+            return _e.hasMoreElements();
+        }
+
+        public Object next()
+        {
+            return _currentKey = _e.nextElement();
+        }
+    }
+
+    private class Values extends KeySet
+    {
+        public Iterator iterator()
+        {
+            return new ValuesIterator();
+        }
+
+        public boolean contains(Object o)
+        {
+            return _AbstractAttributeMap.this.containsValue(o);
+        }
+
+        public boolean remove(Object o)
+        {
+            if (o == null)
+            {
+                return false;
+            }
+
+            for (Iterator it = iterator(); it.hasNext();)
+            {
+                if (o.equals(it.next()))
+                {
+                    it.remove();
+                    return true;
+                }
+            }
+
+            return false;
+        }
+    }
+
+    private class ValuesIterator extends KeyIterator
+    {
+        public Object next()
+        {
+            super.next();
+            return _AbstractAttributeMap.this.get(_currentKey);
+        }
+    }
+
+    private class EntrySet extends KeySet
+    {
+        public Iterator iterator() {
+            return new EntryIterator();
+        }
+
+        public boolean contains(Object o) {
+            if (!(o instanceof Entry))
+            {
+                return false;
+            }
+
+            Entry entry = (Entry) o;
+            Object key = entry.getKey();
+            Object value = entry.getValue();
+            if (key == null || value == null)
+            {
+                return false;
+            }
+
+            return value.equals(_AbstractAttributeMap.this.get(key));
+        }
+
+        public boolean remove(Object o) {
+            if (!(o instanceof Entry))
+            {
+                return false;
+            }
+
+            Entry entry = (Entry) o;
+            Object key = entry.getKey();
+            Object value = entry.getValue();
+            if (key == null || value == null
+                || !value.equals(_AbstractAttributeMap.this.get(key)))
+            {
+                return false;
+            }
+
+            return _AbstractAttributeMap.this.remove(((Entry) o).getKey()) != null;
+        }
+    }
+
+    /**
+     * Not very efficient since it generates a new instance of <code>Entry</code>
+     * for each element and still internaly uses the <code>KeyIterator</code>.
+     * It is more efficient to use the <code>KeyIterator</code> directly.
+     */
+    private class EntryIterator extends KeyIterator
+    {
+        public Object next()
+        {
+            super.next();
+            // Must create new Entry every time--value of the entry must stay
+            // linked to the same attribute name
+            return new EntrySetEntry(_currentKey);
+        }
+    }
+
+    private class EntrySetEntry implements Entry
+    {
+        private final Object _currentKey;
+
+        public EntrySetEntry(Object currentKey)
+        {
+            _currentKey = currentKey;
+        }
+
+        public Object getKey()
+        {
+            return _currentKey;
+        }
+
+        public Object getValue()
+        {
+            return _AbstractAttributeMap.this.get(_currentKey);
+        }
+
+        public Object setValue(Object value)
+        {
+            return _AbstractAttributeMap.this.put(_currentKey, value);
+        }
+
+        public int hashCode() {
+            return _currentKey == null ? 0 : _currentKey.hashCode();
+        }
+
+        public boolean equals(Object obj) {
+            if (!(obj instanceof EntrySetEntry))
+                return false;
+            return _currentKey != null && _currentKey.equals(obj);
+        }
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_ApplicationMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_ApplicationMap.java
new file mode 100644
index 0000000..bfe1154
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_ApplicationMap.java
@@ -0,0 +1,87 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+
+/**
+ * ServletContext attributes as a Map.
+ *
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _ApplicationMap extends _AbstractAttributeMap
+{
+    final ServletContext _servletContext;
+
+    _ApplicationMap(ServletContext servletContext)
+    {
+        _servletContext = servletContext;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _servletContext.getAttribute(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        _servletContext.setAttribute(key, value);
+    }
+
+    protected void removeAttribute(String key)
+    {
+        _servletContext.removeAttribute(key);
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _servletContext.getAttributeNames();
+    }
+
+    public void putAll(Map t)
+    {
+        for (Iterator it = t.entrySet().iterator(); it.hasNext();)
+        {
+            Map.Entry entry = (Map.Entry) it.next();
+            _servletContext.setAttribute((String)entry.getKey(), entry.getValue());
+        }
+    }
+
+    public void clear()
+    {
+        List names = new ArrayList();
+        for (Enumeration e = _servletContext.getAttributeNames(); e.hasMoreElements();)
+        {
+            String name = (String) e.nextElement();
+            names.add(name);
+        }
+        for (int i = 0; i < names.size(); i++)
+        {
+            _servletContext.removeAttribute((String) names.get(i));
+        }
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_CookieMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_CookieMap.java
new file mode 100644
index 0000000..df22bd2
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_CookieMap.java
@@ -0,0 +1,173 @@
+/*
+ * 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 java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * HttpServletRequest Cookies as Map.
+ *
+ * @author Dimitry D'hondt
+ * @author Anton Koinov
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _CookieMap extends _AbstractAttributeMap
+{
+    private static final Cookie[] EMPTY_ARRAY = new Cookie[0];
+
+    final HttpServletRequest _httpServletRequest;
+
+    _CookieMap(HttpServletRequest httpServletRequest)
+    {
+        _httpServletRequest = httpServletRequest;
+    }
+
+    public void clear()
+    {
+        throw new UnsupportedOperationException(
+            "Cannot clear HttpRequest Cookies");
+    }
+
+    public boolean containsKey(Object key)
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        if (cookies == null) return false;
+        for (int i = 0, len = cookies.length; i < len; i++)
+        {
+            if (cookies[i].getName().equals(key))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean containsValue(Object findValue)
+    {
+        if (findValue == null)
+        {
+            return false;
+        }
+
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        if (cookies == null) return false;
+        for (int i = 0, len = cookies.length; i < len; i++)
+        {
+            if (findValue.equals(cookies[i]))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean isEmpty()
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        return cookies == null || cookies.length == 0;
+    }
+
+    public int size()
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        return cookies == null ? 0 : cookies.length;
+    }
+
+    public void putAll(Map t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    protected Object getAttribute(String key)
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        if (cookies == null) return null;
+        for (int i = 0, len = cookies.length; i < len; i++)
+        {
+            if (cookies[i].getName().equals(key))
+            {
+                return cookies[i];
+            }
+        }
+
+        return null;
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        if (_httpServletRequest instanceof MockHttpServletRequest)
+        {
+            ((MockHttpServletRequest) _httpServletRequest).addCookie((Cookie) value);
+        }
+        else
+        {
+            throw new UnsupportedOperationException(
+                "Cannot set HttpRequest Cookies");
+        }
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove HttpRequest Cookies");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        if (cookies == null)
+        {
+            return new CookieNameEnumeration(EMPTY_ARRAY);
+        }
+        else
+        {
+            return new CookieNameEnumeration(cookies);
+        }
+    }
+
+    private static class CookieNameEnumeration implements Enumeration
+    {
+        private final Cookie[] _cookies;
+        private final int _length;
+        private int _index;
+
+        public CookieNameEnumeration(Cookie[] cookies)
+        {
+            _cookies = cookies;
+            _length = cookies.length;
+        }
+
+        public boolean hasMoreElements()
+        {
+            return _index < _length;
+        }
+
+        public Object nextElement()
+        {
+            return _cookies[_index++].getName();
+        }
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_InitParameterMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_InitParameterMap.java
new file mode 100644
index 0000000..13020ed
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_InitParameterMap.java
@@ -0,0 +1,74 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.servlet.ServletContext;
+
+
+/**
+ * ServletContext init parameters as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _InitParameterMap extends _AbstractAttributeMap
+{
+    final ServletContext _servletContext;
+
+    _InitParameterMap(ServletContext servletContext)
+    {
+        _servletContext = servletContext;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _servletContext.getInitParameter(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        if (_servletContext instanceof MockServletContext)
+        {
+            ((MockServletContext)_servletContext).addInitParameter(key, (String) value);
+        }
+        else
+        {
+            throw new UnsupportedOperationException(
+                "Cannot set ServletContext InitParameter");
+        }
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove ServletContext InitParameter");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _servletContext.getInitParameterNames();
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_NullEnumeration.java b/test12/src/main/java/org/apache/myfaces/test/mock/_NullEnumeration.java
new file mode 100644
index 0000000..be471e9
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_NullEnumeration.java
@@ -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.test.mock;
+
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+/**
+ * Enumeration without elements
+ *
+ * @author Anton Koinov (latest modification by $Author: matzew $)
+ * @version $Revision: 557350 $ $Date: 2007-07-18 13:19:50 -0500 (Mié, 18 Jul 2007) $
+ */
+final class _NullEnumeration implements Enumeration
+{
+    private static final _NullEnumeration s_nullEnumeration = new _NullEnumeration();
+
+    public static final _NullEnumeration instance()
+    {
+        return s_nullEnumeration;
+    }
+
+    public boolean hasMoreElements()
+    {
+        return false;
+    }
+
+    public Object nextElement()
+    {
+        throw new NoSuchElementException("NullEnumeration has no elements");
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_RequestHeaderMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestHeaderMap.java
new file mode 100644
index 0000000..f8d5dc7
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestHeaderMap.java
@@ -0,0 +1,70 @@
+/*
+ * 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 java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * HttpServletRequest headers as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _RequestHeaderMap extends _AbstractAttributeMap
+{
+    private final HttpServletRequest _httpServletRequest;
+
+    _RequestHeaderMap(HttpServletRequest httpServletRequest)
+    {
+        _httpServletRequest = httpServletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _httpServletRequest.getHeader(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        if (_httpServletRequest instanceof MockHttpServletRequest)
+        {
+            ((MockHttpServletRequest)_httpServletRequest).addHeader(key, (String)value);
+        }
+        else
+        {
+            throw new UnsupportedOperationException(
+                "Cannot set HttpServletRequest Header");
+        }
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove HttpServletRequest Header");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _httpServletRequest.getHeaderNames();
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_RequestHeaderValuesMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestHeaderValuesMap.java
new file mode 100644
index 0000000..8059936
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestHeaderValuesMap.java
@@ -0,0 +1,76 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+class _RequestHeaderValuesMap extends _AbstractAttributeMap
+{
+    private final HttpServletRequest _httpServletRequest;
+    private final Map _valueCache = new HashMap();
+
+    _RequestHeaderValuesMap(final HttpServletRequest httpServletRequest)
+    {
+        _httpServletRequest = httpServletRequest;
+    }
+
+    protected Object getAttribute(final String key)
+    {
+        String[] ret = (String[])_valueCache.get(key);
+        if (ret == null)
+        {
+            _valueCache.put(key, ret = toArray(_httpServletRequest.getHeaders(key)));
+        }
+
+        return ret;
+    }
+
+    protected void setAttribute(final String key, final Object value)
+    {
+        throw new UnsupportedOperationException("Cannot set HttpServletRequest HeaderValues");
+    }
+
+    protected void removeAttribute(final String key)
+    {
+        throw new UnsupportedOperationException("Cannot remove HttpServletRequest HeaderValues");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _httpServletRequest.getHeaderNames();
+    }
+
+    private String[] toArray(Enumeration e)
+    {
+        List ret = new ArrayList();
+
+        while (e.hasMoreElements())
+        {
+            ret.add(e.nextElement());
+        }
+
+        return (String[]) ret.toArray(new String[ret.size()]);
+    }
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_RequestMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestMap.java
new file mode 100644
index 0000000..878485a
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestMap.java
@@ -0,0 +1,61 @@
+/*
+ * 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 java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.ServletRequest;
+
+
+/**
+ * ServletRequest attributes Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _RequestMap extends _AbstractAttributeMap
+{
+    final ServletRequest _servletRequest;
+
+    _RequestMap(ServletRequest servletRequest)
+    {
+        _servletRequest = servletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _servletRequest.getAttribute(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        _servletRequest.setAttribute(key, value);
+    }
+
+    protected void removeAttribute(String key)
+    {
+        _servletRequest.removeAttribute(key);
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _servletRequest.getAttributeNames();
+    }   
+}
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterMap.java
new file mode 100644
index 0000000..c3fb130
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterMap.java
@@ -0,0 +1,68 @@
+/*
+ * 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 java.util.Enumeration;
+
+import javax.servlet.ServletRequest;
+
+/**
+ * ServletRequest parameters as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _RequestParameterMap extends _AbstractAttributeMap
+{
+    private final ServletRequest _servletRequest;
+
+    _RequestParameterMap(ServletRequest servletRequest)
+    {
+        _servletRequest = servletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _servletRequest.getParameter(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        if( _servletRequest instanceof MockHttpServletRequest)
+        {
+            ((MockHttpServletRequest)_servletRequest).addParameter(key, (String)value);
+        }
+        else
+        {
+            throw new UnsupportedOperationException(
+                "Cannot set ServletRequest Parameter");
+        }
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove ServletRequest Parameter");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _servletRequest.getParameterNames();
+    }
+}
\ No newline at end of file
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterValuesMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterValuesMap.java
new file mode 100644
index 0000000..80bcc22
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_RequestParameterValuesMap.java
@@ -0,0 +1,61 @@
+/*
+ * 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 java.util.Enumeration;
+
+import javax.servlet.ServletRequest;
+
+/**
+ * ServletRequest multi-value parameters as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _RequestParameterValuesMap extends _AbstractAttributeMap
+{
+    private final ServletRequest _servletRequest;
+
+    _RequestParameterValuesMap(ServletRequest servletRequest)
+    {
+        _servletRequest = servletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _servletRequest.getParameterValues(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set ServletRequest ParameterValues");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove ServletRequest ParameterValues");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _servletRequest.getParameterNames();
+    }
+}
\ No newline at end of file
diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/_SessionMap.java b/test12/src/main/java/org/apache/myfaces/test/mock/_SessionMap.java
new file mode 100644
index 0000000..cdd2097
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/_SessionMap.java
@@ -0,0 +1,88 @@
+/*
+ * 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 java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+
+/**
+ * HttpSession attibutes as Map.
+ *
+ * @author Anton Koinov (latest modification by $Author: grantsmith $)
+ * @version $Revision: 472618 $ $Date: 2006-11-08 15:06:54 -0500 (Mié, 08 Nov 2006) $
+ */
+class _SessionMap extends _AbstractAttributeMap
+{
+    private final HttpServletRequest _httpRequest;
+
+    _SessionMap(HttpServletRequest httpRequest)
+    {
+        _httpRequest = httpRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        HttpSession httpSession = getSession();
+        return (httpSession == null)
+            ? null : httpSession.getAttribute(key.toString());
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        _httpRequest.getSession(true).setAttribute(key, value);
+    }
+
+    protected void removeAttribute(String key)
+    {
+        HttpSession httpSession = getSession();
+        if (httpSession != null)
+        {
+            httpSession.removeAttribute(key);
+        }
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        HttpSession httpSession = getSession();
+        return (httpSession == null)
+            ? _NullEnumeration.instance()
+            : httpSession.getAttributeNames();
+    }
+
+    private HttpSession getSession()
+    {
+        return _httpRequest.getSession(false);
+    }
+
+
+    public void putAll(Map t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void clear()
+    {
+        throw new UnsupportedOperationException();
+    }
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 19/24: MYFACESTEST-14 Update myfaces-test to use JUnit 4.x

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit be6fa62b1ec87888f7e7dc63a173d997a8646005
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 20:38:30 2010 +0000

    MYFACESTEST-14 Update myfaces-test to use JUnit 4.x
---
 test12/pom.xml                                     |  12 +-
 .../myfaces/test/base/AbstractJsfTestCase.java     |   5 +
 .../AbstractJsfConfigurableMockTestCase.java}      |  50 ++--
 .../base/{ => junit4}/AbstractJsfTestCase.java     |  25 +-
 .../htmlunit/junit4/AbstractHtmlUnitTestCase.java  | 320 +++++++++++++++++++++
 .../test/mock/{TestMockBean.java => MockBean.java} |   2 +-
 .../myfaces/test/mock/MockObjectsTestCase.java     |   4 +-
 test20/pom.xml                                     |   2 +-
 8 files changed, 386 insertions(+), 34 deletions(-)

diff --git a/test12/pom.xml b/test12/pom.xml
index 3ffa3bb..4484902 100644
--- a/test12/pom.xml
+++ b/test12/pom.xml
@@ -67,7 +67,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>3.8.1</version>
+            <version>4.5</version>
             <scope>compile</scope>
         </dependency>
 
@@ -97,6 +97,13 @@
     <build>
         <plugins>
             <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+            <plugin>
                 <artifactId>maven-source-plugin</artifactId>
                 <executions>
                     <execution>
@@ -112,7 +119,7 @@
     <!-- Allow building with JDK 1.4 as well as JDK 1.5,
          the 1.4 profile caters only to JSF 1.1 -->
     <profiles>
-
+        <!-- 
         <profile>
             <id>myfaces-test-jdk14</id>
             <activation>
@@ -162,6 +169,7 @@
                 </plugins>
             </build>
         </profile>
+         -->
 
         <profile>
             <id>myfaces-test-jdk15</id>
diff --git a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java b/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
index 4c11900..fbe30cb 100644
--- a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
@@ -108,6 +108,11 @@ public abstract class AbstractJsfTestCase extends TestCase {
 
         setFactories();
 
+        setUpJSFObjects();
+    }
+    
+    protected void setUpJSFObjects()  throws Exception
+    {
         setUpExternalContext();
         setUpLifecycle();
         setUpFacesContext();
diff --git a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java b/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
similarity index 86%
copy from test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
copy to test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
index 4c11900..f8cbe11 100644
--- a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfConfigurableMockTestCase.java
@@ -15,20 +15,23 @@
  * limitations under the License.
  */
 
-package org.apache.myfaces.test.base;
+package org.apache.myfaces.test.base.junit4;
 
 import java.net.URL;
 import java.net.URLClassLoader;
 
 import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
 import javax.faces.application.ApplicationFactory;
 import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
 import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
 
-import junit.framework.TestCase;
-
-import org.apache.myfaces.test.mock.MockApplication;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
 import org.apache.myfaces.test.mock.MockFacesContextFactory;
@@ -40,9 +43,11 @@ import org.apache.myfaces.test.mock.MockServletConfig;
 import org.apache.myfaces.test.mock.MockServletContext;
 import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
 import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
+import org.junit.After;
+import org.junit.Before;
 
 /**
- * <p>Abstract JUnit test case base class, which sets up the JavaServer Faces
+ * <p>Abstract JUnit 4.5 test case base class, which sets up the JavaServer Faces
  * mock object environment for a particular simulated request.  The following
  * protected variables are initialized in the <code>setUp()</code> method, and
  * cleaned up in the <code>tearDown()</code> method:</p>
@@ -71,7 +76,7 @@ import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
  * the test methods for your test case.</p>
  */
 
-public abstract class AbstractJsfTestCase extends TestCase {
+public abstract class AbstractJsfConfigurableMockTestCase {
 
 
     // ------------------------------------------------------------ Constructors
@@ -82,8 +87,8 @@ public abstract class AbstractJsfTestCase extends TestCase {
      *
      * @param name Name of this test case
      */
-    public AbstractJsfTestCase(String name) {
-        super(name);
+    public AbstractJsfConfigurableMockTestCase()
+    {
     }
 
 
@@ -93,7 +98,8 @@ public abstract class AbstractJsfTestCase extends TestCase {
     /**
      * <p>Set up instance variables required by this test case.</p>
      */
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
 
         // Set up a new thread context class loader
         threadContextClassLoader = Thread.currentThread().getContextClassLoader();
@@ -108,6 +114,11 @@ public abstract class AbstractJsfTestCase extends TestCase {
 
         setFactories();
 
+        setUpJSFObjects();
+    }
+    
+    protected void setUpJSFObjects()  throws Exception
+    {
         setUpExternalContext();
         setUpLifecycle();
         setUpFacesContext();
@@ -177,8 +188,8 @@ public abstract class AbstractJsfTestCase extends TestCase {
     {
         ApplicationFactory applicationFactory = (ApplicationFactory)
         FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
-        application = (MockApplication) applicationFactory.getApplication();
-        facesContext.setApplication(application);
+        application = applicationFactory.getApplication();
+        ((MockFacesContext)facesContext).setApplication(application);
     }
     
     protected void setUpRenderKit() throws Exception
@@ -192,7 +203,8 @@ public abstract class AbstractJsfTestCase extends TestCase {
     /**
      * <p>Tear down instance variables required by this test case.</p>
      */
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
 
         application = null;
         config = null;
@@ -218,14 +230,14 @@ public abstract class AbstractJsfTestCase extends TestCase {
 
 
     // Mock object instances for our tests
-    protected MockApplication         application = null;
+    protected Application             application = null;
     protected MockServletConfig       config = null;
-    protected MockExternalContext     externalContext = null;
-    protected MockFacesContext        facesContext = null;
-    protected MockFacesContextFactory facesContextFactory = null;
-    protected MockLifecycle           lifecycle = null;
-    protected MockLifecycleFactory    lifecycleFactory = null;
-    protected MockRenderKit           renderKit = null;
+    protected ExternalContext         externalContext = null;
+    protected FacesContext            facesContext = null;
+    protected FacesContextFactory     facesContextFactory = null;
+    protected Lifecycle               lifecycle = null;
+    protected LifecycleFactory        lifecycleFactory = null;
+    protected RenderKit               renderKit = null;
     protected MockHttpServletRequest  request = null;
     protected MockHttpServletResponse response = null;
     protected MockServletContext      servletContext = null;
diff --git a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java b/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
similarity index 94%
copy from test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
copy to test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
index 4c11900..2734ee2 100644
--- a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/base/junit4/AbstractJsfTestCase.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.myfaces.test.base;
+package org.apache.myfaces.test.base.junit4;
 
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -26,8 +26,6 @@ import javax.faces.component.UIViewRoot;
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.RenderKitFactory;
 
-import junit.framework.TestCase;
-
 import org.apache.myfaces.test.mock.MockApplication;
 import org.apache.myfaces.test.mock.MockExternalContext;
 import org.apache.myfaces.test.mock.MockFacesContext;
@@ -40,9 +38,11 @@ import org.apache.myfaces.test.mock.MockServletConfig;
 import org.apache.myfaces.test.mock.MockServletContext;
 import org.apache.myfaces.test.mock.lifecycle.MockLifecycle;
 import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
+import org.junit.After;
+import org.junit.Before;
 
 /**
- * <p>Abstract JUnit test case base class, which sets up the JavaServer Faces
+ * <p>Abstract JUnit 4.5 test case base class, which sets up the JavaServer Faces
  * mock object environment for a particular simulated request.  The following
  * protected variables are initialized in the <code>setUp()</code> method, and
  * cleaned up in the <code>tearDown()</code> method:</p>
@@ -71,7 +71,7 @@ import org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory;
  * the test methods for your test case.</p>
  */
 
-public abstract class AbstractJsfTestCase extends TestCase {
+public abstract class AbstractJsfTestCase {
 
 
     // ------------------------------------------------------------ Constructors
@@ -82,8 +82,8 @@ public abstract class AbstractJsfTestCase extends TestCase {
      *
      * @param name Name of this test case
      */
-    public AbstractJsfTestCase(String name) {
-        super(name);
+    public AbstractJsfTestCase()
+    {
     }
 
 
@@ -93,7 +93,8 @@ public abstract class AbstractJsfTestCase extends TestCase {
     /**
      * <p>Set up instance variables required by this test case.</p>
      */
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
 
         // Set up a new thread context class loader
         threadContextClassLoader = Thread.currentThread().getContextClassLoader();
@@ -108,6 +109,11 @@ public abstract class AbstractJsfTestCase extends TestCase {
 
         setFactories();
 
+        setUpJSFObjects();
+    }
+    
+    protected void setUpJSFObjects()  throws Exception
+    {
         setUpExternalContext();
         setUpLifecycle();
         setUpFacesContext();
@@ -192,7 +198,8 @@ public abstract class AbstractJsfTestCase extends TestCase {
     /**
      * <p>Tear down instance variables required by this test case.</p>
      */
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
 
         application = null;
         config = null;
diff --git a/test12/src/main/java/org/apache/myfaces/test/htmlunit/junit4/AbstractHtmlUnitTestCase.java b/test12/src/main/java/org/apache/myfaces/test/htmlunit/junit4/AbstractHtmlUnitTestCase.java
new file mode 100644
index 0000000..7151773
--- /dev/null
+++ b/test12/src/main/java/org/apache/myfaces/test/htmlunit/junit4/AbstractHtmlUnitTestCase.java
@@ -0,0 +1,320 @@
+/*
+ * 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.htmlunit.junit4;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+
+import org.junit.After;
+import org.junit.Before;
+
+import com.gargoylesoftware.htmlunit.ElementNotFoundException;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
+import com.gargoylesoftware.htmlunit.html.HtmlBody;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlHead;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+
+
+
+/**
+ * <p>Abstract base class for system integration tests based on HtmlUnit.
+ * These tests will expect a system property named <code>url</code> to be
+ * present, which will define the URL (including the context path, but
+ * without a trailing slash) of the application to be tested.</p>
+ */
+
+public abstract class AbstractHtmlUnitTestCase {
+
+
+    // ------------------------------------------------------------ Constructors
+
+
+    /**
+     * <p>Construct a new instance of this test case.</p>
+     *
+     * @param name Name of the new test case
+     */
+    public AbstractHtmlUnitTestCase()
+    {
+    }
+
+
+    // ------------------------------------------------------ Instance Variables
+
+
+    /**
+     * <p>The most recently retrieved page from the server.</p>
+     */
+    protected HtmlPage page = null;
+
+
+    /**
+     * <p>The calculated URL for the installed "systest" web application.
+     * This value is based on a system property named <code>url</code>,
+     * which must be defined as part of the command line that executes
+     * each test case.</p>
+     */
+    protected URL url = null;
+
+
+    /**
+     * <p>The web client for this test case.</p>
+     */
+    protected WebClient webClient = null;
+
+
+    // ------------------------------------------------------ Test Setup Methods
+
+
+    /**
+     * <p>Set up the instance variables required for this test case.</p>
+     *
+     * @exception Exception if an error occurs
+     */
+    @Before
+    protected void setUp() throws Exception {
+
+        // Calculate the URL for the installed "systest" web application
+        String url = System.getProperty("url");
+        this.url = new URL(url + "/");
+
+        // Initialize HtmlUnit constructs for this test case
+        webClient = new WebClient();
+
+    }
+
+    /**
+     * <p>Tear down instance variables required by this test case.</p>
+     */
+    @After
+    protected void tearDown() throws Exception {
+
+        page = null;
+        url = null;
+        webClient = null;
+
+    }
+
+
+
+    // ------------------------------------------------------- Protected Methods
+
+
+    /**
+     * <p>Return the body element for the most recently retrieved page.
+     * If there is no such element, return <code>null</code>.</p>
+     *
+     * @exception Exception if an error occurs
+     */
+    protected HtmlBody body() throws Exception {
+
+        Iterator elements = page.getAllHtmlChildElements();
+        while (elements.hasNext()) {
+            HtmlElement element = (HtmlElement) elements.next();
+            if (element instanceof HtmlBody) {
+                return ((HtmlBody) element);
+            }
+        }
+        return (null);
+
+    }
+
+
+    /**
+     * <p>Return the HTML element with the specified <code>id</code> from the
+     * most recently retrieved page.  If there is no such element, return
+     * <code>null</code>.</p>
+     *
+     * @param id Identifier of the requested element.
+     *
+     * @exception Exception if an error occurs
+     */
+    protected HtmlElement element(String id) throws Exception {
+
+        try {
+            return (page.getHtmlElementById(id));
+        } catch (ElementNotFoundException e) {
+            return (null);
+        }
+
+    }
+
+
+    /**
+     * <p>Return the form with the specified <code>id</code> from the most
+     * recently retrieved page.  If there is no such form, return
+     * <code>null</code>.<p>
+     *
+     * @param id Identifier of the requested form.
+     *
+     * @exception Exception if an error occurs
+     */
+    protected HtmlForm form(String id) throws Exception {
+
+        Iterator forms = page.getForms().iterator();
+        while (forms.hasNext()) {
+            HtmlForm form = (HtmlForm) forms.next();
+            if (id.equals(form.getAttributeValue("id"))) {
+                return (form);
+            }
+        }
+        return (null);
+
+    }
+
+
+    /**
+     * <p>Return the head element for the most recently retrieved page.
+     * If there is no such element, return <code>null</code>.</p>
+     *
+     * @exception Exception if an error occurs
+     */
+    protected HtmlHead head() throws Exception {
+
+        Iterator elements = page.getAllHtmlChildElements();
+        while (elements.hasNext()) {
+            HtmlElement element = (HtmlElement) elements.next();
+            if (element instanceof HtmlHead) {
+                return ((HtmlHead) element);
+            }
+        }
+        return (null);
+
+    }
+
+
+    /**
+     * <p>Click the specified hyperlink, and retrieve the subsequent page,
+     * saving a reference so that other utility methods may be used to
+     * retrieve information from it.</p>
+     *
+     * @param anchor Anchor component to click
+     *
+     * @exception IOException if an input/output error occurs
+     */
+    protected HtmlPage link(HtmlAnchor anchor) throws IOException {
+
+        HtmlPage page = (HtmlPage) anchor.click();
+        this.page = page;
+        return page;
+
+    }
+
+
+    /**
+     * <p>Return the currently stored page reference.</p>
+     */
+    protected HtmlPage page() {
+
+        return this.page;
+
+    }
+
+
+    /**
+     * <p>Retrieve and return the page at the specified context relative path.
+     * Save a reference to this page so that other utility methods may be used
+     * to retrieve information from it.</p>
+     *
+     * @param path Context relative path
+     *
+     * @exception IllegalArgumentException if the context relative path
+     *  does not begin with a '/' character
+     * @exception Exception if a different error occurs
+     */
+    protected HtmlPage page(String path) throws Exception {
+
+        HtmlPage page = (HtmlPage) webClient.getPage(url(path));
+        this.page = page;
+        return (page);
+
+    }
+
+
+    /**
+     * <p>Reset the stored page reference to the specified value.  This is
+     * useful for scenarios testing resubmit of the same page (simulating the
+     * user pressing the back button and then submitting again).</p>
+     *
+     * @param page Previously saved page to which to reset
+     */
+    protected void reset(HtmlPage page) {
+
+        this.page = page;
+
+    }
+
+
+    /**
+     * <p>Submit the current page, using the specified component, and retrieve
+     * the subsequent page, saving a reference so that other utility methods
+     * may be used to retrieve information from it.</p>
+     *
+     * @param submit Submit button component to click
+     *
+     * @exception IOException if an input/output error occurs
+     */
+    protected HtmlPage submit(HtmlSubmitInput submit) throws IOException {
+
+        HtmlPage page = (HtmlPage) submit.click();
+        this.page = page;
+        return page;
+
+    }
+
+
+    /**
+     * <p>Return the page title from the most recently retrieved page.
+     * Any leading and trailing whitespace will be trimmed.</p>
+     *
+     * @exception Exception if an error occurs
+     */
+    protected String title() throws Exception {
+
+        return (page.getTitleText().trim());
+
+    }
+
+
+    /**
+     * <p>Calculate and return an absolute URL for the specified context
+     * relative path, which must begin with a '/' character.</p>
+     *
+     * @param path Context relative path
+     *
+     * @exception IllegalArgumentException if the context relative path
+     *  does not begin with a '/' character
+     * @exception Exception if a different error ocurs
+     */
+    protected URL url(String path) throws Exception {
+
+        if (path.charAt(0) != '/') {
+            throw new IllegalArgumentException("Context path '" + path
+                                               + "' does not start with '/'");
+        }
+        return new URL(url, path.substring(1));
+
+    }
+
+
+}
diff --git a/test12/src/test/java/org/apache/myfaces/test/mock/TestMockBean.java b/test12/src/test/java/org/apache/myfaces/test/mock/MockBean.java
similarity index 97%
rename from test12/src/test/java/org/apache/myfaces/test/mock/TestMockBean.java
rename to test12/src/test/java/org/apache/myfaces/test/mock/MockBean.java
index cd4acf5..2e05dda 100644
--- a/test12/src/test/java/org/apache/myfaces/test/mock/TestMockBean.java
+++ b/test12/src/test/java/org/apache/myfaces/test/mock/MockBean.java
@@ -24,7 +24,7 @@ import java.io.Serializable;
  *
  * $Id$
  */
-public class TestMockBean implements Serializable {
+public class MockBean implements Serializable {
 
     private static final long serialVersionUID = 8879968751506858610L;
     private String command;
diff --git a/test12/src/test/java/org/apache/myfaces/test/mock/MockObjectsTestCase.java b/test12/src/test/java/org/apache/myfaces/test/mock/MockObjectsTestCase.java
index c8755c7..7721a75 100644
--- a/test12/src/test/java/org/apache/myfaces/test/mock/MockObjectsTestCase.java
+++ b/test12/src/test/java/org/apache/myfaces/test/mock/MockObjectsTestCase.java
@@ -57,7 +57,7 @@ public class MockObjectsTestCase extends AbstractJsfTestCase {
         session.setAttribute("sameKey", "sameKeySesValue");
         request.setAttribute("reqScopeName", "reqScopeValue");
         request.setAttribute("sameKey", "sameKeyReqValue");
-        request.setAttribute("test", new TestMockBean());
+        request.setAttribute("test", new MockBean());
 
     }
 
@@ -103,7 +103,7 @@ public class MockObjectsTestCase extends AbstractJsfTestCase {
 
     public void testMethodBindingInvokePositive() throws Exception {
 
-        TestMockBean bean = (TestMockBean) request.getAttribute("test");
+        MockBean bean = (MockBean) request.getAttribute("test");
         MethodBinding mb = null;
         Class argsString[] = new Class[] { String.class };
         Class argsNone[] = new Class[0];
diff --git a/test20/pom.xml b/test20/pom.xml
index 8021996..86c5c99 100644
--- a/test20/pom.xml
+++ b/test20/pom.xml
@@ -67,7 +67,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>3.8.1</version>
+            <version>4.5</version>
             <scope>compile</scope>
         </dependency>
 

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 24/24: move to branch for release procedure

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit b4499bb219252ec7a927ba90dbcd5e2fd2418f39
Merge: 7c3ff98 747a119
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 15 18:15:35 2010 +0000

    move to branch for release procedure

 test12/pom.xml                                     |  20 +-
 .../myfaces/test/base/AbstractJsfTestCase.java     |  62 +-
 .../AbstractJsfConfigurableMockTestCase.java}      | 124 ++--
 .../base/{ => junit4}/AbstractJsfTestCase.java     |  78 ++-
 .../htmlunit/junit4/AbstractHtmlUnitTestCase.java  | 320 ++++++++++
 .../test/jmock/AbstractJmockJsfTestCase.java       |  54 +-
 .../myfaces/test/mock/MockExternalContext.java     | 431 +++++++------
 .../myfaces/test/mock/MockHttpServletRequest.java  |  85 ++-
 .../myfaces/test/mock/MockHttpServletResponse.java | 121 ++--
 .../apache/myfaces/test/mock/MockRenderKit.java    |  73 ++-
 .../myfaces/test/mock/MockRequestDispatcher.java   |  59 ++
 .../test/mock/MockResponseStateManager.java        | 280 ++++++++
 .../myfaces/test/mock/MockServletContext.java      | 433 +++++++------
 .../myfaces/test/mock/MockServletInputStream.java  |  53 ++
 .../myfaces/test/mock/_AbstractAttributeMap.java   | 351 ++++++++++
 .../apache/myfaces/test/mock/_ApplicationMap.java  |  87 +++
 .../org/apache/myfaces/test/mock/_CookieMap.java   | 173 +++++
 .../java/org/apache/myfaces/test/mock/_Hex.java    | 310 +++++++++
 .../myfaces/test/mock/_InitParameterMap.java       |  74 +++
 .../apache/myfaces/test/mock/_NullEnumeration.java |  48 ++
 .../myfaces/test/mock/_RequestHeaderMap.java       |  70 ++
 .../myfaces/test/mock/_RequestHeaderValuesMap.java |  76 +++
 .../org/apache/myfaces/test/mock/_RequestMap.java  |  61 ++
 .../myfaces/test/mock/_RequestParameterMap.java    |  68 ++
 .../test/mock/_RequestParameterValuesMap.java      |  61 ++
 .../org/apache/myfaces/test/mock/_SessionMap.java  |  88 +++
 .../apache/myfaces/test/runners/NamedRunner.java   | 123 ++++
 .../myfaces/test/runners/TestClassLoader.java      | 332 ++++++++++
 .../test/runners/TestPerClassLoaderRunner.java     | 293 +++++++++
 test12/src/main/resources/META-INF/NOTICE.txt      |  16 +-
 .../META-INF/licenses/facelets-LICENSE.txt         |  70 ++
 .../myfaces/test/runners/excluded.properties       |  12 +
 .../test/mock/{TestMockBean.java => MockBean.java} |   2 +-
 .../myfaces/test/mock/MockObjectsTestCase.java     |   4 +-
 .../runner/TestPerCLassLoaderDefaultTestCase.java  |  71 +++
 .../test/runner/TestPerClassLoaderTestCase.java    |  66 ++
 .../myfaces/test/runner/WebXmlParameter.java       |  58 +-
 .../apache/myfaces/test/runner/WebXmlUtils.java    |  68 +-
 test20/pom.xml                                     |   2 +-
 .../apache/myfaces/test/config/ConfigParser.java   | 607 ++++++++++++++++++
 .../apache/myfaces/test/config/ConfigParser20.java | 164 -----
 .../myfaces/test/mock/MockApplication20.java       |   2 +
 .../test/mock/MockResponseStateManager.java        | 353 +++++++++++
 .../resource/MockClassLoaderResourceLoader.java    | 122 ++++
 .../MockExternalContextResourceLoader.java         | 208 ++++++
 .../myfaces/test/mock/resource/MockResource.java   | 161 ++---
 .../test/mock/resource/MockResourceHandler.java    | 378 +++++------
 .../mock/resource/MockResourceHandlerSupport.java  | 115 ++++
 .../test/mock/resource/MockResourceLoader.java     | 155 +++++
 .../test/mock/resource/MockResourceMeta.java       | 110 ++++
 .../{MockResource.java => MockSimpleResource.java} | 361 +++++------
 ...Handler.java => MockSimpleResourceHandler.java} | 703 +++++++++++----------
 .../test/config/ConfigParser20TestCase.java        | 119 ----
 .../myfaces/test/config/ConfigParserTestCase.java  | 196 ++++++
 .../org/apache/myfaces/test/config/MyBehavior.java |  56 +-
 .../test/config/MyClientBehaviorRenderer.java}     |  56 +-
 .../apache/myfaces/test/config/MyConverter.java}   |  65 +-
 .../apache/myfaces/test/config/MyValidator.java}   |  62 +-
 .../myfaces/test/mock/MockResourceTestCase.java    |  28 +-
 ...ces20-faces-config-1.xml => faces-config-1.xml} | 173 ++---
 60 files changed, 7012 insertions(+), 1959 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 17/24: IOException(Exception e) does not exists in jdk 1.5

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 1651f0a09af5e8737d2cac5121840026114f3b2b
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 00:57:13 2010 +0000

    IOException(Exception e) does not exists in jdk 1.5
---
 .../java/org/apache/myfaces/test/mock/MockResponseStateManager.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java b/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
index 2bb2548..45effe1 100644
--- a/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
+++ b/test12/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
@@ -209,7 +209,7 @@ public class MockResponseStateManager extends ResponseStateManager
         }
         catch (ClassNotFoundException e)
         {
-            throw new IOException(e);
+            throw new IOException(e.getMessage());
         }
         finally
         {

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 13/24: MYFACESTEST-16 Update license and notice for myfaces test

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit a20596155f0840af495a17ec108fa03f0c6e88eb
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 00:08:39 2010 +0000

    MYFACESTEST-16 Update license and notice for myfaces test
---
 test12/src/main/resources/META-INF/NOTICE.txt      | 16 +++--
 .../META-INF/licenses/facelets-LICENSE.txt         | 70 ++++++++++++++++++++++
 2 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/test12/src/main/resources/META-INF/NOTICE.txt b/test12/src/main/resources/META-INF/NOTICE.txt
index 107a084..1a25de2 100644
--- a/test12/src/main/resources/META-INF/NOTICE.txt
+++ b/test12/src/main/resources/META-INF/NOTICE.txt
@@ -1,9 +1,17 @@
-Apache Shale Test Framework
-Copyright 2004-2007 The Apache Software Foundation
-
-This product includes software developed by
+This product includes software developed by:
 The Apache Software Foundation (http://www.apache.org/).
 
+------------------------------------------------------------------------
+See the file LICENSE.txt
+See licenses for accompanying products in the "/licenses" subdirectory.
+------------------------------------------------------------------------
+
+This software also includes code from Facelets (https://facelets.dev.java.net/)
+
+This software also includes code from Apache Shale Test Framework
+
+This software also includes code from Apache Commons Codec
+
 This product contains code written by David Geary and Cay Horstmann
 for the first edition of Core JavaServer Faces. 
 
diff --git a/test12/src/main/resources/META-INF/licenses/facelets-LICENSE.txt b/test12/src/main/resources/META-INF/licenses/facelets-LICENSE.txt
new file mode 100644
index 0000000..959625a
--- /dev/null
+++ b/test12/src/main/resources/META-INF/licenses/facelets-LICENSE.txt
@@ -0,0 +1,70 @@
+Apache License, Version 2.0
+
+Apache License
+Version 2.0, January 2004
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or it [...]
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License.
+
+Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License.
+
+Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution( [...]
+
+4. Redistribution.
+
+You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+   1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
+   2. You must cause any modified files to carry prominent notices stating that You changed the files; and
+   3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+   4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; [...]
+
+You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions.
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks.
+
+This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty.
+
+Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks  [...]
+
+8. Limitation of Liability.
+
+In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of go [...]
+
+9. Accepting Warranty or Additional Liability.
+
+While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claim [...]
+
+END OF TERMS AND CONDITIONS

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 16/24: MYFACESTEST-18 Include in AbstractJsfTestCase and AbstractJmockTestCase protected methods for setup elements and allow better customization

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 7dfcc08011d89479df8ba35b57a622b49f757914
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 00:20:39 2010 +0000

    MYFACESTEST-18 Include in AbstractJsfTestCase and AbstractJmockTestCase protected methods for setup elements and allow better customization
---
 .../myfaces/test/base/AbstractJsfTestCase.java     | 53 ++++++++++++++++++---
 .../test/jmock/AbstractJmockJsfTestCase.java       | 54 +++++++++++++++++++---
 2 files changed, 94 insertions(+), 13 deletions(-)

diff --git a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java b/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
index 609a57b..4c11900 100644
--- a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
@@ -101,6 +101,23 @@ public abstract class AbstractJsfTestCase extends TestCase {
                 this.getClass().getClassLoader()));
 
         // Set up Servlet API Objects
+        setUpServletObjects();
+
+        // Set up JSF API Objects
+        FactoryFinder.releaseFactories();
+
+        setFactories();
+
+        setUpExternalContext();
+        setUpLifecycle();
+        setUpFacesContext();
+        setUpView();
+        setUpApplication();
+        setUpRenderKit();
+    }
+    
+    protected void setUpServletObjects() throws Exception 
+    {
         servletContext = new MockServletContext();
         config = new MockServletConfig(servletContext);
         session = new MockHttpSession();
@@ -108,9 +125,10 @@ public abstract class AbstractJsfTestCase extends TestCase {
         request = new MockHttpServletRequest(session);
         request.setServletContext(servletContext);
         response = new MockHttpServletResponse();
-
-        // Set up JSF API Objects
-        FactoryFinder.releaseFactories();
+    }
+    
+    protected void setFactories() throws Exception 
+    {
         FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
         "org.apache.myfaces.test.mock.MockApplicationFactory");
         FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
@@ -119,13 +137,24 @@ public abstract class AbstractJsfTestCase extends TestCase {
         "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
         FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
         "org.apache.myfaces.test.mock.MockRenderKitFactory");
-
+    }
+    
+    protected void setUpExternalContext() throws Exception
+    {
         externalContext =
             new MockExternalContext(servletContext, request, response);
+    }
+    
+    protected void setUpLifecycle() throws Exception
+    {
         lifecycleFactory = (MockLifecycleFactory)
         FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         lifecycle = (MockLifecycle)
         lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+    }
+    
+    protected void setUpFacesContext() throws Exception
+    {
         facesContextFactory = (MockFacesContextFactory)
         FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
         facesContext = (MockFacesContext)
@@ -134,22 +163,32 @@ public abstract class AbstractJsfTestCase extends TestCase {
                 response,
                 lifecycle);
         externalContext = (MockExternalContext) facesContext.getExternalContext();
+    }
+
+    protected void setUpView() throws Exception
+    {
         UIViewRoot root = new UIViewRoot();
         root.setViewId("/viewId");
         root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
         facesContext.setViewRoot(root);
+    }
+    
+    protected void setUpApplication() throws Exception
+    {
         ApplicationFactory applicationFactory = (ApplicationFactory)
-          FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
         application = (MockApplication) applicationFactory.getApplication();
         facesContext.setApplication(application);
+    }
+    
+    protected void setUpRenderKit() throws Exception
+    {
         RenderKitFactory renderKitFactory = (RenderKitFactory)
         FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
         renderKit = new MockRenderKit();
         renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
-
     }
 
-
     /**
      * <p>Tear down instance variables required by this test case.</p>
      */
diff --git a/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java b/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
index 309f526..eb7d4c8 100644
--- a/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
@@ -94,6 +94,25 @@ public abstract class AbstractJmockJsfTestCase extends MockObjectTestCase {
                 this.getClass().getClassLoader()));
         
         // Set up Servlet API Objects
+        setUpServletObjects();
+        
+        // Set up JSF API Objects
+        FactoryFinder.releaseFactories();
+        
+        setFactories();
+        
+        setFactories();
+
+        setUpExternalContext();
+        setUpLifecycle();
+        setUpFacesContext();
+        setUpView();
+        setUpApplication();
+        setUpRenderKit();
+    }
+    
+    protected void setUpServletObjects() throws Exception 
+    {
         servletContext = new MockServletContext();
         config = new MockServletConfig(servletContext);
         session = new MockHttpSession();
@@ -101,9 +120,10 @@ public abstract class AbstractJmockJsfTestCase extends MockObjectTestCase {
         request = new MockHttpServletRequest(session);
         request.setServletContext(servletContext);
         response = new MockHttpServletResponse();
-        
-        // Set up JSF API Objects
-        FactoryFinder.releaseFactories();
+    }
+    
+    protected void setFactories() throws Exception 
+    {
         FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
         "org.apache.myfaces.test.mock.MockApplicationFactory");
         FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
@@ -112,13 +132,24 @@ public abstract class AbstractJmockJsfTestCase extends MockObjectTestCase {
         "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
         FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
         "org.apache.myfaces.test.mock.MockRenderKitFactory");
-        
+    }
+    
+    protected void setUpExternalContext() throws Exception
+    {
         externalContext =
             new MockExternalContext(servletContext, request, response);
+    }
+    
+    protected void setUpLifecycle() throws Exception
+    {
         lifecycleFactory = (MockLifecycleFactory)
         FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         lifecycle = (MockLifecycle)
         lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+    }
+    
+    protected void setUpFacesContext() throws Exception
+    {
         facesContextFactory = (MockFacesContextFactory)
         FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
         facesContext = (MockFacesContext)
@@ -127,19 +158,30 @@ public abstract class AbstractJmockJsfTestCase extends MockObjectTestCase {
                 response,
                 lifecycle);
         externalContext = (MockExternalContext) facesContext.getExternalContext();
+    }
+
+    protected void setUpView() throws Exception
+    {
         UIViewRoot root = new UIViewRoot();
         root.setViewId("/viewId");
         root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
         facesContext.setViewRoot(root);
+    }
+    
+    protected void setUpApplication() throws Exception
+    {
         ApplicationFactory applicationFactory = (ApplicationFactory)
-          FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
         application = (MockApplication) applicationFactory.getApplication();
         facesContext.setApplication(application);
+    }
+    
+    protected void setUpRenderKit() throws Exception
+    {
         RenderKitFactory renderKitFactory = (RenderKitFactory)
         FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
         renderKit = new MockRenderKit();
         renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
-        
     }
 
     // Tear down instance variables required by this test case.

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 01/24: [maven-release-plugin] prepare release 1_0_0_beta_3

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 3c3e81ac623247dc07796cd941d06a24ee057e26
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Wed Apr 14 01:32:40 2010 +0000

    [maven-release-plugin] prepare release 1_0_0_beta_3
---
 pom.xml        | 8 ++++----
 test12/pom.xml | 2 +-
 test20/pom.xml | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index af3cfaf..817590e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,16 +30,16 @@
     <artifactId>myfaces-test-project</artifactId>
     <packaging>pom</packaging>
     <name>Myfaces Test Framework</name>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0-beta-3</version>
     <url>http://myfaces.apache.org/test</url>
     <issueManagement>
       <system>jira</system>
       <url>http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10600</url>
     </issueManagement>
     <scm>
-      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/trunk</connection>
-      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/trunk</developerConnection>
-      <url>http://svn.apache.org/repos/asf/myfaces/test/trunk</url>
+      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_3</connection>
+      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_3</developerConnection>
+      <url>http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_3</url>
     </scm>
     <modules>
       <module>test12</module>
diff --git a/test12/pom.xml b/test12/pom.xml
index 3ffa3bb..132862a 100644
--- a/test12/pom.xml
+++ b/test12/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0-beta-3</version>
     </parent>
 
     <artifactId>myfaces-test12</artifactId>
diff --git a/test20/pom.xml b/test20/pom.xml
index 8021996..8976be8 100644
--- a/test20/pom.xml
+++ b/test20/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0-beta-3</version>
     </parent>
 
     <artifactId>myfaces-test20</artifactId>

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 10/24: MYFACESTEST-11 Update ConfigParser to jsf 2

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit cc3d9a0754a965f373f2708c89662bf21cc4b3fc
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Wed Jun 30 23:58:45 2010 +0000

    MYFACESTEST-11 Update ConfigParser to jsf 2
---
 .../apache/myfaces/test/config/ConfigParser.java   | 607 +++++++++++++++++++++
 .../apache/myfaces/test/config/ConfigParser20.java | 164 ------
 .../test/config/ConfigParser20TestCase.java        | 119 ----
 .../myfaces/test/config/ConfigParserTestCase.java  | 196 +++++++
 .../org/apache/myfaces/test/config/MyBehavior.java |  56 +-
 .../test/config/MyClientBehaviorRenderer.java}     |  56 +-
 .../apache/myfaces/test/config/MyConverter.java}   |  65 ++-
 .../apache/myfaces/test/config/MyValidator.java}   |  63 ++-
 ...ces20-faces-config-1.xml => faces-config-1.xml} | 173 +++---
 9 files changed, 1026 insertions(+), 473 deletions(-)

diff --git a/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser.java b/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser.java
new file mode 100644
index 0000000..81dd213
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser.java
@@ -0,0 +1,607 @@
+/*
+ * 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.io.IOException;
+import java.net.URL;
+
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.Rule;
+import org.apache.myfaces.test.mock.MockRenderKit;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * <p>Utility class to parse JavaServer Faces configuration resources, and
+ * register JSF artifacts with the mock object hierarchy.</p>
+ *
+ * <p>The following artifacts are registered:</p>
+ * <ul>
+ *     <li><code>Converter</code> (by-id and by-class)</li>
+ *     <li><code>RenderKit</code> and <code>Renderer</code></li>
+ *     <li><code>UIComponent</code></li>
+ *     <li><code>Validator</code></li>
+ * </ul>
+ *
+ * <p>Note that any declared <em>factory</em> instances are explicitly
+ * <strong>NOT</strong> registered, allowing the mock object hierarchy
+ * of the Myfaces Test Framework to manage these APIs.</p>
+ *
+ * <p><strong>USAGE NOTE</strong> - If you are using an instance of this
+ * class within a subclass of <code>AbstractJsfTestCase</code> or
+ * <code>AbstractJmockJsfTestCase</code>, be sure you have completed the
+ * <code>setUp()</code> processing in this base class before calling one
+ * of the <code>parse()</code> methods.</p>
+ *
+ * @since 1.1
+ */
+public class ConfigParser {
+    
+
+    // ------------------------------------------------------------ Constructors
+
+
+    /** Creates a new instance of ConfigParser */
+    public ConfigParser() {
+    }
+    
+
+    // ------------------------------------------------------ Manifest Constants
+
+
+    /**
+     * <p>Configuration resource URLs for the JSF RI.</p>
+     */
+    private static final String[] JSFRI_RESOURCES =
+    { "/com/sun/faces/jsf-ri-runtime.xml",
+    };
+
+
+    /**
+     * <p>Configuration resource URLs for Apache MyFaces.</p>
+     */
+    private static final String[] MYFACES_RESOURCES =
+    { "/org/apache/myfaces/resource/standard-faces-config.xml",
+    };
+
+    /**
+     * <p>Configuration resource URLs for Apache MyFaces 1.2.</p>
+     */
+    private static final String[] MYFACES_RESOURCES12 =
+    { "/META-INF/standard-faces-config.xml",
+    };    
+
+    // ------------------------------------------------------ Instance Variables
+
+
+    /**
+     * <p>The <code>Digester</code> instance we will use for parsing.</p>
+     */
+    private Digester digester = null;
+
+
+    // ------------------------------------------------------- Public Properties
+
+
+    /**
+     * <p>Return the URLs of the platform configuration resources for this
+     * application.  The following platforms are currently supported:</p>
+     * <ul>
+     * <li>JavaServer Faces Reference Implementation (version 1.0 - 1.2)</li>
+     * <li>MyFaces (version 1.1)</li>
+     * </ul>
+     *
+     * <p>If MyFaces (version 1.2), currently under development, does not change
+     * the name of the configuration resource, it will be supported as well.</p>
+     */
+    public URL[] getPlatformURLs() {
+
+        URL[] urls = translate(JSFRI_RESOURCES);
+        if (urls[0] == null) {
+            urls = translate(MYFACES_RESOURCES12);
+            if (urls[0] == null) {
+                urls = translate(MYFACES_RESOURCES);
+            }
+        }
+        return urls;
+
+    }
+
+
+    // ---------------------------------------------------------- Public Methods
+
+
+    /**
+     * <p>Parse the specified JavaServer Faces configuration resource, causing
+     * the appropriate JSF artifacts to be registered with the mock object
+     * hierarchy.</p>
+     *
+     * @param url <code>URL</code> of the configuration resource to parse
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception SAXException if a parsing error occurs
+     */
+    public void parse(URL url) throws IOException, SAXException {
+
+        // Acquire and configure the Digester instance we will use
+        Digester digester = digester();
+        ApplicationFactory factory = (ApplicationFactory)
+          FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        Application application = factory.getApplication();
+        digester.push(application);
+
+        // Perform the required parsing
+        try {
+            digester.parse(url);
+        } finally {
+            digester.clear();
+        }
+
+    }
+
+
+    /**
+     * <p>Parse the specified set of JavaServer Faces configuration resources,
+     * in the listed order, causing the appropriate JSF artifacts to be registered
+     * with the mock object hierarchy.</p>
+     *
+     * @param urls <code>URL</code>s of the configuration resources to parse
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception SAXException if a parsing error occurs
+     */
+    public void parse(URL[] urls) throws IOException, SAXException {
+
+        for (int i = 0; i < urls.length; i++) {
+            parse(urls[i]);
+        }
+
+    }
+
+
+    // --------------------------------------------------------- Private Methods
+
+
+    /**
+     * <p>Return the <code>Digester</code> instance we will use for parsing,
+     * creating and configuring a new instance if necessary.</p>
+     */
+    private Digester digester() {
+
+        if (this.digester == null) {
+            this.digester = new Digester();
+            digester.addRule("faces-config/component", new ComponentRule());
+            digester.addCallMethod
+              ("faces-config/component/component-type", "setComponentType", 0);
+            digester.addCallMethod
+              ("faces-config/component/component-class", "setComponentClass", 0);
+            digester.addRule("faces-config/converter", new ConverterRule());
+            digester.addCallMethod
+              ("faces-config/converter/converter-id", "setConverterId", 0);
+            digester.addCallMethod
+              ("faces-config/converter/converter-class", "setConverterClass", 0);
+            digester.addCallMethod
+              ("faces-config/converter/converter-for-class", "setConverterForClass", 0);
+            digester.addRule("faces-config/render-kit", new RenderKitRule());
+            digester.addRule("faces-config/render-kit/render-kit-id", new RenderKitIdRule());
+            digester.addRule("faces-config/render-kit/renderer", new RendererRule());
+            digester.addCallMethod
+              ("faces-config/render-kit/renderer/component-family", "setComponentFamily", 0);
+            digester.addCallMethod
+              ("faces-config/render-kit/renderer/renderer-class", "setRendererClass", 0);
+            digester.addCallMethod
+              ("faces-config/render-kit/renderer/renderer-type", "setRendererType", 0);
+            digester.addRule("faces-config/render-kit/client-behavior-renderer", new ClientBehaviorRendererRule());
+            digester.addCallMethod
+              ("faces-config/render-kit/client-behavior-renderer/client-behavior-renderer-type", "setClientBehaviorRendererType", 0);
+            digester.addCallMethod
+              ("faces-config/render-kit/client-behavior-renderer/client-behavior-renderer-class", "setClientBehaviorRendererClass", 0);
+            digester.addRule("faces-config/validator", new ValidatorRule());
+            digester.addCallMethod
+              ("faces-config/validator/validator-id", "setValidatorId", 0);
+            digester.addCallMethod
+              ("faces-config/validator/validator-class", "setValidatorClass", 0);
+            digester.addRule("faces-config/behavior", new BehaviorRule());
+            digester.addCallMethod
+                ("faces-config/behavior/behavior-id", "setBehaviorId", 0);
+            digester.addCallMethod
+                ("faces-config/behavior/behavior-class", "setBehaviorClass", 0);
+        }
+        return this.digester;
+
+    }
+
+
+    /**
+     * <p>Translate an array of resource names into an array of resource URLs.</p>
+     *
+     * @param names Resource names to translate
+     */
+    private URL[] translate(String[] names) {
+
+        URL[] results = new URL[names.length];
+        for (int i = 0; i < names.length; i++) {
+            results[i] = this.getClass().getResource(names[i]);
+        }
+        return results;
+        
+    }
+
+
+    // --------------------------------------------------------- Private Classes
+
+
+    /**
+     * <p>Data bean that stores information related to a component.</p>
+     */
+    class ComponentBean {
+
+        private String componentClass;
+        public String getComponentClass() {
+            return this.componentClass;
+        }
+        public void setComponentClass(String componentClass) {
+            this.componentClass = componentClass;
+        }
+
+        private String componentType;
+        public String getComponentType() {
+            return this.componentType;
+        }
+        public void setComponentType(String componentType) {
+            this.componentType = componentType;
+        }
+
+    }
+
+
+    /**
+     * <p>Digester <code>Rule</code> for processing components.</p>
+     */
+    class ComponentRule extends Rule {
+
+        public void begin(String namespace, String name, Attributes attributes) {
+            getDigester().push(new ComponentBean());
+        }
+
+        public void end(String namespace, String name) {
+            ComponentBean bean = (ComponentBean) getDigester().pop();
+            Application application = (Application) getDigester().peek();
+            application.addComponent(bean.getComponentType(), bean.getComponentClass());
+        }
+
+    }
+
+
+    /**
+     * <p>Data bean that stores information related to a converter.</p>
+     */
+    class ConverterBean {
+
+        private String converterClass;
+        public String getConverterClass() {
+            return this.converterClass;
+        }
+        public void setConverterClass(String converterClass) {
+            this.converterClass = converterClass;
+        }
+
+        private String converterForClass;
+        public String getConverterForClass() {
+            return this.converterForClass;
+        }
+        public void setConverterForClass(String converterForClass) {
+            this.converterForClass = converterForClass;
+        }
+
+        private String converterId;
+        public String getConverterId() {
+            return this.converterId;
+        }
+        public void setConverterId(String converterId) {
+            this.converterId = converterId;
+        }
+
+    }
+
+
+    /**
+     * <p>Digester <code>Rule</code> for processing converers.</p>
+     */
+    class ConverterRule extends Rule {
+
+        public void begin(String namespace, String name, Attributes attributes) {
+            getDigester().push(new ConverterBean());
+        }
+
+        public void end(String namespace, String name) {
+            ConverterBean bean = (ConverterBean) getDigester().pop();
+            Application application = (Application) getDigester().peek();
+            if (bean.getConverterId() != null) {
+                application.addConverter(bean.getConverterId(), bean.getConverterClass());
+            } else {
+                Class clazz = null;
+                try {
+                    clazz = this.getClass().getClassLoader().loadClass(bean.getConverterForClass());
+                } catch (ClassNotFoundException e) {
+                    throw new IllegalArgumentException("java.lang.ClassNotFoundException: "
+                        + bean.getConverterForClass());
+                }
+                application.addConverter(clazz, bean.getConverterClass());
+            }
+        }
+
+    }
+
+
+    /**
+     * <p>Digester <code>Rule</code> for processing render kits.</p>
+     */
+    class RenderKitRule extends Rule {
+
+        public void begin(String namespace, String name, Attributes attributes) {
+            RenderKitFactory factory = (RenderKitFactory)
+              FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+            getDigester().push(factory.getRenderKit(null, RenderKitFactory.HTML_BASIC_RENDER_KIT));
+        }
+
+        public void end(String namespace, String name) {
+            getDigester().pop();
+        }
+
+    }
+
+
+    /**
+     * <p>Digester <code>Rule</code> for processing render kit identifiers.</p>
+     */
+    class RenderKitIdRule extends Rule {
+
+        public void body(String namespace, String name, String text) {
+            String renderKitId = text.trim();
+            RenderKitFactory factory = (RenderKitFactory)
+              FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+            RenderKit renderKit = factory.getRenderKit(null, renderKitId);
+            if (renderKit == null) {
+                renderKit = new MockRenderKit();
+                factory.addRenderKit(renderKitId, renderKit);
+            }
+            getDigester().pop();
+            getDigester().push(renderKit);
+        }
+
+    }
+
+
+    /**
+     * <p>Data bean that stores information related to a renderer.</p>
+     */
+    class RendererBean {
+
+        private String componentFamily;
+        public String getComponentFamily() {
+            return this.componentFamily;
+        }
+        public void setComponentFamily(String componentFamily) {
+            this.componentFamily = componentFamily;
+        }
+
+        private String rendererClass;
+        public String getRendererClass() {
+            return this.rendererClass;
+        }
+        public void setRendererClass(String rendererClass) {
+            this.rendererClass = rendererClass;
+        }
+
+        private String rendererType;
+        public String getRendererType() {
+            return this.rendererType;
+        }
+        public void setRendererType(String rendererType) {
+            this.rendererType = rendererType;
+        }
+
+    }
+
+
+    /**
+     * <p>Digester <code>Rule</code> for processing renderers.</p>
+     */
+    class RendererRule extends Rule {
+
+        public void begin(String namespace, String name, Attributes attributes) {
+            getDigester().push(new RendererBean());
+        }
+
+        public void end(String namespace, String name) {
+            RendererBean bean = (RendererBean) getDigester().pop();
+            RenderKit kit = (RenderKit) getDigester().peek();
+            Renderer renderer = null;
+            Class clazz = null;
+            try {
+                clazz = this.getClass().getClassLoader().loadClass(bean.getRendererClass());
+                renderer = (Renderer) clazz.newInstance();
+            } catch (Exception e) {
+                throw new IllegalArgumentException("Exception while trying to instantiate"
+                    + " renderer class '" + bean.getRendererClass() + "' : "
+                    + e.getMessage());
+            }
+            kit.addRenderer(bean.getComponentFamily(), bean.getRendererType(),
+                            renderer);
+        }
+
+    }
+
+
+    /**
+     * <p>Data bean that stores information related to a validator.</p>
+     */
+    class ValidatorBean {
+
+        private String validatorClass;
+        public String getValidatorClass() {
+            return this.validatorClass;
+        }
+        public void setValidatorClass(String validatorClass) {
+            this.validatorClass = validatorClass;
+        }
+
+        private String validatorId;
+        public String getValidatorId() {
+            return this.validatorId;
+        }
+        public void setValidatorId(String validatorId) {
+            this.validatorId = validatorId;
+        }
+
+    }
+
+
+    /**
+     * <p>Digester <code>Rule</code> for processing validators.</p>
+     */
+    class ValidatorRule extends Rule {
+
+        public void begin(String namespace, String name, Attributes attributes) {
+            getDigester().push(new ValidatorBean());
+        }
+
+        public void end(String namespace, String name) {
+            ValidatorBean bean = (ValidatorBean) getDigester().pop();
+            Application application = (Application) getDigester().peek();
+            application.addValidator(bean.getValidatorId(), bean.getValidatorClass());
+        }
+
+    }
+
+    class ClientBehaviorRendererBean
+    {
+        private String clientBehaviorRendererType;
+        
+        private String clientBehaviorRendererClass;
+        
+        public String getClientBehaviorRendererType()
+        {
+            return clientBehaviorRendererType;
+        }
+
+        public void setClientBehaviorRendererType(String clientBehaviorRendererType)
+        {
+            this.clientBehaviorRendererType = clientBehaviorRendererType;
+        }
+
+        public String getClientBehaviorRendererClass()
+        {
+            return clientBehaviorRendererClass;
+        }
+
+        public void setClientBehaviorRendererClass(String clientBehaviorRendererClass)
+        {
+            this.clientBehaviorRendererClass = clientBehaviorRendererClass;
+        }
+    }
+    
+    class ClientBehaviorRendererRule extends Rule
+    {
+        public void begin(String namespace, String name, Attributes attributes)
+        {
+            getDigester().push(new ClientBehaviorRendererBean());
+        }
+
+        public void end(String namespace, String name) {
+            ClientBehaviorRendererBean bean = (ClientBehaviorRendererBean) getDigester().pop();
+            RenderKit kit = (RenderKit) getDigester().peek();
+            ClientBehaviorRenderer renderer = null;
+            Class clazz = null;
+            try {
+                clazz = this.getClass().getClassLoader().loadClass(bean.getClientBehaviorRendererClass());
+                renderer = (ClientBehaviorRenderer) clazz.newInstance();
+            } catch (Exception e) {
+                throw new IllegalArgumentException("Exception while trying to instantiate"
+                    + " client behavior renderer class '" + bean.getClientBehaviorRendererClass() + "' : "
+                    + e.getMessage());
+            }
+            kit.addClientBehaviorRenderer(bean.getClientBehaviorRendererType(), 
+                            renderer);
+        }
+    }
+
+    /**
+     * <p>Data bean that stores information related to a behavior.</p>
+     */
+    class BehaviorBean
+    {
+
+        private String behaviorClass;
+
+        public String getBehaviorClass()
+        {
+            return this.behaviorClass;
+        }
+
+        @SuppressWarnings("unused")
+        public void setBehaviorClass(String behaviorClass)
+        {
+            this.behaviorClass = behaviorClass;
+        }
+
+        private String behaviorId;
+
+        public String getBehaviorId()
+        {
+            return this.behaviorId;
+        }
+
+        @SuppressWarnings("unused")
+        public void setBehaviorId(String behaviorId)
+        {
+            this.behaviorId = behaviorId;
+        }
+
+    }
+
+
+    /**
+     * <p>Digester <code>Rule</code> for processing behaviors.</p>
+     */
+    class BehaviorRule extends Rule
+    {
+
+        public void begin(String namespace, String name, Attributes attributes)
+        {
+            getDigester().push(new BehaviorBean());
+        }
+
+        public void end(String namespace, String name)
+        {
+            BehaviorBean bean = (BehaviorBean) getDigester().pop();
+            Application application = (Application) getDigester().peek();
+            application.addBehavior(bean.getBehaviorId(), bean.getBehaviorClass());
+        }
+
+    }
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser20.java b/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser20.java
deleted file mode 100644
index 8325508..0000000
--- a/test20/src/main/java/org/apache/myfaces/test/config/ConfigParser20.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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 org.apache.commons.digester.Digester;
-import org.apache.commons.digester.Rule;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * <p>Extended {@link org.apache.myfaces.test.config.ConfigParser ConfigParser} to cover JSF 2.0 artifacts</p>
- * <p/>
- * <p>The following artifacts are registered additionally:</p>
- * <ul>
- * <li><code>Behavior</code></li>
- * </ul>
- *
- * @since 2.0
- */
-public class ConfigParser20 extends ConfigParser
-{
-
-    /**
-     * Creates a new instance of ConfigParser
-     */
-    public ConfigParser20()
-    {
-        super();
-    }
-
-    /**
-     * <p>The <code>Digester</code> instance we will use for parsing.</p>
-     */
-    private Digester digester = null;
-
-    @Override
-    public void parse(URL url) throws IOException, SAXException
-    {
-
-        super.parse(url);
-
-        // Acquire and configure the Digester instance we will use
-        Digester digester = digester();
-        ApplicationFactory factory = (ApplicationFactory)
-            FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
-        Application application = factory.getApplication();
-        digester.push(application);
-
-        // Perform the required parsing
-        try {
-            digester.parse(url);
-        }
-        finally {
-            digester.clear();
-        }
-
-    }
-
-
-    @Override
-    public void parse(URL[] urls) throws IOException, SAXException
-    {
-
-        for (URL url : urls) {
-            parse(url);
-        }
-    }
-
-
-    /**
-     * @return Return the <code>Digester</code> instance we will use for parsing,
-     *         creating and configuring a new instance if necessary.
-     */
-    private Digester digester()
-    {
-
-        if (this.digester == null) {
-            this.digester = new Digester();
-
-            digester.addRule("faces-config/behavior", new BehaviorRule());
-            digester.addCallMethod
-                ("faces-config/behavior/behavior-id", "setBehaviorId", 0);
-            digester.addCallMethod
-                ("faces-config/behavior/behavior-class", "setBehaviorClass", 0);
-        }
-        return this.digester;
-
-    }
-
-    /**
-     * <p>Data bean that stores information related to a behavior.</p>
-     */
-    class BehaviorBean
-    {
-
-        private String behaviorClass;
-
-        public String getBehaviorClass()
-        {
-            return this.behaviorClass;
-        }
-
-        @SuppressWarnings("unused")
-        public void setBehaviorClass(String behaviorClass)
-        {
-            this.behaviorClass = behaviorClass;
-        }
-
-        private String behaviorId;
-
-        public String getBehaviorId()
-        {
-            return this.behaviorId;
-        }
-
-        @SuppressWarnings("unused")
-        public void setBehaviorId(String behaviorId)
-        {
-            this.behaviorId = behaviorId;
-        }
-
-    }
-
-
-    /**
-     * <p>Digester <code>Rule</code> for processing behaviors.</p>
-     */
-    class BehaviorRule extends Rule
-    {
-
-        public void begin(String namespace, String name, Attributes attributes)
-        {
-            getDigester().push(new BehaviorBean());
-        }
-
-        public void end(String namespace, String name)
-        {
-            BehaviorBean bean = (BehaviorBean) getDigester().pop();
-            Application application = (Application) getDigester().peek();
-            application.addBehavior(bean.getBehaviorId(), bean.getBehaviorClass());
-        }
-
-    }
-}
diff --git a/test20/src/test/java/org/apache/myfaces/test/config/ConfigParser20TestCase.java b/test20/src/test/java/org/apache/myfaces/test/config/ConfigParser20TestCase.java
deleted file mode 100644
index 4c6f928..0000000
--- a/test20/src/test/java/org/apache/myfaces/test/config/ConfigParser20TestCase.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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 junit.framework.Test;
-import junit.framework.TestSuite;
-import org.apache.myfaces.test.base.AbstractJsfTestCase;
-import org.apache.myfaces.test.mock.MockApplication20;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Test case for <code>ConfigParser20</code>
- */
-public class ConfigParser20TestCase extends AbstractJsfTestCase
-{
-
-
-    // ------------------------------------------------------------ Constructors
-
-
-    // Construct a new instance of this test case.
-
-    public ConfigParser20TestCase(String name)
-    {
-        super(name);
-    }
-
-
-    // ---------------------------------------------------- Overall Test Methods
-
-
-    // Set up instance variables required by this test case.
-
-    protected void setUp() throws Exception
-    {
-
-        super.setUp();
-        parser = new ConfigParser20();
-        application20 = (MockApplication20) application;
-
-    }
-
-
-    // Return the tests included in this test case.
-
-    public static Test suite()
-    {
-
-        return (new TestSuite(ConfigParser20TestCase.class));
-
-    }
-
-
-    // Tear down instance variables required by this test case.
-
-    protected void tearDown() throws Exception
-    {
-
-        parser = null;
-        super.tearDown();
-
-    }
-
-
-    // ------------------------------------------------------ Instance Variables
-
-
-    // ConfigParser instance under test
-    ConfigParser20 parser = null;
-
-    MockApplication20 application20 = null;
-
-    // ------------------------------------------------- Individual Test Methods
-
-    @SuppressWarnings("unchecked")
-    public void testSimple() throws Exception
-    {
-
-        URL url = this.getClass().getResource("/org/apache/myfaces/test/config/myfaces20-faces-config-1.xml");
-        assertNotNull(url);
-        parser.parse(url);
-        Iterator items;
-        List list = new ArrayList();
-
-        items = application20.getComponentTypes();
-        list.clear();
-        while (items.hasNext()) {
-            list.add(items.next());
-        }
-        assertTrue(list.contains("component-type-1"));
-        assertTrue(list.contains("component-type-2"));
-
-        items = application20.getBehaviorIds();
-        list.clear();
-        while (items.hasNext()) {
-            list.add(items.next());
-        }
-        assertTrue(list.contains("behavior-1"));
-        assertTrue(list.contains("behavior-2"));
-    }
-}
diff --git a/test20/src/test/java/org/apache/myfaces/test/config/ConfigParserTestCase.java b/test20/src/test/java/org/apache/myfaces/test/config/ConfigParserTestCase.java
new file mode 100644
index 0000000..1aab275
--- /dev/null
+++ b/test20/src/test/java/org/apache/myfaces/test/config/ConfigParserTestCase.java
@@ -0,0 +1,196 @@
+/*
+ * 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.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.convert.Converter;
+import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.Renderer;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.test.base.AbstractJsfTestCase;
+import org.apache.myfaces.test.mock.MockApplication20;
+
+/**
+ * Test case for <code>ConfigParser20</code>
+ */
+public class ConfigParserTestCase extends AbstractJsfTestCase
+{
+
+
+    // ------------------------------------------------------------ Constructors
+
+
+    // Construct a new instance of this test case.
+
+    public ConfigParserTestCase(String name)
+    {
+        super(name);
+    }
+
+
+    // ---------------------------------------------------- Overall Test Methods
+
+
+    // Set up instance variables required by this test case.
+
+    protected void setUp() throws Exception
+    {
+
+        super.setUp();
+        parser = new ConfigParser();
+        application20 = (MockApplication20) application;
+
+    }
+
+
+    // Return the tests included in this test case.
+
+    public static Test suite()
+    {
+
+        return (new TestSuite(ConfigParserTestCase.class));
+
+    }
+
+
+    // Tear down instance variables required by this test case.
+
+    protected void tearDown() throws Exception
+    {
+
+        parser = null;
+        super.tearDown();
+
+    }
+
+
+    // ------------------------------------------------------ Instance Variables
+
+
+    // ConfigParser instance under test
+    ConfigParser parser = null;
+
+    MockApplication20 application20 = null;
+
+    // ------------------------------------------------- Individual Test Methods
+
+
+    // Test access to the platform configuration resources
+    public void testPlatform() throws Exception {
+
+        // Make sure we can acquire a good set of URLs
+        URL[] urls = parser.getPlatformURLs();
+        assertNotNull(urls);
+        assertEquals(1, urls.length);
+        assertNotNull(urls[0]);
+
+        // Now can we actually parse them?
+        parser.parse(urls);
+
+    }
+
+
+    // Test a pristine instance
+    public void testPristine() {
+
+        assertNotNull(parser);
+
+    }
+
+
+    // Test loading a simple configuration resource
+    @SuppressWarnings("unchecked")
+    public void testSimple() throws Exception
+    {
+
+
+        URL url = this.getClass().getResource("/org/apache/myfaces/test/config/faces-config-1.xml");
+        assertNotNull(url);
+        parser.parse(url);
+        Iterator items;
+        List list = new ArrayList();
+
+        items = application20.getComponentTypes();
+        list.clear();
+        while (items.hasNext()) {
+            list.add(items.next());
+        }
+        assertTrue(list.contains("component-type-1"));
+        assertTrue(list.contains("component-type-2"));
+
+        items = application.getConverterIds();
+        list.clear();
+        while (items.hasNext()) {
+            list.add(items.next());
+        }
+        assertTrue(list.contains("converter-id-1"));
+        assertTrue(list.contains("converter-id-2"));
+
+        Converter converter = application.createConverter(Integer.class);
+        assertNotNull(converter);
+        assertTrue(converter instanceof MyConverter);
+
+        items = application.getValidatorIds();
+        list.clear();
+        while (items.hasNext()) {
+            list.add(items.next());
+        }
+        assertTrue(list.contains("validator-id-1"));
+        assertTrue(list.contains("validator-id-2"));
+
+        Renderer renderer = renderKit.getRenderer("component-family-1", "renderer-type-1");
+        assertNotNull(renderer);
+        assertTrue(renderer instanceof MyRenderer);
+        
+        renderer = renderKit.getRenderer("component-family-2", "renderer-type-2");
+        assertNotNull(renderer);
+        assertTrue(renderer instanceof MyRenderer);
+        
+        items = application20.getBehaviorIds();
+        list.clear();
+        while (items.hasNext()) {
+            list.add(items.next());
+        }
+        assertTrue(list.contains("behavior-1"));
+        assertTrue(list.contains("behavior-2"));
+        
+        items = renderKit.getClientBehaviorRendererTypes();
+        list.clear();
+        while (items.hasNext()) {
+            list.add(items.next());
+        }
+        assertTrue(list.contains("client-behavior-renderer-1"));
+        assertTrue(list.contains("client-behavior-renderer-2"));
+        
+        ClientBehaviorRenderer clientBehaviorRenderer1 = renderKit.getClientBehaviorRenderer("client-behavior-renderer-1");
+        assertNotNull(clientBehaviorRenderer1);
+        assertTrue(clientBehaviorRenderer1 instanceof MyClientBehaviorRenderer);
+
+        ClientBehaviorRenderer clientBehaviorRenderer2 = renderKit.getClientBehaviorRenderer("client-behavior-renderer-2");
+        assertNotNull(clientBehaviorRenderer2);
+        assertTrue(clientBehaviorRenderer2 instanceof MyClientBehaviorRenderer);
+    }
+
+    // --------------------------------------------------------- Private Methods
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java b/test20/src/test/java/org/apache/myfaces/test/config/MyBehavior.java
similarity index 97%
copy from test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java
copy to test20/src/test/java/org/apache/myfaces/test/config/MyBehavior.java
index c5f113a..0c6a183 100644
--- a/test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java
+++ b/test20/src/test/java/org/apache/myfaces/test/config/MyBehavior.java
@@ -1,28 +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.test.config;
-
-import javax.faces.component.behavior.Behavior;
-import javax.faces.event.BehaviorEvent;
-
-public class MyBehavior implements Behavior
-{
-    public void broadcast(BehaviorEvent event)
-    {
-        
-    }
-}
+/*
+ * 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 javax.faces.component.behavior.Behavior;
+import javax.faces.event.BehaviorEvent;
+
+public class MyBehavior implements Behavior
+{
+    public void broadcast(BehaviorEvent event)
+    {
+        
+    }
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java b/test20/src/test/java/org/apache/myfaces/test/config/MyClientBehaviorRenderer.java
similarity index 73%
copy from test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java
copy to test20/src/test/java/org/apache/myfaces/test/config/MyClientBehaviorRenderer.java
index c5f113a..48e693d 100644
--- a/test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java
+++ b/test20/src/test/java/org/apache/myfaces/test/config/MyClientBehaviorRenderer.java
@@ -1,28 +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.test.config;
-
-import javax.faces.component.behavior.Behavior;
-import javax.faces.event.BehaviorEvent;
-
-public class MyBehavior implements Behavior
-{
-    public void broadcast(BehaviorEvent event)
-    {
-        
-    }
-}
+/*
+ * 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 javax.faces.render.ClientBehaviorRenderer;
+
+/**
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 816435 $ $Date: 2009-09-17 21:10:12 -0500 (jue, 17 sep 2009) $
+ */
+public class MyClientBehaviorRenderer extends ClientBehaviorRenderer
+{
+
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java b/test20/src/test/java/org/apache/myfaces/test/config/MyConverter.java
similarity index 60%
copy from test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java
copy to test20/src/test/java/org/apache/myfaces/test/config/MyConverter.java
index c5f113a..0d8137d 100644
--- a/test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java
+++ b/test20/src/test/java/org/apache/myfaces/test/config/MyConverter.java
@@ -1,28 +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.test.config;
-
-import javax.faces.component.behavior.Behavior;
-import javax.faces.event.BehaviorEvent;
-
-public class MyBehavior implements Behavior
-{
-    public void broadcast(BehaviorEvent event)
-    {
-        
-    }
-}
+/*
+ * 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 javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ * <p>Concrete converter implementation for testing.</p>
+ */
+public class MyConverter implements Converter {
+
+    public Object getAsObject(FacesContext context, UIComponent component, String value) {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getAsString(FacesContext context, UIComponent component, Object value) {
+        throw new UnsupportedOperationException();
+    }
+
+}
diff --git a/test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java b/test20/src/test/java/org/apache/myfaces/test/config/MyValidator.java
similarity index 65%
rename from test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java
rename to test20/src/test/java/org/apache/myfaces/test/config/MyValidator.java
index c5f113a..3dbc014 100644
--- a/test20/src/main/java/org/apache/myfaces/test/config/MyBehavior.java
+++ b/test20/src/test/java/org/apache/myfaces/test/config/MyValidator.java
@@ -1,28 +1,35 @@
-/*
- * 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 javax.faces.component.behavior.Behavior;
-import javax.faces.event.BehaviorEvent;
-
-public class MyBehavior implements Behavior
-{
-    public void broadcast(BehaviorEvent event)
-    {
-        
-    }
-}
+/*
+ * 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 javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * <p>Concrete validator implementation for testing.</p>
+ */
+public class MyValidator implements Validator {
+
+    @Override
+    public void validate(FacesContext context, UIComponent component,
+            Object value) throws ValidatorException
+    {
+    }
+}
diff --git a/test20/src/test/resources/org/apache/myfaces/test/config/myfaces20-faces-config-1.xml b/test20/src/test/resources/org/apache/myfaces/test/config/faces-config-1.xml
similarity index 69%
rename from test20/src/test/resources/org/apache/myfaces/test/config/myfaces20-faces-config-1.xml
rename to test20/src/test/resources/org/apache/myfaces/test/config/faces-config-1.xml
index f3df8a4..0823403 100644
--- a/test20/src/test/resources/org/apache/myfaces/test/config/myfaces20-faces-config-1.xml
+++ b/test20/src/test/resources/org/apache/myfaces/test/config/faces-config-1.xml
@@ -1,78 +1,95 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  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.
--->
-
-<faces-config version="2.0"
-    xmlns="http://java.sun.com/xml/ns/javaee"
-    xmlns:xi="http://www.w3.org/2001/XInclude"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
-
-  <component>
-      <component-type>component-type-1</component-type>
-      <component-class>com.mycompany.MyComponent1</component-class>
-  </component>
-
-  <component>
-      <component-type>component-type-2</component-type>
-      <component-class>com.mycompany.MyComponent2</component-class>
-  </component>
-
-  <converter>
-      <converter-for-class>java.lang.Integer</converter-for-class>
-      <converter-class>org.apache.myfaces.test.config.MyConverter</converter-class>
-  </converter>
-
-  <validator>
-      <validator-id>validator-id-1</validator-id>
-      <validator-class>javax.faces.validator.LengthValidator</validator-class>
-  </validator>
-
-  <validator>
-      <validator-id>validator-id-2</validator-id>
-      <validator-class>javax.faces.validator.LongRangeValidator</validator-class>
-  </validator>
-
-  <behavior>
-      <behavior-id>behavior-1</behavior-id>
-      <behavior-class>org.apache.myfaces.test.config.MyBehavior</behavior-class>
-  </behavior>
-  <behavior>
-      <behavior-id>behavior-2</behavior-id>
-      <behavior-class>org.apache.myfaces.test.config.MyBehavior</behavior-class>
-  </behavior>
-
-  <render-kit>
-
-      <renderer>
-          <component-family>component-family-1</component-family>
-          <renderer-type>renderer-type-1</renderer-type>
-          <renderer-class>org.apache.myfaces.test.config.MyRenderer</renderer-class>
-      </renderer>
-
-      <renderer>
-          <component-family>component-family-2</component-family>
-          <renderer-type>renderer-type-2</renderer-type>
-          <renderer-class>org.apache.myfaces.test.config.MyRenderer</renderer-class>
-      </renderer>
-
-  </render-kit>
-
-
-
-</faces-config>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<faces-config version="2.0"
+    xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xi="http://www.w3.org/2001/XInclude"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
+
+  <component>
+      <component-type>component-type-1</component-type>
+      <component-class>com.mycompany.MyComponent1</component-class>
+  </component>
+
+  <component>
+      <component-type>component-type-2</component-type>
+      <component-class>com.mycompany.MyComponent2</component-class>
+  </component>
+
+  <converter>
+      <converter-id>converter-id-1</converter-id>
+      <converter-class>com.mycompany.MyConverter1</converter-class>
+  </converter>
+
+  <converter>
+      <converter-id>converter-id-2</converter-id>
+      <converter-class>com.mycompany.MyConverter2</converter-class>
+  </converter>
+
+  <converter>
+      <converter-for-class>java.lang.Integer</converter-for-class>
+      <converter-class>org.apache.myfaces.test.config.MyConverter</converter-class>
+  </converter>
+
+  <validator>
+      <validator-id>validator-id-1</validator-id>
+      <validator-class>org.apache.myfaces.test.config.MyValidator</validator-class>
+  </validator>
+
+  <validator>
+      <validator-id>validator-id-2</validator-id>
+      <validator-class>org.apache.myfaces.test.config.MyValidator</validator-class>
+  </validator>
+
+  <behavior>
+      <behavior-id>behavior-1</behavior-id>
+      <behavior-class>org.apache.myfaces.test.config.MyBehavior</behavior-class>
+  </behavior>
+  <behavior>
+      <behavior-id>behavior-2</behavior-id>
+      <behavior-class>org.apache.myfaces.test.config.MyBehavior</behavior-class>
+  </behavior>
+
+  <render-kit>
+
+      <renderer>
+          <component-family>component-family-1</component-family>
+          <renderer-type>renderer-type-1</renderer-type>
+          <renderer-class>org.apache.myfaces.test.config.MyRenderer</renderer-class>
+      </renderer>
+
+      <renderer>
+          <component-family>component-family-2</component-family>
+          <renderer-type>renderer-type-2</renderer-type>
+          <renderer-class>org.apache.myfaces.test.config.MyRenderer</renderer-class>
+      </renderer>
+
+      <client-behavior-renderer>
+          <client-behavior-renderer-type>client-behavior-renderer-1</client-behavior-renderer-type>
+          <client-behavior-renderer-class>org.apache.myfaces.test.config.MyClientBehaviorRenderer</client-behavior-renderer-class>
+      </client-behavior-renderer>
+
+      <client-behavior-renderer>
+          <client-behavior-renderer-type>client-behavior-renderer-2</client-behavior-renderer-type>
+          <client-behavior-renderer-class>org.apache.myfaces.test.config.MyClientBehaviorRenderer</client-behavior-renderer-class>
+      </client-behavior-renderer>
+  </render-kit>
+
+</faces-config>

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 08/24: [maven-release-plugin] prepare for next development iteration

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit c724ce2a65bb432e0e7897ec48fc9a8762dcff73
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Fri Jun 11 02:33:02 2010 +0000

    [maven-release-plugin] prepare for next development iteration
---
 pom.xml        | 8 ++++----
 test12/pom.xml | 2 +-
 test20/pom.xml | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0eea5db..af3cfaf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,16 +30,16 @@
     <artifactId>myfaces-test-project</artifactId>
     <packaging>pom</packaging>
     <name>Myfaces Test Framework</name>
-    <version>1.0.0-beta-4</version>
+    <version>1.0.0-SNAPSHOT</version>
     <url>http://myfaces.apache.org/test</url>
     <issueManagement>
       <system>jira</system>
       <url>http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10600</url>
     </issueManagement>
     <scm>
-      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</connection>
-      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</developerConnection>
-      <url>http://svn.apache.org/repos/asf/myfaces/test/tags/1_0_0_beta_4</url>
+      <connection>scm:svn:http://svn.apache.org/repos/asf/myfaces/test/trunk</connection>
+      <developerConnection>scm:svn:https://svn.apache.org/repos/asf/myfaces/test/trunk</developerConnection>
+      <url>http://svn.apache.org/repos/asf/myfaces/test/trunk</url>
     </scm>
     <modules>
       <module>test12</module>
diff --git a/test12/pom.xml b/test12/pom.xml
index 90ef95d..3ffa3bb 100644
--- a/test12/pom.xml
+++ b/test12/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-beta-4</version>
+        <version>1.0.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>myfaces-test12</artifactId>
diff --git a/test20/pom.xml b/test20/pom.xml
index 60fe388..8021996 100644
--- a/test20/pom.xml
+++ b/test20/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.apache.myfaces.test</groupId>
         <artifactId>myfaces-test-project</artifactId>
-        <version>1.0.0-beta-4</version>
+        <version>1.0.0-SNAPSHOT</version>
     </parent>
 
     <artifactId>myfaces-test20</artifactId>

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.

[myfaces-test] 12/24: MYFACESTEST-15 Add new MockResponseStateManager

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 7e066e8a336523cec879a6381a0056decd99069c
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 00:05:51 2010 +0000

    MYFACESTEST-15 Add new MockResponseStateManager
---
 .../test/mock/MockResponseStateManager.java        | 353 +++++++++++++++++++++
 1 file changed, 353 insertions(+)

diff --git a/test20/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java b/test20/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
new file mode 100644
index 0000000..d9b9e16
--- /dev/null
+++ b/test20/src/main/java/org/apache/myfaces/test/mock/MockResponseStateManager.java
@@ -0,0 +1,353 @@
+package org.apache.myfaces.test.mock;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.faces.FacesException;
+import javax.faces.application.StateManager.SerializedView;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.ResponseStateManager;
+
+/**
+ * Mock class that encode view state in hex format
+ * 
+ * @author lu4242
+ *
+ */
+public class MockResponseStateManager extends ResponseStateManager
+{
+    // ------------------------------------------------------------ Constructors
+
+    // ------------------------------------------------------ Instance Variables
+    
+    private static final int TREE_PARAM = 0;
+    private static final int STATE_PARAM = 1;
+    private static final int VIEWID_PARAM = 2;
+    private static final String ZIP_CHARSET = "ISO-8859-1";
+
+    
+    // ----------------------------------------------------- Mock Object Methods
+
+    // -------------------------------------------------- ResponseStateManager Methods
+    
+    public Object getState(FacesContext facesContext, String viewId)
+    {
+        Object[] savedState = getSavedState(facesContext);
+        if (savedState == null)
+        {
+            return null;
+        }
+
+        return new Object[] { savedState[TREE_PARAM], savedState[STATE_PARAM] };
+    }
+
+    public Object getTreeStructureToRestore(FacesContext facesContext, String viewId)
+    {
+        // Although this method won't be called anymore,
+        // it has been kept for backward compatibility.
+        Object[] savedState = getSavedState(facesContext);
+        if (savedState == null)
+        {
+            return null;
+        }
+
+        return savedState[TREE_PARAM];
+    }
+
+    public Object getComponentStateToRestore(FacesContext facesContext)
+    {
+        // Although this method won't be called anymore,
+        // it has been kept for backward compatibility.
+        Object[] savedState = getSavedState(facesContext);
+        if (savedState == null)
+        {
+            return null;
+        }
+
+        return savedState[STATE_PARAM];
+    }
+
+    public boolean isPostback(FacesContext context)
+    {
+        return context.getExternalContext().getRequestParameterMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM);
+    }
+
+    public void writeState(FacesContext facescontext, SerializedView serializedview)
+            throws IOException
+    {
+        ResponseWriter responseWriter = facescontext.getResponseWriter();
+
+        Object[] savedState = new Object[3];
+
+        if (facescontext.getApplication().getStateManager().isSavingStateInClient(facescontext))
+        {
+            Object treeStruct = serializedview.getStructure();
+            Object compStates = serializedview.getState();
+
+            if (treeStruct != null)
+            {
+                savedState[TREE_PARAM] = treeStruct;
+            }
+
+            if (compStates != null)
+            {
+                savedState[STATE_PARAM] = compStates;
+            }
+        }
+        else
+        {
+            // write viewSequence
+            Object treeStruct = serializedview.getStructure();
+            if (treeStruct != null)
+            {
+                if (treeStruct instanceof String)
+                {
+                    savedState[TREE_PARAM] = treeStruct;
+                }
+            }
+        }
+
+        savedState[VIEWID_PARAM] = facescontext.getViewRoot().getViewId();
+
+        // write the view state field
+        writeViewStateField(facescontext, responseWriter, savedState);
+
+        // renderKitId field
+        writeRenderKitIdField(facescontext, responseWriter);
+    }
+
+    private void writeViewStateField(FacesContext facesContext, ResponseWriter responseWriter, Object savedState)
+    throws IOException
+    {
+        
+        String serializedState = construct(facesContext, savedState);
+        responseWriter.startElement("input", null);
+        responseWriter.writeAttribute("type", "hidden", null);
+        responseWriter.writeAttribute("name", VIEW_STATE_PARAM, null);
+        responseWriter.writeAttribute("value", serializedState, null);
+        responseWriter.endElement("input");
+    }
+    
+
+    private void writeRenderKitIdField(FacesContext facesContext, ResponseWriter responseWriter) throws IOException
+    {
+    
+        String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
+        if (defaultRenderKitId != null && !RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(defaultRenderKitId))
+        {
+            responseWriter.startElement("input", null);
+            responseWriter.writeAttribute("type", "hidden", null);
+            responseWriter.writeAttribute("name", ResponseStateManager.RENDER_KIT_ID_PARAM, null);
+            responseWriter.writeAttribute("value", defaultRenderKitId, null);
+            responseWriter.endElement("input");
+        }
+    }
+    
+    private String construct(FacesContext facesContext, Object savedState) throws IOException
+    {
+        byte[] bytes = null;
+        ByteArrayOutputStream baos = null;
+        ObjectOutputStream oos = null;
+        try
+        {
+            baos = new ByteArrayOutputStream();
+            oos = new ObjectOutputStream(baos);
+            oos.writeObject(savedState);
+            bytes = baos.toByteArray();
+        }
+        finally
+        {
+            if (oos != null)
+            {
+                try
+                {
+                    oos.close();
+                }
+                catch(IOException e)
+                {
+                }
+                finally
+                {
+                    oos = null;
+                }
+            }
+            if (baos != null)
+            {
+                try
+                {
+                    baos.close();
+                }
+                catch(IOException e)
+                {
+                }
+                finally
+                {
+                    baos = null;
+                }
+            }
+        }
+        return new String(new _Hex().encode(bytes), ZIP_CHARSET);
+    }
+    
+    private Object reconstruct(FacesContext facesContext, String encodedState) throws IOException
+    {
+        byte[] bytes = encodedState.getBytes(ZIP_CHARSET);
+        
+        ByteArrayInputStream input = null;
+        ObjectInputStream s = null;
+        Object object = null;
+        
+        try
+        {
+            input = new ByteArrayInputStream(bytes);
+            s = new ObjectInputStream(input); 
+            object = s.readObject();
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new IOException(e);
+        }
+        finally
+        {
+            if (s != null)
+            {
+                try
+                {
+                    s.close();
+                }
+                catch(IOException e)
+                {
+                }
+                finally
+                {
+                    s = null;
+                }
+            }
+            if (input != null)
+            {
+                try
+                {
+                    input.close();
+                }
+                catch(IOException e)
+                {
+                }
+                finally
+                {
+                    input = null;
+                }
+            }
+        }
+        return object;
+    }
+
+    private Object[] getSavedState(FacesContext facesContext) {
+        Object encodedState = 
+            facesContext.getExternalContext().
+                getRequestParameterMap().get(VIEW_STATE_PARAM);
+        if(encodedState==null || (((String) encodedState).length() == 0)) { 
+            return null;
+        }
+
+        Object[] savedState = null;
+        
+        try
+        {
+            savedState = (Object[])reconstruct(facesContext, (String)encodedState);
+        }
+        catch(IOException e)
+        {
+            facesContext.getExternalContext().log("Cannot reconstruct view state", e);
+        }
+
+        if (savedState == null)
+        {
+            return null;
+        }
+        
+        String restoredViewId = (String)savedState[VIEWID_PARAM];
+
+        if (restoredViewId == null)
+        {
+            return null;
+        }
+        return savedState;
+    }
+    
+    public String getViewState(FacesContext facesContext, Object state)
+    {
+        if (state == null)
+        {
+            return null;
+        }
+        
+        Object treeStruct = null;
+        Object compStates = null;
+        
+        if (state instanceof SerializedView)
+        {
+            SerializedView view = (SerializedView)state; 
+            treeStruct = view.getStructure();
+            compStates = view.getState();
+        }
+        else if (state instanceof Object[])
+        {
+            Object[] structureAndState = (Object[])state;
+
+            if (structureAndState.length == 2)
+            {
+                treeStruct = structureAndState[0];
+                compStates = structureAndState[1];
+            }
+            else
+            {
+                throw new FacesException("The state should be an array of Object[] of lenght 2");
+            }
+        }
+        else
+        {
+            throw new FacesException("The state should be an array of Object[] of lenght 2, or a SerializedView instance");
+        }
+        
+        Object[] savedState = new Object[3];
+
+        if (facesContext.getApplication().getStateManager().isSavingStateInClient(facesContext))
+        {
+            if (treeStruct != null)
+            {
+                savedState[TREE_PARAM] = treeStruct;
+            }
+
+            if (compStates != null)
+            {
+                savedState[STATE_PARAM] = compStates;
+            }
+        }
+        else
+        {
+            // write viewSequence
+            if (treeStruct != null)
+            {
+                if (treeStruct instanceof String)
+                {
+                    savedState[TREE_PARAM] = treeStruct;
+                }
+            }
+        }
+        savedState[VIEWID_PARAM] = facesContext.getViewRoot().getViewId();
+
+        try
+        {
+            return construct(facesContext, savedState);
+        }
+        catch(IOException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }    
+}

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.