You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2014/02/25 06:50:10 UTC

svn commit: r1571570 [2/4] - in /myfaces/core/trunk: impl-test/ impl-test/src/main/java/org/ impl-test/src/main/java/org/apache/ impl-test/src/main/java/org/apache/myfaces/ impl-test/src/main/java/org/apache/myfaces/mc/ impl-test/src/main/java/org/apac...

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/BeforeRequest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/BeforeRequest.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/BeforeRequest.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/BeforeRequest.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.mc.test.core.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value =
+{
+    ElementType.METHOD
+})
+public @interface BeforeRequest
+{
+    
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/BeforeRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,44 @@
+/*
+ * 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.mc.test.core.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Using this annotation allows to use a custom faces-config.xml for the test class.
+ * The values here are relative to the web context path, defined by 
+ * AbstractMyFacesTestCase.getWebappContextFilePath() and
+ * AbstractMyFacesTestCase.getWebappContextURI(), so it can be seen as an alias for
+ * javax.faces.CONFIG_FILES web config param, just to make easier work with different
+ * config files. 
+ *
+ */
+@Documented
+@Inherited
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface DeclareFacesConfig
+{
+    String[] value() default {};
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,38 @@
+/*
+ * 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.mc.test.core.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ *
+ */
+@Documented
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ManagedBeans
+{
+    PageBean[] value() default {};
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java Tue Feb 25 05:50:09 2014
@@ -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.mc.test.core.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The page bean of the TestCase view.
+ *
+ */
+@Documented
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface PageBean
+{
+
+    String scope() default "request";
+
+    String name() default ""; // empty String specifies: name = clazz.getName()
+
+    /**
+     * Taken to be the value of the eager attribute of the managed-bean.
+     */
+    boolean eager() default false;
+    
+    Class<?> clazz();
+
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/SetupWebConfigParams.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/SetupWebConfigParams.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/SetupWebConfigParams.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/SetupWebConfigParams.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.mc.test.core.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value =
+{
+    ElementType.METHOD
+})
+public @interface SetupWebConfigParams
+{
+    
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/SetupWebConfigParams.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestConfig.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestConfig.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestConfig.java Tue Feb 25 05:50:09 2014
@@ -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.mc.test.core.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value =
+{
+    ElementType.TYPE
+})
+@Inherited
+public @interface TestConfig
+{
+    String expressionFactory() default "";
+    
+    String webappResourcePath() default "testClassResourcePackage";
+    
+    boolean scanAnnotations() default false;
+
+    String oamAnnotationScanPackages() default "";
+    
+    String contextPath() default "/test";
+    
+    String servletPath() default "/faces";
+    
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestContainer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestContainer.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestContainer.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestContainer.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,36 @@
+/*
+ * 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.mc.test.core.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ */
+@Target(value={ElementType.FIELD})
+@Retention(value=RetentionPolicy.RUNTIME)
+@Documented
+public @interface TestContainer
+{
+    
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestServletListeners.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestServletListeners.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestServletListeners.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestServletListeners.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,39 @@
+/*
+ * 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.mc.test.core.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value =
+{
+    ElementType.TYPE
+})
+@Inherited
+public @interface TestServletListeners
+{
+    String[] value() default {};
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/annotation/TestServletListeners.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguage.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguage.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguage.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,270 @@
+/*
+ * 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.mc.test.core.mock;
+
+import java.beans.BeanInfo;
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.Resource;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.view.StateManagementStrategy;
+import javax.faces.view.ViewDeclarationLanguage;
+import javax.faces.view.ViewMetadata;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.myfaces.shared.application.InvalidViewIdException;
+
+/**
+ * It is a vdl that is just provided as fallback, to ensure if
+ * viewHandler.createView(context, null) is called, an instance
+ * is retrieved just like with jsp vdl, and it provides some methods
+ * to hook a view instance for createView() and restoreView() methods.
+ * 
+ * In this way, it is possible to create view instance programatically
+ * and simulate that it is generated by the vdl. 
+ * 
+ * @author Leonardo Uribe
+ *
+ */
+public class MockDefaultViewDeclarationLanguage extends ViewDeclarationLanguage
+{
+    public static final String DUMMY_VIEW_CREATE_HOOK = "oam.dummy.create.UIViewRoot";
+    public static final String DUMMY_VIEW_RESTORE_HOOK = "oam.dummy.restore.UIViewRoot";
+
+    @Override
+    public void buildView(FacesContext context, UIViewRoot view)
+            throws IOException
+    {
+    }
+
+    @Override
+    public UIViewRoot createView(FacesContext context, String viewId)
+    {
+        if (context.getAttributes().containsKey(DUMMY_VIEW_CREATE_HOOK))
+        {
+            UIViewRoot root = (UIViewRoot) context.getAttributes().remove(DUMMY_VIEW_CREATE_HOOK);
+            Application application = context.getApplication();
+            ViewHandler handler = application.getViewHandler();
+            root.setLocale(handler.calculateLocale(context));
+            root.setRenderKitId(handler.calculateRenderKitId(context));
+            root.setViewId(viewId);
+            return root;
+        }
+        else
+        {
+            try
+            {
+                viewId = calculateViewId(context, viewId);
+                
+                Application application = context.getApplication();
+                // Create a new UIViewRoot object instance using Application.createComponent(UIViewRoot.COMPONENT_TYPE).
+                UIViewRoot newViewRoot = (UIViewRoot) application.createComponent(UIViewRoot.COMPONENT_TYPE);
+                UIViewRoot oldViewRoot = context.getViewRoot();
+                if (oldViewRoot == null)
+                {
+                    // If not, this method must call calculateLocale() and calculateRenderKitId(), and store the results
+                    // as the values of the locale and renderKitId, proeprties, respectively, of the newly created
+                    // UIViewRoot.
+                    ViewHandler handler = application.getViewHandler();
+                    newViewRoot.setLocale(handler.calculateLocale(context));
+                    newViewRoot.setRenderKitId(handler.calculateRenderKitId(context));
+                }
+                else
+                {
+                    // If there is an existing UIViewRoot available on the FacesContext, 
+                    //this method must copy its locale
+                    // and renderKitId to this new view root
+                    newViewRoot.setLocale(oldViewRoot.getLocale());
+                    newViewRoot.setRenderKitId(oldViewRoot.getRenderKitId());
+                }
+                
+                // TODO: VALIDATE - The spec is silent on the following line, but I feel bad if I don't set it
+                newViewRoot.setViewId(viewId);
+    
+                return newViewRoot;
+            }
+            catch (InvalidViewIdException e)
+            {
+                // If no viewId could be identified, or the viewId is exactly equal to the servlet mapping, 
+                // send the response error code SC_NOT_FOUND with a suitable message to the client.
+                sendSourceNotFound(context, e.getMessage());
+                
+                // TODO: VALIDATE - Spec is silent on the return value when an error was sent
+                return null;
+            }
+        }
+    }
+    
+    /**
+     * Calculates the effective view identifier for the specified raw view identifier.
+     * 
+     * @param context le current FacesContext
+     * @param viewId the raw view identifier
+     * 
+     * @return the effective view identifier
+     */
+    protected String calculateViewId(FacesContext context, String viewId)
+    {
+        if (viewId != null)
+        {
+            throw new InvalidViewIdException();
+        }
+        return null;
+    }
+    
+    protected void sendSourceNotFound(FacesContext context, String message)
+    {
+        HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
+        try
+        {
+            context.responseComplete();
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, message);
+        }
+        catch (IOException ioe)
+        {
+            throw new FacesException(ioe);
+        }
+    }
+    
+    /**
+     * Hook the passed instance on UIViewRoot, storing into facesContext attribute map,
+     * so the next call to createView() will return that value.
+     * 
+     * @param context
+     * @param root
+     */
+    public static void hookCreateView(FacesContext context, UIViewRoot root)
+    {
+        context.getAttributes().put(DUMMY_VIEW_CREATE_HOOK, root);
+    }
+
+    /**
+     * Hook the passed instance on UIViewRoot, storing into facesContext attribute map,
+     * so the next call to createView() will return that value.
+     * 
+     * @param context
+     * @param root
+     */
+    public static void hookRestoreView(FacesContext context, UIViewRoot root)
+    {
+        context.getAttributes().put(DUMMY_VIEW_RESTORE_HOOK, root);
+    }
+
+    @Override
+    public BeanInfo getComponentMetadata(FacesContext context,
+            Resource componentResource)
+    {
+        return null;
+    }
+
+    @Override
+    public Resource getScriptComponentResource(FacesContext context,
+            Resource componentResource)
+    {
+        return null;
+    }
+
+    @Override
+    public StateManagementStrategy getStateManagementStrategy(
+            FacesContext context, String viewId)
+    {
+        return null;
+    }
+
+    @Override
+    public ViewMetadata getViewMetadata(FacesContext context, String viewId)
+    {
+        return null;
+    }
+
+    @Override
+    public void renderView(FacesContext context, UIViewRoot view)
+            throws IOException
+    {
+        checkNull(context, "context");
+        checkNull(view, "view");
+        
+        ExternalContext externalContext = context.getExternalContext();
+        ResponseWriter responseWriter = context.getResponseWriter();
+        if (responseWriter == null)
+        {
+            RenderKitFactory renderFactory = (RenderKitFactory) 
+                FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+            RenderKit renderKit = renderFactory.getRenderKit(context, view.getRenderKitId());
+
+            responseWriter = renderKit.createResponseWriter(externalContext.getResponseOutputWriter(), 
+                    null, externalContext.getRequestCharacterEncoding());
+            context.setResponseWriter(responseWriter);
+        }
+
+        // Now we actually render the document
+        // Call startDocument() on the ResponseWriter.
+        responseWriter.startDocument();
+
+        view.encodeAll(context);
+        
+        // Call endDocument() on the ResponseWriter
+        responseWriter.endDocument();
+    
+        responseWriter.flush();
+    }
+
+    @Override
+    public UIViewRoot restoreView(FacesContext context, String viewId)
+    {
+        checkNull(context, "context");
+        //checkNull(viewId, "viewId");
+
+        if (context.getAttributes().containsKey(DUMMY_VIEW_RESTORE_HOOK))
+        {
+            UIViewRoot root = (UIViewRoot) context.getAttributes().remove(DUMMY_VIEW_RESTORE_HOOK);
+            root.setViewId(viewId);
+            return root;
+        }
+        else
+        {
+            Application application = context.getApplication();
+            
+            ViewHandler applicationViewHandler = application.getViewHandler();
+            
+            String renderKitId = applicationViewHandler.calculateRenderKitId(context);
+    
+            UIViewRoot viewRoot = application.getStateManager().restoreView(context, viewId, renderKitId);
+    
+            return viewRoot;
+        }
+    }
+    
+    protected void checkNull(final Object o, final String param)
+    {
+        if (o == null)
+        {
+            throw new NullPointerException(param + " can not be null.");
+        }
+    }
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguageStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguageStrategy.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguageStrategy.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguageStrategy.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,46 @@
+/*
+ * 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.mc.test.core.mock;
+
+import javax.faces.view.ViewDeclarationLanguage;
+
+import org.apache.myfaces.view.ViewDeclarationLanguageStrategy;
+
+public class MockDefaultViewDeclarationLanguageStrategy 
+    implements ViewDeclarationLanguageStrategy
+{
+    
+    private ViewDeclarationLanguage _language;
+
+    public MockDefaultViewDeclarationLanguageStrategy()
+    {
+        super();
+        _language = new MockDefaultViewDeclarationLanguage();
+    }
+
+    public ViewDeclarationLanguage getViewDeclarationLanguage()
+    {
+        return _language;
+    }
+
+    public boolean handles(String viewId)
+    {
+        return true;
+    }
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockDefaultViewDeclarationLanguageStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,355 @@
+/*
+ * 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.mc.test.core.mock;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.faces.FacesException;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlCommandButton;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+import javax.faces.render.ResponseStateManager;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
+
+import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.myfaces.test.mock.MockHttpServletResponse;
+import org.junit.Assert;
+
+/**
+ * Client that keep track and "translate" the commands done in a JSF component.
+ * It simulates the effect of a browser, but without execute any javascript
+ * or check the html output. If that level of detail is required, use an
+ * in-container alternative like Arquillian and others. This strategy is designed
+ * for server-side testing. 
+ * 
+ * @author Leonardo Uribe
+ *
+ */
+public class MockMyFacesClient
+{
+    private Map<String, String> parameters = new HashMap<String, String>();
+    private Map<String, Cookie> cookies = new HashMap<String, Cookie>();
+    private Map<String, Object> headers = new HashMap<String, Object>();
+    
+    // It has sense the client has a reference over the test, because 
+    // after all this class encapsulate some automatic operations
+    private ServletMockContainer testCase;
+    
+    public MockMyFacesClient(FacesContext facesContext, ServletMockContainer testCase)
+    {
+        this.testCase = testCase;
+    }
+    
+    public void processRedirect()
+    {
+        HttpServletResponse response = testCase.getResponse();
+        HttpServletRequest request = testCase.getRequest();
+        if (response.getStatus() == HttpServletResponse.SC_FOUND)
+        {
+            testCase.processRemainingPhases(); //testCase.processRemainingPhases();
+            testCase.endRequest();
+            String location = response.getHeader("Location");
+            String contextPath = request.getContextPath() == null ? "" : request.getContextPath();
+            String servletPath = request.getServletPath() == null ? "" : request.getServletPath();
+            int cpi = location.indexOf(contextPath);
+            int spi = cpi < 0 ? -1 : location.indexOf(servletPath, cpi+contextPath.length());
+            String viewId;
+            if (spi >= 0)
+            {
+                viewId = location.substring(spi+servletPath.length());
+            }
+            else
+            {
+                viewId = location;
+            }
+            testCase.startViewRequest(viewId);
+        }
+        else
+        {
+            Assert.fail("Expected redirect not found");
+        }
+    }
+    
+    public void inputText(UIInput input, String text)
+    {
+        parameters.put(input.getClientId(), text);
+    }
+    
+    public void inputText(String clientId, String text)
+    {
+        UIComponent input = getTestCase().getFacesContext().
+            getViewRoot().findComponent(clientId);
+        if (input == null)
+        {
+            throw new FacesException("input with clientId:"+clientId+" not found");
+        }
+        else
+        {
+            parameters.put(input.getClientId(), text);
+        }
+    }
+    
+    /**
+     * Simulate a submit, processing the remaining phases and setting up the new request.
+     * It delegates to client.submit, where the necessary data is gathered to be applied
+     * later on client.apply method.
+     * 
+     * @param component
+     * @throws Exception
+     */
+    public void submit(UIComponent component)
+    {
+        testCase.processRemainingPhases();
+        this.internalSubmit((UICommand)component);
+        String viewId = testCase.getFacesContext().getViewRoot().getViewId();
+        testCase.endRequest();
+        testCase.startViewRequest(viewId);
+    }
+    
+    public void submit(String clientId)
+    {
+        UIComponent button = getTestCase().getFacesContext().
+            getViewRoot().findComponent(clientId);
+        if (button == null)
+        {
+            throw new FacesException("button with clientId:"+clientId+" not found");
+        }
+        else
+        {
+            submit(button);
+        }
+    }
+    
+    protected void internalSubmit(UICommand command)
+    {
+        if (command instanceof HtmlCommandButton)
+        {
+            final FacesContext facesContext = testCase.getFacesContext();
+            UIForm form = getParentForm(command);
+            VisitContext visitContext = VisitContext.createVisitContext(facesContext);
+            form.visitTree(visitContext, new VisitCallback(){
+
+                public VisitResult visit(VisitContext context,
+                        UIComponent target)
+                {
+                    if (target instanceof UIInput)
+                    {
+                        if (!parameters.containsKey(target.getClientId(facesContext)))
+                        {
+                            parameters.put(target.getClientId(facesContext), 
+                                RendererUtils.getStringValue(facesContext, target));
+                        }
+                    }
+                    return VisitResult.ACCEPT;
+                }
+                
+            });
+            parameters.put(form.getClientId(facesContext)+"_SUBMIT", "1");
+            Object value = command.getValue();
+            parameters.put(command.getClientId(), value == null ? "" : value.toString());
+            
+            applyStateFromPreviousRequest();
+            /*
+            parameters.put(ResponseStateManager.VIEW_STATE_PARAM, 
+                facesContext.getApplication().getStateManager().getViewState(facesContext));
+            if (facesContext.getExternalContext().getClientWindow() != null)
+            {
+                parameters.put(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, 
+                facesContext.getExternalContext().getClientWindow().getId());
+            }
+            MockHttpServletResponse response = (MockHttpServletResponse) 
+                facesContext.getExternalContext().getResponse(); 
+            Cookie cookie = response.getCookie("oam.Flash.RENDERMAP.TOKEN");
+            getCookies().put("oam.Flash.RENDERMAP.TOKEN", cookie);*/
+        }
+    }
+    
+    public void ajax(UIComponent source, String event, String execute, String render, boolean submit) throws Exception
+    {
+        ajax(source, event, execute, render, submit, false);
+    }
+            
+    public void ajax(UIComponent source, String event, String execute, String render, 
+        boolean submit, boolean resetValues)
+    {
+        testCase.processRemainingPhases();
+        this.internalAjax(source, event, execute, render, submit, resetValues);
+        String viewId = testCase.getFacesContext().getViewRoot().getViewId();
+        testCase.endRequest();
+        testCase.startViewRequest(viewId);
+    }
+    
+    protected void internalAjax(UIComponent source, String event, String execute, String render, 
+        boolean submit, boolean resetValues)
+    {
+        final FacesContext facesContext = testCase.getFacesContext();
+        parameters.put("javax.faces.partial.ajax", "true");
+        parameters.put("javax.faces.behavior.event", event);
+        parameters.put("javax.faces.partial.event", "action".equals(event) ? "click" : event);
+        applyStateFromPreviousRequest();
+        //parameters.put(ResponseStateManager.VIEW_STATE_PARAM, 
+        //    facesContext.getApplication().getStateManager().getViewState(facesContext));
+        parameters.put("javax.faces.source", source.getClientId(facesContext));
+        if (execute == null)
+        {
+            parameters.put("javax.faces.partial.execute", source.getClientId(facesContext));
+        }
+        else
+        {
+            parameters.put("javax.faces.partial.execute", execute);
+        }
+        if (render != null)
+        {
+            parameters.put("javax.faces.partial.render", render);
+        }
+        
+        if (submit)
+        {
+            parameters.put(source.getClientId(facesContext)+"_SUBMIT", "1");
+            parameters.put(source.getClientId(facesContext), source.getClientId(facesContext));
+        }
+        
+        if (resetValues)
+        {
+            parameters.put("javax.faces.partial.resetValues", "true");
+        }
+        
+        headers.put("Faces-Request", "partial/ajax");
+        headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
+    }
+    
+    protected void applyStateFromPreviousRequest()
+    {
+        FacesContext facesContext = testCase.getFacesContext();
+        
+        parameters.put(ResponseStateManager.VIEW_STATE_PARAM, 
+            facesContext.getApplication().getStateManager().getViewState(facesContext));
+        if (facesContext.getExternalContext().getClientWindow() != null)
+        {
+            parameters.put(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, 
+                facesContext.getExternalContext().getClientWindow().getId());
+        }
+        
+        applyCookiesFromPreviousRequest();
+    }
+    
+    protected void applyCookiesFromPreviousRequest()
+    {
+        MockHttpServletResponse response = (MockHttpServletResponse) testCase.getResponse();
+        if (response.getCookies() != null && !response.getCookies().isEmpty())
+        {
+            for (Map.Entry<String, Cookie> entry : response.getCookies().entrySet())
+            {
+                getCookies().put(entry.getKey(), entry.getValue());
+            }
+        }
+    }
+    
+    public Map<String, String> getParameters()
+    {
+        return parameters;
+    }
+    
+    public Map<String, Object> getHeaders()
+    {
+        return headers;
+    }
+    
+    public Map<String, Cookie> getCookies()
+    {
+        return cookies;
+    }
+    
+    private UIForm getParentForm(UIComponent component)
+    {
+        UIComponent parent = component.getParent();
+        while ( parent != null)
+        {
+            if (parent instanceof UIForm)
+            {
+                return (UIForm) parent;
+            }
+            parent = parent.getParent();
+        }
+        return null;
+    }
+    
+    /**
+     * Apply all params, headers and cookies into the request.
+     * 
+     * @param request
+     */
+    public void apply(MockHttpServletRequest request)
+    {
+        Map<String, String> inputFields = getParameters();
+        for (Map.Entry<String, String> entry : inputFields.entrySet())
+        {
+            request.addParameter(entry.getKey(), entry.getValue());
+        }
+        Map<String, Object> headerFields = getHeaders();
+        for (Map.Entry<String, Object> entry : headerFields.entrySet())
+        {
+            if (entry.getValue() instanceof String)
+            {
+                request.addHeader(entry.getKey(), (String) entry.getValue());
+            }
+            else if (entry.getValue() instanceof Integer)
+            {
+                request.addIntHeader(entry.getKey(), (Integer) entry.getValue());
+            }
+            else if (entry.getValue() instanceof java.util.Date)
+            {
+                request.addDateHeader(entry.getKey(), ((java.util.Date) entry.getValue()).getTime());
+            }
+        }
+        Map<String, Cookie> cookies = getCookies();
+        for (Map.Entry<String, Cookie> entry : cookies.entrySet())
+        {
+            request.addCookie(entry.getValue());
+        }
+    }
+    
+    public void reset(FacesContext facesContext)
+    {
+        this.parameters.clear();
+        this.headers.clear();
+        this.cookies.clear();
+    }
+
+    public ServletMockContainer getTestCase()
+    {
+        return testCase;
+    }
+
+    public void setTestCase(AbstractMyFacesRequestTestCase testCase)
+    {
+        this.testCase = testCase;
+    }
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguage.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguage.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguage.java Tue Feb 25 05:50:09 2014
@@ -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.mc.test.core.mock;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.application.Resource;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.apache.myfaces.view.ViewDeclarationLanguageStrategy;
+import org.apache.myfaces.view.facelets.FaceletFactory;
+import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage;
+import org.apache.myfaces.view.facelets.compiler.Compiler;
+
+public class MockMyFacesFaceletViewDeclarationLanguage extends FaceletViewDeclarationLanguage
+{
+    private String _renderedViewId;
+    private Map<Resource, Resource> _scriptComponentResources;
+
+    public MockMyFacesFaceletViewDeclarationLanguage(FacesContext context)
+    {
+        super(context);
+    }
+
+    public MockMyFacesFaceletViewDeclarationLanguage(FacesContext context,
+            ViewDeclarationLanguageStrategy strategy)
+    {
+        super(context, strategy);
+    }
+    
+    @Override
+    public void buildView(FacesContext context, UIViewRoot view)
+            throws IOException
+    {
+        _renderedViewId = null;
+        super.buildView(context, view);
+    }
+
+    public void buildView(FacesContext context, UIViewRoot view, String xmlFile) throws IOException
+    {
+        _renderedViewId = xmlFile;
+        view.setViewId(xmlFile);
+        super.buildView(context, view);
+    }
+    
+    @Override
+    public String getRenderedViewId(FacesContext context, String actionId)
+    {
+        if (_renderedViewId != null)
+        {
+            return _renderedViewId;//super.getRenderedViewId(context, actionId);
+        }
+        else
+        {
+            return super.getRenderedViewId(context, actionId);
+        }
+    }    
+
+    @Override
+    public String calculateViewId(FacesContext context, String viewId)
+    {
+        String calculatedViewId = super.calculateViewId(context, viewId);
+        if (calculatedViewId == null)
+        {
+            //can't calculate it, just passthrough the received one
+            calculatedViewId = viewId;
+        }
+        return calculatedViewId;
+    }
+
+    @Override
+    public Compiler createCompiler(FacesContext context)
+    {
+        return super.createCompiler(context);
+    }
+
+    @Override
+    public FaceletFactory createFaceletFactory(FacesContext context,
+            Compiler compiler)
+    {
+        return super.createFaceletFactory(context, compiler);
+    }
+
+    @Override
+    public ResponseWriter createResponseWriter(FacesContext context)
+            throws IOException, FacesException
+    {
+        return super.createResponseWriter(context);
+    }
+
+    @Override
+    public String getDefaultSuffix(FacesContext context)
+            throws FacesException
+    {
+        return super.getDefaultSuffix(context);
+    }
+
+    @Override
+    public String getResponseContentType(FacesContext context, String orig)
+    {
+        return super.getResponseContentType(context, orig);
+    }
+
+    @Override
+    public String getResponseEncoding(FacesContext context, String orig)
+    {
+        return super.getResponseEncoding(context, orig);
+    }
+
+    @Override
+    public void handleFaceletNotFound(FacesContext context, String viewId)
+            throws FacesException, IOException
+    {
+        super.handleFaceletNotFound(context, viewId);
+    }
+
+    @Override
+    public void handleRenderException(FacesContext context, Exception e)
+            throws IOException, ELException, FacesException
+    {
+        super.handleRenderException(context, e);
+    }
+
+    @Override
+    public void initialize(FacesContext context)
+    {
+        super.initialize(context);
+    }
+
+    @Override
+    public void loadDecorators(FacesContext context, Compiler compiler)
+    {
+        super.loadDecorators(context, compiler);
+    }
+
+    @Override
+    public void loadLibraries(FacesContext context, Compiler compiler)
+    {
+        super.loadLibraries(context, compiler);
+    }
+
+    @Override
+    public void loadOptions(FacesContext context, Compiler compiler)
+    {
+        super.loadOptions(context, compiler);
+    }
+
+    @Override
+    public void sendSourceNotFound(FacesContext context, String message)
+    {
+        super.sendSourceNotFound(context, message);
+    }
+
+    @Override
+    public Resource getScriptComponentResource(FacesContext context,
+            Resource componentResource)
+    {
+        if (_scriptComponentResources != null)
+        {
+            Resource installedResource = _scriptComponentResources.get(componentResource);
+            if (installedResource != null)
+            {
+                // if we have a Resource installed for this componentResource, return it
+                return installedResource;
+            }
+        }
+        return super.getScriptComponentResource(context, componentResource);
+    }
+    
+    /**
+     * This method sets the scriptResource for a given componentResource so that
+     * a call to getScriptComponentResource() with the given componentResource
+     * will return the installed scriptResource.
+     * @param componentResource
+     * @param scriptResource
+     */
+    public void setScriptComponentResource(Resource componentResource, Resource scriptResource)
+    {
+        if (_scriptComponentResources == null)
+        {
+            _scriptComponentResources = new HashMap<Resource, Resource>();
+        }
+        _scriptComponentResources.put(componentResource, scriptResource);
+    }
+
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguageStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguageStrategy.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguageStrategy.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguageStrategy.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,160 @@
+/*
+ * 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.mc.test.core.mock;
+
+import java.util.regex.Pattern;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.view.ViewDeclarationLanguage;
+
+import org.apache.myfaces.view.ViewDeclarationLanguageStrategy;
+
+/**
+ * @author Leonardo Uribe 
+ * @since 2.0
+ */
+public class MockMyFacesFaceletViewDeclarationLanguageStrategy implements ViewDeclarationLanguageStrategy
+{
+    private Pattern _acceptPatterns;
+    private String _extension;
+
+    private ViewDeclarationLanguage _language;
+
+    public MockMyFacesFaceletViewDeclarationLanguageStrategy()
+    {
+        FacesContext context = FacesContext.getCurrentInstance();
+        ExternalContext eContext = context.getExternalContext();
+
+        _acceptPatterns = loadAcceptPattern(eContext);
+
+        _extension = loadFaceletExtension(eContext);
+
+        _language = new MockMyFacesFaceletViewDeclarationLanguage(context, this);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ViewDeclarationLanguage getViewDeclarationLanguage()
+    {
+        return _language;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean handles(String viewId)
+    {
+        if (viewId == null)
+        {
+            return false;
+        }
+        // Check extension first as it's faster than mappings
+        if (viewId.endsWith(_extension))
+        {
+            // If the extension matches, it's a Facelet viewId.
+            return true;
+        }
+
+        // Otherwise, try to match the view identifier with the facelet mappings
+        return _acceptPatterns != null && _acceptPatterns.matcher(viewId).matches();
+    }
+
+    /**
+     * Load and compile a regular expression pattern built from the Facelet view mapping parameters.
+     * 
+     * @param context
+     *            the application's external context
+     * 
+     * @return the compiled regular expression
+     */
+    private Pattern loadAcceptPattern(ExternalContext context)
+    {
+        assert context != null;
+
+        String mappings = context.getInitParameter(ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME);
+        if(mappings == null)    //consider alias facelets.VIEW_MAPPINGS
+        {
+            mappings = context.getInitParameter("facelets.VIEW_MAPPINGS");
+        }
+        if (mappings == null)
+        {
+            return null;
+        }
+
+        // Make sure the mappings contain something
+        mappings = mappings.trim();
+        if (mappings.length() == 0)
+        {
+            return null;
+        }
+
+        return Pattern.compile(toRegex(mappings));
+    }
+
+    private String loadFaceletExtension(ExternalContext context)
+    {
+        assert context != null;
+
+        String suffix = context.getInitParameter(ViewHandler.FACELETS_SUFFIX_PARAM_NAME);
+        if (suffix == null)
+        {
+            suffix = ViewHandler.DEFAULT_FACELETS_SUFFIX;
+        }
+        else
+        {
+            suffix = suffix.trim();
+            if (suffix.length() == 0)
+            {
+                suffix = ViewHandler.DEFAULT_FACELETS_SUFFIX;
+            }
+        }
+
+        return suffix;
+    }
+
+    /**
+     * Convert the specified mapping string to an equivalent regular expression.
+     * 
+     * @param mappings
+     *            le mapping string
+     * 
+     * @return an uncompiled regular expression representing the mappings
+     */
+    private String toRegex(String mappings)
+    {
+        assert mappings != null;
+
+        // Get rid of spaces
+        mappings = mappings.replaceAll("\\s", "");
+
+        // Escape '.'
+        mappings = mappings.replaceAll("\\.", "\\\\.");
+
+        // Change '*' to '.*' to represent any match
+        mappings = mappings.replaceAll("\\*", ".*");
+
+        // Split the mappings by changing ';' to '|'
+        mappings = mappings.replaceAll(";", "|");
+
+        return mappings;
+    }
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesFaceletViewDeclarationLanguageStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesViewDeclarationLanguageFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesViewDeclarationLanguageFactory.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesViewDeclarationLanguageFactory.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesViewDeclarationLanguageFactory.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,65 @@
+/*
+ * 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.mc.test.core.mock;
+
+import javax.faces.FacesException;
+import javax.faces.view.ViewDeclarationLanguage;
+import javax.faces.view.ViewDeclarationLanguageFactory;
+
+import org.apache.myfaces.view.ViewDeclarationLanguageStrategy;
+
+public class MockMyFacesViewDeclarationLanguageFactory extends ViewDeclarationLanguageFactory
+{
+
+    private boolean _initialized;
+    private ViewDeclarationLanguageStrategy[] _supportedLanguages;
+    
+    public MockMyFacesViewDeclarationLanguageFactory()
+    {
+        _initialized = false;
+    }
+
+    @Override
+    public ViewDeclarationLanguage getViewDeclarationLanguage(String viewId)
+    {
+        initialize();
+        
+        for (ViewDeclarationLanguageStrategy strategy : _supportedLanguages)
+        {
+            if (strategy.handles(viewId))
+            {
+                return strategy.getViewDeclarationLanguage();
+            }
+        }
+        
+        throw new FacesException("Cannot find a valid PDL for view id " + viewId);
+    }
+
+    private synchronized void initialize()
+    {
+        if (!_initialized)
+        {
+            _supportedLanguages = new ViewDeclarationLanguageStrategy[2];
+            _supportedLanguages[0] = new MockMyFacesFaceletViewDeclarationLanguageStrategy();
+            _supportedLanguages[1] = new MockDefaultViewDeclarationLanguageStrategy(); 
+            _initialized = true;
+        }
+    }
+
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesViewDeclarationLanguageFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/ServletMockContainer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/ServletMockContainer.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/ServletMockContainer.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/ServletMockContainer.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,43 @@
+/*
+ * 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.mc.test.core.mock;
+
+import javax.faces.context.FacesContext;
+import org.apache.myfaces.test.mock.MockHttpServletRequest;
+import org.apache.myfaces.test.mock.MockHttpServletResponse;
+
+/**
+ *
+ */
+public interface ServletMockContainer
+{
+    
+    public MockHttpServletRequest getRequest();
+    
+    public MockHttpServletResponse getResponse();
+    
+    public FacesContext getFacesContext();
+
+    public void processRemainingPhases();
+
+    public void endRequest();
+
+    public void startViewRequest(String viewId);
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/mock/ServletMockContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/runner/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfRequestTestContainer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfRequestTestContainer.java?rev=1571570&view=auto
==============================================================================
--- myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfRequestTestContainer.java (added)
+++ myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfRequestTestContainer.java Tue Feb 25 05:50:09 2014
@@ -0,0 +1,381 @@
+/*
+ * 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.mc.test.core.runner;
+
+import java.io.IOException;
+import java.util.List;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.ServletRequestEvent;
+import org.apache.myfaces.mc.test.core.mock.MockMyFacesClient;
+import org.apache.myfaces.mc.test.core.mock.ServletMockContainer;
+import org.apache.myfaces.mc.test.core.annotation.AfterRequest;
+import org.apache.myfaces.mc.test.core.annotation.BeforeRequest;
+import org.apache.myfaces.mc.test.core.annotation.TestConfig;
+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.MockHttpSessionProxy;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.TestClass;
+
+/**
+ *
+ */
+public class AbstractJsfRequestTestContainer extends AbstractJsfTestContainer
+    implements ServletMockContainer
+{
+
+    public AbstractJsfRequestTestContainer(TestClass testClass)
+    {
+        super(testClass);
+    }
+    
+    @Override
+    public void setUp(Object testInstance)
+    {
+        super.setUp(testInstance);
+        
+    }
+
+    @Override
+    public void tearDown()
+    {
+        endRequest();
+        session = null;
+        lastSession = null;
+        if (client != null)
+        {
+            client.setTestCase(null);
+        }
+        client = null;
+        super.tearDown();
+    }
+
+    protected void setupRequest()
+    {
+        setupRequest(null);
+    }
+
+    protected void setupRequest(String pathInfo)
+    {
+        if (pathInfo == null)
+        {
+            setupRequest(null, null);
+        }
+        else
+        {
+            int queryIndex = pathInfo.indexOf("?");
+            if (queryIndex >= 0) 
+            {
+                setupRequest(pathInfo.substring(0,queryIndex), pathInfo.substring(queryIndex+1));
+            }
+            else
+            {
+                setupRequest(pathInfo, null);
+            }
+        }
+    }
+
+    protected void setupRequest(String pathInfo, String query)
+    {
+        if (request != null)
+        {
+            //tear down previous request
+            endRequest();
+        }
+        request = lastSession == null ? 
+            new MockHttpServletRequest() : new MockHttpServletRequest(lastSession);
+        request.setServletContext(servletContext);
+        requestInitializedCalled = false;
+        if (session == null)
+        {
+            session = new MockHttpSessionProxy(servletContext, request);
+        }
+        else
+        {
+            session.setRequest(request);
+        }
+        session.setServletContext(servletContext);
+        response = new MockHttpServletResponse();
+        //TODO check if this is correct
+        request.setPathElements(getContextPath(), getServletPath(), pathInfo, query);
+
+        facesContext = facesContextFactory.getFacesContext(
+            servletContext, request, response, lifecycle);
+        externalContext = facesContext.getExternalContext();
+        application = facesContext.getApplication();
+        if (client != null)
+        {
+            client.apply(request);
+            client.reset(facesContext);
+        }
+        else
+        {
+            client = createClient();
+        }
+    }
+    
+    protected MockMyFacesClient createClient()
+    {
+        return new MockMyFacesClient(facesContext, this);
+    }
+
+    /**
+     * This method call startViewRequest(viewId) and doRequestInitialized()
+     */
+    public final void startViewRequest(String viewId)
+    {
+        setupRequest(viewId);
+        doRequestInitialized();
+    }
+    
+    /**
+     * This method call startViewRequest(null) and doRequestInitialized()
+     */
+    public final void startRequest()
+    {
+        startViewRequest(null);
+        doRequestInitialized();
+    }
+    
+    public void doRequestInitialized()
+    {
+        if (!requestInitializedCalled)
+        {
+            List<FrameworkMethod> beforeRequestMethods = testClass.getAnnotatedMethods(BeforeRequest.class);
+            if (beforeRequestMethods != null && !beforeRequestMethods.isEmpty())
+            {
+                for (FrameworkMethod fm : beforeRequestMethods)
+                {
+                    try
+                    {
+                        fm.invokeExplosively(testInstance);
+                    }
+                    catch (Throwable ex)
+                    {
+                        throw new FacesException(ex);
+                    }
+                }
+            }
+            
+            webContainer.requestInitialized(new ServletRequestEvent(servletContext, request));
+            requestInitializedCalled = true;
+        }
+    }
+    
+    /**
+     * This method call doRequestDestroyed() and then tearDownRequest(). 
+     */
+    public final void endRequest()
+    {
+        doRequestDestroyed();
+        tearDownRequest();
+    }
+    
+    public void doRequestDestroyed()
+    {
+        if (request != null)
+        {
+            List<FrameworkMethod> afterRequestMethods = testClass.getAnnotatedMethods(AfterRequest.class);
+            if (afterRequestMethods != null && !afterRequestMethods.isEmpty())
+            {
+                for (FrameworkMethod fm : afterRequestMethods)
+                {
+                    try
+                    {
+                        fm.invokeExplosively(testInstance);
+                    }
+                    catch (Throwable ex)
+                    {
+                        throw new FacesException(ex);
+                    }
+                }
+            }
+            lastSession = (MockHttpSession) request.getSession(false);
+            webContainer.requestDestroyed(new ServletRequestEvent(servletContext, request));
+        }
+    }
+    
+    protected void tearDownRequest()
+    {
+        if (facesContext != null)
+        {
+            facesContext.release();
+        }
+        facesContext = null;
+        externalContext = null;
+        application = null;
+        
+        response = null;
+        request = null;
+        //session = null;
+    }
+    
+    protected String getContextPath()
+    {
+        TestConfig testConfig = testClass.getJavaClass().getAnnotation(TestConfig.class);
+        if (testConfig != null)
+        {
+            return testConfig.contextPath();
+        }
+        return "/test";
+    }
+    
+    protected String getServletPath()
+    {
+        TestConfig testConfig = testClass.getJavaClass().getAnnotation(TestConfig.class);
+        if (testConfig != null)
+        {
+            return testConfig.servletPath();
+        }
+        return "/faces";
+    }
+
+    public void processLifecycleExecute()
+    {
+        processLifecycleExecute(facesContext);
+    }
+
+    public void processLifecycleRender()
+    {
+        processLifecycleRender(facesContext);
+    }
+    
+    public void processLifecycleExecuteAndRender()
+    {
+        processLifecycleExecute();
+        renderResponse();
+    }
+
+    public void restoreView()
+    {
+        restoreView(facesContext);
+    }
+    
+    public void applyRequestValues()
+    {
+        applyRequestValues(facesContext);
+    }
+
+    public void processValidations()
+    {
+        processValidations(facesContext);
+    }
+
+    public void updateModelValues()
+    {
+        updateModelValues(facesContext);
+
+    }
+
+    public void invokeApplication()
+    {
+        invokeApplication(facesContext);
+    }
+    
+    public void renderResponse()
+    {
+        renderResponse(facesContext);
+    }
+    
+    public void processRemainingExecutePhases()
+    {
+        processRemainingExecutePhases(facesContext);
+    }
+
+    public void processRemainingPhases()
+    {
+        processRemainingPhases(facesContext);
+    }
+    
+    public void executeBeforeRender()
+    {
+        executeBeforeRender(facesContext);
+    }
+    
+    public void executeViewHandlerRender()
+    {
+        executeViewHandlerRender(facesContext);
+    }
+        
+    public void executeBuildViewCycle()
+    {
+        executeBuildViewCycle(facesContext);
+    }
+    
+    public void executeAfterRender()
+    {
+        executeAfterRender(facesContext);
+    }
+    
+    public String getRenderedContent() throws IOException
+    {
+        return getRenderedContent(facesContext);
+    }
+    
+    protected MockMyFacesClient client = null;
+    
+    // Servlet objects 
+    protected MockHttpServletRequest request = null;
+    protected boolean requestInitializedCalled = false;
+    protected MockHttpServletResponse response = null;
+    protected MockHttpSessionProxy session = null;
+    protected MockHttpSession lastSession = null;
+    
+    protected Application application = null;
+    protected ExternalContext externalContext = null;
+    protected FacesContext facesContext = null;
+
+    @Override
+    public MockHttpServletRequest getRequest()
+    {
+        return request;
+    }
+
+    @Override
+    public MockHttpServletResponse getResponse()
+    {
+        return response;
+    }
+
+    @Override
+    public FacesContext getFacesContext()
+    {
+        return facesContext;
+    }
+
+    public MockMyFacesClient getClient()
+    {
+        return client;
+    }
+
+    public Application getApplication()
+    {
+        return application;
+    }
+
+    public ExternalContext getExternalContext()
+    {
+        return externalContext;
+    }
+
+}

Propchange: myfaces/core/trunk/impl-test/src/main/java/org/apache/myfaces/mc/test/core/runner/AbstractJsfRequestTestContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native