myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r833628 - in /myfaces/extensions/validator/branches/branch_for_jsf_1_1: test-modules/ test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/ test-modules/bean-validation-tests/ test-modules/be...
Date Sat, 07 Nov 2009 04:58:55 GMT
Author: gpetracek
Date: Sat Nov  7 04:58:54 2009
New Revision: 833628

URL: http://svn.apache.org/viewvc?rev=833628&view=rev
Log:
EXTVAL-30 and refactored exception handling (bv integration)

Added:
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/AbstractBeanValidationTestCase.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/BaseBeanValPropertyValidationTestCase.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/DefaultGroupTestCase.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/TestCase1Bean.java
Modified:
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/pom.xml
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/pom.xml
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/AbstractPropertyValidationTestCase.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/CrossValTestCase.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ELCrossValTestCase.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValTestCase.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
Sat Nov  7 04:58:54 2009
@@ -28,6 +28,7 @@
 import javax.faces.FactoryFinder;
 import javax.faces.el.ValueBinding;
 import javax.faces.application.ApplicationFactory;
+import javax.faces.application.FacesMessage;
 import javax.faces.component.UIViewRoot;
 import javax.faces.component.UIInput;
 import javax.faces.render.RenderKit;
@@ -254,6 +255,21 @@
         assertEquals("Complete message count", expected, actual);
     }
 
