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/05/31 23:11:59 UTC
svn commit: r780506 -
/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/
Author: gpetracek
Date: Sun May 31 21:11:58 2009
New Revision: 780506
URL: http://svn.apache.org/viewvc?rev=780506&view=rev
Log:
EXTVAL-43 some test-cases
Added:
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/ParameterTestCase.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestAllowClientSideValidation.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestDenyClientSideValidation.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPerson.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriority.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityHigh.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityLow.java
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/ParameterTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/ParameterTestCase.java?rev=780506&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/ParameterTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/ParameterTestCase.java Sun May 31 21:11:58 2009
@@ -0,0 +1,76 @@
+/*
+ * 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.baseval.parameter;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameterExtractor;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.DefaultValidationParameterExtractor;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ViolationSeverity;
+import org.apache.myfaces.extensions.validator.baseval.annotation.Required;
+
+import javax.faces.application.FacesMessage;
+
+public class ParameterTestCase extends TestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(ParameterTestCase.class);
+ }
+
+ public void testParameterStyleOne() throws Exception
+ {
+ ValidationParameterExtractor extractor = new DefaultValidationParameterExtractor();
+
+ TestPerson person = new TestPerson();
+ Required required = person.getClass().getDeclaredField("firstName").getAnnotation(Required.class);
+
+ assertNotNull(extractor.extract(required).containsKey(ViolationSeverity.class));
+ assertNotNull(extractor.extract(required, ViolationSeverity.class).iterator().next());
+ assertEquals(extractor.extract(required, ViolationSeverity.class).iterator().next(), FacesMessage.SEVERITY_WARN);
+ }
+
+ public void testParameterStyleTwo() throws Exception
+ {
+ ValidationParameterExtractor extractor = new DefaultValidationParameterExtractor();
+
+ TestPerson person = new TestPerson();
+ Required required = person.getClass().getDeclaredField("lastName").getAnnotation(Required.class);
+
+ assertNotNull(extractor.extract(required).containsKey("client_side_validation_support"));
+ assertNotNull(extractor.extract(required, "client_side_validation_support").iterator().next());
+ assertEquals(extractor.extract(required, "client_side_validation_support").iterator().next(), false);
+ }
+
+ public void testParameterStyleThree() throws Exception
+ {
+ ValidationParameterExtractor extractor = new DefaultValidationParameterExtractor();
+
+ TestPerson person = new TestPerson();
+ Required required = person.getClass().getDeclaredField("lastName").getAnnotation(Required.class);
+
+ assertNotNull(extractor.extract(required).containsKey(TestPriority.class));
+ assertNotNull(extractor.extract(required, TestPriority.class).iterator().next());
+ assertEquals(extractor.extract(required, TestPriority.class, Integer.class).iterator().next(), new Integer(1));
+ assertEquals(extractor.extract(required, TestPriority.class, String.class).size(), 2);
+ assertEquals(extractor.extract(required, TestPriority.class, String.class, TestPriority.ShortDescription.class), "do it asap");
+ assertEquals(extractor.extract(required, TestPriority.class, String.class, TestPriority.LongDescription.class), "do it immediately");
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestAllowClientSideValidation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestAllowClientSideValidation.java?rev=780506&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestAllowClientSideValidation.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestAllowClientSideValidation.java Sun May 31 21:11:58 2009
@@ -0,0 +1,32 @@
+/*
+ * 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.baseval.parameter;
+
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ParameterValue;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ParameterKey;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameter;
+
+public interface TestAllowClientSideValidation extends ValidationParameter
+{
+ @ParameterKey
+ public String KEY = "client_side_validation_support";
+
+ @ParameterValue
+ boolean value = true;
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestDenyClientSideValidation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestDenyClientSideValidation.java?rev=780506&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestDenyClientSideValidation.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestDenyClientSideValidation.java Sun May 31 21:11:58 2009
@@ -0,0 +1,32 @@
+/*
+ * 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.baseval.parameter;
+
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ParameterValue;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ParameterKey;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameter;
+
+public interface TestDenyClientSideValidation extends ValidationParameter
+{
+ @ParameterKey
+ public String key = "client_side_validation_support";
+
+ @ParameterValue
+ boolean value = false;
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPerson.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPerson.java?rev=780506&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPerson.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPerson.java Sun May 31 21:11:58 2009
@@ -0,0 +1,54 @@
+/*
+ * 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.baseval.parameter;
+
+import org.apache.myfaces.extensions.validator.baseval.annotation.Required;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ViolationSeverity;
+
+public class TestPerson
+{
+ @Required(parameters = {ViolationSeverity.Warn.class, TestAllowClientSideValidation.class})
+ private String firstName;
+
+ @Required(parameters = {
+ ViolationSeverity.Info.class,
+ TestDenyClientSideValidation.class,
+ TestPriorityHigh.class})
+ private String lastName;
+
+ public String getFirstName()
+ {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName)
+ {
+ this.firstName = firstName;
+ }
+
+ public String getLastName()
+ {
+ return lastName;
+ }
+
+ public void setLastName(String lastName)
+ {
+ this.lastName = lastName;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriority.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriority.java?rev=780506&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriority.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriority.java Sun May 31 21:11:58 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.baseval.parameter;
+
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameter;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ParameterValue;
+
+public interface TestPriority extends ValidationParameter
+{
+ @ParameterValue
+ Integer getValue();
+
+ @ParameterValue(id = ShortDescription.class)
+ String getShortDescription();
+
+ @ParameterValue(id = LongDescription.class)
+ String getLongDescription();
+
+ interface ShortDescription{}
+ interface LongDescription{}
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityHigh.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityHigh.java?rev=780506&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityHigh.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityHigh.java Sun May 31 21:11:58 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.baseval.parameter;
+
+public class TestPriorityHigh implements TestPriority
+{
+ public Integer getValue()
+ {
+ return 1;
+ }
+
+ public String getShortDescription()
+ {
+ return "do it asap";
+ }
+
+ public String getLongDescription()
+ {
+ return "do it immediately";
+ }
+
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityLow.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityLow.java?rev=780506&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityLow.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/test/baseval/parameter/TestPriorityLow.java Sun May 31 21:11:58 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.baseval.parameter;
+
+public class TestPriorityLow implements TestPriority
+{
+ public Integer getValue()
+ {
+ return 3;
+ }
+
+ public String getShortDescription()
+ {
+ return "not that important";
+ }
+
+ public String getLongDescription()
+ {
+ return "the topic is not that important";
+ }
+}
\ No newline at end of file