Return-Path: X-Original-To: apmail-incubator-bval-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-bval-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CB20661D6 for ; Fri, 3 Jun 2011 17:14:48 +0000 (UTC) Received: (qmail 92498 invoked by uid 500); 3 Jun 2011 17:14:48 -0000 Delivered-To: apmail-incubator-bval-commits-archive@incubator.apache.org Received: (qmail 92473 invoked by uid 500); 3 Jun 2011 17:14:48 -0000 Mailing-List: contact bval-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bval-dev@incubator.apache.org Delivered-To: mailing list bval-commits@incubator.apache.org Received: (qmail 92466 invoked by uid 99); 3 Jun 2011 17:14:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Jun 2011 17:14:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Jun 2011 17:14:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4D79A23889E1; Fri, 3 Jun 2011 17:14:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: bval-commits@incubator.apache.org From: mbenson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110603171427.4D79A23889E1@eris.apache.org> 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() {