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 2013/05/24 03:27:33 UTC

svn commit: r1485917 [3/4] - in /myfaces/core/trunk: api/src/main/java/javax/faces/application/ api/src/main/java/javax/faces/context/ api/src/main/java/javax/faces/view/ impl/src/main/java/org/apache/myfaces/application/ impl/src/main/java/org/apache/...

Copied: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/contracts/ContractsCreateResourceMyFacesRequestTestCase.java (from r1470662, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/contracts/ContractsCreateResourceMyFacesRequestTestCase.java?p2=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/contracts/ContractsCreateResourceMyFacesRequestTestCase.java&p1=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java&r1=1470662&r2=1485917&rev=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/contracts/ContractsCreateResourceMyFacesRequestTestCase.java Fri May 24 01:27:31 2013
@@ -16,23 +16,23 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.view.facelets.pss.acid;
+package org.apache.myfaces.application.contracts;
 
+import java.util.List;
+import java.util.Set;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
 import javax.faces.application.StateManager;
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.component.UIPanel;
-import javax.faces.component.html.HtmlDataTable;
 
 import junit.framework.Assert;
+import org.apache.myfaces.config.RuntimeConfig;
 
 import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
 import org.apache.myfaces.shared.config.MyfacesConfig;
-import org.apache.myfaces.view.facelets.pss.acid.managed.ResourceDependencyBean;
+import org.apache.myfaces.shared.resource.ContractResource;
 import org.junit.Test;
 
-public class AcidMyFacesRequestTestCase extends AbstractMyFacesRequestTestCase
+public class ContractsCreateResourceMyFacesRequestTestCase extends AbstractMyFacesRequestTestCase
 {
 
     @Override
@@ -45,467 +45,55 @@ public class AcidMyFacesRequestTestCase 
     protected void setUpWebConfigParams() throws Exception
     {
         super.setUpWebConfigParams();
-        servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES","org.apache.myfaces.view.facelets.pss.acid");
-        servletContext.addInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/testcomponent.taglib.xml");
+        servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES","org.apache.myfaces.application.contracts");
         servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_CLIENT);
         servletContext.addInitParameter("javax.faces.PARTIAL_STATE_SAVING", "true");
         servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS, "auto");
+        servletContext.addInitParameter("javax.faces.CONFIG_FILES", "/blue-faces-config.xml");
     }
     
     @Test
-    public void testIndex() throws Exception
+    public void testDefaultConfiguration() throws Exception
     {
         setupRequest("/index.xhtml");
-        processLifecycleExecuteAndRender();
+        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
         
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
-        
-        /*
-        MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer1.content()).contains(
-                "<div style=\"border: 1px solid red; margin: 2px\">" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
-                "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
-                "</div>" +
-                "Dynamically added child" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
-                */
-        //System.out.println(writer1.content());
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
-        /*
-        MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer2.content()).contains(
-                "<div style=\"border: 1px solid red; margin: 2px\">" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
-                "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
-                "</div>" +
-                "Dynamically added child" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
-                */
-        //System.out.println(writer2.content());
-        tearDownRequest();
-    }
-    
-    @Test
-    public void testInput() throws Exception
-    {
-        setupRequest("/input.xhtml");
-        processLifecycleExecuteAndRender();
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        
-        Assert.assertEquals(1, comp.getChildCount());
-        Assert.assertEquals(1, comp.getChildren().get(0).getChildCount());
-        Assert.assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext));
-        /*
-        MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer1.content()).contains(
-               "<div style=\"border: 1px solid red; margin: 2px\">" +
-               "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
-               "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
-               "</div>" +
-               "<span style=\"border: 1px dashed blue; padding: 5px; margin: 5px\">" +
-               "<input id=\"mainForm:input\" name=\"mainForm:input\" type=\"text\" value=\"Foo\" style=\"background-color: red\" />" +
-               "</span>" +
-               "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
-               */
-        //System.out.println(writer1.content());
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
+        Set<String> allContracts = runtimeConfig.getResourceLibraryContracts();
+        Set<String> externalContextContracts = runtimeConfig.getExternalContextResourceLibraryContracts();
+        Set<String> classloaderContracts = runtimeConfig.getClassLoaderResourceLibraryContracts();
 
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        Assert.assertEquals(1, comp.getChildren().get(0).getChildCount());
-        Assert.assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext));
+        Assert.assertTrue(allContracts.contains("yellow"));
+        Assert.assertTrue(allContracts.contains("blue"));
+        Assert.assertTrue(allContracts.contains("red"));
 
