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 2011/11/11 03:55:16 UTC

svn commit: r1200712 - in /myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces: mc/test/core/ mc/test/core/annotation/ view/facelets/tag/composite/localized/

Author: lu4242
Date: Fri Nov 11 02:55:15 2011
New Revision: 1200712

URL: http://svn.apache.org/viewvc?rev=1200712&view=rev
Log:
[testing] add some useful testing annotations and fix viewHandler.createView(context, null) case, with a MockDefaultViewDeclarationLanguage that allows to "mimic" a vdl.

Added:
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguage.java   (with props)
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguageStrategy.java   (with props)
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java   (with props)
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java   (with props)
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java   (with props)
Modified:
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockMyFacesViewDeclarationLanguageFactory.java
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java

Modified: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java?rev=1200712&r1=1200711&r2=1200712&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/AbstractMyFacesTestCase.java Fri Nov 11 02:55:15 2011
@@ -20,14 +20,19 @@ package org.apache.myfaces.mc.test.core;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.net.URI;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.el.ExpressionFactory;
+import javax.faces.FacesException;
 import javax.faces.FactoryFinder;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
@@ -41,11 +46,16 @@ import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.myfaces.config.ConfigFilesXmlValidationUtils;
 import org.apache.myfaces.config.DefaultFacesConfigurationProvider;
 import org.apache.myfaces.config.RuntimeConfig;
 import org.apache.myfaces.config.element.FacesConfig;
 import org.apache.myfaces.config.impl.digester.elements.Factory;
 import org.apache.myfaces.lifecycle.LifecycleImpl;
+import org.apache.myfaces.mc.test.core.annotation.DeclareFacesConfig;
+import org.apache.myfaces.mc.test.core.annotation.ManagedBeans;
+import org.apache.myfaces.mc.test.core.annotation.PageBean;
+import org.apache.myfaces.shared.config.MyfacesConfig;
 import org.apache.myfaces.spi.FacesConfigurationProvider;
 import org.apache.myfaces.spi.impl.DefaultFacesConfigurationProviderFactory;
 import org.apache.myfaces.test.el.MockExpressionFactory;
@@ -57,6 +67,7 @@ import org.apache.myfaces.webapp.Abstrac
 import org.apache.myfaces.webapp.StartupServletContextListener;
 import org.junit.After;
 import org.junit.Before;
+import org.xml.sax.SAXException;
 
 /**
  * <p>Abstract JUnit test case base class, which sets up MyFaces Core environment
@@ -244,7 +255,7 @@ public abstract class AbstractMyFacesTes
      */
     protected FacesConfigurationProvider createFacesConfigurationProvider()
     {
-        return new MyFacesMockFacesConfigurationProvider(); 
+        return new MyFacesMockFacesConfigurationProvider(this); 
     }
     
     protected void setUpMyFaces() throws Exception
@@ -512,7 +523,7 @@ public abstract class AbstractMyFacesTes
     
     /**
      * Indicate if annotation scanning should be done over the classpath. 
-     * By default it is set to false.  
+     * By default it is set to false.
      * 
      * @return
      */
