incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1131113 - /incubator/bval/sandbox/lang3-work/bval-jsr303-dynamic/extval-shared-tests/src/main/java/org/apache/bval/jsr303/dynamic/extval/AllowedValuesComponentInitializerTestCase.java
Date Fri, 03 Jun 2011 17:14:27 GMT
Author: mbenson
Date: Fri Jun  3 17:14:26 2011
New Revision: 1131113

URL: http://svn.apache.org/viewvc?rev=1131113&view=rev
Log:
use util code

Modified:
    incubator/bval/sandbox/lang3-work/bval-jsr303-dynamic/extval-shared-tests/src/main/java/org/apache/bval/jsr303/dynamic/extval/AllowedValuesComponentInitializerTestCase.java

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303-dynamic/extval-shared-tests/src/main/java/org/apache/bval/jsr303/dynamic/extval/AllowedValuesComponentInitializerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303-dynamic/extval-shared-tests/src/main/java/org/apache/bval/jsr303/dynamic/extval/AllowedValuesComponentInitializerTestCase.java?rev=1131113&r1=1131112&r2=1131113&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303-dynamic/extval-shared-tests/src/main/java/org/apache/bval/jsr303/dynamic/extval/AllowedValuesComponentInitializerTestCase.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303-dynamic/extval-shared-tests/src/main/java/org/apache/bval/jsr303/dynamic/extval/AllowedValuesComponentInitializerTestCase.java
Fri Jun  3 17:14:26 2011
@@ -29,7 +29,6 @@ import java.util.Map;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.UISelectItems;
-import javax.faces.component.UISelectOne;
 import javax.faces.component.html.HtmlSelectOneListbox;
 import javax.faces.component.html.HtmlSelectOneMenu;
 import javax.faces.component.html.HtmlSelectOneRadio;
@@ -39,6 +38,7 @@ import javax.validation.metadata.Element
 
 import org.apache.bval.constraints.dynamic.Values;
 import org.apache.bval.constraints.dynamic.Values.Labeled.Item;
+import org.apache.bval.jsr303.dynamic.extval.util.ComponentUtils;
 import org.junit.Test;
 
 /**
@@ -129,7 +129,7 @@ public class AllowedValuesComponentIniti
     public void testSelectOneListbox() throws IOException {
         createValueBindingForComponent(selectOneListbox, "#{testBean.string}");
         selectOneListbox.encodeAll(facesContext);
-        UISelectItems items = findUISelectItems(selectOneListbox);
+        UISelectItems items = ComponentUtils.findFirstChildOfType(UISelectItems.class, selectOneListbox);
         assertNotNull(items);
         Object value = items.getValue();
         assertNotNull(value);
@@ -151,14 +151,14 @@ public class AllowedValuesComponentIniti
         UISelectItems empty = createEmptyUISelectItems();
         selectOneListbox.getChildren().add(empty);
         selectOneListbox.encodeAll(facesContext);
-        assertSame(empty, findUISelectItems(selectOneListbox));
+        assertSame(empty, ComponentUtils.findFirstChildOfType(UISelectItems.class, selectOneListbox));
     }
 
     @Test
     public void testSelectOneMenu() throws IOException {
         createValueBindingForComponent(selectOneMenu, "#{testBean.code}");
         selectOneMenu.encodeAll(facesContext);
-        UISelectItems items = findUISelectItems(selectOneMenu);
+        UISelectItems items = ComponentUtils.findFirstChildOfType(UISelectItems.class, selectOneMenu);
         assertNotNull(items);
         Object value = items.getValue();
         assertNotNull(value);
@@ -180,14 +180,14 @@ public class AllowedValuesComponentIniti
         UISelectItems empty = createEmptyUISelectItems();
         selectOneMenu.getChildren().add(empty);
         selectOneMenu.encodeAll(facesContext);
-        assertSame(empty, findUISelectItems(selectOneMenu));
+        assertSame(empty, ComponentUtils.findFirstChildOfType(UISelectItems.class, selectOneMenu));
     }
 
     @Test
     public void testSelectOneRadio() throws IOException {
         createValueBindingForComponent(selectOneRadio, "#{testBean.elementType}");
         selectOneRadio.encodeAll(facesContext);
-        UISelectItems items = findUISelectItems(selectOneRadio);
+        UISelectItems items = ComponentUtils.findFirstChildOfType(UISelectItems.class, selectOneRadio);
         assertNotNull(items);
         Object value = items.getValue();
         assertNotNull(value);
@@ -209,16 +209,7 @@ public class AllowedValuesComponentIniti
         UISelectItems empty = createEmptyUISelectItems();
         selectOneRadio.getChildren().add(empty);
         selectOneRadio.encodeAll(facesContext);
-        assertSame(empty, findUISelectItems(selectOneRadio));
-    }
-
-    protected UISelectItems findUISelectItems(UISelectOne parent) {
-        for (UIComponent child : parent.getChildren()) {
-            if (child instanceof UISelectItems) {
-                return (UISelectItems) child;
-            }
-        }
-        return null;
+        assertSame(empty, ComponentUtils.findFirstChildOfType(UISelectItems.class, selectOneRadio));
     }
 
     protected UISelectItems createEmptyUISelectItems() {



Mime
View raw message