You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2011/10/21 10:09:28 UTC

svn commit: r1187200 - /myfaces/core/branches/2.0.x/api/src/test/java/javax/faces/component/UIComponentFindComponentTest.java

Author: bommel
Date: Fri Oct 21 08:09:27 2011
New Revision: 1187200

URL: http://svn.apache.org/viewvc?rev=1187200&view=rev
Log:
added test for (MYFACES-3364)

Modified:
    myfaces/core/branches/2.0.x/api/src/test/java/javax/faces/component/UIComponentFindComponentTest.java

Modified: myfaces/core/branches/2.0.x/api/src/test/java/javax/faces/component/UIComponentFindComponentTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/test/java/javax/faces/component/UIComponentFindComponentTest.java?rev=1187200&r1=1187199&r2=1187200&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/test/java/javax/faces/component/UIComponentFindComponentTest.java (original)
+++ myfaces/core/branches/2.0.x/api/src/test/java/javax/faces/component/UIComponentFindComponentTest.java Fri Oct 21 08:09:27 2011
@@ -118,6 +118,51 @@ public class UIComponentFindComponentTes
         assertEquals(_testImpl, namingContainer.findComponent(expression));
     }
 
+    public void testOverriddenFindComponent() {
+        UIViewRoot viewRoot = new UIViewRoot();
+        UIData uiData = new UIData()
+        {
+            public UIComponent findComponent(String expr)
+            {
+                return super.findComponent(stripRowIndex(expr));
+            }
+
+            public String stripRowIndex(String searchId) {
+                if (searchId.length() > 0 && Character.isDigit(searchId.charAt(0)))
+                {
+                    for (int i = 1; i < searchId.length(); ++i)
+                    {
+                        char c = searchId.charAt(i);
+                        if (c == SEPARATOR_CHAR)
+                        {
+                            searchId = searchId.substring(i + 1);
+                            break;
+                        }
+                        if (!Character.isDigit(c))
+                        {
+                            break;
+                        }
+                    }
+                }
+                return searchId;
+            }
+        };
+        uiData.setId("data");
+        UIColumn column = new UIColumn();
+        column.setId("column");
+        UICommand command = new UICommand();
+        command.setId("command");
+        viewRoot.getChildren().add(uiData);
+        uiData.getChildren().add(column);
+        column.getChildren().add(command);
+
+        assertNull(viewRoot.findComponent(":xx"));
+        assertNotNull(viewRoot.findComponent(":data"));
+        assertNotNull(viewRoot.findComponent(":data:column"));
+        assertNotNull(viewRoot.findComponent(":data:command"));
+        assertNotNull(viewRoot.findComponent(":data:1:command"));
+    }
+
     public void testWithRelativeExpressionNamingContainer() throws Exception
     {
         String expression = "testimpl";