-        /*
-        MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
-        System.out.println(writer2.content());
-        Assert.assertTrue(new String(writer2.content()).contains(
-                "<div style=\"border: 1px solid red; margin: 2px\">" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
-                "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
-                "</div>" +
-                "<span style=\"border: 1px dashed blue; padding: 5px; margin: 5px\">" +
-                "<input id=\"mainForm:input\" name=\"mainForm:input\" type=\"text\" value=\"Foo\" style=\"background-color: red\" />" +
-                "</span>" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
-                */
-    }
-    
-    @Test
-    public void testRecursive() throws Exception
-    {
-        setupRequest("/recursive.xhtml");
-        processLifecycleExecuteAndRender();
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals(1, comp.getChildren().get(1).getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value"));
+        Assert.assertTrue(classloaderContracts.contains("yellow"));
+        Assert.assertTrue(classloaderContracts.contains("blue"));
+        Assert.assertTrue(externalContextContracts.contains("red"));
         
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
+        List<String> defaultContracts = runtimeConfig.getContractMappings().get("*");
         
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals(1, comp.getChildren().get(1).getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value"));
-        
-        tearDownRequest();
-    }
-    
-    @Test
-    public void testStable() throws Exception
-    {
-        setupRequest("/stable.xhtml");
-        processLifecycleExecuteAndRender();
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(3, comp.getChildCount());
-        Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
-        Assert.assertEquals("text3", comp.getChildren().get(2).getId());
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(3, comp.getChildCount());
-        Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
-        Assert.assertEquals("text3", comp.getChildren().get(2).getId());
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(3, comp.getChildCount());
-        Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
-        Assert.assertEquals("text3", comp.getChildren().get(2).getId());
-
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        UIInput input = (UIInput) facesContext.getViewRoot().findComponent("mainForm:text3");
-        inputText(input, "3");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(3, comp.getChildCount());
-        Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
-        Assert.assertEquals("text3", comp.getChildren().get(2).getId());
-        
-    }
-    
-    @Test
-    public void testTable() throws Exception
-    {
-        setupRequest("/table.xhtml");
-        processLifecycleExecuteAndRender();
-        
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        HtmlDataTable dataTable = (HtmlDataTable) comp.getChildren().get(0);
-        Assert.assertEquals(1, dataTable.getChildCount());
-
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        dataTable = (HtmlDataTable) comp.getChildren().get(0);
-        Assert.assertEquals(1, dataTable.getChildCount());
-    }
-    
-    @Test
-    public void testToggle() throws Exception
-    {
-        setupRequest("/toggle.xhtml");
-        processLifecycleExecuteAndRender();
-        
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(1).getAttributes().get("value"));
-
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(1).getAttributes().get("value"));
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(1).getAttributes().get("value"));
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(1).getAttributes().get("value"));
-        
-    }
-    
-    @Test
-    public void testInclude() throws Exception
-    {
-        setupRequest("/include.xhtml");
-        processLifecycleExecute();
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-        //Set a token to save on the state as delta
-        UIComponent component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        component.getAttributes().put("test", "test1");
-        processRender();
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page1");
-        submit(button);
-        processLifecycleExecute();
-        //Check it is restored
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertEquals("test1", component.getAttributes().get("test"));
-        processRender();
-        //Check buildView does not destroy the state
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertEquals("test1", component.getAttributes().get("test"));
-        
-        //Go to page2
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
+        Assert.assertFalse(defaultContracts.contains("yellow"));
+        Assert.assertTrue(defaultContracts.contains("blue"));
+        Assert.assertFalse(defaultContracts.contains("red"));
         
         processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        //Check it is restored
-        Assert.assertEquals("test1", component.getAttributes().get("test"));
-        
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-
-        //Check the page was changed and the state discarded, because it is a different component.
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertNull(component.getAttributes().get("test"));
-        //Set a token to save on the state as delta
-        component.getAttributes().put("test", "test2");
-        processRender();
-        
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertEquals("test2", component.getAttributes().get("test"));
-
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-        
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        //Check it is restored
-        Assert.assertNotNull("mainForm:component2 was not restored correctly",component);
-        Assert.assertEquals("test2", component.getAttributes().get("test"));
-        
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-
-        //Check buildView does not destroy the state
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertEquals("test2", component.getAttributes().get("test"));
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        //Check it is restored
-        Assert.assertEquals("test2", component.getAttributes().get("test"));
-    }
-
-    /**
-     * Same as testInclude, but only check the component is restored correctly.
-     * Since there is no delta, no state is saved unless it is necessary.
-     * 
-     * @throws Exception
-     */
-    @Test
-    public void testInclude2() throws Exception
-    {
-        setupRequest("/include.xhtml");
-        processLifecycleExecute();
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-        //Set a token to save on the state as delta
-        UIComponent component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertNotNull(component);
-        processRender();
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page1");
-        submit(button);
-        
-        processLifecycleExecute();
-        //Check it is restored
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertNotNull(component);
-        processRender();
-        //Check buildView does not destroy the state
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertNotNull(component);
-        
-        //Go to page2
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-        
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        //Check it is restored
-        Assert.assertNotNull(component);
-        
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-
-        //Check the page was changed and the state discarded, because it is a different component.
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertNotNull(component);
-        processRender();
-        
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertNotNull(component);
-
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-        
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        //Check it is restored
-        Assert.assertNotNull(component);
-        
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-
-        //Check buildView does not destroy the state
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertNotNull(component);
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        //Check it is restored
-        Assert.assertNotNull(component);
-    }
-    
-    /**
-     * Check if a dynamic subtree can be created from a binding property, and if it
-     * will be preserved across request. 
-     * 
-     * The idea is just inject a subtree using some code like this:
-     * <code>&lt;h:panelGroup id="panel" binding="#{componentBindingBean.panel}"&gt;</code>
-     * 
-     * The solution is if a binding returns a component that has children or facets
-     * attached, it is not elegible for PSS algorithm because the additional components
-     * are created outside facelets control, and there is no warrant that the same structure
-     * will be generated across requests, violating PSS base principle (it is possible to
-     * restore to the initial state calling vdl.buildView).
-     * 
-     * This test is here because all state saving modes should support this method.
-     * 
-     * @throws Exception 
-     */
-    @Test
-    public void testComponentBinding() throws Exception
-    {
-        setupRequest("/componentBinding1.xhtml");
-        processLifecycleExecuteAndRender();
-        
-        UIComponent comp = facesContext.getViewRoot().findComponent("panel");
-        Assert.assertNotNull(comp);
-        Assert.assertEquals(1, comp.getChildCount());
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("panel");
-        
-        Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
-        Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-
-        comp = facesContext.getViewRoot().findComponent("panel");
-        
-        Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
-        Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
-        
-        tearDownRequest();
-    }
-    
-    @Test
-    public void testResourceDependency() throws Exception
-    {
-        setupRequest("/resourceDependency1.xhtml");
-        processLifecycleExecute();
-
-        executeBeforeRender(facesContext);
         executeBuildViewCycle(facesContext);
-
-        UIPanel headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
-        Assert.assertNotNull(headPanel);
-        Assert.assertEquals(1, headPanel.getChildCount());
-        
-        String nextUniqueId = facesContext.getViewRoot().createUniqueId(facesContext, null);
         
-        executeViewHandlerRender(facesContext);
-        executeAfterRender(facesContext);
+        List<String> contractsList = facesContext.getResourceLibraryContracts();
+        Assert.assertFalse(contractsList.contains("yellow"));
+        Assert.assertTrue(contractsList.contains("blue"));
+        Assert.assertFalse(contractsList.contains("red"));
+        
+        ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
+        
+        Resource resource1 = resourceHandler.createViewResource(facesContext, "/panel.xhtml");
+        Assert.assertNotNull(resource1);
+        Assert.assertEquals("panel.xhtml", resource1.getResourceName());
         
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
+        Resource resource2 = resourceHandler.createResource("myjs.js", "mylib");
+        Assert.assertNotNull(resource2);
         
-        processLifecycleExecute();
-        
-        ResourceDependencyBean bean = facesContext.getApplication().evaluateExpressionGet(
-            facesContext, "#{resourceDependencyBean}", ResourceDependencyBean.class);
-        bean.setIncludeContent(true);
-        
-        executeBeforeRender(facesContext);
-        executeBuildViewCycle(facesContext);
-        
-        headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
-        Assert.assertNotNull(headPanel);
-        Assert.assertEquals(1, headPanel.getChildCount());
-        Assert.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId());
-        
-        executeViewHandlerRender(facesContext);
-        executeAfterRender(facesContext);
+        tearDownRequest();
     }
 
 }

