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 2010/07/22 14:24:19 UTC
svn commit: r966614 [2/5] - in /myfaces/extensions/validator/trunk:
core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/
core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/resolver/
test-modules/ test...
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,117 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @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();
+
+ }
+ };
+
+ public ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomMessageBundleBaseNameDefault() throws Exception
+ {
+ VisibleDefaultValidationErrorMessageResolver messageResolver = new VisibleDefaultValidationErrorMessageResolver();
+ assertNull(messageResolver.getCustomBaseName());
+
+ }
+
+ public void testCustomMessageBundleBaseNameWebXml() throws Exception
+ {
+
+ VisibleDefaultValidationErrorMessageResolver messageResolver = new VisibleDefaultValidationErrorMessageResolver();
+
+ assertEquals(ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_TEST, messageResolver.getCustomBaseName());
+ }
+
+ public void testCustomMessageBundleBaseNameCustomConfig() throws Exception
+ {
+ VisibleDefaultValidationErrorMessageResolver messageResolver = new VisibleDefaultValidationErrorMessageResolver();
+
+ assertEquals(ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_CONFIG, messageResolver.getCustomBaseName());
+
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ 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());
+ assertEquals(MockMessageResolverFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ public void testCustomMessageResolverFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.MESSAGE_RESOLVER_FACTORY, Object.class);
+ assertEquals(CustomMessageResolverFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomMessageResolverFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.MESSAGE_RESOLVER_FACTORY, Object.class);
+ assertEquals(Custom2MessageResolverFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -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 java.util.List;
+
+import junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomMetaDataExtractionInterceptorClassNameDefault()
+ {
+ assertEquals(0, ExtValContext.getContext().getMetaDataExtractionInterceptors().size());
+ }
+
+ public void testCustomMetaDataExtractionInterceptorClassNameWebXml()
+ {
+ List<MetaDataExtractionInterceptor> result = ExtValContext.getContext().getMetaDataExtractionInterceptors();
+ assertEquals(1, result.size());
+ assertEquals(CustomMetaDataExtractionInterceptor.class.getName(), result.get(0).getClass().getName());
+ }
+
+ public void testCustomMetaDataExtractionInterceptorClassNameCustomConfig()
+ {
+ List<MetaDataExtractionInterceptor> result = ExtValContext.getContext().getMetaDataExtractionInterceptors();
+ assertEquals(1, result.size());
+ assertEquals(Custom2MetaDataExtractionInterceptor.class.getName(), result.get(0).getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,146 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ 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);
+ assertNotNull(data);
+ List<MetaDataStorageFilter> metaDataStorageFilters = (List<MetaDataStorageFilter>) data;
+ assertEquals(0, metaDataStorageFilters.size());
+ }
+
+ 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);
+ assertNotNull(data);
+ List<MetaDataStorageFilter> metaDataStorageFilters = (List<MetaDataStorageFilter>) data;
+ assertEquals(1, metaDataStorageFilters.size());
+ assertEquals(CustomMetaDataStorageFilter.class.getName(), metaDataStorageFilters.get(0).getClass().getName());
+ }
+
+ 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);
+ assertNotNull(data);
+ List<MetaDataStorageFilter> metaDataStorageFilters = (List<MetaDataStorageFilter>) data;
+ assertEquals(1, metaDataStorageFilters.size());
+ assertEquals(Custom2MetaDataStorageFilter.class.getName(), metaDataStorageFilters.get(0).getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,153 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @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 ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomMetaDataToValidationStrategyNameMapperClassNameDefault()
+ {
+ List<NameMapper<String>> nameMappers = getNameMappers();
+ 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.
+ assertNull(mapper.createName(null));
+
+ }
+
+ public void testCustomMetaDataToValidationStrategyNameMapperClassNameWebXml()
+ {
+ List<NameMapper<String>> nameMappers = getNameMappers();
+ // No mapper additional, but the first mapper contain now our custom
+ // configured mapper.
+ assertEquals(8, nameMappers.size());
+ NameMapper<String> mapper = nameMappers.get(0);
+ // So now it should return some value.
+ assertEquals(WEB_XML, mapper.createName(null));
+ }
+
+ public void testCustomMetaDataToValidationStrategyNameMapperClassNameCustomConfig()
+ {
+ List<NameMapper<String>> nameMappers = getNameMappers();
+ // No mapper additional, but the first mapper contain now our custom
+ // configured mapper.
+ assertEquals(8, nameMappers.size());
+ NameMapper<String> mapper = nameMappers.get(0);
+ // So now it should return some value.
+ 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();
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,127 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ 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());
+ assertEquals(MockMetaDataTransformerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomMetaDataTransformerFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.META_DATA_TRANSFORMER_FACTORY, Object.class);
+
+ assertEquals(CustomMetaDataTransformerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomMetaDataTransformerFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.META_DATA_TRANSFORMER_FACTORY, Object.class);
+
+ assertEquals(Custom2MetaDataTransformerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,143 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomPropertyValidationInterceptorClassNameDefault()
+ {
+ assertEquals(1, ExtValContext.getContext().getPropertyValidationInterceptors().size());
+ }
+
+ public void testCustomPropertyValidationInterceptorClassNameWebXml()
+ {
+ List<PropertyValidationInterceptor> data = ExtValContext.getContext().getPropertyValidationInterceptors();
+ assertEquals(2, data.size());
+ assertEquals(CustomPropertyValidationInterceptor.class.getName(), data.get(1).getClass().getName());
+ }
+
+ public void testCustomPropertyValidationInterceptorClassNameCustomConfig()
+ {
+ List<PropertyValidationInterceptor> data = ExtValContext.getContext().getPropertyValidationInterceptors();
+ assertEquals(2, data.size());
+ assertEquals(Custom2PropertyValidationInterceptor.class.getName(), data.get(1).getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,133 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomStaticValidationStrategyMappingSourceDefault()
+ {
+ DefaultValidationStrategyFactory validationStrategyFactory = new DefaultValidationStrategyFactory();
+ // Something that isn't available, so should return null.
+ assertNull(validationStrategyFactory.create("UnitTest"));
+ }
+
+ public void testCustomStaticValidationStrategyMappingSourceWebXml()
+ {
+ DefaultValidationStrategyFactory validationStrategyFactory = new DefaultValidationStrategyFactory();
+ assertEquals(CustomValidationStrategy.class.getName(), validationStrategyFactory.create("UnitTest").getClass()
+ .getName());
+ }
+
+ public void testCustomStaticValidationStrategyMappingSourceCustomConfig()
+ {
+ DefaultValidationStrategyFactory validationStrategyFactory = new DefaultValidationStrategyFactory();
+ assertEquals(Custom2ValidationStrategy.class.getName(), validationStrategyFactory.create("UnitTest").getClass()
+ .getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,117 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomStorageManagerFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.STORAGE_MANAGER_FACTORY, Object.class);
+ assertEquals(DefaultStorageManagerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomStorageManagerFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.STORAGE_MANAGER_FACTORY, Object.class);
+ assertEquals(CustomDefaultStorageManagerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomStorageManagerFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.STORAGE_MANAGER_FACTORY, Object.class);
+ assertEquals(Custom2DefaultStorageManagerFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,87 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @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 ExtValCoreConfigurationCustomTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+
+
+ public void testExtValCoreConfigurationCustomDefault()
+ {
+ assertEquals(ViolationSeverity.class.getName(), ((Class)ExtValCoreConfiguration.get().violationSeverity()).getName());
+ }
+
+ public void testExtValCoreConfigurationCustomCustomConfig()
+ {
+ assertEquals(Object.class.getName(), ((Class)ExtValCoreConfiguration.get().violationSeverity()).getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomTestCase.class);
+ }
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,133 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomValidationExceptionInterceptorClassNameDefault()
+ {
+ assertEquals(3, ExtValContext.getContext().getValidationExceptionInterceptors().size());
+ }
+
+ public void testCustomValidationExceptionInterceptorClassNameWebXml()
+ {
+ List<ValidationExceptionInterceptor> data = ExtValContext.getContext().getValidationExceptionInterceptors();
+ assertEquals(4, data.size());
+ assertEquals(CustomValidationExceptionInterceptor.class.getName(), data.get(3).getClass().getName());
+ }
+
+ public void testCustomValidationExceptionInterceptorClassNameCustomConfig()
+ {
+ List<ValidationExceptionInterceptor> data = ExtValContext.getContext().getValidationExceptionInterceptors();
+ assertEquals(4, data.size());
+ assertEquals(Custom2ValidationExceptionInterceptor.class.getName(), data.get(3).getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,160 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomValidationParameterExtractorClassNameDefault()
+ {
+ ValidationParameterExtractorFactory factory = new DefaultValidationParameterExtractorFactory();
+ assertEquals(DefaultValidationParameterExtractor.class.getName(), factory.create().getClass().getName());
+
+ }
+
+ public void testCustomValidationParameterExtractorClassNameWebXml()
+ {
+ ValidationParameterExtractorFactory factory = new DefaultValidationParameterExtractorFactory();
+ assertEquals(CustomValidationParameterExtractor.class.getName(), factory.create().getClass().getName());
+ }
+
+ public void testCustomValidationParameterExtractorClassNameCustomConfig()
+ {
+ ValidationParameterExtractorFactory factory = new DefaultValidationParameterExtractorFactory();
+ assertEquals(Custom2ValidationParameterExtractor.class.getName(), factory.create().getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,129 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomValidationParameterExtractorFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_EXTRACTOR_FACTORY, Object.class);
+ assertEquals(DefaultValidationParameterExtractorFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ public void testCustomValidationParameterExtractorFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_EXTRACTOR_FACTORY, Object.class);
+ assertEquals(CustomValidationParameterExtractorFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomValidationParameterExtractorFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_EXTRACTOR_FACTORY, Object.class);
+ assertEquals(Custom2ValidationParameterExtractorFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/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/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config;
+
+import junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomValidationParameterFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_FACTORY, Object.class);
+ assertEquals(DefaultValidationParameterFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ public void testCustomValidationParameterFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_FACTORY, Object.class);
+ assertEquals(CustomValidationParameterFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomValidationParameterFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_PARAMETER_FACTORY, Object.class);
+ assertEquals(Custom2ValidationParameterFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.class);
+ }
+
+}
Added: myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase.java?rev=966614&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase.java Thu Jul 22 12:24:16 2010
@@ -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 junit.framework.Test;
+
+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.strategy.DefaultValidationStrategyFactory;
+import org.apache.myfaces.extensions.validator.test.base.mock.MockValidationStrategyFactory;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomValidationStrategyFactory extends DefaultValidationStrategyFactory
+ {
+
+ }
+
+ public static class Custom2ValidationStrategyFactory extends DefaultValidationStrategyFactory
+ {
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_VALIDATION_STRATEGY_FACTORY",
+ CustomValidationStrategyFactory.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customValidationStrategyFactoryClassName()
+ {
+ return Custom2ValidationStrategyFactory.class.getName();
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testCustomValidationStrategyFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_STRATEGY_FACTORY, Object.class);
+ // The testcase install a MockFactory for it that exposes some protected
+ // information
+ // assertEquals(DefaultValidationStrategyFactory.class.getName(),
+ // factory
+ // .getClass().getName());
+ assertEquals(MockValidationStrategyFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ public void testCustomValidationStrategyFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_STRATEGY_FACTORY, Object.class);
+ assertEquals(CustomValidationStrategyFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomValidationStrategyFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.VALIDATION_STRATEGY_FACTORY, Object.class);
+ assertEquals(Custom2ValidationStrategyFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase.class);
+ }
+
+}