You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2009/11/11 00:35:37 UTC
svn commit: r834709 - in
/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval:
./ model/ validation/ view/
Author: gpetracek
Date: Tue Nov 10 23:35:37 2009
New Revision: 834709
URL: http://svn.apache.org/viewvc?rev=834709&view=rev
Log:
EXTVAL-30 bv model validation and group validation test cases
Added:
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ModelValidation4TestCase.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/UseGroupValidation1TestCase.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/GroupValidationTestCase1Bean.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/ModelValidationTestCase2Bean.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator1.java
- copied, changed from r833899, myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator2.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group1.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group2.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group3.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/ModelValidationTestCase4PageBean.java
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/UseGroupValidationTestCase1PageBean.java
Removed:
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator.java
Modified:
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqual.java
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ModelValidation4TestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ModelValidation4TestCase.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ModelValidation4TestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ModelValidation4TestCase.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,79 @@
+/*
+ * 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.view.ModelValidationTestCase4PageBean;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+
+public class ModelValidation4TestCase extends
+ BaseBeanValPropertyValidationTestCase<ModelValidationTestCase4PageBean>
+{
+ public ModelValidation4TestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(ModelValidation4TestCase.class);
+ }
+
+ protected ModelValidationTestCase4PageBean getBeanToTest()
+ {
+ return new ModelValidationTestCase4PageBean();
+ }
+
+ public void testModelValidationNoViewIdMatch()
+ {
+ validate();
+
+ assertNavigationBlocked(false);
+
+ checkMessageCount(0);
+ }
+
+ public void testModelValidationViewIdMatch()
+ {
+ FacesContext.getCurrentInstance().getViewRoot().setViewId("/pages/modelValidationAwarePage.xhtml");
+
+ validate();
+
+ assertNavigationBlocked(true);
+
+ checkMessageCount(1);
+ checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+ }
+
+ private void validate()
+ {
+ createValueBindingForComponent(this.inputComponent1, "#{testBean.model.property1}");
+ setValueToValidate(this.inputComponent1, "123");
+
+ createValueBindingForComponent(this.inputComponent2, "#{testBean.model.property2}");
+ setValueToValidate(this.inputComponent2, "456");
+
+ validateComponents();
+ updateComponents();
+ processModelValidation();
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/UseGroupValidation1TestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/UseGroupValidation1TestCase.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/UseGroupValidation1TestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/UseGroupValidation1TestCase.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,186 @@
+/*
+ * 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 junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.extensions.validator.test.beanval.view.UseGroupValidationTestCase1PageBean;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+
+public class UseGroupValidation1TestCase extends BaseBeanValPropertyValidationTestCase<UseGroupValidationTestCase1PageBean>
+{
+ public UseGroupValidation1TestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(UseGroupValidation1TestCase.class);
+ }
+
+ protected UseGroupValidationTestCase1PageBean getBeanToTest()
+ {
+ return new UseGroupValidationTestCase1PageBean();
+ }
+
+ public void testGroup1AwareValidation()
+ {
+ createValueBindingForComponent(this.inputComponent1, "#{testBean.model1.property1}");
+ createValueBindingForComponent(this.inputComponent2, "#{testBean.model1.property2}");
+ setValueToValidate(this.inputComponent1, "");
+ setValueToValidate(this.inputComponent2, "");
+
+ validateComponents();
+
+ assertComponentInvalid(this.inputComponent1);
+ assertComponentValid(this.inputComponent2);
+ assertNavigationBlocked(true);
+
+ checkMessageCount(1);
+ checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+ }
+
+ public void testGroup1AndGroup2AwareValidation()
+ {
+ createValueBindingForComponent(this.inputComponent1, "#{testBean.model2.property1}");
+ createValueBindingForComponent(this.inputComponent2, "#{testBean.model2.property2}");
+ setValueToValidate(this.inputComponent1, "");
+ setValueToValidate(this.inputComponent2, "");
+
+ validateComponents();
+
+ assertComponentInvalid(this.inputComponent1);
+ assertComponentInvalid(this.inputComponent2);
+ assertNavigationBlocked(true);
+
+ checkMessageCount(2);
+ checkMessageSeverities(FacesMessage.SEVERITY_ERROR, FacesMessage.SEVERITY_ERROR);
+ }
+
+ public void testGroup2AndGroup3AwareValidationWithWrongViewId()
+ {
+ createValueBindingForComponent(this.inputComponent1, "#{testBean.model3.property1}");
+ createValueBindingForComponent(this.inputComponent2, "#{testBean.model3.property2}");
+ setValueToValidate(this.inputComponent1, "g");
+ setValueToValidate(this.inputComponent2, "p");
+
+ validateComponents();
+
+ assertComponentValid(this.inputComponent1);
+ assertComponentValid(this.inputComponent2);
+ assertNavigationBlocked(false);
+
+ checkMessageCount(0);
+ }
+
+ public void testGroup2AndGroup3AwareValidationWithCorrectViewId1()
+ {
+ FacesContext.getCurrentInstance().getViewRoot().setViewId("/pages/page1.xhtml");
+ createValueBindingForComponent(this.inputComponent1, "#{testBean.model3.property1}");
+ createValueBindingForComponent(this.inputComponent2, "#{testBean.model3.property2}");
+ setValueToValidate(this.inputComponent1, "g");
+ setValueToValidate(this.inputComponent2, "p");
+
+ validateComponents();
+
+ assertComponentValid(this.inputComponent1);
+ assertComponentInvalid(this.inputComponent2);
+ assertNavigationBlocked(true);
+
+ checkMessageCount(2);
+ checkMessageSeverities(FacesMessage.SEVERITY_ERROR, FacesMessage.SEVERITY_ERROR);
+ }
+
+ public void testGroup2AndGroup3AwareValidationWithCorrectViewId2()
+ {
+ FacesContext.getCurrentInstance().getViewRoot().setViewId("/pages/page2.xhtml");
+ createValueBindingForComponent(this.inputComponent1, "#{testBean.model3.property1}");
+ createValueBindingForComponent(this.inputComponent2, "#{testBean.model3.property2}");
+ setValueToValidate(this.inputComponent1, "g");
+ setValueToValidate(this.inputComponent2, "p");
+
+ validateComponents();
+
+ assertComponentValid(this.inputComponent1);
+ assertComponentInvalid(this.inputComponent2);
+ assertNavigationBlocked(true);
+
+ checkMessageCount(2);
+ checkMessageSeverities(FacesMessage.SEVERITY_ERROR, FacesMessage.SEVERITY_ERROR);
+ }
+
+ public void testGroup2AwareValidationWithRoleAdmin()
+ {
+ createRequestScopedBean("currentUser", new SimulatedUserInformation("admin"));
+ createValueBindingForComponent(this.inputComponent1, "#{testBean.model4.property1}");
+ createValueBindingForComponent(this.inputComponent2, "#{testBean.model4.property2}");
+ setValueToValidate(this.inputComponent1, "g"); //don't force a violation with Group1
+ setValueToValidate(this.inputComponent2, "");
+
+ validateComponents();
+
+ assertComponentValid(this.inputComponent1);
+ assertComponentInvalid(this.inputComponent2);
+ assertNavigationBlocked(true);
+
+ checkMessageCount(1);
+ checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+ }
+
+ public void testGroup2AndGroup3AwareValidationWithRoleUser()
+ {
+ createRequestScopedBean("currentUser", new SimulatedUserInformation("user"));
+ createValueBindingForComponent(this.inputComponent1, "#{testBean.model4.property1}");
+ createValueBindingForComponent(this.inputComponent2, "#{testBean.model4.property2}");
+ setValueToValidate(this.inputComponent1, "g");
+ setValueToValidate(this.inputComponent2, "p");
+
+ validateComponents();
+
+ assertComponentValid(this.inputComponent1);
+ assertComponentInvalid(this.inputComponent2);
+ assertNavigationBlocked(true);
+
+ checkMessageCount(2);
+ checkMessageSeverities(FacesMessage.SEVERITY_ERROR, FacesMessage.SEVERITY_ERROR);
+ }
+
+ public class SimulatedUserInformation
+ {
+ private String value;
+
+ SimulatedUserInformation(String value)
+ {
+ this.value = value;
+ }
+
+ public boolean isAdminRole()
+ {
+ return "admin".equals(value);
+ }
+
+ public boolean isUserRole()
+ {
+ return "user".equals(value);
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/GroupValidationTestCase1Bean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/GroupValidationTestCase1Bean.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/GroupValidationTestCase1Bean.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/GroupValidationTestCase1Bean.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.test.beanval.validation.Group1;
+import org.apache.myfaces.extensions.validator.test.beanval.validation.Group2;
+import org.apache.myfaces.extensions.validator.test.beanval.validation.Group3;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.constraints.Pattern;
+
+public class GroupValidationTestCase1Bean
+{
+ @NotNull(groups = Group1.class)
+ private String property1;
+
+ @Pattern(regexp = "[A-Z][a-z]", groups = Group3.class)
+ @Size(min = 3, groups = Group2.class)
+ @NotNull(groups = Group2.class)
+ private String property2;
+
+ 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;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/ModelValidationTestCase2Bean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/ModelValidationTestCase2Bean.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/ModelValidationTestCase2Bean.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/model/ModelValidationTestCase2Bean.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,57 @@
+/*
+ * 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.test.beanval.validation.ClassLevelEqual;
+import org.apache.myfaces.extensions.validator.beanval.annotation.BeanValidation;
+import org.apache.myfaces.extensions.validator.beanval.annotation.ModelValidation;
+
+import javax.validation.constraints.NotNull;
+
+@ClassLevelEqual
+@BeanValidation(viewIds = "/pages/modelValidationAwarePage.xhtml",
+ modelValidation = @ModelValidation(isActive = true))
+public class ModelValidationTestCase2Bean
+{
+ @NotNull
+ private String property1;
+
+ @NotNull
+ private String property2;
+
+ 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;
+ }
+}
\ No newline at end of file
Modified: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqual.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqual.java?rev=834709&r1=834708&r2=834709&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqual.java (original)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqual.java Tue Nov 10 23:35:37 2009
@@ -25,7 +25,7 @@
@java.lang.annotation.Target(TYPE)
@java.lang.annotation.Retention(RUNTIME)
@java.lang.annotation.Documented
-@javax.validation.Constraint(validatedBy = ClassLevelEqualsValidator.class)
+@javax.validation.Constraint(validatedBy = {ClassLevelEqualsValidator1.class, ClassLevelEqualsValidator2.class})
public @interface ClassLevelEqual
{
String message() default "class-level equal violation";
Copied: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator1.java (from r833899, myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator1.java?p2=myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator1.java&p1=myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator.java&r1=833899&r2=834709&rev=834709&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator.java (original)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator1.java Tue Nov 10 23:35:37 2009
@@ -23,7 +23,7 @@
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
-public class ClassLevelEqualsValidator implements
+public class ClassLevelEqualsValidator1 implements
ConstraintValidator<ClassLevelEqual, ModelValidationTestCase1Bean>
{
public void initialize(ClassLevelEqual parameters)
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator2.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator2.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator2.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/ClassLevelEqualsValidator2.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,42 @@
+/*
+ * 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.validation;
+
+import org.apache.myfaces.extensions.validator.test.beanval.model.ModelValidationTestCase2Bean;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+public class ClassLevelEqualsValidator2 implements
+ ConstraintValidator<ClassLevelEqual, ModelValidationTestCase2Bean>
+{
+ public void initialize(ClassLevelEqual parameters)
+ {
+ }
+
+ public boolean isValid(ModelValidationTestCase2Bean pageBean,
+ ConstraintValidatorContext constraintValidatorContext)
+ {
+ String property1 = pageBean.getProperty1();
+ String property2 = pageBean.getProperty2();
+
+ return property1 == null && property2 == null || property1 != null && property1.equals(property2);
+
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group1.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group1.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group1.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group1.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,23 @@
+/*
+ * 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.validation;
+
+public interface Group1
+{
+}
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group2.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group2.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group2.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group2.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,23 @@
+/*
+ * 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.validation;
+
+public interface Group2
+{
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group3.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group3.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group3.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/validation/Group3.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,23 @@
+/*
+ * 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.validation;
+
+public interface Group3
+{
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/ModelValidationTestCase4PageBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/ModelValidationTestCase4PageBean.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/ModelValidationTestCase4PageBean.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/ModelValidationTestCase4PageBean.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,31 @@
+/*
+ * 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.view;
+
+import org.apache.myfaces.extensions.validator.test.beanval.model.ModelValidationTestCase2Bean;
+
+public class ModelValidationTestCase4PageBean
+{
+ private ModelValidationTestCase2Bean model = new ModelValidationTestCase2Bean();
+
+ public ModelValidationTestCase2Bean getModel()
+ {
+ return model;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/UseGroupValidationTestCase1PageBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/UseGroupValidationTestCase1PageBean.java?rev=834709&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/UseGroupValidationTestCase1PageBean.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/view/UseGroupValidationTestCase1PageBean.java Tue Nov 10 23:35:37 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.view;
+
+import org.apache.myfaces.extensions.validator.test.beanval.model.GroupValidationTestCase1Bean;
+import org.apache.myfaces.extensions.validator.test.beanval.validation.Group1;
+import org.apache.myfaces.extensions.validator.test.beanval.validation.Group2;
+import org.apache.myfaces.extensions.validator.test.beanval.validation.Group3;
+import org.apache.myfaces.extensions.validator.beanval.annotation.BeanValidation;
+
+@BeanValidation(useGroups = Group1.class)
+public class UseGroupValidationTestCase1PageBean
+{
+ private GroupValidationTestCase1Bean model1 = new GroupValidationTestCase1Bean();
+
+ private GroupValidationTestCase1Bean model2 = new GroupValidationTestCase1Bean();
+
+ @BeanValidation(viewIds = {"/pages/page1.xhtml", "/pages/page2.xhtml"},useGroups = {Group2.class, Group3.class})
+ private GroupValidationTestCase1Bean model3 = new GroupValidationTestCase1Bean();
+
+ @BeanValidation.List({
+ @BeanValidation(useGroups = Group2.class, conditions = "#{currentUser.adminRole}"),
+ @BeanValidation(useGroups = {Group2.class, Group3.class}, conditions = "#{currentUser.userRole}")
+ })
+ private GroupValidationTestCase1Bean model4 = new GroupValidationTestCase1Bean();
+
+ public GroupValidationTestCase1Bean getModel1()
+ {
+ return model1;
+ }
+
+ @BeanValidation(useGroups = Group2.class)
+ public GroupValidationTestCase1Bean getModel2()
+ {
+ return model2;
+ }
+
+ public GroupValidationTestCase1Bean getModel3()
+ {
+ return model3;
+ }
+
+ public GroupValidationTestCase1Bean getModel4()
+ {
+ return model4;
+ }
+}
\ No newline at end of file