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

svn commit: r1641508 - in /myfaces/core/trunk/impl/src/test: java/org/apache/myfaces/mc/test/core/mock/ java/org/apache/myfaces/view/facelets/pss/acid/ java/org/apache/myfaces/view/facelets/pss/acid/managed/ resources/org/apache/myfaces/view/facelets/p...

Author: lu4242
Date: Mon Nov 24 23:18:12 2014
New Revision: 1641508

URL: http://svn.apache.org/r1641508
Log:
add test for ui:repeat and nested composite component in acid test

Added:
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/TestBean.java
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ValueHolder.java
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/nested_ui_repeat_1.xhtml
      - copied, changed from r1641481, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/viewParamBinding1.xhtml
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/testUIRepeatCC.xhtml
      - copied, changed from r1638905, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_1.xhtml
Modified:
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java?rev=1641508&r1=1641507&r2=1641508&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/mc/test/core/mock/MockMyFacesClient.java Mon Nov 24 23:18:12 2014
@@ -195,31 +195,45 @@ public class MockMyFacesClient
     {
         ajax(source, event, execute, render, submit, false);
     }
+    
+    public void ajax(String sourceClientId, String event, String execute, String render, boolean submit) throws Exception
+    {
+        ajax(sourceClientId, event, execute, render, submit, false);
+    }    
             
     public void ajax(UIComponent source, String event, String execute, String render, 
         boolean submit, boolean resetValues)
     {
         testCase.processRemainingPhases();
-        this.internalAjax(source, event, execute, render, submit, resetValues);
+        this.internalAjax(source.getClientId(testCase.getFacesContext()), event, execute, render, submit, resetValues);
+        String viewId = testCase.getFacesContext().getViewRoot().getViewId();
+        testCase.endRequest();
+        testCase.startViewRequest(viewId);
+    }
+    
+    public void ajax(String sourceClientId, String event, String execute, String render, 
+        boolean submit, boolean resetValues)
+    {
+        testCase.processRemainingPhases();
+        this.internalAjax(sourceClientId, event, execute, render, submit, resetValues);
         String viewId = testCase.getFacesContext().getViewRoot().getViewId();
         testCase.endRequest();
         testCase.startViewRequest(viewId);
     }
     