Copied: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/contracts/DefaultContractsConfigMyFacesRequestTestCase.java (from r1470662, myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/contracts/DefaultContractsConfigMyFacesRequestTestCase.java?p2=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/contracts/DefaultContractsConfigMyFacesRequestTestCase.java&p1=myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java&r1=1470662&r2=1485917&rev=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/application/contracts/DefaultContractsConfigMyFacesRequestTestCase.java Fri May 24 01:27:31 2013
@@ -16,23 +16,20 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.myfaces.view.facelets.pss.acid;
+package org.apache.myfaces.application.contracts;
 
+import java.util.List;
+import java.util.Set;
 import javax.faces.application.StateManager;
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.component.UIPanel;
-import javax.faces.component.html.HtmlDataTable;
 
 import junit.framework.Assert;
+import org.apache.myfaces.config.RuntimeConfig;
 
 import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
 import org.apache.myfaces.shared.config.MyfacesConfig;
-import org.apache.myfaces.view.facelets.pss.acid.managed.ResourceDependencyBean;
 import org.junit.Test;
 
-public class AcidMyFacesRequestTestCase extends AbstractMyFacesRequestTestCase
+public class DefaultContractsConfigMyFacesRequestTestCase extends AbstractMyFacesRequestTestCase
 {
 
     @Override
@@ -45,467 +42,45 @@ public class AcidMyFacesRequestTestCase 
     protected void setUpWebConfigParams() throws Exception
     {
         super.setUpWebConfigParams();
-        servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES","org.apache.myfaces.view.facelets.pss.acid");
-        servletContext.addInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/testcomponent.taglib.xml");
+        servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES","org.apache.myfaces.application.contracts");
         servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_CLIENT);
         servletContext.addInitParameter("javax.faces.PARTIAL_STATE_SAVING", "true");
         servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS, "auto");
     }
     
     @Test