+    protected void checkMessageSeverities(FacesMessage.Severity... severities)
+    {
+        int i = 0;
+        for(Iterator messages = facesContext.getMessages(); messages.hasNext();)
+        {
+            assertEquals(severities[i], ((FacesMessage)messages.next()).getSeverity());
+            i++;
+        }
+    }
+
+    protected void assertNavigationBlocked(boolean isBlocked)
+    {
+        assertEquals(isBlocked, this.facesContext.getRenderResponse());
+    }
+
     /**
      * Verify the following:
      * <ul>

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/pom.xml?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/pom.xml
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/pom.xml
Sat Nov  7 04:58:54 2009
@@ -30,8 +30,8 @@
     <version>1.1.3-SNAPSHOT</version>
 
     <parent>
-        <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
-        <artifactId>validation-modules-project</artifactId>
+        <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+        <artifactId>test-modules-project</artifactId>
         <version>1.1.3-SNAPSHOT</version>
     </parent>
 
@@ -40,7 +40,7 @@
             <groupId>javax.validation</groupId>
             <artifactId>validation-api</artifactId>
             <version>1.0.0.GA</version>
-            <scope>compile</scope>
+            <scope>test</scope>
         </dependency>
 
         <dependency>
@@ -63,7 +63,7 @@
             <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
             <artifactId>myfaces-extval-bean-validation</artifactId>
             <version>1.1.3-SNAPSHOT</version>
-            <scope>compile</scope>
+            <scope>test</scope>
         </dependency>
 
         <dependency>

Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/AbstractBeanValidationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/AbstractBeanValidationTestCase.java?rev=833628&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/AbstractBeanValidationTestCase.java
(added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/AbstractBeanValidationTestCase.java
Sat Nov  7 04:58:54 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.extensions.validator.test.beanval;
+
+import org.apache.myfaces.extensions.validator.test.base.AbstractExValTestCase;
+import org.apache.myfaces.extensions.validator.beanval.startup.BeanValidationStartupListener;
+import org.apache.myfaces.extensions.validator.beanval.validation.ModelValidationPhaseListener;
+
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+
+public class AbstractBeanValidationTestCase extends AbstractExValTestCase
+{
+    public AbstractBeanValidationTestCase(String name)
+    {
+        super(name);
+    }
+
+    protected void invokeStartupListeners()
+    {
+        new BeanValidationStartupListener() {
+
+            private static final long serialVersionUID = -3124182355444754497L;
+
+            @Override
+            protected void init()
+            {
+                super.init();
+            }
+        }.init();
+    }
+
+    protected void processModelValidation()
+    {
+        new ModelValidationPhaseListener().afterPhase(new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES,
lifecycle));
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/BaseBeanValPropertyValidationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/BaseBeanValPropertyValidationTestCase.java?rev=833628&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/BaseBeanValPropertyValidationTestCase.java
(added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/BaseBeanValPropertyValidationTestCase.java
Sat Nov  7 04:58:54 2009
@@ -0,0 +1,126 @@
+/*
+ * 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.extensions.validator.test.beanval;
+
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.UIInput;
+import javax.faces.el.ValueBinding;
+
+public abstract class BaseBeanValPropertyValidationTestCase<T> extends AbstractBeanValidationTestCase
+{
+    public BaseBeanValPropertyValidationTestCase(String name)
+    {
+        super(name);
+        inputComponent1 = null;
+        inputComponent2 = null;
+        inputComponent3 = null;
+        rootComponent = null;
+        bean = null;
+    }
+
+    protected HtmlInputText inputComponent1 = null;
+    protected HtmlInputText inputComponent2 = null;
+    protected HtmlInputText inputComponent3 = null;
+
+    private UIViewRoot rootComponent = null;
+
+    protected T bean;
+
+    @SuppressWarnings({"UnusedDeclaration"})
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        bean = getBeanToTest();
+        bindBeanToExpression();
+
+        createComponents();
+    }
+
+    private void createComponents()
+    {
+        rootComponent = new UIViewRoot();
+        HtmlForm form = new HtmlForm();
+        form.setId("form");
+        rootComponent.getChildren().add(form);
+        inputComponent1 = new HtmlInputText();
+        inputComponent2 = new HtmlInputText();
+        inputComponent3 = new HtmlInputText();
+        form.getChildren().add(inputComponent1);
+        form.getChildren().add(inputComponent2);
+        form.getChildren().add(inputComponent3);
+        inputComponent1.setId("input1");
+        inputComponent2.setId("input2");
+        inputComponent3.setId("input3");
+    }
+
+    @SuppressWarnings({"UnusedDeclaration"})
+    private void bindBeanToExpression()
+    {
+        ValueBinding vb = application.createValueBinding("#{testBean}");
+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);
+    }
+
+    protected abstract T getBeanToTest();
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        inputComponent1 = null;
+        inputComponent2 = null;
+        inputComponent3 = null;
+        rootComponent = null;
+        bean = null;
+    }
+
+    protected void createValueBindingForComponent(UIInput uiComponent, String valueBinding)
+    {
+        createValueBinding(uiComponent, "value", valueBinding);
+    }
+
+    protected void setValueToValidate(UIInput uiComponent, String valueToValidate)
+    {
+        uiComponent.setSubmittedValue(valueToValidate);
+    }
+
+    protected void validateComponents()
+    {
+        inputComponent1.processValidators(facesContext);
+        inputComponent2.processValidators(facesContext);
+        inputComponent3.processValidators(facesContext);
+    }
+
+    protected void assertComponentValid(UIInput uiInput)
+    {
+        assertTrue(isComponentValid(uiInput));
+    }
+
+    protected void assertComponentInvalid(UIInput uiInput)
+    {
+        assertFalse(isComponentValid(uiInput));
+    }
+
+    private boolean isComponentValid(UIInput uiComponent)
+    {
+        return uiComponent.isValid();
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/DefaultGroupTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/DefaultGroupTestCase.java?rev=833628&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/DefaultGroupTestCase.java
(added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/DefaultGroupTestCase.java
Sat Nov  7 04:58:54 2009
@@ -0,0 +1,85 @@
+/*
+ * 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.extensions.validator.test.beanval;
+
+import org.apache.myfaces.extensions.validator.test.beanval.model.TestCase1Bean;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import javax.faces.application.FacesMessage;
+
+public class DefaultGroupTestCase extends BaseBeanValPropertyValidationTestCase<TestCase1Bean>
+{
+    public DefaultGroupTestCase(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(DefaultGroupTestCase.class);
+    }
+
+    protected TestCase1Bean getBeanToTest()
+    {
+        return new TestCase1Bean();
+    }
+
+    public void testNotNullSeverityError()
+    {
+        createValueBindingForComponent(this.inputComponent1, "#{testBean.property1}");
+        setValueToValidate(this.inputComponent1, "");
+
+        validateComponents();
+
+        assertComponentInvalid(this.inputComponent1);
+        assertNavigationBlocked(true);
+
+        checkMessageCount(1);
+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+    }
+
+    public void testNotNullSeverityWarn()
+    {
+        createValueBindingForComponent(this.inputComponent1, "#{testBean.property2}");
+        setValueToValidate(this.inputComponent1, "");
+
+        validateComponents();
+
+        assertComponentValid(this.inputComponent1);
+        assertNavigationBlocked(false);
+
+        checkMessageCount(1);
+        checkMessageSeverities(FacesMessage.SEVERITY_WARN);
+    }
+
+    public void testSeverityOrder()
+    {
+        createValueBindingForComponent(this.inputComponent1, "#{testBean.property3}");
+        setValueToValidate(this.inputComponent1, "ab");
+
+        validateComponents();
+
+        assertComponentInvalid(this.inputComponent1);
+        assertNavigationBlocked(true);
+
+        checkMessageCount(2);
+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR, FacesMessage.SEVERITY_WARN);
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/TestCase1Bean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/TestCase1Bean.java?rev=833628&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/TestCase1Bean.java
(added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/TestCase1Bean.java
Sat Nov  7 04:58:54 2009
@@ -0,0 +1,68 @@
+/*
+ * 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.extensions.validator.test.beanval.model;
+
+import org.apache.myfaces.extensions.validator.beanval.payload.ViolationSeverity;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
+public class TestCase1Bean
+{
+    @NotNull
+    private String property1;
+
+    @NotNull(payload = ViolationSeverity.Warn.class)
+    private String property2;
+
+    @Size(min = 3, payload = ViolationSeverity.Warn.class)
+    @Pattern(regexp = "[A-Z][a-z]+", payload = ViolationSeverity.Error.class)
+    private String property3;
+
+    public String getProperty1()
+    {
+        return property1;
+    }
+
+    public void setProperty1(String property1)
+    {
+        this.property1 = property1;
+    }
+
+    public String getProperty2()
+    {
+        return property2;
+    }
+
+    public void setProperty2(String property2)
+    {
+        this.property2 = property2;
+    }
+
+    public String getProperty3()
+    {
+        return property3;
+    }
+
+    public void setProperty3(String property3)
+    {
+        this.property3 = property3;
+    }
+}

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/pom.xml?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/pom.xml (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/pom.xml Sat Nov
 7 04:58:54 2009
@@ -169,6 +169,7 @@
                 <configuration>
                     <excludes>
                         <exclude>**/Abstract*.java</exclude>