@@ -635,6 +646,12 @@ public abstract class AbstractMyFacesTes
      */
     protected class MyFacesMockFacesConfigurationProvider extends DefaultFacesConfigurationProvider
     {
+        private AbstractMyFacesTestCase testCase;
+        
+        public MyFacesMockFacesConfigurationProvider(AbstractMyFacesTestCase testCase)
+        {
+            this.testCase = testCase;
+        }
         
         @Override
         public FacesConfig getStandardFacesConfig(ExternalContext ectx)
@@ -655,11 +672,105 @@ public abstract class AbstractMyFacesTes
         public FacesConfig getAnnotationsFacesConfig(ExternalContext ectx,
                 boolean metadataComplete)
         {
+            FacesConfig facesConfig = null;
             if (isScanAnnotations())
             {
-                return super.getAnnotationsFacesConfig(ectx, metadataComplete);
+                facesConfig = super.getAnnotationsFacesConfig(ectx, metadataComplete); 
+            }
+            
+            ManagedBeans annoManagedBeans = testCase.getClass().getAnnotation(ManagedBeans.class);
+            if (annoManagedBeans != null)
+            {
+                if (facesConfig == null)
+                {
+                    facesConfig = new org.apache.myfaces.config.impl.digester.elements.FacesConfig();
+                }
+                for (PageBean annoPageBean : annoManagedBeans.values())
+                {
+                    org.apache.myfaces.config.impl.digester.elements.ManagedBean bean = new 
+                        org.apache.myfaces.config.impl.digester.elements.ManagedBean();
+                    bean.setBeanClass(annoPageBean.clazz().getName());
+                    bean.setName(annoPageBean.name() == null ? annoPageBean.clazz().getName() : annoPageBean.name());
+                    bean.setScope(annoPageBean.scope() == null ? "request" : annoPageBean.scope());
+                    bean.setEager(Boolean.toString(annoPageBean.eager()));
+                    
+                    ((org.apache.myfaces.config.impl.digester.elements.FacesConfig)facesConfig).addManagedBean(bean);
+                }
+            }
+
+            PageBean annoPageBean = testCase.getClass().getAnnotation(PageBean.class);
+            if (annoPageBean != null)
+            {
+                if (facesConfig == null)
+                {
+                    facesConfig = new org.apache.myfaces.config.impl.digester.elements.FacesConfig();
+                }
+                org.apache.myfaces.config.impl.digester.elements.ManagedBean bean = new 
+                    org.apache.myfaces.config.impl.digester.elements.ManagedBean();
+                bean.setBeanClass(annoPageBean.clazz().getName());
+                bean.setName(annoPageBean.name() == null ? annoPageBean.clazz().getName() : annoPageBean.name());
+                bean.setScope(annoPageBean.scope() == null ? "request" : annoPageBean.scope());
+                bean.setEager(Boolean.toString(annoPageBean.eager()));
+                
+                ((org.apache.myfaces.config.impl.digester.elements.FacesConfig)facesConfig).addManagedBean(bean);
+            }
+            return facesConfig;
+        }
+        
+        @Override
+        public List<FacesConfig> getContextSpecifiedFacesConfig(ExternalContext ectx)
+        {
+            List<FacesConfig> appConfigResources = super.getContextSpecifiedFacesConfig(ectx);
+            
+            DeclareFacesConfig annoFacesConfig = testCase.getClass().getAnnotation(DeclareFacesConfig.class);
+            if (annoFacesConfig != null)
+            {
+                Logger log = Logger.getLogger(testCase.getClass().getName());
+                try
+                {
+                    for (String systemId : annoFacesConfig.value())
+                    {
+                        if (MyfacesConfig.getCurrentInstance(ectx).isValidateXML())
+                        {
+                            URL url = ectx.getResource(systemId);
+                            if (url != null)
+                            {
+                                validateFacesConfig(ectx, url);
+                            }
+                        }   
+                        InputStream stream = ectx.getResourceAsStream(systemId);
+                        if (stream == null)
+                        {
+                            
+                            log.severe("Faces config resource " + systemId + " not found");
+                            continue;
+                        }
+            
+                        if (log.isLoggable(Level.INFO))
+                        {
+                            log.info("Reading config " + systemId);
+                        }
+                        appConfigResources.add(getUnmarshaller(ectx).getFacesConfig(stream, systemId));
+                        //getDispenser().feed(getUnmarshaller().getFacesConfig(stream, systemId));
+                        stream.close();
+    
+                    }
+                }
+                catch (Throwable e)
+                {
+                    throw new FacesException(e);
+                }
             }
-            return null;
+            return appConfigResources;
+        }
+    }
+    
+    private void validateFacesConfig(ExternalContext ectx, URL url) throws IOException, SAXException
+    {
+        String version = ConfigFilesXmlValidationUtils.getFacesConfigVersion(url);
+        if ("1.2".equals(version) || "2.0".equals(version) || "2.1".equals(version))
+        {
+            ConfigFilesXmlValidationUtils.validateFacesConfigFile(url, ectx, version);
         }
     }
 }