-    public void testIndex() throws Exception
+    public void testDefaultConfiguration() throws Exception
     {
         setupRequest("/index.xhtml");
-        processLifecycleExecuteAndRender();
+        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
         
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
-        
-        /*
-        MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer1.content()).contains(
-                "<div style=\"border: 1px solid red; margin: 2px\">" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
-                "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
-                "</div>" +
-                "Dynamically added child" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
-                */
-        //System.out.println(writer1.content());
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
-        /*
-        MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer2.content()).contains(
-                "<div style=\"border: 1px solid red; margin: 2px\">" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
-                "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
-                "</div>" +
-                "Dynamically added child" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
-                */
-        //System.out.println(writer2.content());
-        tearDownRequest();
-    }
-    
-    @Test
-    public void testInput() throws Exception
-    {
-        setupRequest("/input.xhtml");
-        processLifecycleExecuteAndRender();
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        
-        Assert.assertEquals(1, comp.getChildCount());
-        Assert.assertEquals(1, comp.getChildren().get(0).getChildCount());
-        Assert.assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext));
-        /*
-        MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
-        Assert.assertTrue(new String(writer1.content()).contains(
-               "<div style=\"border: 1px solid red; margin: 2px\">" +
-               "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
-               "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
-               "</div>" +
-               "<span style=\"border: 1px dashed blue; padding: 5px; margin: 5px\">" +
-               "<input id=\"mainForm:input\" name=\"mainForm:input\" type=\"text\" value=\"Foo\" style=\"background-color: red\" />" +
-               "</span>" +
-               "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
-               */
-        //System.out.println(writer1.content());
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        Assert.assertEquals(1, comp.getChildren().get(0).getChildCount());
-        Assert.assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext));
-
-        /*
-        MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
-        System.out.println(writer2.content());
-        Assert.assertTrue(new String(writer2.content()).contains(
-                "<div style=\"border: 1px solid red; margin: 2px\">" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
-                "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
-                "</div>" +
-                "<span style=\"border: 1px dashed blue; padding: 5px; margin: 5px\">" +
-                "<input id=\"mainForm:input\" name=\"mainForm:input\" type=\"text\" value=\"Foo\" style=\"background-color: red\" />" +
-                "</span>" +
-                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
-                */
-    }
-    
-    @Test
-    public void testRecursive() throws Exception
-    {
-        setupRequest("/recursive.xhtml");
-        processLifecycleExecuteAndRender();
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals(1, comp.getChildren().get(1).getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value"));
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals(1, comp.getChildren().get(1).getChildCount());
-        Assert.assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value"));
-        
-        tearDownRequest();
-    }
-    
-    @Test
-    public void testStable() throws Exception
-    {
-        setupRequest("/stable.xhtml");
-        processLifecycleExecuteAndRender();
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(3, comp.getChildCount());
-        Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
-        Assert.assertEquals("text3", comp.getChildren().get(2).getId());
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(3, comp.getChildCount());
-        Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
-        Assert.assertEquals("text3", comp.getChildren().get(2).getId());
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(3, comp.getChildCount());
-        Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
-        Assert.assertEquals("text3", comp.getChildren().get(2).getId());
-
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        UIInput input = (UIInput) facesContext.getViewRoot().findComponent("mainForm:text3");
-        inputText(input, "3");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(3, comp.getChildCount());
-        Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
-        Assert.assertEquals("text3", comp.getChildren().get(2).getId());
-        
-    }
-    
-    @Test
-    public void testTable() throws Exception
-    {
-        setupRequest("/table.xhtml");
-        processLifecycleExecuteAndRender();
-        
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        HtmlDataTable dataTable = (HtmlDataTable) comp.getChildren().get(0);
-        Assert.assertEquals(1, dataTable.getChildCount());
-
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(1, comp.getChildCount());
-        dataTable = (HtmlDataTable) comp.getChildren().get(0);
-        Assert.assertEquals(1, dataTable.getChildCount());
-    }
-    
-    @Test
-    public void testToggle() throws Exception
-    {
-        setupRequest("/toggle.xhtml");
-        processLifecycleExecuteAndRender();
-        
-        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(1).getAttributes().get("value"));
-
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(1).getAttributes().get("value"));
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(1).getAttributes().get("value"));
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("mainForm:component");
-        Assert.assertEquals(2, comp.getChildCount());
-        Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(0).getAttributes().get("value"));
-        Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(1).getAttributes().get("value"));
-        
-    }
-    
-    @Test
-    public void testInclude() throws Exception
-    {
-        setupRequest("/include.xhtml");
-        processLifecycleExecute();
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-        //Set a token to save on the state as delta
-        UIComponent component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        component.getAttributes().put("test", "test1");
-        processRender();
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page1");
-        submit(button);
-        processLifecycleExecute();
-        //Check it is restored
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertEquals("test1", component.getAttributes().get("test"));
-        processRender();
-        //Check buildView does not destroy the state
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertEquals("test1", component.getAttributes().get("test"));
-        
-        //Go to page2
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-        
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        //Check it is restored
-        Assert.assertEquals("test1", component.getAttributes().get("test"));
-        
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
+        Set<String> allContracts = runtimeConfig.getResourceLibraryContracts();
+        Set<String> externalContextContracts = runtimeConfig.getExternalContextResourceLibraryContracts();
+        Set<String> classloaderContracts = runtimeConfig.getClassLoaderResourceLibraryContracts();
 
-        //Check the page was changed and the state discarded, because it is a different component.
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertNull(component.getAttributes().get("test"));
-        //Set a token to save on the state as delta
-        component.getAttributes().put("test", "test2");
-        processRender();
-        
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertEquals("test2", component.getAttributes().get("test"));
+        Assert.assertTrue(allContracts.contains("yellow"));
+        Assert.assertTrue(allContracts.contains("blue"));
+        Assert.assertTrue(allContracts.contains("red"));
 
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
+        Assert.assertTrue(classloaderContracts.contains("yellow"));
+        Assert.assertTrue(classloaderContracts.contains("blue"));
+        Assert.assertTrue(externalContextContracts.contains("red"));
         
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        //Check it is restored
-        Assert.assertNotNull("mainForm:component2 was not restored correctly",component);
-        Assert.assertEquals("test2", component.getAttributes().get("test"));
+        List<String> defaultContracts = runtimeConfig.getContractMappings().get("*");
         
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-
-        //Check buildView does not destroy the state
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertEquals("test2", component.getAttributes().get("test"));
+        Assert.assertTrue(defaultContracts.contains("yellow"));
+        Assert.assertTrue(defaultContracts.contains("blue"));
+        Assert.assertTrue(defaultContracts.contains("red"));
         
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-
         processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        //Check it is restored
-        Assert.assertEquals("test2", component.getAttributes().get("test"));
-    }
-
-    /**
-     * Same as testInclude, but only check the component is restored correctly.
-     * Since there is no delta, no state is saved unless it is necessary.
-     * 
-     * @throws Exception
-     */
-    @Test
-    public void testInclude2() throws Exception
-    {
-        setupRequest("/include.xhtml");
-        processLifecycleExecute();
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-        //Set a token to save on the state as delta
-        UIComponent component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertNotNull(component);
-        processRender();
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page1");
-        submit(button);
-        
-        processLifecycleExecute();
-        //Check it is restored
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertNotNull(component);
-        processRender();
-        //Check buildView does not destroy the state
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        Assert.assertNotNull(component);
-        
-        //Go to page2
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-        
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component1");
-        //Check it is restored
-        Assert.assertNotNull(component);
-        
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-
-        //Check the page was changed and the state discarded, because it is a different component.
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertNotNull(component);
-        processRender();
-        
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertNotNull(component);
-
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-        
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        //Check it is restored
-        Assert.assertNotNull(component);
-        
-        //Build the view
-        facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
-                facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
-
-        //Check buildView does not destroy the state
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        Assert.assertNotNull(component);
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
-        submit(button);
-
-        processLifecycleExecute();
-        component = facesContext.getViewRoot().findComponent("mainForm:component2");
-        //Check it is restored
-        Assert.assertNotNull(component);
-    }
-    
-    /**
-     * Check if a dynamic subtree can be created from a binding property, and if it
-     * will be preserved across request. 
-     * 
-     * The idea is just inject a subtree using some code like this:
-     * <code>&lt;h:panelGroup id="panel" binding="#{componentBindingBean.panel}"&gt;</code>
-     * 
-     * The solution is if a binding returns a component that has children or facets
-     * attached, it is not elegible for PSS algorithm because the additional components
-     * are created outside facelets control, and there is no warrant that the same structure
-     * will be generated across requests, violating PSS base principle (it is possible to
-     * restore to the initial state calling vdl.buildView).
-     * 
-     * This test is here because all state saving modes should support this method.
-     * 
-     * @throws Exception 
-     */
-    @Test
-    public void testComponentBinding() throws Exception
-    {
-        setupRequest("/componentBinding1.xhtml");
-        processLifecycleExecuteAndRender();
-        
-        UIComponent comp = facesContext.getViewRoot().findComponent("panel");
-        Assert.assertNotNull(comp);
-        Assert.assertEquals(1, comp.getChildCount());
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-        
-        comp = facesContext.getViewRoot().findComponent("panel");
-        
-        Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
-        Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
-        
-        button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        processLifecycleExecuteAndRender();
-
-        comp = facesContext.getViewRoot().findComponent("panel");
-        
-        Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
-        Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
-        
-        tearDownRequest();
-    }
-    
-    @Test
-    public void testResourceDependency() throws Exception
-    {
-        setupRequest("/resourceDependency1.xhtml");
-        processLifecycleExecute();
-
-        executeBeforeRender(facesContext);
-        executeBuildViewCycle(facesContext);
-
-        UIPanel headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
-        Assert.assertNotNull(headPanel);
-        Assert.assertEquals(1, headPanel.getChildCount());
-        
-        String nextUniqueId = facesContext.getViewRoot().createUniqueId(facesContext, null);
-        
-        executeViewHandlerRender(facesContext);
-        executeAfterRender(facesContext);
-        
-        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
-        submit(button);
-        
-        processLifecycleExecute();
-        
-        ResourceDependencyBean bean = facesContext.getApplication().evaluateExpressionGet(
-            facesContext, "#{resourceDependencyBean}", ResourceDependencyBean.class);
-        bean.setIncludeContent(true);
-        
-        executeBeforeRender(facesContext);
         executeBuildViewCycle(facesContext);
         
-        headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
-        Assert.assertNotNull(headPanel);
-        Assert.assertEquals(1, headPanel.getChildCount());
-        Assert.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId());
+        List<String> contractsList = facesContext.getResourceLibraryContracts();
+        Assert.assertTrue(contractsList.contains("yellow"));
+        Assert.assertTrue(contractsList.contains("blue"));
+        Assert.assertTrue(contractsList.contains("red"));
         
