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 [5/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/ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,131 @@
+/*
+ * 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 javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.factory.DefaultFactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FacesMessageFactory;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.validation.message.DefaultFacesMessageFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase extends ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomFacesMessageFactory implements FacesMessageFactory
+ {
+
+ public FacesMessage convert(FacesMessage facesMessage)
+ {
+ return null;
+ }
+
+ public FacesMessage create(Severity severity, String summary, String detail)
+ {
+ return null;
+ }
+
+ }
+
+ public static class Custom2FacesMessageFactory implements FacesMessageFactory
+ {
+
+ public FacesMessage convert(FacesMessage facesMessage)
+ {
+ return null;
+ }
+
+ public FacesMessage create(Severity severity, String summary, String detail)
+ {
+ return null;
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_FACES_MESSAGE_FACTORY",
+ CustomFacesMessageFactory.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customFacesMessageFactoryClassName()
+ {
+ return Custom2FacesMessageFactory.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomFacesMessageFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.FACES_MESSAGE_FACTORY, FacesMessageFactory.class);
+ Assert.assertEquals(DefaultFacesMessageFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ @Test
+ public void testCustomFacesMessageFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.FACES_MESSAGE_FACTORY, FacesMessageFactory.class);
+ Assert.assertEquals(CustomFacesMessageFactory.class.getName(), factory.getClass().getName());
+ }
+
+ @Test
+ public void testCustomFacesMessageFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.FACES_MESSAGE_FACTORY, FacesMessageFactory.class);
+ Assert.assertEquals(Custom2FacesMessageFactory.class.getName(), factory.getClass().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/ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase.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/ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase.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/ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase.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/ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,125 @@
+/*
+ * 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 org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.CustomInformation;
+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.InformationProviderBean;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomInformationProviderBean extends InformationProviderBean
+ {
+
+ @Override
+ protected void applyCustomValues(Map<CustomInformation, String> map)
+ {
+ map.put(CustomInformation.MESSAGE_BUNDLE_NAME, "X");
+ }
+
+ }
+
+ public static class CustomInformationProviderBean2 extends InformationProviderBean
+ {
+
+ @Override
+ protected void applyCustomValues(Map<CustomInformation, String> map)
+ {
+ map.put(CustomInformation.MESSAGE_BUNDLE_NAME, "Y");
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_INFORMATION_PROVIDER_BEAN",
+ CustomInformationProviderBean.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customInformationProviderBeanClassName()
+ {
+ return CustomInformationProviderBean2.class.getName();
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+ @Test
+ public void testCustomInformationProviderBeanClassNameDefault()
+ {
+ InformationProviderBean bean = ExtValContext.getContext().getInformationProviderBean();
+ Assert.assertEquals(InformationProviderBean.class.getName(), bean.getClass().getName());
+ }
+
+ @Test
+ public void testCustomInformationProviderBeanClassNameWebXml()
+ {
+ InformationProviderBean bean = ExtValContext.getContext().getInformationProviderBean();
+ Assert.assertEquals(CustomInformationProviderBean.class.getName(), bean.getClass().getName());
+ // An additional test to make sure we have the custom
+ // informationProviderBean.
+ Assert.assertEquals(ExtValInformation.EXTENSIONS_VALIDATOR_BASE_PACKAGE_NAME + ".custom.X", bean
+ .get(CustomInformation.MESSAGE_BUNDLE_NAME));
+ }
+
+ @Test
+ public void testCustomInformationProviderBeanClassNameCustomConfig()
+ {
+ InformationProviderBean bean = ExtValContext.getContext().getInformationProviderBean();
+ Assert.assertEquals(CustomInformationProviderBean2.class.getName(), bean.getClass().getName());
+ // An additional test to make sure we have the custom
+ // informationProviderBean.
+ Assert.assertEquals(ExtValInformation.EXTENSIONS_VALIDATOR_BASE_PACKAGE_NAME + ".custom.Y", bean
+ .get(CustomInformation.MESSAGE_BUNDLE_NAME));
+ }
+
+}
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/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.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/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.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/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.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/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.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.config;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.validation.message.resolver.DefaultValidationErrorMessageResolver;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase extends ExtValCoreConfigurationTestCase
+{
+
+ private static final String ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_TEST = "org.apache.myfaces.extensions.validator.test.";
+ private static final String ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_CONFIG = "org.apache.myfaces.extensions.validator.config.";
+
+ static class VisibleDefaultValidationErrorMessageResolver extends DefaultValidationErrorMessageResolver
+ {
+ public String getCustomBaseName()
+ {
+ return super.getCustomBaseName();
+
+ }
+ };
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_MESSAGE_BUNDLE",
+ ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_TEST);
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public String customMessageBundleBaseName()
+ {
+
+ return ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_CONFIG;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomMessageBundleBaseNameDefault() throws Exception
+ {
+ VisibleDefaultValidationErrorMessageResolver messageResolver = new VisibleDefaultValidationErrorMessageResolver();
+ Assert.assertNull(messageResolver.getCustomBaseName());
+
+ }
+
+ @Test
+ public void testCustomMessageBundleBaseNameWebXml() throws Exception
+ {
+
+ VisibleDefaultValidationErrorMessageResolver messageResolver = new VisibleDefaultValidationErrorMessageResolver();
+
+ Assert.assertEquals(ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_TEST, messageResolver.getCustomBaseName());
+ }
+
+ @Test
+ public void testCustomMessageBundleBaseNameCustomConfig() throws Exception
+ {
+ VisibleDefaultValidationErrorMessageResolver messageResolver = new VisibleDefaultValidationErrorMessageResolver();
+
+ Assert.assertEquals(ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_CONFIG, messageResolver.getCustomBaseName());
+
+ }
+
+}
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/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,115 @@
+/*
+ * 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.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.factory.DefaultFactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.validation.message.resolver.DefaultMessageResolverFactory;
+import org.apache.myfaces.extensions.validator.test.base.mock.MockMessageResolverFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+
+ public static class CustomMessageResolverFactory extends DefaultMessageResolverFactory
+ {
+
+ }
+
+ public static class Custom2MessageResolverFactory extends DefaultMessageResolverFactory
+ {
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_MESSAGE_RESOLVER_FACTORY",
+ CustomMessageResolverFactory.class.getName());
+
+ }
+
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customMessageResolverFactoryClassName()
+ {
+ return Custom2MessageResolverFactory.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomMessageResolverFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.MESSAGE_RESOLVER_FACTORY, Object.class);
+ // The TestCase setup registers a Mockfactory so that a protected method
+ // is made visible.
+ // assertEquals(DefaultMessageResolverFactory.class.getName(), factory
+ // .getClass().getName());
+ Assert.assertEquals(MockMessageResolverFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ @Test
+ public void testCustomMessageResolverFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.MESSAGE_RESOLVER_FACTORY, Object.class);
+ Assert.assertEquals(CustomMessageResolverFactory.class.getName(), factory.getClass().getName());
+ }
+
+ @Test
+ public void testCustomMessageResolverFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.MESSAGE_RESOLVER_FACTORY, Object.class);
+ Assert.assertEquals(Custom2MessageResolverFactory.class.getName(), factory.getClass().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/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,115 @@
+/*
+ * 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.List;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+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.interceptor.MetaDataExtractionInterceptor;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomMetaDataExtractionInterceptor implements MetaDataExtractionInterceptor
+ {
+
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+
+ }
+
+ public static class Custom2MetaDataExtractionInterceptor implements MetaDataExtractionInterceptor
+ {
+
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_META_DATA_EXTRACTION_INTERCEPTOR",
+ CustomMetaDataExtractionInterceptor.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customMetaDataExtractionInterceptorClassName()
+ {
+ return Custom2MetaDataExtractionInterceptor.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ @Test
+ public void testCustomMetaDataExtractionInterceptorClassNameDefault()
+ {
+ Assert.assertEquals(0, ExtValContext.getContext().getMetaDataExtractionInterceptors().size());
+ }
+
+ @Test
+ public void testCustomMetaDataExtractionInterceptorClassNameWebXml()
+ {
+ List<MetaDataExtractionInterceptor> result = ExtValContext.getContext().getMetaDataExtractionInterceptors();
+ Assert.assertEquals(1, result.size());
+ Assert.assertEquals(CustomMetaDataExtractionInterceptor.class.getName(), result.get(0).getClass().getName());
+ }
+
+ @Test
+ public void testCustomMetaDataExtractionInterceptorClassNameCustomConfig()
+ {
+ List<MetaDataExtractionInterceptor> result = ExtValContext.getContext().getMetaDataExtractionInterceptors();
+ Assert.assertEquals(1, result.size());
+ Assert.assertEquals(Custom2MetaDataExtractionInterceptor.class.getName(), result.get(0).getClass().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/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.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.config;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.storage.DefaultMetaDataStorage;
+import org.apache.myfaces.extensions.validator.core.storage.MetaDataStorageFilter;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+
+ public static class CustomMetaDataStorageFilter implements MetaDataStorageFilter
+ {
+
+ public void filter(PropertyInformation propertyInformation)
+ {
+
+ }
+
+ }
+
+ public static class Custom2MetaDataStorageFilter implements MetaDataStorageFilter
+ {
+
+ public void filter(PropertyInformation propertyInformation)
+ {
+
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_META_DATA_STORAGE_FILTER",
+ CustomMetaDataStorageFilter.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customMetaDataStorageFilterClassName()
+ {
+ return Custom2MetaDataStorageFilter.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomMetaDataStorageFilterClassNameDefault() throws Exception
+ {
+ DefaultMetaDataStorage metaDataStorage = new DefaultMetaDataStorage();
+ // A little reflection stuff because filters can not be exposed in any
+ // way.
+ Field field = DefaultMetaDataStorage.class.getDeclaredField("metaDataStorageFilters");
+ field.setAccessible(true);
+ Object data = field.get(metaDataStorage);
+ Assert.assertNotNull(data);
+ List<MetaDataStorageFilter> metaDataStorageFilters = (List<MetaDataStorageFilter>) data;
+ Assert.assertEquals(0, metaDataStorageFilters.size());
+ }
+
+ @Test
+ public void testCustomMetaDataStorageFilterClassNameWebXml() throws Exception
+ {
+ DefaultMetaDataStorage metaDataStorage = new DefaultMetaDataStorage();
+ // A little reflection stuff because filters can not be exposed in any
+ // way.
+ Field field = DefaultMetaDataStorage.class.getDeclaredField("metaDataStorageFilters");
+ field.setAccessible(true);
+ Object data = field.get(metaDataStorage);
+ Assert.assertNotNull(data);
+ List<MetaDataStorageFilter> metaDataStorageFilters = (List<MetaDataStorageFilter>) data;
+ Assert.assertEquals(1, metaDataStorageFilters.size());
+ Assert.assertEquals(CustomMetaDataStorageFilter.class.getName(), metaDataStorageFilters.get(0).getClass().getName());
+ }
+
+ @Test
+ public void testCustomMetaDataStorageFilterClassNameCustomConfig() throws Exception
+ {
+ DefaultMetaDataStorage metaDataStorage = new DefaultMetaDataStorage();
+ // A little reflection stuff because filters can not be exposed in any
+ // way.
+ Field field = DefaultMetaDataStorage.class.getDeclaredField("metaDataStorageFilters");
+ field.setAccessible(true);
+ Object data = field.get(metaDataStorage);
+ Assert.assertNotNull(data);
+ List<MetaDataStorageFilter> metaDataStorageFilters = (List<MetaDataStorageFilter>) data;
+ Assert.assertEquals(1, metaDataStorageFilters.size());
+ Assert.assertEquals(Custom2MetaDataStorageFilter.class.getName(), metaDataStorageFilters.get(0).getClass().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/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,144 @@
+/*
+ * 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.List;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+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.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.test.base.mock.MockValidationStrategyFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ private static final String WEB_XML = "Web.xml";
+ private static final String CUSTOM_CONFIG = "Custom Config";
+
+ public static class CustomNameMapper implements NameMapper<String>
+ {
+
+ public String createName(String source)
+ {
+ return WEB_XML;
+ }
+
+ }
+
+ public static class Custom2NameMapper implements NameMapper<String>
+ {
+
+ public String createName(String source)
+ {
+ return CUSTOM_CONFIG;
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX
+ + ".CUSTOM_META_DATA_TO_VALIDATION_STRATEGY_NAME_MAPPER", CustomNameMapper.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customMetaDataToValidationStrategyNameMapperClassName()
+ {
+ return Custom2NameMapper.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomMetaDataToValidationStrategyNameMapperClassNameDefault()
+ {
+ List<NameMapper<String>> nameMappers = getNameMappers();
+ Assert.assertEquals(8, nameMappers.size());
+ // The first one (due to @InvocationOrder) is the
+ // CustomConfiguredAnnotationToValidationStrategyNameMapper which we can
+ // customize and testing here.
+ NameMapper<String> mapper = nameMappers.get(0);
+ // By default nothing is configures so should return null.
+ Assert.assertNull(mapper.createName(null));
+
+ }
+
+ @Test
+ public void testCustomMetaDataToValidationStrategyNameMapperClassNameWebXml()
+ {
+ List<NameMapper<String>> nameMappers = getNameMappers();
+ // No mapper additional, but the first mapper contain now our custom
+ // configured mapper.
+ Assert.assertEquals(8, nameMappers.size());
+ NameMapper<String> mapper = nameMappers.get(0);
+ // So now it should return some value.
+ Assert.assertEquals(WEB_XML, mapper.createName(null));
+ }
+
+ @Test
+ public void testCustomMetaDataToValidationStrategyNameMapperClassNameCustomConfig()
+ {
+ List<NameMapper<String>> nameMappers = getNameMappers();
+ // No mapper additional, but the first mapper contain now our custom
+ // configured mapper.
+ Assert.assertEquals(8, nameMappers.size());
+ NameMapper<String> mapper = nameMappers.get(0);
+ // So now it should return some value.
+ Assert.assertEquals(CUSTOM_CONFIG, mapper.createName(null));
+ }
+
+ private List<NameMapper<String>> getNameMappers()
+ {
+ NameMapperAwareFactory result = ExtValContext.getContext().getFactoryFinder().getFactory(
+ FactoryNames.VALIDATION_STRATEGY_FACTORY, NameMapperAwareFactory.class);
+
+ return ((MockValidationStrategyFactory) result).getRegisteredNameMapperList();
+ }
+
+
+}
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/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,121 @@
+/*
+ * 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.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.factory.DefaultFactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.metadata.transformer.DefaultMetaDataTransformerFactory;
+import org.apache.myfaces.extensions.validator.test.base.mock.MockMetaDataTransformerFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomMetaDataTransformerFactory extends DefaultMetaDataTransformerFactory
+ {
+
+ }
+
+ public static class Custom2MetaDataTransformerFactory extends DefaultMetaDataTransformerFactory
+ {
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_META_DATA_TRANSFORMER_FACTORY",
+ CustomMetaDataTransformerFactory.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public String customMetaDataTransformerFactoryClassName()
+ {
+ return Custom2MetaDataTransformerFactory.class.getName();
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomMetaDataTransformerFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.META_DATA_TRANSFORMER_FACTORY, Object.class);
+
+ // The TestCase setup registers a Mockfactory so that a protected method
+ // is made visible.
+ // assertEquals(DefaultMetaDataTransformerFactory.class.getName(),
+ // factory
+ // .getClass().getName());
+ Assert.assertEquals(MockMetaDataTransformerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ @Test
+ public void testCustomMetaDataTransformerFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.META_DATA_TRANSFORMER_FACTORY, Object.class);
+
+ Assert.assertEquals(CustomMetaDataTransformerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ @Test
+ public void testCustomMetaDataTransformerFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.META_DATA_TRANSFORMER_FACTORY, Object.class);
+
+ Assert.assertEquals(Custom2MetaDataTransformerFactory.class.getName(), factory.getClass().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/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,136 @@
+/*
+ * 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.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+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.interceptor.PropertyValidationInterceptor;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+
+ public static class CustomPropertyValidationInterceptor implements PropertyValidationInterceptor
+ {
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject,
+ Map<String, Object> properties)
+ {
+
+ }
+
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject,
+ Map<String, Object> properties)
+ {
+ return false;
+ }
+
+ }
+
+ public static class Custom2PropertyValidationInterceptor implements PropertyValidationInterceptor
+ {
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject,
+ Map<String, Object> properties)
+ {
+
+ }
+
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject,
+ Map<String, Object> properties)
+ {
+ return false;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_PROPERTY_VALIDATION_INTERCEPTOR",
+ CustomPropertyValidationInterceptor.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public String customPropertyValidationInterceptorClassName()
+ {
+ return Custom2PropertyValidationInterceptor.class.getName();
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomPropertyValidationInterceptorClassNameDefault()
+ {
+ Assert.assertEquals(1, ExtValContext.getContext().getPropertyValidationInterceptors().size());
+ }
+
+ @Test
+ public void testCustomPropertyValidationInterceptorClassNameWebXml()
+ {
+ List<PropertyValidationInterceptor> data = ExtValContext.getContext().getPropertyValidationInterceptors();
+ Assert.assertEquals(2, data.size());
+ Assert.assertEquals(CustomPropertyValidationInterceptor.class.getName(), data.get(1).getClass().getName());
+ }
+
+ @Test
+ public void testCustomPropertyValidationInterceptorClassNameCustomConfig()
+ {
+ List<PropertyValidationInterceptor> data = ExtValContext.getContext().getPropertyValidationInterceptors();
+ Assert.assertEquals(2, data.size());
+ Assert.assertEquals(Custom2PropertyValidationInterceptor.class.getName(), data.get(1).getClass().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/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.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/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.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/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.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/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,123 @@
+/*
+ * 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 javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.DefaultValidationStrategyFactory;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomValidationStrategy implements ValidationStrategy
+ {
+
+ public void validate(FacesContext facesContext, UIComponent uiComponent, MetaDataEntry metaDataEntry,
+ Object convertedObject)
+ {
+
+ }
+
+ }
+
+ public static class Custom2ValidationStrategy implements ValidationStrategy
+ {
+
+ public void validate(FacesContext facesContext, UIComponent uiComponent, MetaDataEntry metaDataEntry,
+ Object convertedObject)
+ {
+
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(
+ ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_STATIC_VALIDATION_STRATEGY_MAPPING",
+ "org.apache.myfaces.extensions.validator.core.config.ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCaseWebXml");
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customStaticValidationStrategyMappingSource()
+ {
+ return "org.apache.myfaces.extensions.validator.core.config.ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCaseCustomConfig";
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomStaticValidationStrategyMappingSourceDefault()
+ {
+ DefaultValidationStrategyFactory validationStrategyFactory = new DefaultValidationStrategyFactory();
+ // Something that isn't available, so should return null.
+ Assert.assertNull(validationStrategyFactory.create("UnitTest"));
+ }
+
+ @Test
+ public void testCustomStaticValidationStrategyMappingSourceWebXml()
+ {
+ DefaultValidationStrategyFactory validationStrategyFactory = new DefaultValidationStrategyFactory();
+ Assert.assertEquals(CustomValidationStrategy.class.getName(), validationStrategyFactory.create("UnitTest").getClass()
+ .getName());
+ }
+
+ @Test
+ public void testCustomStaticValidationStrategyMappingSourceCustomConfig()
+ {
+ DefaultValidationStrategyFactory validationStrategyFactory = new DefaultValidationStrategyFactory();
+ Assert.assertEquals(Custom2ValidationStrategy.class.getName(), validationStrategyFactory.create("UnitTest").getClass()
+ .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/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,111 @@
+/*
+ * 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.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.factory.DefaultFactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.storage.DefaultStorageManagerFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+
+ public static class CustomDefaultStorageManagerFactory extends DefaultStorageManagerFactory
+ {
+
+ }
+
+ public static class Custom2DefaultStorageManagerFactory extends DefaultStorageManagerFactory
+ {
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_STORAGE_MANAGER_FACTORY",
+ CustomDefaultStorageManagerFactory.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customStorageManagerFactoryClassName()
+ {
+
+ return Custom2DefaultStorageManagerFactory.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomStorageManagerFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.STORAGE_MANAGER_FACTORY, Object.class);
+ Assert.assertEquals(DefaultStorageManagerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ @Test
+ public void testCustomStorageManagerFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.STORAGE_MANAGER_FACTORY, Object.class);
+ Assert.assertEquals(CustomDefaultStorageManagerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ @Test
+ public void testCustomStorageManagerFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.STORAGE_MANAGER_FACTORY, Object.class);
+ Assert.assertEquals(Custom2DefaultStorageManagerFactory.class.getName(), factory.getClass().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/ExtValCoreConfigurationCustomTestCase.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/ExtValCoreConfigurationCustomTestCase.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/ExtValCoreConfigurationCustomTestCase.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/ExtValCoreConfigurationCustomTestCase.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.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 ExtValCoreConfigurationCustomTestCase extends ExtValCoreConfigurationTestCase
+{
+
+ // Testcase to see if the configuration object from web.xml is taken.
+ // Basicly a test for ExtValContext.addModuleConfiguration
+
+
+ public static class CustomExtValCoreConfiguration extends DefaultExtValCoreConfiguration {
+
+ @Override
+ public Class violationSeverity()
+ {
+ return Object.class;
+ }
+
+ }
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needCustomConfig())
+ {
+ addInitParameter(ExtValCoreConfiguration.class.getName(),
+ CustomExtValCoreConfiguration.class.getName());
+
+ }
+ }
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ // Don't specify the custom config here. We explicitly want to test the web.xml parameter.
+ return null;
+ }
+
+
+ @Test
+ public void testExtValCoreConfigurationCustomDefault()
+ {
+ Assert.assertEquals(ViolationSeverity.class.getName(), ((Class)ExtValCoreConfiguration.get().violationSeverity()).getName());
+ }
+
+ @Test
+ public void testExtValCoreConfigurationCustomCustomConfig()
+ {
+ Assert.assertEquals(Object.class.getName(), ((Class)ExtValCoreConfiguration.get().violationSeverity()).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/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.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/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,124 @@
+/*
+ * 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.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+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.interceptor.ValidationExceptionInterceptor;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomValidationExceptionInterceptor implements ValidationExceptionInterceptor
+ {
+
+ public boolean afterThrowing(UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject,
+ ValidatorException validatorException, ValidationStrategy validatorExceptionSource)
+ {
+ return false;
+ }
+
+ }
+
+ public static class Custom2ValidationExceptionInterceptor implements ValidationExceptionInterceptor
+ {
+
+ public boolean afterThrowing(UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject,
+ ValidatorException validatorException, ValidationStrategy validatorExceptionSource)
+ {
+ return false;
+ }
+
+ }
+
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_VALIDATION_EXCEPTION_INTERCEPTOR",
+ CustomValidationExceptionInterceptor.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customValidationExceptionInterceptorClassName()
+ {
+ return Custom2ValidationExceptionInterceptor.class.getName();
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomValidationExceptionInterceptorClassNameDefault()
+ {
+ Assert.assertEquals(3, ExtValContext.getContext().getValidationExceptionInterceptors().size());
+ }
+
+ @Test
+ public void testCustomValidationExceptionInterceptorClassNameWebXml()
+ {
+ List<ValidationExceptionInterceptor> data = ExtValContext.getContext().getValidationExceptionInterceptors();
+ Assert.assertEquals(4, data.size());
+ Assert.assertEquals(CustomValidationExceptionInterceptor.class.getName(), data.get(3).getClass().getName());
+ }
+
+ @Test
+ public void testCustomValidationExceptionInterceptorClassNameCustomConfig()
+ {
+ List<ValidationExceptionInterceptor> data = ExtValContext.getContext().getValidationExceptionInterceptors();
+ Assert.assertEquals(4, data.size());
+ Assert.assertEquals(Custom2ValidationExceptionInterceptor.class.getName(), data.get(3).getClass().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/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,150 @@
+/*
+ * 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.util.List;
+import java.util.Map;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.DefaultValidationParameterExtractor;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.DefaultValidationParameterExtractorFactory;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameterExtractor;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameterExtractorFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomValidationParameterExtractor implements ValidationParameterExtractor
+ {
+
+ public Map<Object, List<Object>> extract(Annotation annotation)
+ {
+ return null;
+ }
+
+ public List<Object> extract(Annotation annotation, Object key)
+ {
+ return null;
+ }
+
+ public <T> List<T> extract(Annotation annotation, Object key, Class<T> valueType)
+ {
+ return null;
+ }
+
+ public <T> T extract(Annotation annotation, Object key, Class<T> valueType, Class valueId)
+ {
+ return null;
+ }
+
+ }
+
+ public static class Custom2ValidationParameterExtractor implements ValidationParameterExtractor
+ {
+
+ public Map<Object, List<Object>> extract(Annotation annotation)
+ {
+ return null;
+ }
+
+ public List<Object> extract(Annotation annotation, Object key)
+ {
+ return null;
+ }
+
+ public <T> List<T> extract(Annotation annotation, Object key, Class<T> valueType)
+ {
+ return null;
+ }
+
+ public <T> T extract(Annotation annotation, Object key, Class<T> valueType, Class valueId)
+ {
+ return null;
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_VALIDATION_PARAMETER_EXTRACTOR",
+ CustomValidationParameterExtractor.class.getName());
+ }
+
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customValidationParameterExtractorClassName()
+ {
+ return Custom2ValidationParameterExtractor.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomValidationParameterExtractorClassNameDefault()
+ {
+ ValidationParameterExtractorFactory factory = new DefaultValidationParameterExtractorFactory();
+ Assert.assertEquals(DefaultValidationParameterExtractor.class.getName(), factory.create().getClass().getName());
+
+ }
+
+ @Test
+ public void testCustomValidationParameterExtractorClassNameWebXml()
+ {
+ ValidationParameterExtractorFactory factory = new DefaultValidationParameterExtractorFactory();
+ Assert.assertEquals(CustomValidationParameterExtractor.class.getName(), factory.create().getClass().getName());
+ }
+
+ @Test
+ public void testCustomValidationParameterExtractorClassNameCustomConfig()
+ {
+ ValidationParameterExtractorFactory factory = new DefaultValidationParameterExtractorFactory();
+ Assert.assertEquals(Custom2ValidationParameterExtractor.class.getName(), factory.create().getClass().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/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,120 @@
+/*
+ * 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.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.factory.DefaultFactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.DefaultValidationParameterExtractorFactory;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameterExtractor;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameterExtractorFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomValidationParameterExtractorFactory implements ValidationParameterExtractorFactory
+ {
+
+ public ValidationParameterExtractor create()
+ {
+ return null;
+ }
+
+ }
+
+ public static class Custom2ValidationParameterExtractorFactory implements ValidationParameterExtractorFactory
+ {
+
+ public ValidationParameterExtractor create()
+ {
+ return null;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_VALIDATION_PARAMETER_EXTRACTOR_FACTORY",
+ CustomValidationParameterExtractorFactory.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customValidationParameterExtractorFactoryClassName()
+ {
+ return Custom2ValidationParameterExtractorFactory.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomValidationParameterExtractorFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_EXTRACTOR_FACTORY, Object.class);
+ Assert.assertEquals(DefaultValidationParameterExtractorFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ @Test
+ public void testCustomValidationParameterExtractorFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_EXTRACTOR_FACTORY, Object.class);
+ Assert.assertEquals(CustomValidationParameterExtractorFactory.class.getName(), factory.getClass().getName());
+ }
+
+ @Test
+ public void testCustomValidationParameterExtractorFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_EXTRACTOR_FACTORY, Object.class);
+ Assert.assertEquals(Custom2ValidationParameterExtractorFactory.class.getName(), factory.getClass().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/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.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/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.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 org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.factory.DefaultFactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.DefaultValidationParameterFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public static class CustomValidationParameterFactory extends DefaultValidationParameterFactory
+ {
+
+ }
+
+ public static class Custom2ValidationParameterFactory extends DefaultValidationParameterFactory
+ {
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_VALIDATION_PARAMETER_FACTORY",
+ CustomValidationParameterFactory.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customValidationParameterFactoryClassName()
+ {
+ return Custom2ValidationParameterFactory.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Test
+ public void testCustomValidationParameterFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_FACTORY, Object.class);
+ Assert.assertEquals(DefaultValidationParameterFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ @Test
+ public void testCustomValidationParameterFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_FACTORY, Object.class);
+ Assert.assertEquals(CustomValidationParameterFactory.class.getName(), factory.getClass().getName());
+ }
+
+ @Test
+ public void testCustomValidationParameterFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_FACTORY, Object.class);
+ Assert.assertEquals(Custom2ValidationParameterFactory.class.getName(), factory.getClass().getName());
+ }
+
+}