-    protected void internalAjax(UIComponent source, String event, String execute, String render, 
+    protected void internalAjax(String source, String event, String execute, String render, 
         boolean submit, boolean resetValues)
     {
-        final FacesContext facesContext = testCase.getFacesContext();
         parameters.put("javax.faces.partial.ajax", "true");
         parameters.put("javax.faces.behavior.event", event);
         parameters.put("javax.faces.partial.event", "action".equals(event) ? "click" : event);
         applyStateFromPreviousRequest();
         //parameters.put(ResponseStateManager.VIEW_STATE_PARAM, 
         //    facesContext.getApplication().getStateManager().getViewState(facesContext));
-        parameters.put("javax.faces.source", source.getClientId(facesContext));
+        parameters.put("javax.faces.source", source);
         if (execute == null)
         {
-            parameters.put("javax.faces.partial.execute", source.getClientId(facesContext));
+            parameters.put("javax.faces.partial.execute", source);
         }
         else
         {
@@ -232,8 +246,8 @@ public class MockMyFacesClient
         
         if (submit)
         {
-            parameters.put(source.getClientId(facesContext)+"_SUBMIT", "1");
-            parameters.put(source.getClientId(facesContext), source.getClientId(facesContext));
+            parameters.put(source+"_SUBMIT", "1");
+            parameters.put(source, source);
         }
         
         if (resetValues)

Modified: 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/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java?rev=1641508&r1=1641507&r2=1641508&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/view/facelets/pss/acid/AcidMyFacesRequestTestCase.java Mon Nov 24 23:18:12 2014
@@ -2139,4 +2139,30 @@ public class AcidMyFacesRequestTestCase 
 
         endRequest();
     }
+    
+    @Test
+    public void testUIRepeatCC1() throws Exception
+    {
+        startViewRequest("/nested_ui_repeat_1.xhtml");
+        processLifecycleExecuteAndRender();
+        
+        MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
+        String content1 = new String(writer1.content());
+        Assert.assertTrue(content1.contains("A-"));
+        Assert.assertTrue(content1.contains("B-"));
+        Assert.assertTrue(content1.contains("C-"));
+        
+        this.client.ajax("mainForm:j_id_7:1:j_id_8:refresh", "action", 
+                "mainForm:j_id_7:1:j_id_8:refresh", 
+                "mainForm:j_id_7:1:j_id_8:compToUpdate", true);
+        
+        processLifecycleExecuteAndRender();
+        
+        MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
+        String content2 = new String(writer2.content());
+        Assert.assertTrue(content2.contains("mainForm:j_id_7:1:j_id_8:compToUpdate"));
+        Assert.assertTrue(content2.contains("B-"));
+
+        endRequest();
+    }
 }

Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/TestBean.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/TestBean.java?rev=1641508&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/TestBean.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/TestBean.java Mon Nov 24 23:18:12 2014
@@ -0,0 +1,67 @@
+/*
+ * 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.view.facelets.pss.acid.managed;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+/**
+ *
+ * @author lu4242
+ */
+@ManagedBean(name="testBean")
+@RequestScoped
+public class TestBean
+{
+
+    private List<ValueHolder> values = new ArrayList<ValueHolder>();
+
+    public TestBean()
+    {
+    }
+    
+    @PostConstruct
+    public void init()
+    {
+        values.add(new ValueHolder("A-"+System.currentTimeMillis()));
+        values.add(new ValueHolder("B-"+System.currentTimeMillis()));
+        values.add(new ValueHolder("C-"+System.currentTimeMillis()));
+    }
+    
+    /**
+     * @return the values
+     */
+    public List<ValueHolder> getValues()
+    {
+        return values;
+    }
+
+    /**
+     * @param values the values to set
+     */
+    public void setValues(List<ValueHolder> values)
+    {
+        this.values = values;
+    }
+
+    
+}

Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ValueHolder.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ValueHolder.java?rev=1641508&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ValueHolder.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/pss/acid/managed/ValueHolder.java Mon Nov 24 23:18:12 2014
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.view.facelets.pss.acid.managed;
+
+/**
+ *
+ * @author lu4242
+ */
+public class ValueHolder
+{
+
+    private String value;
+
+    public ValueHolder(String value)
+    {
+        this.value = value;
+    }
+
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+}

Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/nested_ui_repeat_1.xhtml (from r1641481, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/viewParamBinding1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/nested_ui_repeat_1.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/nested_ui_repeat_1.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/viewParamBinding1.xhtml&r1=1641481&r2=1641508&rev=1641508&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/viewParamBinding1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/nested_ui_repeat_1.xhtml Mon Nov 24 23:18:12 2014
@@ -15,16 +15,16 @@
 <html 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">
-<f:metadata>
-    <f:viewParam name="foo" binding="#{foo}"/>
-    <f:viewParam name="foo2" binding="#{componentBindingBean.viewParam}"/>
-</f:metadata>
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:testComposite="http://java.sun.com/jsf/composite/testComposite">
 <h:head>
 </h:head>
 <h:body>
   <h:panelGroup id="panel" binding="#{componentBindingBean.panel}"/>
   <h:form id="mainForm">
+     <ui:repeat var="item" value="#{testBean.values}">
+        <testComposite:testUIRepeatCC item="#{item}"/>
+     </ui:repeat>
      <h:commandButton id="postback" value="POSTBACK"/>
   </h:form>
 </h:body>

Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/testUIRepeatCC.xhtml (from r1638905, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/testUIRepeatCC.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/testUIRepeatCC.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_1.xhtml&r1=1638905&r2=1641508&rev=1641508&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/dynComp_1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/pss/acid/resources/testComposite/testUIRepeatCC.xhtml Mon Nov 24 23:18:12 2014
@@ -19,13 +19,12 @@
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:cc="http://java.sun.com/jsf/composite">
 <cc:interface>
-    <cc:facet name="header" required="true"/>
+    <cc:attribute name="item" required="true"/>
 </cc:interface>
 <cc:implementation>
-    <h:panelGrid>
-        <cc:insertFacet name="header"/>
-    </h:panelGrid>
-    Dynamically added markup
-    <h:outputText value="Dynamically added child"/>
+    <h:outputText id="compToUpdate" value="Component: #{cc.attrs.item.value}"/>
+    <h:commandButton id="refresh" value="Refresh">
+        <f:ajax render="compToUpdate"/>
+    </h:commandButton>
 </cc:implementation>
 </html>
\ No newline at end of file