-        executeViewHandlerRender(facesContext);
-        executeAfterRender(facesContext);
+        tearDownRequest();
     }
 
 }

Added: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/javax.faces.contract.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/javax.faces.contract.xml?rev=1485917&view=auto
==============================================================================
    (empty)

Propchange: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/javax.faces.contract.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/mylib/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/mylib/myjs.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/mylib/myjs.js?rev=1485917&view=auto
==============================================================================
    (empty)

Propchange: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/mylib/myjs.js
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/panel.xhtml (from r1470662, myfaces/current22/client-window-example/src/main/webapp/flashKeep1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/panel.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/panel.xhtml&p1=myfaces/current22/client-window-example/src/main/webapp/flashKeep1.xhtml&r1=1470662&r2=1485917&rev=1485917&view=diff
==============================================================================
--- myfaces/current22/client-window-example/src/main/webapp/flashKeep1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/blue/panel.xhtml Fri May 24 01:27:31 2013
@@ -19,25 +19,12 @@
 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
 	xmlns:h="http://java.sun.com/jsf/html"
 	xmlns:f="http://java.sun.com/jsf/core"
 	xmlns:c="http://java.sun.com/jsp/jstl/core"
-        xmlns:ui="http://java.sun.com/jsf/facelets">
-<body>
-<ui:composition template="/META-INF/templates/example.xhtml">
-  <ui:define name="container">
-    <h1>Myfaces Examples</h1>
-    <h:form id="mainForm">
-            <h3><h:outputText value="Flash Keep" /></h3>
-            <h:panelGrid columns="2">
-                <h:outputLabel value="Name" for="name" />
-                <h:inputText id="name" value="#{helloWorldFlashBean.name}" />
-            </h:panelGrid>
-            <h:commandButton action="#{helloWorldFlashBean.keepRedirect}" 
-                    value="Keep over Redirect" />
-    </h:form>
-  </ui:define>
+    xmlns:ui="http://java.sun.com/jsf/facelets">
+    <h:panelGroup layout="block" style="background-color: blue">
+        <ui:insert name="panel_content"/>
+    </h:panelGroup>
 </ui:composition>
-</body>
-</html>

Propchange: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/yellow/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/yellow/javax.faces.contract.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/yellow/javax.faces.contract.xml?rev=1485917&view=auto
==============================================================================
    (empty)

Propchange: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/yellow/javax.faces.contract.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/yellow/mylib/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/yellow/mylib/myjs.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/yellow/mylib/myjs.js?rev=1485917&view=auto
==============================================================================
    (empty)

Propchange: myfaces/core/trunk/impl/src/test/resources/META-INF/contracts/yellow/mylib/myjs.js
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/blue-faces-config.xml (from r1470662, myfaces/current22/client-window-example/src/main/webapp/WEB-INF/faces-config.xml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/blue-faces-config.xml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/blue-faces-config.xml&p1=myfaces/current22/client-window-example/src/main/webapp/WEB-INF/faces-config.xml&r1=1470662&r2=1485917&rev=1485917&view=diff
==============================================================================
--- myfaces/current22/client-window-example/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/blue-faces-config.xml Fri May 24 01:27:31 2013
@@ -17,48 +17,20 @@
  * specific language governing permissions and limitations
  * under the License.
 -->
-<faces-config version="2.0"
-              xmlns="http://java.sun.com/xml/ns/javaee"
+<faces-config version="2.2"
+              xmlns="http://xmlns.jcp.org/xml/ns/javaee"
               xmlns:xi="http://www.w3.org/2001/XInclude"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
-              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
+              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
     
     <application>
-        <el-resolver>org.apache.myfaces.example.windowScope.WindowScopeELResolver</el-resolver>
+        <resource-library-contracts>
+            <contract-mapping>
+                <url-pattern>*</url-pattern>
+                <contracts>blue</contracts>
+            </contract-mapping>
+        </resource-library-contracts>
     </application>
     
-    <!-- navigation rules for helloWorld flash post-redirect-get pattern -->
-    <navigation-rule>
-        <from-view-id>/flashprg1.xhtml</from-view-id>
-        <navigation-case>
-            <from-outcome>success</from-outcome>
-            <to-view-id>/flashprg2.xhtml</to-view-id>
-            <redirect/>
-        </navigation-case>
-    </navigation-rule>
-    <navigation-rule>
-        <from-view-id>/flashprg2.xhtml</from-view-id>
-        <navigation-case>
-            <from-outcome>back</from-outcome>
-            <to-view-id>/flashprg1.xhtml</to-view-id>
-        </navigation-case>
-    </navigation-rule>
- 
-    <!-- navigation rules for helloWorld flash using putNow/keep method to keep previous name -->
-    <navigation-rule>
-        <from-view-id>/flashhw1.xhtml</from-view-id>
-        <navigation-case>
-            <from-outcome>success</from-outcome>
-            <to-view-id>/flashhw2.xhtml</to-view-id>
-        </navigation-case>
-    </navigation-rule>
-    <navigation-rule>
-        <from-view-id>/flashhw2.xhtml</from-view-id>
-        <navigation-case>
-            <from-outcome>back</from-outcome>
-            <to-view-id>/flashhw1.xhtml</to-view-id>
-        </navigation-case>
-    </navigation-rule>
-
 </faces-config>
         
\ No newline at end of file

Propchange: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/contracts/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/contracts/red/
------------------------------------------------------------------------------
    bugtraq:number = true

Propchange: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/contracts/red/mylib/
------------------------------------------------------------------------------
    bugtraq:number = true

Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/contracts/red/mylib/myjs.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/contracts/red/mylib/myjs.js?rev=1485917&view=auto
==============================================================================
    (empty)

Propchange: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/contracts/red/mylib/myjs.js
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/index.xhtml (from r1470662, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/index.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/index.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/index.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/index.xhtml&r1=1470662&r2=1485917&rev=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/index.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/contracts/index.xhtml Fri May 24 01:27:31 2013
@@ -1,4 +1,3 @@
-<?xml version='1.0' encoding='UTF-8' ?>
 <!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
@@ -11,32 +10,17 @@
  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.
--->
-<ui:composition xmlns="http://www.w3.org/1999/xhtml"
-				xmlns:h="http://java.sun.com/jsf/html"
-				xmlns:f="http://java.sun.com/jsf/core"
-				xmlns:ui="http://java.sun.com/jsf/facelets"
-				xmlns:test="http://testcomponent"
-				template="common.xhtml">
 
-	<h2>Add Test Instructions</h2>
-	
-	<ol>
-		<li>The component should have dynamically modified the tree so that 'Dynamically added child' appears inside the red box</li>
-		<li>Click 'POSTback'. The 'Dynamically added child' should not disappear (because it should have been serialized in the ViewState)</li>
-	</ol>
-		
-	<h:messages/>
-		
-	<h:form id="mainForm">
-	
-		<test:addcomponent id="component"/>
-		
-		<br/>
-		
-		<h:commandButton id="postback" value="POSTback" action="#{testManagedBean.save}"/>
-		
-	</h:form>			
-	
-</ui:composition>
+ $Id: selectOne.xml 804043 2009-08-13 22:08:44Z lu4242 $
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional" "http://www.w3.org/TR/xhtml1/DTD/xhtml22-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+<h:head>
+</h:head>
+<h:body>
+</h:body>
+</html>
 

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/AliasResourceMetaImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/AliasResourceMetaImpl.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/AliasResourceMetaImpl.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/AliasResourceMetaImpl.java Fri May 24 01:27:31 2013
@@ -33,8 +33,16 @@ public class AliasResourceMetaImpl exten
     public AliasResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
             String resourceName, String resourceVersion, String realResourceName, boolean couldContainValueExpressions)
     {
+        this(prefix, libraryName, libraryVersion, resourceName, resourceVersion, realResourceName, 
+            couldContainValueExpressions, null);
+    }
+    
+    public AliasResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
+            String resourceName, String resourceVersion, String realResourceName, 
+            boolean couldContainValueExpressions, String contractName)
+    {
         super(prefix, libraryName, libraryVersion,
-            resourceName, resourceVersion);
+            resourceName, resourceVersion, contractName);
         _realResourceName = realResourceName;
         _couldContainValueExpressions = couldContainValueExpressions;
     }

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/BaseResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/BaseResourceHandlerSupport.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/BaseResourceHandlerSupport.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/BaseResourceHandlerSupport.java Fri May 24 01:27:31 2013
@@ -64,6 +64,16 @@ public class BaseResourceHandlerSupport 
     {
         return null;
     }