+                        <exclude>**/Base*.java</exclude>
                         <exclude>**/TestUtils.java</exclude>
                         <exclude>**/*Bean.java</exclude>
                     </excludes>

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/AbstractPropertyValidationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/AbstractPropertyValidationTestCase.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/AbstractPropertyValidationTestCase.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/AbstractPropertyValidationTestCase.java
Sat Nov  7 04:58:54 2009
@@ -45,7 +45,7 @@
         }.init();
     }
 
-    protected void processCrossValValidation()
+    protected void processCrossValidation()
     {
         new CrossValidationPhaseListener().afterPhase(new PhaseEvent(facesContext, PhaseId.ANY_PHASE,lifecycle));
     }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/CrossValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/CrossValTestCase.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/CrossValTestCase.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/CrossValTestCase.java
Sat Nov  7 04:58:54 2009
@@ -89,7 +89,7 @@
         inputComponent1.validate(facesContext);
         inputComponent2.validate(facesContext);
 
-        processCrossValValidation();
+        processCrossValidation();
         checkMessageCount(0);
 
         //no update model needed
@@ -109,9 +109,9 @@
         inputComponent2.validate(facesContext);
 
 
-        processCrossValValidation();
+        processCrossValidation();
         checkMessageCount(2);
 
         //no update model needed
     }
-}
\ No newline at end of file
+}

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ELCrossValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ELCrossValTestCase.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ELCrossValTestCase.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ELCrossValTestCase.java
Sat Nov  7 04:58:54 2009
@@ -119,7 +119,7 @@
         inputComponent1.validate(facesContext);
         inputComponent2.validate(facesContext);
 
-        processCrossValValidation();
+        processCrossValidation();
 
         //no update model needed
     }
@@ -154,7 +154,7 @@
         //validate
         inputComponent1.validate(facesContext);
 
-        processCrossValValidation();
+        processCrossValidation();
 
         //no update model needed
     }
@@ -163,4 +163,4 @@
     {
         return new ELCrossValTestDateBean();
     }
-}
\ No newline at end of file
+}

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValTestCase.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValTestCase.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValTestCase.java
Sat Nov  7 04:58:54 2009
@@ -110,7 +110,7 @@
         inputComponent1.validate(facesContext);
         inputComponent2.validate(facesContext);
 
-        processCrossValValidation();
+        processCrossValidation();
 
         //no update model needed
     }
@@ -143,7 +143,7 @@
         //validate
         inputComponent1.validate(facesContext);
 
-        processCrossValValidation();
+        processCrossValidation();
 
         //no update model needed
     }
@@ -152,4 +152,4 @@
     {
         return new PropertyChainCrossValTestDateBean();
     }
-}
\ No newline at end of file
+}

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationInterceptor.java
Sat Nov  7 04:58:54 2009
@@ -139,8 +139,7 @@
 
         if(violations != null && !violations.isEmpty())
         {
-            BeanValidationUtils
-                    .processConstraintViolations(facesContext, uiComponent, convertedObject,
violations, true);
+            BeanValidationUtils.processConstraintViolations(facesContext, uiComponent, convertedObject,
violations);
         }
     }
 

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java
Sat Nov  7 04:58:54 2009
@@ -29,6 +29,7 @@
 
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
+import javax.faces.component.EditableValueHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.validator.ValidatorException;
 import javax.validation.ConstraintViolation;
@@ -78,8 +79,7 @@
     public static void processConstraintViolations(FacesContext facesContext,
                                                    UIComponent uiComponent,
                                                    Object convertedObject,
-                                                   Set<ConstraintViolation> violations,
-                                                   boolean firstErrorCausesAnException)
+                                                   Set<ConstraintViolation> violations)
     {
         List<FacesMessageHolder> facesMessageHolderList = new ArrayList<FacesMessageHolder>();
 
@@ -96,7 +96,7 @@
             bvmi.processFacesMessage(facesContext, uiComponent, facesMessageHolderList, facesMessage);
         }
 
-        processViolationMessages(facesMessageHolderList, firstErrorCausesAnException);
+        processViolationMessages(facesMessageHolderList, uiComponent);
     }
 
     public static FacesMessage createFacesMessageForConstraintViolation(UIComponent uiComponent,
@@ -131,7 +131,7 @@
     }
 
     public static void processViolationMessages(List<FacesMessageHolder> violationMessageHolderList,
-                                                boolean firstErrorCausesAnException)
+                                                UIComponent uiComponent)
     {
         if (violationMessageHolderList == null || violationMessageHolderList.isEmpty())
         {
@@ -143,14 +143,21 @@
         List<FacesMessageHolder> facesMessageListWithHighSeverity =
                 bvmi.getFacesMessageListWithHighSeverity(violationMessageHolderList);
 
-        bvmi.addMessagesWithHighSeverity(facesMessageListWithHighSeverity, firstErrorCausesAnException);
-        bvmi.addMessagesWithLowSeverity(facesMessageListWithLowSeverity);
+        tryToSetComponentInvalid(uiComponent, facesMessageListWithHighSeverity);
 
-        if (!facesMessageListWithHighSeverity.isEmpty() && firstErrorCausesAnException)
+        bvmi.addMessages(facesMessageListWithHighSeverity);
+        bvmi.addMessages(facesMessageListWithLowSeverity);
+    }
+
+    private static void tryToSetComponentInvalid(
+            UIComponent uiComponent, List<FacesMessageHolder> facesMessageListWithHighSeverity)
+    {
+        if(!facesMessageListWithHighSeverity.isEmpty())
         {
-            FacesMessageHolder facesMessageHolder = facesMessageListWithHighSeverity.iterator().next();
-            ExtValUtils.tryToThrowValidatorExceptionForComponentId(
-                    facesMessageHolder.getClientId(), facesMessageHolder.getFacesMessage(),
null);
+            if(uiComponent instanceof EditableValueHolder)
+            {
+                ((EditableValueHolder)uiComponent).setValid(false);
+            }
         }
     }
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
Sat Nov  7 04:58:54 2009
@@ -637,26 +637,7 @@
         return result;
     }
 
-    void addMessagesWithHighSeverity(List<FacesMessageHolder> facesMessageHolderListWithHighSeverity,
-                                     boolean firstErrorCausesAnException)
-    {
-        boolean firstMessage = true;
-        for (FacesMessageHolder facesMessageHolder : facesMessageHolderListWithHighSeverity)
-        {
-            if (firstMessage && firstErrorCausesAnException)
-            {
-                //the first error will be thrown as exception
-                firstMessage = false;
-            }
-            else
-            {
-                ExtValUtils.tryToAddViolationMessageForComponentId(
-                        facesMessageHolder.getClientId(), facesMessageHolder.getFacesMessage());
-            }
-        }
-    }
-
-    void addMessagesWithLowSeverity(List<FacesMessageHolder> facesMessageHolderListWithLowSeverity)
+    void addMessages(List<FacesMessageHolder> facesMessageHolderListWithLowSeverity)
     {
         for (FacesMessageHolder facesMessageHolder : facesMessageHolderListWithLowSeverity)
         {

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java?rev=833628&r1=833627&r2=833628&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
Sat Nov  7 04:58:54 2009
@@ -31,6 +31,8 @@
 import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
 import org.apache.myfaces.extensions.validator.core.validation.message.FacesMessageHolder;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -426,11 +428,12 @@
                 );
     }
 
+    @ToDo(Priority.MEDIUM)
     private void processModelValidationResults(Map<String, ModelValidationResult> results)
     {
         for (ModelValidationResult result : results.values())
         {
-            BeanValidationUtils.processViolationMessages(result.getFacesMessageHolderList(),
false);
+            BeanValidationUtils.processViolationMessages(result.getFacesMessageHolderList(),
null);
         }
     }
 



Mime
View raw message