myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r884962 - in /myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules: bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ bean-validation-tests/src/test/java/org/apache/myfaces/extensions...
Date Fri, 27 Nov 2009 19:10:36 GMT
Author: gpetracek
Date: Fri Nov 27 19:10:36 2009
New Revision: 884962

URL: http://svn.apache.org/viewvc?rev=884962&view=rev
Log:
EXTVAL-73 test cases

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/CustomSeverity1TestCase.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/custom/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/custom/CustomViolationSeverity.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/view/CustomSeverityTestCase1PageBean.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/CustomSeverityTestBean.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/baseval/CustomSeverity1TestCase.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/custom/
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/custom/CustomViolationSeverity.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/CustomSeverity1TestCase.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/CustomSeverity1TestCase.java?rev=884962&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/CustomSeverity1TestCase.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/CustomSeverity1TestCase.java
Fri Nov 27 19:10:36 2009
@@ -0,0 +1,77 @@
+/*
+ * 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.CustomSeverityTestCase1PageBean;
+import org.apache.myfaces.extensions.validator.test.beanval.custom.CustomViolationSeverity;
+import org.apache.myfaces.extensions.validator.beanval.payload.ViolationSeverity;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+
+import javax.faces.application.FacesMessage;
+
+public class CustomSeverity1TestCase extends BaseBeanValPropertyValidationTestCase<CustomSeverityTestCase1PageBean>
+{
+    public CustomSeverity1TestCase(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(CustomSeverity1TestCase.class);
+    }
+
+    protected CustomSeverityTestCase1PageBean getBeanToTest()
+    {
+        return new CustomSeverityTestCase1PageBean();
+    }
+
+    public void testCustomPayload()
+    {
+        ExtValContext.getContext()
+                .addGlobalProperty(ViolationSeverity.Warn.class.getName(), CustomViolationSeverity.Warning.class);
+
+        createValueBindingForComponent(this.inputComponent1, "#{testBean.property1}");
+        setValueToValidate(this.inputComponent1, "");
+
+        validateComponents();
+
+        assertComponentValid(this.inputComponent1);
+        assertNavigationBlocked(false);
+
+        checkMessageCount(1);
+        checkMessageSeverities(FacesMessage.SEVERITY_WARN);
+    }
+
+    public void testUnknownPayload()
+    {
+        createValueBindingForComponent(this.inputComponent1, "#{testBean.property1}");
+        setValueToValidate(this.inputComponent1, "");
+
+        validateComponents();
+
+        assertComponentInvalid(this.inputComponent1);
+        assertNavigationBlocked(true);
+
+        checkMessageCount(1);
+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+    }
+}

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/custom/CustomViolationSeverity.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/custom/CustomViolationSeverity.java?rev=884962&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/custom/CustomViolationSeverity.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/custom/CustomViolationSeverity.java
Fri Nov 27 19:10:36 2009
@@ -0,0 +1,28 @@
+/*
+ * 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.custom;
+
+import javax.validation.Payload;
+
+public interface CustomViolationSeverity
+{
+    interface Warning extends Payload
+    {
+    }
+}

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/view/CustomSeverityTestCase1PageBean.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/view/CustomSeverityTestCase1PageBean.java?rev=884962&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/view/CustomSeverityTestCase1PageBean.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/view/CustomSeverityTestCase1PageBean.java
Fri Nov 27 19:10:36 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.view;
+
+import org.apache.myfaces.extensions.validator.test.beanval.custom.CustomViolationSeverity;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class CustomSeverityTestCase1PageBean
+{
+    @NotNull(payload = CustomViolationSeverity.Warning.class)
+    private String property1;
+
+    public String getProperty1()
+    {
+        return property1;
+    }
+
+    public void setProperty1(String property1)
+    {
+        this.property1 = property1;
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/CustomSeverityTestBean.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/CustomSeverityTestBean.java?rev=884962&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/CustomSeverityTestBean.java
(added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/CustomSeverityTestBean.java
Fri Nov 27 19:10:36 2009
@@ -0,0 +1,38 @@
+/*
+ * 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.propval;
+
+import org.apache.myfaces.extensions.validator.baseval.annotation.Required;
+import org.apache.myfaces.extensions.validator.test.propval.custom.CustomViolationSeverity;
+
+public class CustomSeverityTestBean
+{
+    @Required(parameters = CustomViolationSeverity.Warning.class)
+    private String name;
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/CustomSeverity1TestCase.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/baseval/CustomSeverity1TestCase.java?rev=884962&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/CustomSeverity1TestCase.java
(added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/CustomSeverity1TestCase.java
Fri Nov 27 19:10:36 2009
@@ -0,0 +1,118 @@
+/*
+ * 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.propval.baseval;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.el.ValueBinding;
+import javax.faces.application.FacesMessage;
+
+import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;
+import org.apache.myfaces.extensions.validator.test.propval.CustomSeverityTestBean;
+import org.apache.myfaces.extensions.validator.test.propval.custom.CustomViolationSeverity;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ViolationSeverity;
+
+public class CustomSeverity1TestCase extends AbstractPropertyValidationTestCase
+{
+    private HtmlInputText inputComponent = null;
+
+    private UIViewRoot rootComponent = null;
+
+    private CustomSeverityTestBean bean = null;
+
+    public CustomSeverity1TestCase(String name)
+    {
+        super(name);
+        inputComponent = null;
+        rootComponent = null;
+        bean = null;
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(CustomSeverity1TestCase.class);
+    }
+
+    @SuppressWarnings({"UnusedDeclaration"})
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        bean = new CustomSeverityTestBean();
+        ValueBinding vb = application.createValueBinding("#{testBean}");
+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);
+
+        rootComponent = new UIViewRoot();
+        HtmlForm form = new HtmlForm();
+        form.setId("form");
+        rootComponent.getChildren().add(form);
+        inputComponent = new HtmlInputText();
+        form.getChildren().add(inputComponent);
+        inputComponent.setId("input1");
+    }
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+        inputComponent = null;
+        rootComponent = null;
+        bean = null;
+    }
+
+    public void testCustomValidationParameter() throws Exception
+    {
+        ExtValContext.getContext()
+                .addGlobalProperty(ViolationSeverity.class.getName(), CustomViolationSeverity.class);
+
+        createValueBinding(inputComponent, "value", "#{testBean.name}");
+
+        inputComponent.setSubmittedValue("");
+
+        inputComponent.validate(facesContext);
+
+        assertTrue(inputComponent.isValid());
+
+        assertNavigationBlocked(false);
+
+        checkMessageCount(1);
+        checkMessageSeverities(FacesMessage.SEVERITY_WARN);
+    }
+
+    public void testUnknownValidationParameter() throws Exception
+    {
+        createValueBinding(inputComponent, "value", "#{testBean.name}");
+
+        inputComponent.setSubmittedValue("");
+
+        inputComponent.validate(facesContext);
+
+        assertFalse(inputComponent.isValid());
+
+        assertNavigationBlocked(true);
+
+        checkMessageCount(1);
+        checkMessageSeverities(FacesMessage.SEVERITY_ERROR);
+    }
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/custom/CustomViolationSeverity.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/custom/CustomViolationSeverity.java?rev=884962&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/custom/CustomViolationSeverity.java
(added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/custom/CustomViolationSeverity.java
Fri Nov 27 19:10:36 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.propval.custom;
+
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameter;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ParameterKey;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ParameterValue;
+
+import javax.faces.application.FacesMessage;
+
+public interface CustomViolationSeverity
+{
+    interface Warning extends ValidationParameter
+    {
+        @ParameterKey
+        public Class KEY = CustomViolationSeverity.class;
+
+        @ParameterValue
+        FacesMessage.Severity SEVERITY = FacesMessage.SEVERITY_WARN;
+    }
+}



Mime
View raw message