+    
+    public ContractResourceLoader[] getContractResourceLoaders()
+    {
+        return null;
+    }
+    
+    public ResourceLoader[] getViewResourceLoaders()
+    {
+        return null;
+    }
 
     public String calculateResourceBasePath(FacesContext facesContext)
     {        

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ClassLoaderResourceLoader.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ClassLoaderResourceLoader.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ClassLoaderResourceLoader.java Fri May 24 01:27:31 2013
@@ -258,13 +258,13 @@ public class ClassLoaderResourceLoader e
         }
     }
 
-    @Override
-    public URL getResourceURL(ResourceMeta resourceMeta)
+    //@Override
+    public URL getResourceURL(String resourceId)
     {
         URL url = null;
         if (getPrefix() != null && !"".equals(getPrefix()))
         {
-            String name = getPrefix() + '/' + resourceMeta.getResourceIdentifier();
+            String name = getPrefix() + '/' + resourceId;
             url = getClassLoader().getResource(name);
             if (url == null)
             {
@@ -274,14 +274,20 @@ public class ClassLoaderResourceLoader e
         }
         else
         {
-            url = getClassLoader().getResource(resourceMeta.getResourceIdentifier());
+            url = getClassLoader().getResource(resourceId);
             if (url == null)
             {
-                url = this.getClass().getClassLoader().getResource(resourceMeta.getResourceIdentifier());
+                url = this.getClass().getClassLoader().getResource(resourceId);
             }
             return url;
         }
     }
+    
+    @Override
+    public URL getResourceURL(ResourceMeta resourceMeta)
+    {
+        return getResourceURL(resourceMeta.getResourceIdentifier());
+    }
 
     @Override
     public String getResourceVersion(String path)
@@ -484,7 +490,7 @@ public class ClassLoaderResourceLoader e
         }
         return false;
     }
-
+    
     /**
      * <p>Determines whether the given URL resource protocol refers to a JAR file. Note that
      * BEA WebLogic and IBM WebSphere don't use the "jar://" protocol for some reason even

Added: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResource.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResource.java?rev=1485917&view=auto
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResource.java (added)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResource.java Fri May 24 01:27:31 2013
@@ -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.shared.resource;
+
+/**
+ * Indicates if a resource has been served from a contract.
+ *
+ * @author Leonardo Uribe
+ */
+public interface ContractResource
+{
+    /**
+     * FacesContext attribute map that helps ResourceHandlerImpl to locate 
+     * a resource from an specified contract.
+     */
+    public static final String CONTRACT_SELECTED = "oam.contract.SELECTED";
+    
+    public boolean isContractResource();
+    
+    public String getContractName();
+}

