You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by rd...@apache.org on 2011/05/30 10:38:54 UTC
svn commit: r1129058 [7/13] - in
/myfaces/extensions/validator/branches/branch_for_jsf_2_0: ./ test-modules/
test-modules/base-test-infrastructure/
test-modules/base-test-infrastructure/src/
test-modules/base-test-infrastructure/src/test/ test-modules/...
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,103 @@
+/*
+ * 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.core.config;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.storage.PropertyStorage;
+import org.apache.myfaces.extensions.validator.core.validation.ConstraintSource;
+import org.apache.myfaces.extensions.validator.test.core.config.support.ConstraintSourceAwareBean;
+import org.apache.myfaces.extensions.validator.test.core.config.support.CustomConstraintSource;
+import org.apache.myfaces.extensions.validator.test.core.config.support.CustomTargetPropertyId;
+import org.apache.myfaces.extensions.validator.util.ConstraintSourceUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValAnnotationUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase extends ExtValCoreConfigurationTestCase
+{
+
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public Class<? extends Annotation> targetPropertyIdAnnotation()
+ {
+ return CustomTargetPropertyId.class;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testTargetPropertyIdAnnotationDefault() throws Exception
+ {
+ Method method = ReflectionUtils.getMethod(ConstraintSourceUtils.class, "getTargetPropertyMetaData",
+ PropertyStorage.class, Class.class, String.class);
+ Assert.assertNotNull(method);
+ PropertyStorage propertyStorage = ReflectionUtils.getPropertyStorage();
+ Annotation target = (Annotation) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ propertyStorage, ConstraintSourceAwareBean.class, "property5");
+
+ Assert.assertEquals(ConstraintSource.class.getName(), ((Class) ExtValAnnotationUtils.extractValueOf(target,
+ Object.class)).getName());
+
+ Assert.assertNull(ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ propertyStorage, ConstraintSourceAwareBean.class, "property6"));
+ }
+
+ @Test
+ public void testTargetPropertyIdAnnotationCustomConfig() throws Exception
+ {
+ Method method = ReflectionUtils.getMethod(ConstraintSourceUtils.class, "getTargetPropertyMetaData",
+ PropertyStorage.class, Class.class, String.class);
+ Assert.assertNotNull(method);
+ PropertyStorage propertyStorage = ReflectionUtils.getPropertyStorage();
+ Annotation target = (Annotation) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ propertyStorage, ConstraintSourceAwareBean.class, "property6");
+
+ Assert.assertEquals(CustomConstraintSource.class.getName(), ((Class) ExtValAnnotationUtils.extractValueOf(target,
+ Object.class)).getName());
+
+ Assert.assertNull(ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ propertyStorage, ConstraintSourceAwareBean.class, "property5"));
+ }
+
+
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,59 @@
+/*
+ * 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.core.config;
+
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import org.apache.myfaces.test.runners.NamedRunner;
+import org.apache.myfaces.test.runners.TestPerClassLoaderRunner;
+import org.junit.runner.RunWith;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+@RunWith(value = TestPerClassLoaderRunner.class)
+public abstract class ExtValCoreConfigurationTestCase extends
+ AbstractExValCoreTestCase
+{
+ protected String getName() {
+ return NamedRunner.getTestMethodName();
+ }
+
+ protected boolean needXmlParameters()
+ {
+ return getName().contains("Xml");
+ }
+
+ protected boolean needCustomConfig()
+ {
+ return !getName().contains("Xml") && !getName().contains("Default");
+ }
+
+ @Override
+ /*
+ * Made the method final because we do
+ */
+ protected final void invokeStartupListeners()
+ {
+ super.invokeStartupListeners();
+ }
+
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationValidateEmptyFieldsTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationValidateEmptyFieldsTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationValidateEmptyFieldsTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationValidateEmptyFieldsTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,110 @@
+/*
+ * 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.core.config;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.initializer.component.AbstractHtmlCoreComponentsComponentInitializer;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationValidateEmptyFieldsTestCase extends ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomComponentInitializer extends AbstractHtmlCoreComponentsComponentInitializer
+ {
+
+ @Override
+ protected void configureRequiredAttribute(FacesContext facesContext, UIComponent uiComponent,
+ Map<String, Object> metaData)
+ {
+
+ }
+
+ @Override
+ public boolean validateEmptyFields()
+ {
+ return super.validateEmptyFields();
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter("javax.faces.VALIDATE_EMPTY_FIELDS", "false");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean validateEmptyFields()
+ {
+ return false;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testValidateEmptyFieldsDefault()
+ {
+ CustomComponentInitializer initializer = new CustomComponentInitializer();
+ Assert.assertTrue(initializer.validateEmptyFields());
+ }
+
+ @Test
+ public void testValidateEmptyFieldsWebXml()
+ {
+ CustomComponentInitializer initializer = new CustomComponentInitializer();
+ Assert.assertFalse(initializer.validateEmptyFields());
+ }
+
+ @Test
+ public void testValidateEmptyFieldsCustomConfig()
+ {
+ CustomComponentInitializer initializer = new CustomComponentInitializer();
+ Assert.assertFalse(initializer.validateEmptyFields());
+ }
+
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationViolationSeverityTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationViolationSeverityTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationViolationSeverityTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationViolationSeverityTestCase.java Mon May 30 08:38:45 2011
@@ -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.core.config;
+
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ViolationSeverity;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationViolationSeverityTestCase extends ExtValCoreConfigurationTestCase
+{
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public Class violationSeverity()
+ {
+ return CustomViolationSeverity.class;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static interface CustomViolationSeverity
+ {
+
+ }
+
+ @Test
+ public void testViolationSeverityDefault()
+ {
+ Assert.assertEquals(ViolationSeverity.class.getName(), ((Class) ExtValContext.getContext().getGlobalProperty(
+ ViolationSeverity.class.getName())).getName());
+ }
+
+ @Test
+ public void testViolationSeverityCustomConfig()
+ {
+ Assert.assertEquals(CustomViolationSeverity.class.getName(), ((Class) ExtValContext.getContext().getGlobalProperty(
+ ViolationSeverity.class.getName())).getName());
+ }
+
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAware2MetaDataBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAware2MetaDataBean.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAware2MetaDataBean.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAware2MetaDataBean.java Mon May 30 08:38:45 2011
@@ -0,0 +1,24 @@
+/*
+ * 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.core.config.support;
+
+public class ConstraintSourceAware2MetaDataBean
+{
+
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareBean.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareBean.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareBean.java Mon May 30 08:38:45 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.core.config.support;
+
+import org.apache.myfaces.extensions.validator.core.validation.ConstraintSource;
+import org.apache.myfaces.extensions.validator.core.validation.IgnoreConstraintSource;
+import org.apache.myfaces.extensions.validator.core.validation.TargetProperty;
+import org.apache.myfaces.extensions.validator.core.validation.TargetPropertyId;
+
+@ConstraintSource(ConstraintSourceAwareMetaDataBean.class)
+public class ConstraintSourceAwareBean
+{
+ @IgnoreConstraintSource
+ private String property1;
+
+ @CustomIgnoreConstraintSource
+ private String property2;
+
+ @TargetProperty(value="test1")
+ private String property3;
+
+ @CustomTargetProperty(value="test2")
+ private String property4;
+
+ @TargetPropertyId(value=ConstraintSource.class)
+ private String property5;
+
+ @CustomTargetPropertyId(value=CustomConstraintSource.class)
+ private String property6;
+
+ public String getProperty1()
+ {
+ return property1;
+ }
+
+ public void setProperty1(String property1)
+ {
+ this.property1 = property1;
+ }
+
+ @CustomConstraintSource(ConstraintSourceAware2MetaDataBean.class)
+ public String getProperty2()
+ {
+ return property2;
+ }
+
+ public void setProperty2(String property2)
+ {
+ this.property2 = property2;
+ }
+}
+
+
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareMetaDataBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareMetaDataBean.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareMetaDataBean.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareMetaDataBean.java Mon May 30 08:38:45 2011
@@ -0,0 +1,24 @@
+/*
+ * 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.core.config.support;
+
+public class ConstraintSourceAwareMetaDataBean
+{
+
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomConstraintSource.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomConstraintSource.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomConstraintSource.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomConstraintSource.java Mon May 30 08:38:45 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.core.config.support;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+@Target({TYPE, FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+@UsageInformation(UsageCategory.API)
+public @interface CustomConstraintSource
+{
+ Class value();
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomIgnoreConstraintSource.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomIgnoreConstraintSource.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomIgnoreConstraintSource.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomIgnoreConstraintSource.java Mon May 30 08:38:45 2011
@@ -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.core.config.support;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+@UsageInformation(UsageCategory.API)
+public @interface CustomIgnoreConstraintSource
+{
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetProperty.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetProperty.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetProperty.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetProperty.java Mon May 30 08:38:45 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.core.config.support;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+public @interface CustomTargetProperty
+{
+ String value();
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetPropertyId.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetPropertyId.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetPropertyId.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetPropertyId.java Mon May 30 08:38:45 2011
@@ -0,0 +1,36 @@
+/*
+ * 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.core.config.support;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+public @interface CustomTargetPropertyId
+{
+ Class<? extends Annotation> value();
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,149 @@
+/*
+ * 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.core.el;
+
+import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.2
+ */
+public class ValueBindingExpressionTestCase extends AbstractExValCoreTestCase
+{
+
+ @Test
+ public void testStandardSyntax() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.property1}");
+
+ Assert.assertEquals("#{bean1.property1}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("property1", valueBindingExpression.getProperty());
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['property1']}");
+
+ Assert.assertEquals("#{bean1['property1']}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("property1", valueBindingExpression.getProperty());
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].property1}");
+
+ Assert.assertEquals("#{bean1['bean2'].property1}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1['bean2']}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getBaseExpression().getExpressionString());
+ Assert.assertEquals("property1", valueBindingExpression.getProperty());
+ }
+
+ @Test
+ public void testStandardSyntaxReplaceProperty() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.property1}");
+
+ valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");
+
+ Assert.assertEquals("#{bean1.property2}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("property2", valueBindingExpression.getProperty());
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['property1']}");
+
+ valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");
+
+ //TODO restore original syntax
+ Assert.assertEquals("#{bean1.property2}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("property2", valueBindingExpression.getProperty());
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].property1}");
+
+ valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");
+
+ Assert.assertEquals("#{bean1['bean2'].property2}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1['bean2']}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getBaseExpression().getExpressionString());
+ Assert.assertEquals("property2", valueBindingExpression.getProperty());
+ }
+
+ @Test
+ public void testStandardSyntaxAddProperty() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.bean2}");
+
+ valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");
+
+ Assert.assertEquals("#{bean1.bean2.property1}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1.bean2}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("property1", valueBindingExpression.getProperty());
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['bean2']}");
+
+ valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");
+
+ Assert.assertEquals("#{bean1['bean2'].property1}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1['bean2']}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("property1", valueBindingExpression.getProperty());
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].bean3}");
+
+ valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");
+
+ Assert.assertEquals("#{bean1['bean2'].bean3.property1}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{bean1['bean2'].bean3}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("#{bean1['bean2']}",
+ valueBindingExpression.getBaseExpression().getBaseExpression().getExpressionString());
+ Assert.assertEquals("property1", valueBindingExpression.getProperty());
+ }
+
+ @Test
+ public void testFaceletsCustomComponentSyntax() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{entity[fieldName]}");
+
+ Assert.assertEquals("#{entity[fieldName]}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{entity}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("fieldName", valueBindingExpression.getProperty());
+ }
+
+ @Test
+ public void testFaceletsCustomComponentSyntaxReplaceProperty() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{entity[fieldName]}");
+
+ valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "newFieldName");
+
+ //TODO restore original syntax
+ Assert.assertEquals("#{entity.newFieldName}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("#{entity}", valueBindingExpression.getBaseExpression().getExpressionString());
+ Assert.assertEquals("newFieldName", valueBindingExpression.getProperty());
+ }
+
+ @Test
+ public void testComplexMapSyntax() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression
+ = new ValueBindingExpression("#{bean1[bean2[bean3['key1']]].property1}");
+
+ //TODO
+ //assertEquals("#{bean1[bean2[bean3['key1']]].property1}", valueBindingExpression.getExpressionString());
+ Assert.assertEquals("property1", valueBindingExpression.getProperty());
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/initializer/RegistrationComponentInitializerTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/initializer/RegistrationComponentInitializerTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/initializer/RegistrationComponentInitializerTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/initializer/RegistrationComponentInitializerTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,110 @@
+/*
+ * 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.core.initializer;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.initializer.component.ComponentInitializer;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import java.util.Map;
+import java.util.List;
+
+public class RegistrationComponentInitializerTestCase extends AbstractExValCoreTestCase
+{
+ @Test
+ public void testComponentInitializerInitialization()
+ {
+ ExtValContext.getContext().addComponentInitializer(new TestComponentInitializer1000());
+ ExtValContext.getContext().addComponentInitializer(new TestComponentInitializer2());
+ ExtValContext.getContext().addComponentInitializer(new TestComponentInitializer());
+ ExtValContext.getContext().addComponentInitializer(new TestComponentInitializer3());
+ ExtValContext.getContext().addComponentInitializer(new TestComponentInitializer1());
+
+ List<ComponentInitializer> result = ExtValContext.getContext().getComponentInitializers();
+
+ int resultLength = 5;
+ Assert.assertTrue(result.size() == resultLength);
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertTrue(result.get(i) instanceof TestComponentInitializer1);
+ break;
+ case 1:
+ Assert.assertTrue(result.get(i) instanceof TestComponentInitializer2);
+ break;
+ case 2:
+ Assert.assertTrue(result.get(i) instanceof TestComponentInitializer3);
+ break;
+ case 3:
+ Assert.assertTrue(result.get(i) instanceof TestComponentInitializer1000);
+ break;
+ case 4:
+ Assert.assertTrue(result.get(i) instanceof TestComponentInitializer);
+ break;
+ }
+ }
+ }
+
+ class TestComponentInitializer implements ComponentInitializer
+ {
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+ }
+ }
+
+ @InvocationOrder(1)
+ class TestComponentInitializer1 implements ComponentInitializer
+ {
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+ }
+ }
+
+ @InvocationOrder(2)
+ class TestComponentInitializer2 implements ComponentInitializer
+ {
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+ }
+ }
+
+ @InvocationOrder(3)
+ class TestComponentInitializer3 implements ComponentInitializer
+ {
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+ }
+ }
+
+ @InvocationOrder(1000)
+ class TestComponentInitializer1000 implements ComponentInitializer
+ {
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationMetaDataExtractionInterceptorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationMetaDataExtractionInterceptorTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationMetaDataExtractionInterceptorTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationMetaDataExtractionInterceptorTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,108 @@
+/*
+ * 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.core.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.interceptor.MetaDataExtractionInterceptor;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+public class RegistrationMetaDataExtractionInterceptorTestCase extends AbstractExValCoreTestCase
+{
+ @Test
+ public void testMetaDataExtractionInterceptorInitialization()
+ {
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestMetaDataExtractionInterceptor1000());
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestMetaDataExtractionInterceptor2());
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestComponentInitializer());
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestMetaDataExtractionInterceptor3());
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestMetaDataExtractionInterceptor1());
+
+ List<MetaDataExtractionInterceptor> result = ExtValContext.getContext().getMetaDataExtractionInterceptors();
+
+ int resultLength = 5;
+ Assert.assertEquals(resultLength, result.size());
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestMetaDataExtractionInterceptor1.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(TestMetaDataExtractionInterceptor2.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestMetaDataExtractionInterceptor3.class, result.get(i).getClass());
+ break;
+ case 3:
+ Assert.assertEquals(TestMetaDataExtractionInterceptor1000.class, result.get(i).getClass());
+ break;
+ case 4:
+ Assert.assertEquals(TestComponentInitializer.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ class TestComponentInitializer implements MetaDataExtractionInterceptor
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+ }
+
+ @InvocationOrder(1)
+ class TestMetaDataExtractionInterceptor1 implements MetaDataExtractionInterceptor
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+ }
+
+ @InvocationOrder(2)
+ class TestMetaDataExtractionInterceptor2 implements MetaDataExtractionInterceptor
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+ }
+
+ @InvocationOrder(3)
+ class TestMetaDataExtractionInterceptor3 implements MetaDataExtractionInterceptor
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+ }
+
+ @InvocationOrder(1000)
+ class TestMetaDataExtractionInterceptor1000 implements MetaDataExtractionInterceptor
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationPropertyValidationInterceptorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationPropertyValidationInterceptorTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationPropertyValidationInterceptorTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationPropertyValidationInterceptorTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,139 @@
+/*
+ * 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.core.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.interceptor.PropertyValidationInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.FacesMessagePropertyValidationInterceptor;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import java.util.List;
+import java.util.Map;
+
+public class RegistrationPropertyValidationInterceptorTestCase extends AbstractExValCoreTestCase
+{
+ @Test
+ public void testPropertyValidationInterceptorInitialization()
+ {
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestComponentInitializer());
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestMetaDataExtractionInterceptor1000());
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestMetaDataExtractionInterceptor2());
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestMetaDataExtractionInterceptor3());
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestMetaDataExtractionInterceptor1());
+
+ List<PropertyValidationInterceptor> result = ExtValContext.getContext().getPropertyValidationInterceptors();
+
+ int resultLength = 6;
+ Assert.assertEquals(resultLength, result.size());
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestMetaDataExtractionInterceptor1.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(TestMetaDataExtractionInterceptor2.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestMetaDataExtractionInterceptor3.class, result.get(i).getClass());
+ break;
+ case 3:
+ Assert.assertEquals(FacesMessagePropertyValidationInterceptor.class, result.get(i).getClass());
+ break;
+ case 4:
+ Assert.assertEquals(TestMetaDataExtractionInterceptor1000.class, result.get(i).getClass());
+ break;
+ case 5:
+ Assert.assertEquals(TestComponentInitializer.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ class TestComponentInitializer implements PropertyValidationInterceptor
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+ }
+
+ @InvocationOrder(1)
+ class TestMetaDataExtractionInterceptor1 implements PropertyValidationInterceptor
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+ }
+
+ @InvocationOrder(2)
+ class TestMetaDataExtractionInterceptor2 implements PropertyValidationInterceptor
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+ }
+
+ @InvocationOrder(3)
+ class TestMetaDataExtractionInterceptor3 implements PropertyValidationInterceptor
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+ }
+
+ @InvocationOrder(1000)
+ class TestMetaDataExtractionInterceptor1000 implements PropertyValidationInterceptor
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationValidationExceptionInterceptorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationValidationExceptionInterceptorTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationValidationExceptionInterceptorTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationValidationExceptionInterceptorTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,128 @@
+/*
+ * 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.core.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.interceptor.ValidationExceptionInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.HtmlCoreComponentsValidationExceptionInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.ViolationSeverityValidationExceptionInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.ViolationExceptionInterceptor;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.faces.component.UIComponent;
+import javax.faces.validator.ValidatorException;
+import java.util.List;
+
+public class RegistrationValidationExceptionInterceptorTestCase extends AbstractExValCoreTestCase
+{
+ @Test
+ public void testValidationExceptionInterceptorInitialization()
+ {
+ ExtValContext.getContext().addValidationExceptionInterceptor(new TestValidationExceptionInterceptor1());
+ ExtValContext.getContext().addValidationExceptionInterceptor(new TestValidationExceptionInterceptor2());
+ ExtValContext.getContext().addValidationExceptionInterceptor(new TestValidationExceptionInterceptor3());
+ ExtValContext.getContext().addValidationExceptionInterceptor(new TestValidationExceptionInterceptor1000());
+ ExtValContext.getContext().addValidationExceptionInterceptor(new TestValidationExceptionInterceptor());
+
+ List<ValidationExceptionInterceptor> result = ExtValContext.getContext().getValidationExceptionInterceptors();
+
+ int resultLength = 8;
+ Assert.assertEquals(resultLength, result.size());
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestValidationExceptionInterceptor1.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(TestValidationExceptionInterceptor2.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestValidationExceptionInterceptor3.class, result.get(i).getClass());
+ break;
+ case 3:
+ Assert.assertEquals(ViolationSeverityValidationExceptionInterceptor.class, result.get(i).getClass());
+ break;
+ case 4:
+ Assert.assertEquals(HtmlCoreComponentsValidationExceptionInterceptor.class, result.get(i).getClass());
+ break;
+ case 5:
+ Assert.assertEquals(ViolationExceptionInterceptor.class, result.get(i).getClass());
+ break;
+ case 6:
+ Assert.assertEquals(TestValidationExceptionInterceptor1000.class, result.get(i).getClass());
+ break;
+ case 7:
+ Assert.assertEquals(TestValidationExceptionInterceptor.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ class TestValidationExceptionInterceptor implements ValidationExceptionInterceptor
+ {
+ public boolean afterThrowing(UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject, ValidatorException validatorException, ValidationStrategy validatorExceptionSource)
+ {
+ return true;
+ }
+ }
+
+ @InvocationOrder(1)
+ class TestValidationExceptionInterceptor1 implements ValidationExceptionInterceptor
+ {
+ public boolean afterThrowing(UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject, ValidatorException validatorException, ValidationStrategy validatorExceptionSource)
+ {
+ return true;
+ }
+ }
+
+ @InvocationOrder(2)
+ class TestValidationExceptionInterceptor2 implements ValidationExceptionInterceptor
+ {
+ public boolean afterThrowing(UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject, ValidatorException validatorException, ValidationStrategy validatorExceptionSource)
+ {
+ return true;
+ }
+ }
+
+ @InvocationOrder(3)
+ class TestValidationExceptionInterceptor3 implements ValidationExceptionInterceptor
+ {
+ public boolean afterThrowing(UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject, ValidatorException validatorException, ValidationStrategy validatorExceptionSource)
+ {
+ return true;
+ }
+ }
+
+ @InvocationOrder(1000)
+ class TestValidationExceptionInterceptor1000 implements ValidationExceptionInterceptor
+ {
+ public boolean afterThrowing(UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject, ValidatorException validatorException, ValidationStrategy validatorExceptionSource)
+ {
+ return true;
+ }
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationMetaDataToValidationStrategyNameMapperTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationMetaDataToValidationStrategyNameMapperTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationMetaDataToValidationStrategyNameMapperTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationMetaDataToValidationStrategyNameMapperTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,197 @@
+/*
+ * 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.core.mapper;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.factory.NameMapperAwareFactory;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.mapper.*;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import org.apache.myfaces.extensions.validator.test.base.mock.MockValidationStrategyFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+public class RegistrationMetaDataToValidationStrategyNameMapperTestCase extends AbstractExValCoreTestCase
+{
+
+ @Test
+ public void testMetaDataToValidationStrategyNameMapperInitialization()
+ {
+ ExtValUtils.registerMetaDataToValidationStrategyNameMapper(
+ new TestValidationStrategyNameMapper());
+ ExtValUtils.registerMetaDataToValidationStrategyNameMapper(
+ new TestValidationStrategyNameMapper650());
+ ExtValUtils.registerMetaDataToValidationStrategyNameMapper(
+ new TestValidationStrategyNameMapper150());
+ ExtValUtils.registerMetaDataToValidationStrategyNameMapper(
+ new TestValidationStrategyNameMapper450());
+ ExtValUtils.registerMetaDataToValidationStrategyNameMapper(
+ new TestValidationStrategyNameMapper250());
+ ExtValUtils.registerMetaDataToValidationStrategyNameMapper(
+ new TestValidationStrategyNameMapper550());
+ ExtValUtils.registerMetaDataToValidationStrategyNameMapper(
+ new TestValidationStrategyNameMapper99());
+ ExtValUtils.registerMetaDataToValidationStrategyNameMapper(
+ new TestValidationStrategyNameMapper350());
+
+ List<NameMapper<String>> result = getNameMappers();
+ int resultLength = 16;
+ Assert.assertEquals(resultLength, result.size());
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestValidationStrategyNameMapper99.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(CustomConfiguredAnnotationToValidationStrategyNameMapper.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestValidationStrategyNameMapper150.class, result.get(i).getClass());
+ break;
+ case 3:
+ Assert.assertEquals(CustomConventionAnnotationToValidationStrategyNameMapper.class, result.get(i).getClass());
+ break;
+ case 4:
+ Assert.assertEquals(TestValidationStrategyNameMapper250.class, result.get(i).getClass());
+ break;
+ case 5:
+ Assert.assertEquals(DefaultAnnotationToValidationStrategyNameMapper.class, result.get(i).getClass());
+ break;
+ case 6:
+ Assert.assertEquals(TestValidationStrategyNameMapper350.class, result.get(i).getClass());
+ break;
+ case 7:
+ Assert.assertEquals(SimpleAnnotationToValidationStrategyNameMapper.class, result.get(i).getClass());
+ break;
+ case 8:
+ Assert.assertEquals(TestValidationStrategyNameMapper450.class, result.get(i).getClass());
+ break;
+ case 9:
+ Assert.assertEquals(AnnotationToValidationStrategyBeanNameMapper.class, result.get(i).getClass());
+ break;
+ case 10:
+ Assert.assertEquals(AnnotationToValidationStrategyBeanNameMapper.class, result.get(i).getClass());
+ break;
+ case 11:
+ Assert.assertEquals(AnnotationToValidationStrategyBeanNameMapper.class, result.get(i).getClass());
+ break;
+ case 12:
+ Assert.assertEquals(AnnotationToValidationStrategyBeanNameMapper.class, result.get(i).getClass());
+ break;
+ case 13:
+ Assert.assertEquals(TestValidationStrategyNameMapper550.class, result.get(i).getClass());
+ break;
+ case 14:
+ Assert.assertEquals(TestValidationStrategyNameMapper650.class, result.get(i).getClass());
+ break;
+ case 15:
+ Assert.assertEquals(TestValidationStrategyNameMapper.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ private List<NameMapper<String>> getNameMappers()
+ {
+ NameMapperAwareFactory result = ExtValContext.getContext()
+ .getFactoryFinder()
+ .getFactory(FactoryNames.VALIDATION_STRATEGY_FACTORY, NameMapperAwareFactory.class);
+
+ return ((MockValidationStrategyFactory)result).getRegisteredNameMapperList();
+ }
+
+ class TestValidationStrategyNameMapper extends AbstractMetaDataToValidationStrategyNameMapper
+ {
+ public String createName(String source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(99)
+ class TestValidationStrategyNameMapper99 extends AbstractMetaDataToValidationStrategyNameMapper
+ {
+ public String createName(String source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(150)
+ class TestValidationStrategyNameMapper150 extends AbstractMetaDataToValidationStrategyNameMapper
+ {
+ public String createName(String source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(250)
+ class TestValidationStrategyNameMapper250 extends AbstractMetaDataToValidationStrategyNameMapper
+ {
+ public String createName(String source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(350)
+ class TestValidationStrategyNameMapper350 extends AbstractMetaDataToValidationStrategyNameMapper
+ {
+ public String createName(String source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(450)
+ class TestValidationStrategyNameMapper450 extends AbstractMetaDataToValidationStrategyNameMapper
+ {
+ public String createName(String source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(550)
+ class TestValidationStrategyNameMapper550 extends AbstractMetaDataToValidationStrategyNameMapper
+ {
+ public String createName(String source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(650)
+ class TestValidationStrategyNameMapper650 extends AbstractMetaDataToValidationStrategyNameMapper
+ {
+ public String createName(String source)
+ {
+ return null;
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationValidationStrategyToMessageResolverNameMapperTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationValidationStrategyToMessageResolverNameMapperTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationValidationStrategyToMessageResolverNameMapperTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationValidationStrategyToMessageResolverNameMapperTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,189 @@
+/*
+ * 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.core.mapper;
+
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.factory.NameMapperAwareFactory;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.validation.message.resolver.mapper.*;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import org.apache.myfaces.extensions.validator.test.base.mock.MockMessageResolverFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+public class RegistrationValidationStrategyToMessageResolverNameMapperTestCase extends AbstractExValCoreTestCase
+{
+
+ @Test
+ public void testValidationStrategyToMessageResolverNameMapperInitialization()
+ {
+ ExtValUtils.registerValidationStrategyToMessageResolverNameMapper(
+ new TestMessageResolverNameMapper());
+ ExtValUtils.registerValidationStrategyToMessageResolverNameMapper(
+ new TestMessageResolverNameMapper301());
+ ExtValUtils.registerValidationStrategyToMessageResolverNameMapper(
+ new TestMessageResolverNameMapper150());
+ ExtValUtils.registerValidationStrategyToMessageResolverNameMapper(
+ new TestMessageResolverNameMapper450());
+ ExtValUtils.registerValidationStrategyToMessageResolverNameMapper(
+ new TestMessageResolverNameMapper250());
+ ExtValUtils.registerValidationStrategyToMessageResolverNameMapper(
+ new TestMessageResolverNameMapper550());
+ ExtValUtils.registerValidationStrategyToMessageResolverNameMapper(
+ new TestMessageResolverNameMapper99());
+ ExtValUtils.registerValidationStrategyToMessageResolverNameMapper(
+ new TestMessageResolverNameMapper350());
+
+ List<NameMapper<ValidationStrategy>> result = getNameMappers();
+ int resultLength = 13;
+ Assert.assertEquals(resultLength, result.size());
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestMessageResolverNameMapper99.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(CustomConfiguredValidationStrategyToMsgResolverNameMapper.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestMessageResolverNameMapper150.class, result.get(i).getClass());
+ break;
+ case 3:
+ Assert.assertEquals(CustomConventionValidationStrategyToMsgResolverNameMapper.class, result.get(i).getClass());
+ break;
+ case 4:
+ Assert.assertEquals(TestMessageResolverNameMapper250.class, result.get(i).getClass());
+ break;
+ case 5:
+ Assert.assertEquals(DefaultValidationStrategyToMsgResolverNameMapper.class, result.get(i).getClass());
+ break;
+ case 6:
+ Assert.assertEquals(TestMessageResolverNameMapper301.class, result.get(i).getClass());
+ break;
+ case 7:
+ Assert.assertEquals(DefaultModuleValidationStrategyToMsgResolverNameMapper.class, result.get(i).getClass());
+ break;
+ case 8:
+ Assert.assertEquals(TestMessageResolverNameMapper350.class, result.get(i).getClass());
+ break;
+ case 9:
+ Assert.assertEquals(SimpleValidationStrategyToMsgResolverNameMapper.class, result.get(i).getClass());
+ break;
+ case 10:
+ Assert.assertEquals(TestMessageResolverNameMapper450.class, result.get(i).getClass());
+ break;
+ case 11:
+ Assert.assertEquals(TestMessageResolverNameMapper550.class, result.get(i).getClass());
+ break;
+ case 12:
+ Assert.assertEquals(TestMessageResolverNameMapper.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ private List<NameMapper<ValidationStrategy>> getNameMappers()
+ {
+ NameMapperAwareFactory result = ExtValContext.getContext()
+ .getFactoryFinder()
+ .getFactory(FactoryNames.MESSAGE_RESOLVER_FACTORY, NameMapperAwareFactory.class);
+
+ return ((MockMessageResolverFactory)result).getRegisteredNameMapperList();
+ }
+
+ class TestMessageResolverNameMapper extends AbstractValidationStrategyToMsgResolverNameMapper
+ {
+ public String createName(ValidationStrategy source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(99)
+ class TestMessageResolverNameMapper99 extends AbstractValidationStrategyToMsgResolverNameMapper
+ {
+ public String createName(ValidationStrategy source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(150)
+ class TestMessageResolverNameMapper150 extends AbstractValidationStrategyToMsgResolverNameMapper
+ {
+ public String createName(ValidationStrategy source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(250)
+ class TestMessageResolverNameMapper250 extends AbstractValidationStrategyToMsgResolverNameMapper
+ {
+ public String createName(ValidationStrategy source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(301)
+ class TestMessageResolverNameMapper301 extends AbstractValidationStrategyToMsgResolverNameMapper
+ {
+ public String createName(ValidationStrategy source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(350)
+ class TestMessageResolverNameMapper350 extends AbstractValidationStrategyToMsgResolverNameMapper
+ {
+ public String createName(ValidationStrategy source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(450)
+ class TestMessageResolverNameMapper450 extends AbstractValidationStrategyToMsgResolverNameMapper
+ {
+ public String createName(ValidationStrategy source)
+ {
+ return null;
+ }
+ }
+
+ @InvocationOrder(550)
+ class TestMessageResolverNameMapper550 extends AbstractValidationStrategyToMsgResolverNameMapper
+ {
+ public String createName(ValidationStrategy source)
+ {
+ return null;
+ }
+ }
+}
\ No newline at end of file