Added: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguage.java?rev=1200712&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguage.java (added)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguage.java Fri Nov 11 02:55:15 2011
@@ -0,0 +1,268 @@
+/*
+ * 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;
+
+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/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguageStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguageStrategy.java?rev=1200712&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguageStrategy.java (added)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguageStrategy.java Fri Nov 11 02:55:15 2011
@@ -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;
+
+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/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockDefaultViewDeclarationLanguageStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockMyFacesViewDeclarationLanguageFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockMyFacesViewDeclarationLanguageFactory.java?rev=1200712&r1=1200711&r2=1200712&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockMyFacesViewDeclarationLanguageFactory.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/MockMyFacesViewDeclarationLanguageFactory.java Fri Nov 11 02:55:15 2011
@@ -23,7 +23,6 @@ import javax.faces.view.ViewDeclarationL
 import javax.faces.view.ViewDeclarationLanguageFactory;
 
 import org.apache.myfaces.view.ViewDeclarationLanguageStrategy;
-import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguageStrategy;
 
 public class MockMyFacesViewDeclarationLanguageFactory extends ViewDeclarationLanguageFactory
 {
@@ -56,8 +55,9 @@ public class MockMyFacesViewDeclarationL
     {
         if (!_initialized)
         {
-            _supportedLanguages = new ViewDeclarationLanguageStrategy[1];
+            _supportedLanguages = new ViewDeclarationLanguageStrategy[2];
             _supportedLanguages[0] = new MockMyFacesFaceletViewDeclarationLanguageStrategy();
+            _supportedLanguages[1] = new MockDefaultViewDeclarationLanguageStrategy(); 
         }
     }
 

Added: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java?rev=1200712&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java (added)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java Fri Nov 11 02:55:15 2011
@@ -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/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/DeclareFacesConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java?rev=1200712&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java (added)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/ManagedBeans.java Fri Nov 11 02:55:15 2011
@@ -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[] values() default {};
+}

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

Added: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java?rev=1200712&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java (added)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java Fri Nov 11 02:55:15 2011
@@ -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/branches/2.0.x/impl/src/test/java/org/apache/myfaces/mc/test/core/annotation/PageBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java?rev=1200712&r1=1200711&r2=1200712&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/localized/LocalizedCompositeComponentTestCase.java Fri Nov 11 02:55:15 2011
@@ -18,9 +18,8 @@
  */
 package org.apache.myfaces.view.facelets.tag.composite.localized;
 
-import javax.faces.webapp.FacesServlet;
-
 import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
+import org.apache.myfaces.mc.test.core.annotation.DeclareFacesConfig;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -32,6 +31,7 @@ import org.junit.Test;
  * @author Leonardo Uribe
  *
  */
+@DeclareFacesConfig("/faces-config.xml")
 public class LocalizedCompositeComponentTestCase extends AbstractMyFacesRequestTestCase
 {
     // This is a nice example that shows how AbstractMyFacesRequestTestCase 
@@ -41,13 +41,6 @@ public class LocalizedCompositeComponent
     // not fit well and it is more easy to use a test case than setup and
     // teardown all MyFaces container. 
     
-    @Override
-    protected void setUpWebConfigParams() throws Exception
-    {
-        super.setUpWebConfigParams();
-        servletContext.addInitParameter(FacesServlet.CONFIG_FILES_ATTR, "/faces-config.xml");
-    }
-
     @Test
     public void testNoLocaleCompositeComponent() throws Exception
     {