Propchange: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResourceLoader.java?rev=1485917&view=auto
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResourceLoader.java (added)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResourceLoader.java Fri May 24 01:27:31 2013
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.resource;
+
+/**
+ * ResourceLoaders that are able to handle contract aware resources
+ * must extends from this class.
+ *
+ * @author Leonardo Uribe
+ */
+public abstract class ContractResourceLoader extends ResourceLoader
+{
+    
+    public static final String VERSION_INVALID = "INVALID";
+    
+    public ContractResourceLoader(String prefix)
+    {
+        super(prefix);
+    }
+    
+    public String getResourceVersion(String path)
+    {
+        return null;
+    }
+
+    public String getLibraryVersion(String path)
+    {
+        return null;
+    }
+
+    public abstract String getResourceVersion(String path, String contractName);
+
+    /**
+     * Return the max available version found (if exists) or
+     * return null if no version available. 
+     */
+    public abstract String getLibraryVersion(String path, String contractName);
+
+    public ResourceMeta createResourceMeta(String prefix, String libraryName, 
+            String libraryVersion, String resourceName, String resourceVersion)
+    {
+        return null;
+    }
+    
+    public abstract ResourceMeta createResourceMeta(String prefix, String libraryName, 
+            String libraryVersion, String resourceName, String resourceVersion, String contractName);
+    
+    public boolean libraryExists(String libraryName)
+    {
+        return false;
+    }
+    
+    public abstract boolean libraryExists(String libraryName, String contractName);
+    
+}

Propchange: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ContractResourceLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ExternalContextResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ExternalContextResourceLoader.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ExternalContextResourceLoader.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ExternalContextResourceLoader.java Fri May 24 01:27:31 2013
@@ -142,19 +142,25 @@ public class ExternalContextResourceLoad
         return libraryVersion;
     }
 
-    @Override
-    public URL getResourceURL(ResourceMeta resourceMeta)
+    //@Override
+    public URL getResourceURL(String resourceId)
     {
         try
         {
             return FacesContext.getCurrentInstance().getExternalContext().getResource(
-                getPrefix() + '/' + resourceMeta.getResourceIdentifier());
+                getPrefix() + '/' + resourceId);
         }
         catch (MalformedURLException e)
         {
             return null;
         }
     }
+    
+    @Override
+    public URL getResourceURL(ResourceMeta resourceMeta)
+    {
+        return getResourceURL(resourceMeta.getResourceIdentifier());
+    }
 
     @Override
     public InputStream getResourceInputStream(ResourceMeta resourceMeta)

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java?rev=1485917&r1=1485916&r2=1485917&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceHandlerCache.java Fri May 24 01:27:31 2013
@@ -35,8 +35,10 @@ public class ResourceHandlerCache
             .getLogger(ResourceHandlerCache.class.getName());
 
     private Boolean _resourceCacheEnabled = null;
-    private volatile ConcurrentLRUCache<ResourceKey, ResourceValue> _resourceCacheMap = null;
+    private volatile ConcurrentLRUCache<Object, ResourceValue> _resourceCacheMap = null;
 
+    private volatile ConcurrentLRUCache<Object, ResourceValue> _viewResourceCacheMap = null;
+    
     /**
      * Controls the size of the cache used to check if a resource exists or not. 
      * 
@@ -62,6 +64,12 @@ public class ResourceHandlerCache
     public ResourceValue getResource(String resourceName, String libraryName,
             String contentType, String localePrefix)
     {
+        return getResource(resourceName, libraryName, contentType, localePrefix, null);
+    }
+    
+    public ResourceValue getResource(String resourceName, String libraryName,
+            String contentType, String localePrefix, String contractName)
+    {
         if (!isResourceCachingEnabled() || _resourceCacheMap == null)
         {
             return null;
@@ -73,12 +81,18 @@ public class ResourceHandlerCache
                     + resourceName);
         }
 
-        ResourceKey key = new ResourceKey(resourceName, libraryName, contentType, localePrefix);
+        ResourceKey key = new ResourceKey(resourceName, libraryName, contentType, localePrefix, contractName);
 
         return _resourceCacheMap.get(key);
+    }    
+
+    public boolean containsResource(String resourceName, String libraryName, String contentType, String localePrefix)
+    {
+        return containsResource(resourceName, libraryName, contentType, localePrefix, null);
     }
     
-    public boolean containsResource(String resourceName, String libraryName, String contentType, String localePrefix)
+    public boolean containsResource(String resourceName, String libraryName, String contentType, 
+        String localePrefix, String contractName)
     {
         if (!isResourceCachingEnabled() || _resourceCacheMap == null)
         {
@@ -92,6 +106,12 @@ public class ResourceHandlerCache
     public void putResource(String resourceName, String libraryName,
             String contentType, String localePrefix, ResourceMeta resource, ResourceLoader loader)
     {
+        putResource(resourceName, libraryName, contentType, localePrefix, null, resource, loader);
+    }
+    
+    public void putResource(String resourceName, String libraryName,
+            String contentType, String localePrefix, String contractName, ResourceMeta resource, ResourceLoader loader)
+    {
         if (!isResourceCachingEnabled())
         {
             return;
@@ -110,12 +130,177 @@ public class ResourceHandlerCache
                 log.log(Level.FINE, "Initializing resource cache map");
             }
             int maxSize = getMaxSize();
-            _resourceCacheMap = new ConcurrentLRUCache<ResourceKey, ResourceValue>(
+            _resourceCacheMap = new ConcurrentLRUCache<Object, ResourceValue>(
                     (maxSize * 4 + 3) / 3, maxSize);
         }
 
         _resourceCacheMap.put(new ResourceKey(resourceName, libraryName,
-                contentType, localePrefix), new ResourceValue(resource, loader));
+                contentType, localePrefix, contractName), new ResourceValue(resource, loader));
+    }
+    
+    public ResourceValue getResource(String resourceId)
+    {
+        if (!isResourceCachingEnabled() || _resourceCacheMap == null)
+        {
+            return null;
+        }
+
+        if (log.isLoggable(Level.FINE))
+        {
+            log.log(Level.FINE, "Attemping to get resource from cache for "
+                    + resourceId);
+        }
+
+        return _resourceCacheMap.get(resourceId);
+    }
+
+    public ResourceValue getResource(String resourceId, String contractName)
+    {
+        if (!isResourceCachingEnabled() || _resourceCacheMap == null)
+        {
+            return null;
+        }
+
+        if (log.isLoggable(Level.FINE))
+        {
+            log.log(Level.FINE, "Attemping to get resource from cache for "
+                    + resourceId);
+        }
+
+        return _resourceCacheMap.get(contractName+':'+resourceId);
+    }
+    
+    public boolean containsResource(String resourceId, String contractName)
+    {
+        if (!isResourceCachingEnabled() || _resourceCacheMap == null)
+        {
+            return false;
+        }
+
+        return _resourceCacheMap.get(contractName+':'+resourceId) != null;
+    }
+    
+    public boolean containsResource(String resourceId)
+    {
+        if (!isResourceCachingEnabled() || _resourceCacheMap == null)
+        {
+            return false;
+        }
+
+        return _resourceCacheMap.get(resourceId) != null;
+    }
+
+    public void putResource(String resourceId, ResourceMeta resource, ResourceLoader loader)
+    {
+        if (!isResourceCachingEnabled())
+        {
+            return;
+        }
+
+        if (log.isLoggable(Level.FINE))
+        {
+            log.log(Level.FINE, "Attemping to put resource to cache for "
+                    + resourceId);
+        }
+
+        if (_resourceCacheMap == null)
+        {
+            if (log.isLoggable(Level.FINE))
+            {
+                log.log(Level.FINE, "Initializing resource cache map");
+            }
+            int maxSize = getMaxSize();
+            _resourceCacheMap = new ConcurrentLRUCache<Object, ResourceValue>(
+                    (maxSize * 4 + 3) / 3, maxSize);
+        }
+
+        if (resource.getContractName() != null)
+        {
+            _resourceCacheMap.put(resource.getContractName()+':'+resourceId, 
+                new ResourceValue(resource, loader));
+        }
+        else
+        {
+            _resourceCacheMap.put(resourceId, new ResourceValue(resource, loader));
+        }
+    }
+
+    public boolean containsViewResource(
+        String resourceName, String contentType, String localePrefix)
+    {
+        return containsViewResource(resourceName, contentType, localePrefix, null);
+    }
+    
+    public boolean containsViewResource(String resourceName, String contentType, 
+        String localePrefix, String contractName)
+    {
+        if (!isResourceCachingEnabled() || _viewResourceCacheMap == null)
+        {
+            return false;
+        }
+
+        ResourceKey key = new ResourceKey(resourceName, null, contentType, localePrefix);
+        return _viewResourceCacheMap.get(key) != null;
+    }
+    
+    public ResourceValue getViewResource(String resourceName,
+            String contentType, String localePrefix)
+    {
+        return getViewResource(resourceName, contentType, localePrefix, null);
+    }
+    
+    public ResourceValue getViewResource(String resourceName,
+            String contentType, String localePrefix, String contractName)
+    {
+        if (!isResourceCachingEnabled() || _viewResourceCacheMap == null)
+        {
+            return null;
+        }
+
+        if (log.isLoggable(Level.FINE))
+        {
+            log.log(Level.FINE, "Attemping to get resource from cache for "
+                    + resourceName);
+        }
+
+        ResourceKey key = new ResourceKey(resourceName, null, contentType, localePrefix, contractName);
+
+        return _viewResourceCacheMap.get(key);
+    }
+    
+    public void putViewResource(String resourceName, String contentType, 
+        String localePrefix, ResourceMeta resource, ResourceLoader loader)
+    {
+        putViewResource(resourceName, contentType, localePrefix, null, resource, loader);
+    }
+    
+    public void putViewResource(String resourceName, String contentType, 
+        String localePrefix, String contractName, ResourceMeta resource, ResourceLoader loader)
+    {
+        if (!isResourceCachingEnabled())
+        {
+            return;
+        }
+
+        if (log.isLoggable(Level.FINE))
+        {
+            log.log(Level.FINE, "Attemping to put resource to cache for "
+                    + resourceName);
+        }
+
+        if (_viewResourceCacheMap == null)
+        {
+            if (log.isLoggable(Level.FINE))
+            {
+                log.log(Level.FINE, "Initializing resource cache map");
+            }
+            int maxSize = getMaxSize();
+            _viewResourceCacheMap = new ConcurrentLRUCache<Object, ResourceValue>(
+                    (maxSize * 4 + 3) / 3, maxSize);
+        }
+
+        _viewResourceCacheMap.put(new ResourceKey(resourceName,
+                contentType, localePrefix, contractName), new ResourceValue(resource, loader));
     }
 
     private boolean isResourceCachingEnabled()
@@ -166,14 +351,22 @@ public class ResourceHandlerCache
         private String libraryName;
         private String contentType;
         private String localePrefix;
+        private String contractName;
 
         public ResourceKey(String resourceName, String libraryName,
                 String contentType, String localePrefix)
         {
+            this(resourceName, libraryName, contentType, localePrefix, null);
+        }
+        
+        public ResourceKey(String resourceName, String libraryName,
+                String contentType, String localePrefix, String contractName)
+        {
             this.resourceName = resourceName;
             this.libraryName = libraryName;
             this.contentType = contentType;
             this.localePrefix = localePrefix;
+            this.contractName = contractName;
         }
 
         @Override
@@ -206,6 +399,10 @@ public class ResourceHandlerCache
             {
                 return false;
             }
+            if (contractName != null ? !contractName.equals(that.contractName) : that.contractName != null)
+            {
+                return false;
+            }
 
             return true;
         }
@@ -217,6 +414,7 @@ public class ResourceHandlerCache
             result = 31 * result + (libraryName != null ? libraryName.hashCode() : 0);
             result = 31 * result + (contentType != null ? contentType.hashCode() : 0);
             result = 31 * result + (localePrefix != null ? localePrefix.hashCode() : 0);
+            result = 31 * result + (contractName != null ? contractName.hashCode() : 0);
             return result;
         }
     }