EXTVAL-106
git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/validator/trunk@966614 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
index e6f1f28..e80e979 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValStartupListener.java
@@ -102,7 +102,6 @@
initPhaseListeners();
initViolationSeverityKey();
initDisableClientSideValidationKey();
- initRequiredInitialization();
executeCustomStartupListener();
}
@@ -219,31 +218,4 @@
ExtValCoreConfiguration.get().disableClientSideValidationValidationParameter(), false);
}
- private void initRequiredInitialization()
- {
- boolean requiredInitialization = ExtValCoreConfiguration.get().activateRequiredInitialization();
-
- //noinspection deprecation
- addRequiredInitializationAsGlobalProperty(requiredInitialization);
-
- initRequiredAttributeSupport();
- }
-
- @Deprecated
- private void addRequiredInitializationAsGlobalProperty(boolean requiredInitialization)
- {
- ExtValContext.getContext().addGlobalProperty("mode:init:required", requiredInitialization, false);
- }
-
- /**
- * if it's configured that required init should happen,
- * it's required to deactivate the support for the required attribute
- */
- @Deprecated
- private void initRequiredAttributeSupport()
- {
- ExtValContext.getContext().addGlobalProperty("mode:reset:required",
- ExtValCoreConfiguration.get().deactivateRequiredAttributeSupport(),
- false);
- }
}
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/resolver/DefaultValidationErrorMessageResolver.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/resolver/DefaultValidationErrorMessageResolver.java
index 38e37ec..96076c7 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/resolver/DefaultValidationErrorMessageResolver.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/resolver/DefaultValidationErrorMessageResolver.java
@@ -18,10 +18,11 @@
*/
package org.apache.myfaces.extensions.validator.core.validation.message.resolver;
-import org.apache.myfaces.extensions.validator.core.InternalConventionProvider;
import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
-import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.core.InternalConventionProvider;
import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
/**
* Default MessageResolver which uses the default convention for the message bundle.
@@ -39,7 +40,7 @@
public DefaultValidationErrorMessageResolver()
{
- this.baseName = InternalConventionProvider.getModuleMessageBundleName(getClass().getPackage().getName());
+ this.baseName = InternalConventionProvider.getModuleMessageBundleName(ClassUtils.getPackageName(getClass()));
}
//not used at the moment - just for a convention
diff --git a/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java b/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
index 74fc549..533ff6f 100644
--- a/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
+++ b/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
@@ -32,6 +32,7 @@
import org.apache.myfaces.extensions.validator.core.ExtValContext;
import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValModuleConfiguration;
import org.apache.myfaces.extensions.validator.core.el.AbstractELHelperFactory;
import org.apache.myfaces.extensions.validator.core.el.ELHelper;
import org.apache.myfaces.shared_impl.config.MyfacesConfig;
@@ -49,6 +50,7 @@
import java.net.URL;
import java.io.StringWriter;
import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Iterator;
@@ -162,6 +164,10 @@
expressionFactory = (MockExpressionFactory)application.getExpressionFactory();
+ applyCustomConfigurations();
+
+ // This triggers already the config object. So it is possible that you
+ // need to set your custom config also in the getCustomConfigObjects method.
final ELHelper defaultElHelper = ExtValUtils.getELHelper();
ExtValContext.getContext().getFactoryFinder()
.getFactory(FactoryNames.EL_HELPER_FACTORY, AbstractELHelperFactory.class)
@@ -219,6 +225,39 @@
servletContext.addInitParameter(key, value);
}
+ private void applyCustomConfigurations()
+ {
+ ExtValModuleConfiguration[] customConfigs = getCustomConfigObjects();
+ if (customConfigs != null)
+ {
+ for (ExtValModuleConfiguration moduleConfiguration : customConfigs)
+ {
+ ExtValContext.getContext().addModuleConfiguration(getAbstractModuleConfiguration(moduleConfiguration),
+ moduleConfiguration, false);
+ }
+ }
+ }
+
+ protected ExtValModuleConfiguration[] getCustomConfigObjects()
+ {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Class<? extends ExtValModuleConfiguration> getAbstractModuleConfiguration(
+ Object moduleConfiguration)
+ {
+ Class<? extends ExtValModuleConfiguration> result = (Class<? extends ExtValModuleConfiguration>) moduleConfiguration
+ .getClass();
+ while (!Modifier.isAbstract(result.getModifiers())
+ && !Object.class.getName().equals(result.getName()))
+ {
+ result = (Class<? extends ExtValModuleConfiguration>) result
+ .getSuperclass();
+ }
+ return result;
+ }
+
protected abstract void invokeStartupListeners();
/**
diff --git a/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/ClassLoaderTestSuite.java b/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/ClassLoaderTestSuite.java
new file mode 100644
index 0000000..72adf0a
--- /dev/null
+++ b/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/ClassLoaderTestSuite.java
@@ -0,0 +1,351 @@
+/*
+ * 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.base.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import java.util.logging.Logger;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.runner.TestCaseClassLoader;
+
+/**
+ * Allows the execution of each test of a TestCase into a different classloader.
+ * Specify the class of the test case in the constructor and return the instance
+ * of the ClassLoaderTestSuite as the result of the suite method.
+ *
+ * Most of the code is borrowed from junit.framework.TestSuite.
+ *
+ * @author Rudy De Busscher
+ *
+ */
+@SuppressWarnings("unchecked")
+public class ClassLoaderTestSuite extends TestSuite
+{
+ private static final Logger LOGGER = Logger.getLogger(ClassLoaderTestSuite.class.getName());
+
+ // The classpath is needed because the custom class loader looks their to find the classes.
+ private static String classPath;
+ private static boolean classPathDetermined = false;
+
+ public ClassLoaderTestSuite(Class theClass)
+ {
+ identifyTestMethods(theClass);
+
+ }
+
+ /**
+ * Identify test methods.
+ *
+ * @param theClass
+ * the class
+ */
+ private void identifyTestMethods(Class theClass)
+ {
+ Class superClass = theClass;
+ Vector names = new Vector();
+ while (Test.class.isAssignableFrom(superClass))
+ {
+ Method[] methods = superClass.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++)
+ {
+ addTestMethod(methods[i], names, theClass);
+ }
+ superClass = superClass.getSuperclass();
+ }
+ }
+
+ /**
+ * Adds the method as a test method when it fulfill all requirements.
+ *
+ * @param method
+ * the method that is maybe a test method
+ * @param names
+ * the names with all the discovered test methods
+ * @param theClass
+ * the class
+ */
+ private void addTestMethod(Method method, Vector names, Class theClass)
+ {
+ String name = method.getName();
+ if (names.contains(name))
+ {
+ return;
+ }
+ if (!isPublicTestMethod(method))
+ {
+ if (isTestMethod(method))
+ {
+ addTest(warning("Test method isn't public: " + method.getName()));
+ }
+ return;
+ }
+ names.addElement(name);
+ addTest(createTestWithCustomClassLoader(theClass, name));
+ }
+
+ /**
+ * The method creates a Test using a custom classloader for each test.
+ *
+ * @param theOriginalClass
+ * The class
+ * @param name
+ * The test method name
+ * @return The test where class is now loaded from a custom class loader.
+ */
+ static public Test createTestWithCustomClassLoader(Class theOriginalClass, String name)
+ {
+
+ ClassLoader classLoader;
+
+ String surefireTestPath = getClassPath();
+ if (surefireTestPath != null)
+ {
+ classLoader = new TestCaseClassLoader(surefireTestPath);
+ }
+
+ else
+ {
+ classLoader = new TestCaseClassLoader();
+
+ }
+
+ Class theClass = null;
+ try
+ {
+ // Use the custom classloader to load the test. The complete
+ // execution of the test will then be done using this new
+ // classloader.
+ theClass = classLoader.loadClass(theOriginalClass.getName());
+ } catch (ClassNotFoundException e)
+ {
+ return warning("Cannot custom load test case: " + name + " (" + exceptionToString(e) + ")");
+ }
+
+ Constructor constructor;
+ try
+ {
+ constructor = getTestConstructor(theClass);
+ } catch (NoSuchMethodException e)
+ {
+ return warning("Class " + theClass.getName()
+ + " has no public constructor TestCase(String name) or TestCase()");
+ }
+ Object test;
+ try
+ {
+ if (constructor.getParameterTypes().length == 0)
+ {
+ test = constructor.newInstance(new Object[0]);
+ if (test instanceof TestCase)
+ ((TestCase) test).setName(name);
+ } else
+ {
+ test = constructor.newInstance(new Object[] { name });
+ }
+ } catch (InstantiationException e)
+ {
+ return (warning("Cannot instantiate test case: " + name + " (" + exceptionToString(e) + ")"));
+ } catch (InvocationTargetException e)
+ {
+ return (warning("Exception in constructor: " + name + " (" + exceptionToString(e.getTargetException())
+ + ")"));
+ } catch (IllegalAccessException e)
+ {
+ return (warning("Cannot access test case: " + name + " (" + exceptionToString(e) + ")"));
+ }
+ return (Test) test;
+ }
+
+ /**
+ * Gets the class path.This value is cached in a static variable for performance reasons.
+ *
+ * @return the class path
+ */
+ private static String getClassPath()
+ {
+ if (classPathDetermined) {
+ return classPath;
+ }
+
+ classPathDetermined = true;
+ // running from maven, we have the classpath in this property.
+ classPath = System.getProperty("surefire.test.class.path");
+ if (classPath != null) {
+ return classPath;
+ }
+
+ // For a multi module project, running it from the top we have to find it using another way.
+ // We also need to set useSystemClassLoader=true in the POM so that we gets a jar with the classpath in it.
+ String booterClassPath = System.getProperty("java.class.path");
+ Vector pathItems = null;
+ if (booterClassPath != null)
+ {
+ pathItems = scanPath(booterClassPath);
+ }
+ // Do we have just 1 entry as classpath which is a jar?
+ if (pathItems != null && pathItems.size() == 1 && isJar((String) pathItems.get(0)))
+ {
+ classPath = loadJarManifestClassPath((String) pathItems.get(0), "META-INF/MANIFEST.MF");
+ }
+ return classPath;
+
+ }
+
+ /**
+ * Load jar manifest class path.
+ *
+ * @param path the path
+ * @param fileName the file name
+ *
+ * @return the string
+ */
+ private static String loadJarManifestClassPath(String path, String fileName)
+ {
+ File archive = new File(path);
+ if (!archive.exists()) {
+ return null;
+ }
+ ZipFile zipFile= null;
+
+ try {
+ zipFile= new ZipFile(archive);
+ } catch(IOException io) {
+ return null;
+ }
+
+ ZipEntry entry= zipFile.getEntry(fileName);
+ if (entry == null) {
+ return null;
+ }
+ try
+ {
+ Manifest mf = new Manifest();
+ mf.read(zipFile.getInputStream(entry));
+
+ return mf.getMainAttributes().getValue(
+ Attributes.Name.CLASS_PATH).replaceAll(" ", System.getProperty("path.separator")).replaceAll("file:/", "");
+ } catch (MalformedURLException e)
+ {
+ LOGGER.throwing("ClassLoaderTestSuite", "loadJarManifestClassPath", e);
+ } catch (IOException e)
+ {
+ LOGGER.throwing("ClassLoaderTestSuite", "loadJarManifestClassPath", e);
+ }
+ return null;
+ }
+
+ private static boolean isJar(String pathEntry)
+ {
+ return pathEntry.endsWith(".jar") || pathEntry.endsWith(".zip");
+ }
+
+ private static Vector scanPath(String classPath)
+ {
+ String separator = System.getProperty("path.separator");
+ Vector pathItems = new Vector(10);
+ StringTokenizer st = new StringTokenizer(classPath, separator);
+ while (st.hasMoreTokens())
+ {
+ pathItems.addElement(st.nextToken());
+ }
+ return pathItems;
+ }
+
+ /**
+ * Checks if is public test method.
+ *
+ * @param method
+ * the method
+ *
+ * @return true, if is public test method
+ */
+ private boolean isPublicTestMethod(Method method)
+ {
+ return isTestMethod(method) && Modifier.isPublic(method.getModifiers());
+ }
+
+ /**
+ * Checks if is test method.
+ *
+ * @param method
+ * the method
+ *
+ * @return true, if is test method
+ */
+ private boolean isTestMethod(Method method)
+ {
+ String name = method.getName();
+ Class[] parameters = method.getParameterTypes();
+ Class returnType = method.getReturnType();
+ return parameters.length == 0 && name.startsWith("test") && returnType.equals(Void.TYPE);
+ }
+
+ /**
+ * Creates a Test that generates a failure with the supplied message.
+ *
+ * @param message
+ * the message
+ *
+ * @return the test
+ */
+ private static Test warning(final String message)
+ {
+ return new TestCase("warning")
+ {
+ protected void runTest()
+ {
+ fail(message);
+ }
+ };
+ }
+
+ /**
+ * Exception to string.
+ *
+ * @param t
+ * the t
+ *
+ * @return the string
+ */
+ private static String exceptionToString(Throwable t)
+ {
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter writer = new PrintWriter(stringWriter);
+ t.printStackTrace(writer);
+ return stringWriter.toString();
+
+ }
+
+}
diff --git a/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ConstraintSourceAwareValidation6TestCase.java b/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ConstraintSourceAwareValidation6TestCase.java
index 4a9e264..5d97398 100644
--- a/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ConstraintSourceAwareValidation6TestCase.java
+++ b/test-modules/bean-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/beanval/ConstraintSourceAwareValidation6TestCase.java
@@ -18,25 +18,29 @@
*/
package org.apache.myfaces.extensions.validator.test.beanval;
+import java.lang.annotation.Annotation;
+
+import javax.faces.application.FacesMessage;
+
import junit.framework.Test;
-import junit.framework.TestSuite;
+
import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValModuleConfiguration;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
import org.apache.myfaces.extensions.validator.test.beanval.custom.CustomConstraintSource;
import org.apache.myfaces.extensions.validator.test.beanval.custom.CustomIgnoreConstraintSource;
import org.apache.myfaces.extensions.validator.test.beanval.custom.CustomTargetProperty;
import org.apache.myfaces.extensions.validator.test.beanval.custom.CustomTargetPropertyId;
import org.apache.myfaces.extensions.validator.test.beanval.model.ConstraintSourceAware6Bean;
-import javax.faces.application.FacesMessage;
-import java.lang.annotation.Annotation;
-
/**
* EXTVAL-83
*
* @author Gerhard Petracek
*/
-public class ConstraintSourceAwareValidation6TestCase extends BaseBeanValPropertyValidationTestCase<ConstraintSourceAware6Bean>
+public class ConstraintSourceAwareValidation6TestCase extends
+ BaseBeanValPropertyValidationTestCase<ConstraintSourceAware6Bean>
{
public ConstraintSourceAwareValidation6TestCase(String name)
{
@@ -45,7 +49,7 @@
public static Test suite()
{
- return new TestSuite(ConstraintSourceAwareValidation6TestCase.class);
+ return new ClassLoaderTestSuite(ConstraintSourceAwareValidation6TestCase.class);
}
protected ConstraintSourceAware6Bean getBeanToTest()
@@ -54,11 +58,10 @@
}
@Override
- protected void setUp() throws Exception
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
{
- super.setUp();
-
- ExtValCoreConfiguration.use(new DefaultExtValCoreConfiguration() {
+ return new DefaultExtValCoreConfiguration()
+ {
@Override
public Class<? extends Annotation> constraintSourceAnnotation()
{
@@ -82,7 +85,8 @@
{
return CustomTargetPropertyId.class;
}
- }, true);
+
+ };
}
public void testCustomAnnotations1()
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/custom/RenderKitWrapperFactory.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/custom/RenderKitWrapperFactory.java
new file mode 100644
index 0000000..b828e3c
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/custom/RenderKitWrapperFactory.java
@@ -0,0 +1,17 @@
+package org.apache.myfaces.extensions.validator.custom;
+
+import org.apache.myfaces.extensions.validator.core.renderkit.DefaultRenderKitWrapperFactory;
+
+public class RenderKitWrapperFactory extends DefaultRenderKitWrapperFactory
+{
+
+ @Override
+ protected boolean isApplicationInitialized()
+ {
+ // Required for testcase
+ // ExtValCoreConfigurationDeactivateRenderKitFactoryTestCase
+ // Otherwise VM parameter is checked for deactivation and not config parameter
+ return true;
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationActivateRequiredInitializationTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationActivateRequiredInitializationTestCase.java
new file mode 100644
index 0000000..9c87d9a
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationActivateRequiredInitializationTestCase.java
@@ -0,0 +1,96 @@
+/*
+ * 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.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationActivateRequiredInitializationTestCase extends ExtValCoreConfigurationTestCase
+{
+
+ public ExtValCoreConfigurationActivateRequiredInitializationTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".ACTIVATE_REQUIRED_INITIALIZATION", "true");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public boolean activateRequiredInitialization()
+ {
+
+ return true;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testActivateRequiredInitializationDefault()
+ {
+ assertFalse(ExtValUtils.isRequiredInitializationActive());
+ }
+
+ public void testActivateRequiredInitializationWebXml()
+ {
+ assertTrue(ExtValUtils.isRequiredInitializationActive());
+ }
+
+ public void testActivateRequiredInitializationCustomConfig()
+ {
+ assertTrue(ExtValUtils.isRequiredInitializationActive());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationActivateRequiredInitializationTestCase.class);
+ }
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationConstraintSourceAnnotationTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationConstraintSourceAnnotationTestCase.java
new file mode 100644
index 0000000..2b1ccc3
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationConstraintSourceAnnotationTestCase.java
@@ -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 java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+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.storage.PropertyStorage;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.test.core.config.support.ConstraintSourceAware2MetaDataBean;
+import org.apache.myfaces.extensions.validator.test.core.config.support.ConstraintSourceAwareBean;
+import org.apache.myfaces.extensions.validator.test.core.config.support.ConstraintSourceAwareMetaDataBean;
+import org.apache.myfaces.extensions.validator.test.core.config.support.CustomConstraintSource;
+import org.apache.myfaces.extensions.validator.util.ConstraintSourceUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationConstraintSourceAnnotationTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationConstraintSourceAnnotationTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public Class<? extends Annotation> constraintSourceAnnotation()
+ {
+ return CustomConstraintSource.class;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testConstraintSourceAnnotationDefault()
+ {
+ // Using the ConstraintSourceUtils.resolveMappedConstraintSourceFor
+ // needs to much setup.
+
+ Method method = ReflectionUtils.tryToGetMethod(ConstraintSourceUtils.class, "findMappedClass",
+ PropertyStorage.class, Class.class, String.class);
+ assertNotNull(method);
+ method.setAccessible(true);
+ Object[] args = new Object[3];
+ args[0] = ReflectionUtils.getPropertyStorage();
+ args[1] = ConstraintSourceAwareBean.class;
+ args[2] = "property2";
+ Object result = ReflectionUtils.tryToInvokeMethodOfClass(ConstraintSourceUtils.class, method, args);
+ assertNotNull(result);
+ assertEquals(ConstraintSourceAwareMetaDataBean.class, result);
+
+ }
+
+ public void testConstraintSourceAnnotationCustomConfig()
+ {
+ Method method = ReflectionUtils.tryToGetMethod(ConstraintSourceUtils.class, "findMappedClass",
+ PropertyStorage.class, Class.class, String.class);
+ assertNotNull(method);
+ method.setAccessible(true);
+ Object[] args = new Object[3];
+ args[0] = ReflectionUtils.getPropertyStorage();
+ args[1] = ConstraintSourceAwareBean.class;
+ args[2] = "property2";
+ Object result = ReflectionUtils.tryToInvokeMethodOfClass(ConstraintSourceUtils.class, method, args);
+ assertNotNull(result);
+ assertEquals(ConstraintSourceAware2MetaDataBean.class, result);
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationConstraintSourceAnnotationTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomBasePackageTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomBasePackageTestCase.java
new file mode 100644
index 0000000..1f01ce1
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomBasePackageTestCase.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config;
+
+import junit.framework.Test;
+
+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.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomBasePackageTestCase 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.";
+
+ public ExtValCoreConfigurationCustomBasePackageTestCase(String name)
+ {
+ super(name);
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_BASE_PACKAGE",
+ ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_TEST);
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customBasePackage()
+ {
+ return ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_CONFIG;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testCustomBasePackageDefault() throws Exception
+ {
+ String value = ExtValContext.getContext().getInformationProviderBean().get(CustomInformation.BASE_PACKAGE);
+ assertEquals("org.apache.myfaces.extensions.validator.custom.", value);
+ }
+
+ public void testCustomBasePackageWebXml()
+ {
+
+ String value = ExtValContext.getContext().getInformationProviderBean().get(CustomInformation.BASE_PACKAGE);
+ assertEquals(ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_TEST, value);
+ }
+
+ public void testCustomBasePackageCustomConfig()
+ {
+
+ String value = ExtValContext.getContext().getInformationProviderBean().get(CustomInformation.BASE_PACKAGE);
+ assertEquals(ORG_APACHE_MYFACES_EXTENSIONS_VALIDATOR_CONFIG, value);
+ }
+
+ public static Test suite()
+ {
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomBasePackageTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentInitializerClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentInitializerClassNameTestCase.java
new file mode 100644
index 0000000..d650e8c
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentInitializerClassNameTestCase.java
@@ -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.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.initializer.component.ComponentInitializer;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomComponentInitializerClassNameTestCase extends ExtValCoreConfigurationTestCase
+{
+
+ public ExtValCoreConfigurationCustomComponentInitializerClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomComponentInitializer implements ComponentInitializer
+ {
+
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+
+ }
+
+ }
+
+ public static class Custom2ComponentInitializer implements ComponentInitializer
+ {
+
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_COMPONENT_INITIALIZER",
+ CustomComponentInitializer.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customComponentInitializerClassName()
+ {
+ return Custom2ComponentInitializer.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testCustomComponentInitializerClassNameDefault()
+ {
+ assertEquals(0, ExtValContext.getContext().getComponentInitializers().size());
+ }
+
+ public void testCustomComponentInitializerClassNameWebXml()
+ {
+ List<ComponentInitializer> initializers = ExtValContext.getContext().getComponentInitializers();
+ assertEquals(1, initializers.size());
+ assertEquals(CustomComponentInitializer.class.getName(), initializers.get(0).getClass().getName());
+ }
+
+ public void testCustomComponentInitializerClassNameCustomConfig()
+ {
+ List<ComponentInitializer> initializers = ExtValContext.getContext().getComponentInitializers();
+ assertEquals(1, initializers.size());
+ assertEquals(Custom2ComponentInitializer.class.getName(), initializers.get(0).getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomComponentInitializerClassNameTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentMetaDataExtractorClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentMetaDataExtractorClassNameTestCase.java
new file mode 100644
index 0000000..4efa647
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentMetaDataExtractorClassNameTestCase.java
@@ -0,0 +1,141 @@
+/*
+ * 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.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.extractor.DefaultComponentMetaDataExtractorFactory;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
+import org.apache.myfaces.extensions.validator.core.property.DefaultPropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomComponentMetaDataExtractorClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ private static final String WEB_XML = "Web.XML";
+ private static final String CUSTOM_CONFIG = "Custom config";
+
+ public ExtValCoreConfigurationCustomComponentMetaDataExtractorClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomMetaDataExtractor implements MetaDataExtractor
+ {
+
+ public PropertyInformation extract(FacesContext facesContext, Object object)
+ {
+ PropertyInformation result = new DefaultPropertyInformation();
+ result.setInformation(PropertyInformationKeys.CUSTOM_PROPERTIES, WEB_XML);
+ return result;
+ }
+
+ }
+
+ public static class CustomMetaDataExtractor2 implements MetaDataExtractor
+ {
+
+ public PropertyInformation extract(FacesContext facesContext, Object object)
+ {
+ PropertyInformation result = new DefaultPropertyInformation();
+ result.setInformation(PropertyInformationKeys.CUSTOM_PROPERTIES, CUSTOM_CONFIG);
+ return result;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_COMPONENT_META_DATA_EXTRACTOR",
+ CustomMetaDataExtractor.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customComponentMetaDataExtractorClassName()
+ {
+ return CustomMetaDataExtractor2.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testCustomComponentMetaDataExtractorClassNameDefault()
+ {
+ DefaultComponentMetaDataExtractorFactory factory = new DefaultComponentMetaDataExtractorFactory();
+ MetaDataExtractor extractor = factory.create();
+ PropertyInformation propInformation = extractor.extract(facesContext, new Object());
+ // Object isn't allowed so we get an empty propertyInformation object
+ // back.
+ // The web.xml and custom config sets an extractor that enters something
+ // here.
+ assertNull(propInformation.getInformation(PropertyInformationKeys.CUSTOM_PROPERTIES));
+ }
+
+ public void testCustomComponentMetaDataExtractorClassNameWebXml()
+ {
+ DefaultComponentMetaDataExtractorFactory factory = new DefaultComponentMetaDataExtractorFactory();
+ MetaDataExtractor extractor = factory.create();
+ PropertyInformation propInformation = extractor.extract(facesContext, new Object());
+ assertEquals(WEB_XML, propInformation.getInformation(PropertyInformationKeys.CUSTOM_PROPERTIES));
+ }
+
+ public void testCustomComponentMetaDataExtractorClassNameCustomConfig()
+ {
+ DefaultComponentMetaDataExtractorFactory factory = new DefaultComponentMetaDataExtractorFactory();
+ MetaDataExtractor extractor = factory.create();
+ PropertyInformation propInformation = extractor.extract(facesContext, new Object());
+ assertEquals(CUSTOM_CONFIG, propInformation.getInformation(PropertyInformationKeys.CUSTOM_PROPERTIES));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomComponentMetaDataExtractorClassNameTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentMetaDataExtractorFactoryClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentMetaDataExtractorFactoryClassNameTestCase.java
new file mode 100644
index 0000000..2fe2e66
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomComponentMetaDataExtractorFactoryClassNameTestCase.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config;
+
+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.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.extractor.ComponentMetaDataExtractorFactory;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractorFactory;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomComponentMetaDataExtractorFactoryClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomComponentMetaDataExtractorFactoryClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomComponentMetaDataExtractorFactory implements ComponentMetaDataExtractorFactory
+ {
+
+ public MetaDataExtractor create()
+ {
+
+ return null;
+ }
+
+ public MetaDataExtractor createWith(Map<String, Object> properties)
+ {
+
+ return null;
+ }
+
+ }
+
+ public static class Custom2ComponentMetaDataExtractorFactory implements ComponentMetaDataExtractorFactory
+ {
+
+ public MetaDataExtractor create()
+ {
+
+ return null;
+ }
+
+ public MetaDataExtractor createWith(Map<String, Object> properties)
+ {
+
+ return null;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_COMPONENT_META_DATA_EXTRACTOR_FACTORY",
+ CustomComponentMetaDataExtractorFactory.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public String customComponentMetaDataExtractorFactoryClassName()
+ {
+
+ return Custom2ComponentMetaDataExtractorFactory.class.getName();
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testCustomComponentMetaDataExtractorFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.COMPONENT_META_DATA_EXTRACTOR_FACTORY,
+ ComponentMetaDataExtractorFactory.class);
+ assertEquals(DefaultComponentMetaDataExtractorFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomComponentMetaDataExtractorFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.COMPONENT_META_DATA_EXTRACTOR_FACTORY,
+ ComponentMetaDataExtractorFactory.class);
+ assertEquals(CustomComponentMetaDataExtractorFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomComponentMetaDataExtractorFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.COMPONENT_META_DATA_EXTRACTOR_FACTORY,
+ ComponentMetaDataExtractorFactory.class);
+ assertEquals(Custom2ComponentMetaDataExtractorFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomComponentMetaDataExtractorFactoryClassNameTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase.java
new file mode 100644
index 0000000..db1bf70
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase.java
@@ -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 javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+
+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.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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ 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;
+ }
+ }
+
+ public void testCustomFacesMessageFactoryClassNameDefault()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.FACES_MESSAGE_FACTORY, FacesMessageFactory.class);
+ assertEquals(DefaultFacesMessageFactory.class.getName(), factory.getClass().getName());
+
+ }
+
+ public void testCustomFacesMessageFactoryClassNameWebXml()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.FACES_MESSAGE_FACTORY, FacesMessageFactory.class);
+ assertEquals(CustomFacesMessageFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public void testCustomFacesMessageFactoryClassNameCustomConfig()
+ {
+ FactoryFinder factoryFinder = DefaultFactoryFinder.getInstance();
+ Object factory = factoryFinder.getFactory(FactoryNames.FACES_MESSAGE_FACTORY, FacesMessageFactory.class);
+ assertEquals(Custom2FacesMessageFactory.class.getName(), factory.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomFacesMessageFactoryClassNameTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase.java
new file mode 100644
index 0000000..dd3674a
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase.java
@@ -0,0 +1,134 @@
+/*
+ * 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 junit.framework.Test;
+
+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.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ public ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase(String name)
+ {
+ super(name);
+
+ }
+
+ 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;
+ }
+
+ }
+
+ public void testCustomInformationProviderBeanClassNameDefault()
+ {
+ InformationProviderBean bean = ExtValContext.getContext().getInformationProviderBean();
+ assertEquals(InformationProviderBean.class.getName(), bean.getClass().getName());
+ }
+
+ public void testCustomInformationProviderBeanClassNameWebXml()
+ {
+ InformationProviderBean bean = ExtValContext.getContext().getInformationProviderBean();
+ assertEquals(CustomInformationProviderBean.class.getName(), bean.getClass().getName());
+ // An additional test to make sure we have the custom
+ // informationProviderBean.
+ assertEquals(ExtValInformation.EXTENSIONS_VALIDATOR_BASE_PACKAGE_NAME + ".custom.X", bean
+ .get(CustomInformation.MESSAGE_BUNDLE_NAME));
+ }
+
+ public void testCustomInformationProviderBeanClassNameCustomConfig()
+ {
+ InformationProviderBean bean = ExtValContext.getContext().getInformationProviderBean();
+ assertEquals(CustomInformationProviderBean2.class.getName(), bean.getClass().getName());
+ // An additional test to make sure we have the custom
+ // informationProviderBean.
+ assertEquals(ExtValInformation.EXTENSIONS_VALIDATOR_BASE_PACKAGE_NAME + ".custom.Y", bean
+ .get(CustomInformation.MESSAGE_BUNDLE_NAME));
+ }
+
+ public static Test suite()
+ {
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationCustomInformationProviderBeanClassNameTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.java
new file mode 100644
index 0000000..bba5c7b
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageBundleBaseNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.java
new file mode 100644
index 0000000..c271599
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMessageResolverFactoryClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.java
new file mode 100644
index 0000000..d5bcdcf
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataExtractionInterceptorClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.java
new file mode 100644
index 0000000..2073e16
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataStorageFilterClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.java
new file mode 100644
index 0000000..aab3d1b
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataToValidationStrategyNameMapperClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.java
new file mode 100644
index 0000000..4d755a7
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomMetaDataTransformerFactoryClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.java
new file mode 100644
index 0000000..7416d12
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomPropertyValidationInterceptorClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.java
new file mode 100644
index 0000000..073d976
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.java
new file mode 100644
index 0000000..90e9545
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomStorageManagerFactoryClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomTestCase.java
new file mode 100644
index 0000000..725d1f6
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomTestCase.java
@@ -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);
+ }
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.java
new file mode 100644
index 0000000..cda7d36
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationExceptionInterceptorClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.java
new file mode 100644
index 0000000..581f3c3
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.java
new file mode 100644
index 0000000..99c657a
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterExtractorFactoryClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.java
new file mode 100644
index 0000000..8dd6e09
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationParameterFactoryClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase.java
new file mode 100644
index 0000000..7a42092
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyFactoryClassNameTestCase.java
@@ -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);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyToMessageResolverNameMapperClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyToMessageResolverNameMapperClassNameTestCase.java
new file mode 100644
index 0000000..db43e62
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyToMessageResolverNameMapperClassNameTestCase.java
@@ -0,0 +1,159 @@
+/*
+ * 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.core.validation.strategy.ValidationStrategy;
+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 ExtValCoreConfigurationCustomValidationStrategyToMessageResolverNameMapperClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+
+ private static final String WEB_XML = "Web.xml";
+ private static final String CUSTOM_CONFIG = "Custom Config";
+
+ public ExtValCoreConfigurationCustomValidationStrategyToMessageResolverNameMapperClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomNameMapper implements NameMapper<ValidationStrategy>
+ {
+
+ public String createName(ValidationStrategy source)
+ {
+ return WEB_XML;
+ }
+
+ }
+
+ public static class Custom2NameMapper implements NameMapper<ValidationStrategy>
+ {
+
+ public String createName(ValidationStrategy source)
+ {
+ return CUSTOM_CONFIG;
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX
+ + ".CUSTOM_VALIDATION_STRATEGY_TO_MESSAGE_RESOLVER_NAME_MAPPER", CustomNameMapper.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customValidationStrategyToMessageResolverNameMapperClassName()
+ {
+ return Custom2NameMapper.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testCustomValidationStrategyToMessageResolverNameMapperClassNameDefault()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertEquals(5, nameMappers.size());
+ // The first one (due to @InvocationOrder) is the
+ // CustomConfiguredValidationStrategyToMsgResolverNameMapper which we
+ // can
+ // customize and testing here.
+ NameMapper<ValidationStrategy> mapper = nameMappers.get(0);
+ // By default nothing is configures so should return null.
+ assertNull(mapper.createName(null));
+
+ }
+
+ public void testCustomValidationStrategyToMessageResolverNameMapperClassNameWebXml()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertEquals(5, nameMappers.size());
+ // No mapper additional, but the first mapper contain now our custom
+ // configured mapper.
+
+ NameMapper<ValidationStrategy> mapper = nameMappers.get(0);
+ // So now it should return some value
+ assertEquals(WEB_XML, mapper.createName(null));
+ }
+
+ public void testCustomValidationStrategyToMessageResolverNameMapperClassNameCustomConfig()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertEquals(5, nameMappers.size());
+ // No mapper additional, but the first mapper contain now our custom
+ // configured mapper.
+
+ NameMapper<ValidationStrategy> mapper = nameMappers.get(0);
+ // So now it should return some value
+ assertEquals(CUSTOM_CONFIG, mapper.createName(null));
+ }
+
+ private List<NameMapper<ValidationStrategy>> getNameMappers()
+ {
+ NameMapperAwareFactory result = ExtValContext.getContext().getFactoryFinder().getFactory(
+ FactoryNames.MESSAGE_RESOLVER_FACTORY, NameMapperAwareFactory.class);
+
+ return ((MockMessageResolverFactory) result).getRegisteredNameMapperList();
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomValidationStrategyToMessageResolverNameMapperClassNameTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyToMetaDataTransformerNameMapperClassNameTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyToMetaDataTransformerNameMapperClassNameTestCase.java
new file mode 100644
index 0000000..b0b6c85
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationCustomValidationStrategyToMetaDataTransformerNameMapperClassNameTestCase.java
@@ -0,0 +1,155 @@
+/*
+ * 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.core.validation.strategy.ValidationStrategy;
+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 ExtValCoreConfigurationCustomValidationStrategyToMetaDataTransformerNameMapperClassNameTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ private static final String WEB_XML = "Web.xml";
+ private static final String CUSTOM_CONFIG = "Custom Config";
+
+ public ExtValCoreConfigurationCustomValidationStrategyToMetaDataTransformerNameMapperClassNameTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomNameMapper implements NameMapper<ValidationStrategy>
+ {
+
+ public String createName(ValidationStrategy source)
+ {
+ return WEB_XML;
+ }
+
+ }
+
+ public static class Custom2NameMapper implements NameMapper<ValidationStrategy>
+ {
+
+ public String createName(ValidationStrategy source)
+ {
+ return CUSTOM_CONFIG;
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX
+ + ".CUSTOM_VALIDATION_STRATEGY_TO_META_DATA_TRANSFORMER_NAME_MAPPER", CustomNameMapper.class
+ .getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public String customValidationStrategyToMetaDataTransformerNameMapperClassName()
+ {
+ return Custom2NameMapper.class.getName();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testCustomValidationStrategyToMetaDataTransformerNameMapperClassNameDefault()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertEquals(6, nameMappers.size());
+ // The first one (due to @InvocationOrder) is the
+ // CustomConfiguredValidationStrategyToMetaDataTransformerNameMapper
+ // which we can customize and testing here.
+ NameMapper<ValidationStrategy> mapper = nameMappers.get(0);
+ // By default nothing is configures so should return null.
+ assertNull(mapper.createName(null));
+ }
+
+ public void testCustomValidationStrategyToMetaDataTransformerNameMapperClassNameWebXml()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertEquals(6, nameMappers.size());
+ // No mapper additional, but the first mapper contain now our custom
+ // configured mapper.
+ NameMapper<ValidationStrategy> mapper = nameMappers.get(0);
+ // So now it should return some value
+ assertEquals(WEB_XML, mapper.createName(null));
+ }
+
+ public void testCustomValidationStrategyToMetaDataTransformerNameMapperClassNameCustomConfig()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertEquals(6, nameMappers.size());
+ // No mapper additional, but the first mapper contain now our custom
+ // configured mapper.
+ NameMapper<ValidationStrategy> mapper = nameMappers.get(0);
+ // So now it should return some value
+ assertEquals(CUSTOM_CONFIG, mapper.createName(null));
+ }
+
+ private List<NameMapper<ValidationStrategy>> getNameMappers()
+ {
+ NameMapperAwareFactory result = ExtValContext.getContext().getFactoryFinder().getFactory(
+ FactoryNames.META_DATA_TRANSFORMER_FACTORY, NameMapperAwareFactory.class);
+
+ return ((MockMetaDataTransformerFactory) result).getRegisteredNameMapperList();
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationCustomValidationStrategyToMetaDataTransformerNameMapperClassNameTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateComponentInitializationTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateComponentInitializationTestCase.java
new file mode 100644
index 0000000..dfbc6fe
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateComponentInitializationTestCase.java
@@ -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.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.initializer.component.ComponentInitializer;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationDeactivateComponentInitializationTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationDeactivateComponentInitializationTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomComponentInitializer implements ComponentInitializer
+ {
+
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+
+ }
+
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+
+ super.setUp();
+ // Make sure we have one ComponentInitializer. When deactivated the
+ // getComponentInitializers returns an empty list whatever registered.
+ ExtValContext.getContext().addComponentInitializer(new CustomComponentInitializer());
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_COMPONENT_INITIALIZATION", "true");
+
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean deactivateComponentInitialization()
+ {
+ return true;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testDeactivateComponentInitializationDefault()
+ {
+
+ assertFalse(ExtValContext.getContext().getComponentInitializers().isEmpty());
+ }
+
+ public void testDeactivateComponentInitializationWebXml()
+ {
+ assertTrue(ExtValContext.getContext().getComponentInitializers().isEmpty());
+ }
+
+ public void testDeactivateComponentInitializationCustomConfig()
+ {
+ assertTrue(ExtValContext.getContext().getComponentInitializers().isEmpty());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationDeactivateComponentInitializationTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateDefaultConventionTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateDefaultConventionTestCase.java
new file mode 100644
index 0000000..19b2428
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateDefaultConventionTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * 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.internal.Priority;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationDeactivateDefaultConventionTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationDeactivateDefaultConventionTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_DEFAULT_CONVENTION", "true");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean deactivateDefaultConvention()
+ {
+ return true;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @ToDo(value = Priority.MEDIUM, description = "some better logic to see if it is really well integrated")
+ public void testDeactivateDefConventionDefault() throws Exception
+ {
+ // Not a very clever testcase but code in
+ // AbstractValidationErrorMessageResolver is too complex to have a quick
+ // simple test of the parameter
+ assertFalse(ExtValCoreConfiguration.get().deactivateDefaultConvention());
+ }
+
+ // Name of method should contain default
+ public void testDeactivateDefConventionWebXml()
+ {
+ assertTrue(ExtValCoreConfiguration.get().deactivateDefaultConvention());
+ }
+
+ // Name of method should contain default
+ public void testDeactivateDefConventionCustomConfig()
+ {
+ assertTrue(ExtValCoreConfiguration.get().deactivateDefaultConvention());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationDeactivateDefaultConventionTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateDefaultNameMappersTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateDefaultNameMappersTestCase.java
new file mode 100644
index 0000000..ae0c73f
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateDefaultNameMappersTestCase.java
@@ -0,0 +1,114 @@
+/*
+ * 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.core.validation.strategy.ValidationStrategy;
+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 ExtValCoreConfigurationDeactivateDefaultNameMappersTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationDeactivateDefaultNameMappersTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_DEFAULT_NAME_MAPPERS", "true");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean deactivateDefaultNameMappers()
+ {
+ return true;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testDeactivateDefaultNameMappersDefault()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertFalse(nameMappers.isEmpty());
+ }
+
+ public void testDeactivateDefaultNameMappersWebXml()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertTrue(nameMappers.isEmpty());
+ }
+
+ // Name shouldn't contain default
+ public void testDeactivateDefNameMappersCustomConfig()
+ {
+ List<NameMapper<ValidationStrategy>> nameMappers = getNameMappers();
+ assertTrue(nameMappers.isEmpty());
+ }
+
+ private List<NameMapper<ValidationStrategy>> getNameMappers()
+ {
+ NameMapperAwareFactory result = ExtValContext.getContext().getFactoryFinder().getFactory(
+ FactoryNames.MESSAGE_RESOLVER_FACTORY, NameMapperAwareFactory.class);
+
+ return ((MockMessageResolverFactory) result).getRegisteredNameMapperList();
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationDeactivateDefaultNameMappersTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateElResolverTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateElResolverTestCase.java
new file mode 100644
index 0000000..e364fe9
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateElResolverTestCase.java
@@ -0,0 +1,159 @@
+/*
+ * 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.component.UIInput;
+import javax.faces.component.html.HtmlInputText;
+
+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.ExtValModuleConfiguration;
+import org.apache.myfaces.extensions.validator.core.el.DefaultELHelper;
+import org.apache.myfaces.extensions.validator.core.el.ELHelper;
+import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.test.core.config.support.ConstraintSourceAwareBean;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationDeactivateElResolverTestCase extends ExtValCoreConfigurationTestCase
+{
+ private UIInput uiComponent;
+
+ public ExtValCoreConfigurationDeactivateElResolverTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomDefaultELHelper extends DefaultELHelper
+ {
+
+ @Override
+ protected PropertyDetails getPropertyDetailsViaReflectionFallback(UIComponent uiComponent)
+ {
+ return null;
+ }
+
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ uiComponent = new HtmlInputText();
+ ConstraintSourceAwareBean bean = new ConstraintSourceAwareBean();
+
+ facesContext.getExternalContext().getRequestMap().put("testBean", bean);
+
+ createValueBinding(uiComponent, "value", "#{testBean.property1}");
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_EL_RESOLVER", "true");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean deactivateElResolver()
+ {
+ return true;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Override
+ protected ExtValModuleConfiguration[] getCustomConfigObjects()
+ {
+ if (needCustomConfig())
+ {
+ // We need to set it here already, because otherwise the setup triggers the creation
+ // of the DefaultELHelper that stores the parameter in a static variable.
+ // Setting the parameter to another value through getCustomExtValCoreConfiguration is then pointless.
+ return new ExtValModuleConfiguration[] { new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean deactivateElResolver()
+ {
+ return true;
+ }
+
+ } };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testDeactivateElResolverDefault()
+ {
+ ELHelper elHelper = new CustomDefaultELHelper();
+ assertNotNull(elHelper.getPropertyDetailsOfValueBinding(uiComponent));
+
+ }
+
+ public void testDeactivateElResolverWebXml()
+ {
+ ELHelper elHelper = new CustomDefaultELHelper();
+ // When deactivated, the getPropertyDetailsViaReflectionFallback method
+ // is called which returns null in our custom version
+ assertNull(elHelper.getPropertyDetailsOfValueBinding(uiComponent));
+ }
+
+ public void testDeactivateElResolverCustomConfig()
+ {
+ ELHelper elHelper = new CustomDefaultELHelper();
+ // When deactivated, the getPropertyDetailsViaReflectionFallback method
+ // is called which returns null in our custom version
+ assertNull(elHelper.getPropertyDetailsOfValueBinding(uiComponent));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationDeactivateElResolverTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateRenderKitFactoryTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateRenderKitFactoryTestCase.java
new file mode 100644
index 0000000..f1aa8e8
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateRenderKitFactoryTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * 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.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+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.renderkit.ExtValRenderKit;
+import org.apache.myfaces.extensions.validator.core.renderkit.ExtValRenderKitFactory;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.shale.test.mock.MockRenderKit;
+import org.apache.shale.test.mock.MockRenderKitFactory;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationDeactivateRenderKitFactoryTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationDeactivateRenderKitFactoryTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_RENDER_KIT_FACTORY", "true");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean deactivateRenderKitFactory()
+ {
+ return true;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testDeactivateRenderKitFactoryDefault()
+ {
+ RenderKitFactory factory = new ExtValRenderKitFactory(new MockRenderKitFactory());
+ RenderKit renderKit = factory.getRenderKit(facesContext, RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ assertEquals(ExtValRenderKit.class.getName(), renderKit.getClass().getName());
+
+ }
+
+ public void testDeactivateRenderKitFactoryWebXml()
+ {
+ RenderKitFactory factory = new ExtValRenderKitFactory(new MockRenderKitFactory());
+ RenderKit renderKit = factory.getRenderKit(facesContext, RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ assertEquals(MockRenderKit.class.getName(), renderKit.getClass().getName());
+ }
+
+ public void testDeactivateRenderKitFactoryCustomConfig()
+ {
+ RenderKitFactory factory = new ExtValRenderKitFactory(new MockRenderKitFactory());
+ RenderKit renderKit = factory.getRenderKit(facesContext, RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ assertEquals(MockRenderKit.class.getName(), renderKit.getClass().getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationDeactivateRenderKitFactoryTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateRequiredAttributeSupportTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateRequiredAttributeSupportTestCase.java
new file mode 100644
index 0000000..2978819
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateRequiredAttributeSupportTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * 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.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationDeactivateRequiredAttributeSupportTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationDeactivateRequiredAttributeSupportTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_REQUIRED_ATTRIBUTE_SUPPORT", "true");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean deactivateRequiredAttributeSupport()
+ {
+ return true;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testDeactivateRequiredAttributeSupportDefault()
+ {
+ assertFalse(ExtValUtils.isRequiredResetActivated());
+ }
+
+ public void testDeactivateRequiredAttributeSupportWebXml()
+ {
+ assertTrue(ExtValUtils.isRequiredResetActivated());
+ }
+
+ public void testDeactivateRequiredAttributeSupportCustomConfig()
+ {
+ assertTrue(ExtValUtils.isRequiredResetActivated());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationDeactivateRequiredAttributeSupportTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateValidationParametersTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateValidationParametersTestCase.java
new file mode 100644
index 0000000..c434735
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDeactivateValidationParametersTestCase.java
@@ -0,0 +1,98 @@
+/*
+ * 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.parameter.DefaultValidationParameterExtractor;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationDeactivateValidationParametersTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationDeactivateValidationParametersTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_VALIDATION_PARAMETERS", "true");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean deactivateValidationParameters()
+ {
+ return true;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testDeactivateValidationParametersDefault()
+ {
+ assertEquals(DefaultValidationParameterExtractor.class.getName(), ExtValUtils.getValidationParameterExtractor()
+ .getClass().getName());
+
+ }
+
+ public void testDeactivateValidationParametersWebXml()
+ {
+ assertTrue(ExtValUtils.getValidationParameterExtractor().getClass().getName().startsWith(
+ ExtValUtils.class.getName()));
+ }
+
+ public void testDeactivateValidationParametersCustomConfig()
+ {
+ assertTrue(ExtValUtils.getValidationParameterExtractor().getClass().getName().startsWith(
+ ExtValUtils.class.getName()));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationDeactivateValidationParametersTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDisableClientSideValidationValidationParameterTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDisableClientSideValidationValidationParameterTestCase.java
new file mode 100644
index 0000000..b82dd99
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationDisableClientSideValidationValidationParameterTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * 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.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.DisableClientSideValidation;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ValidationParameter;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationDisableClientSideValidationValidationParameterTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationDisableClientSideValidationValidationParameterTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static interface CustomDisableClientSideValidation extends DisableClientSideValidation
+ {
+
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public Class<? extends ValidationParameter> disableClientSideValidationValidationParameter()
+ {
+ return CustomDisableClientSideValidation.class;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testDisableClientSideValidationValidationParameterDefault()
+ {
+
+ assertEquals(DisableClientSideValidation.class.getName(), ((Class) ExtValContext.getContext()
+ .getGlobalProperty(DisableClientSideValidation.class.getName())).getName());
+ }
+
+ public void testDisableClientSideValidationValidationParameterCustomConfig()
+ {
+
+ assertEquals(CustomDisableClientSideValidation.class.getName(), ((Class) ExtValContext.getContext()
+ .getGlobalProperty(DisableClientSideValidation.class.getName())).getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(
+ ExtValCoreConfigurationDisableClientSideValidationValidationParameterTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationIgnoreConstraintSourceAnnotationTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationIgnoreConstraintSourceAnnotationTestCase.java
new file mode 100644
index 0000000..b4be4cf
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationIgnoreConstraintSourceAnnotationTestCase.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import 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.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.test.core.config.support.ConstraintSourceAwareBean;
+import org.apache.myfaces.extensions.validator.test.core.config.support.CustomIgnoreConstraintSource;
+import org.apache.myfaces.extensions.validator.util.ConstraintSourceUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationIgnoreConstraintSourceAnnotationTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationIgnoreConstraintSourceAnnotationTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public Class<? extends Annotation> ignoreConstraintSourceAnnotation()
+ {
+ return CustomIgnoreConstraintSource.class;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testIgnoreConstraintSourceAnnotationDefault() throws Exception
+ {
+ Method method = ReflectionUtils.getMethod(ConstraintSourceUtils.class, "isMappedConstraintSourceIgnored",
+ Class.class, String.class);
+ assertNotNull(method);
+ assertTrue((Boolean) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ ConstraintSourceAwareBean.class, "property1"));
+ assertFalse((Boolean) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ ConstraintSourceAwareBean.class, "property2"));
+ }
+
+ public void testIgnoreConstraintSourceAnnotationCustomConfig() throws Exception
+ {
+ Method method = ReflectionUtils.getMethod(ConstraintSourceUtils.class, "isMappedConstraintSourceIgnored",
+ Class.class, String.class);
+ assertNotNull(method);
+ assertFalse((Boolean) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ ConstraintSourceAwareBean.class, "property1"));
+ assertTrue((Boolean) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ ConstraintSourceAwareBean.class, "property2"));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationIgnoreConstraintSourceAnnotationTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationInterpretEmptyStringSubmittedValuesAsNullTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationInterpretEmptyStringSubmittedValuesAsNullTestCase.java
new file mode 100644
index 0000000..b42455b
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationInterpretEmptyStringSubmittedValuesAsNullTestCase.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import 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.interceptor.AbstractValidationInterceptor;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationInterpretEmptyStringSubmittedValuesAsNullTestCase extends
+ ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationInterpretEmptyStringSubmittedValuesAsNullTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class TestValidationInterceptor extends AbstractValidationInterceptor
+ {
+
+ @Override
+ protected MetaDataExtractor getComponentMetaDataExtractor(Map<String, Object> properties)
+ {
+ return null;
+ }
+
+ @Override
+ protected void initComponent(FacesContext facesContext, UIComponent uiComponent)
+ {
+
+ }
+
+ @Override
+ protected void processValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject)
+ {
+
+ }
+
+ @Override
+ public boolean interpretEmptyStringValuesAsNull()
+ {
+ return super.interpretEmptyStringValuesAsNull();
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter("javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL", "false");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean interpretEmptyStringSubmittedValuesAsNull()
+ {
+ return false;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testInterpretEmptyStringSubmittedValuesAsNullDefault()
+ {
+ TestValidationInterceptor interceptor = new TestValidationInterceptor();
+ assertTrue(interceptor.interpretEmptyStringValuesAsNull());
+ }
+
+ public void testInterpretEmptyStringSubmittedValuesAsNullWebXml()
+ {
+ TestValidationInterceptor interceptor = new TestValidationInterceptor();
+ assertFalse(interceptor.interpretEmptyStringValuesAsNull());
+ }
+
+ public void testInterpretEmptyStringSubmittedValuesAsNullCustomConfig()
+ {
+ TestValidationInterceptor interceptor = new TestValidationInterceptor();
+ assertFalse(interceptor.interpretEmptyStringValuesAsNull());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationInterpretEmptyStringSubmittedValuesAsNullTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationProjectStageResolverTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationProjectStageResolverTestCase.java
new file mode 100644
index 0000000..3840a56
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationProjectStageResolverTestCase.java
@@ -0,0 +1,107 @@
+/*
+ * 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.JsfProjectStage;
+import org.apache.myfaces.extensions.validator.core.ProjectStage;
+import org.apache.myfaces.extensions.validator.core.ProjectStageResolver;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationProjectStageResolverTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationProjectStageResolverTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomProjectStageResolver implements ProjectStageResolver
+ {
+
+ public ProjectStage getCurrentProjectStage()
+ {
+
+ return ProjectStage.createStage(JsfProjectStage.UnitTest.getValue());
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter("javax.faces.PROJECT_STAGE", "SystemTest");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public ProjectStageResolver projectStageResolver()
+ {
+ return new CustomProjectStageResolver();
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testProjectStageResolverDefault()
+ {
+ assertTrue(JsfProjectStage.is(JsfProjectStage.Production));
+ }
+
+ public void testProjectStageResolverWebXml()
+ {
+ assertTrue(JsfProjectStage.is(JsfProjectStage.SystemTest));
+ }
+
+ public void testProjectStageResolverCustomConfig()
+ {
+ assertTrue(JsfProjectStage.is(JsfProjectStage.UnitTest));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationProjectStageResolverTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationProxyHelperTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationProxyHelperTestCase.java
new file mode 100644
index 0000000..e500abd
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationProxyHelperTestCase.java
@@ -0,0 +1,145 @@
+/*
+ * 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.proxy.ProxyHelper;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.util.ProxyUtils;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationProxyHelperTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationProxyHelperTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomProxyHelper implements ProxyHelper
+ {
+
+ public String getClassNameOfObject(Object proxiedObject)
+ {
+ return null;
+ }
+
+ public String getNameOfClass(Class proxiedClass)
+ {
+ return null;
+ }
+
+ public Class getUnproxiedClass(Class currentClass)
+ {
+ return null;
+ }
+
+ public <T> Class<T> getUnproxiedClass(Class currentClass, Class<T> targetType)
+ {
+ return null;
+ }
+
+ public boolean isProxiedClass(Class currentClass)
+ {
+ if (currentClass.equals(Object.class))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isProxiedObject(Object proxiedObject)
+ {
+ return false;
+ }
+
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+
+ super.setUp();
+ // Trick the method jsfUtils#isApplicationInitialized to believe the
+ // application is initialized
+ facesContext.getExternalContext().getRequestMap().put("Key", "Value");
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_PROXY_HELPER", CustomProxyHelper.class
+ .getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public ProxyHelper proxyHelper()
+ {
+ return new CustomProxyHelper();
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testProxyHelperDefault()
+ {
+ assertFalse(ProxyUtils.isProxiedClass(Object.class));
+ }
+
+ public void testProxyHelperWebXml()
+ {
+ assertTrue(ProxyUtils.isProxiedClass(Object.class));
+ }
+
+ public void testProxyHelperCustomConfig()
+ {
+ assertTrue(ProxyUtils.isProxiedClass(Object.class));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationProxyHelperTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationRendererProxyTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationRendererProxyTestCase.java
new file mode 100644
index 0000000..d230168
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationRendererProxyTestCase.java
@@ -0,0 +1,151 @@
+/*
+ * 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.context.FacesContext;
+import javax.faces.render.RenderKit;
+import javax.faces.render.Renderer;
+
+import junit.framework.Test;
+
+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.renderkit.ExtValRendererProxy;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationRendererProxyTestCase extends ExtValCoreConfigurationTestCase
+{
+
+ private static final String WEB_XML = "Web.xml";
+ private static final String CUSTOM_CONFIG = "Custom Config";
+
+ public ExtValCoreConfigurationRendererProxyTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomExtValRendererProxy extends ExtValRendererProxy
+ {
+
+ public CustomExtValRendererProxy(Renderer renderer)
+ {
+ super(renderer);
+ }
+
+ @Override
+ public String convertClientId(FacesContext facesContext, String s)
+ {
+ return WEB_XML;
+ }
+
+ }
+
+ public static class Custom2ExtValRendererProxy extends ExtValRendererProxy
+ {
+
+ public Custom2ExtValRendererProxy(Renderer renderer)
+ {
+ super(renderer);
+ }
+
+ @Override
+ public String convertClientId(FacesContext facesContext, String s)
+ {
+ return CUSTOM_CONFIG;
+ }
+
+ }
+
+ public static class CustomExtValCoreConfiguration extends DefaultExtValCoreConfiguration
+ {
+
+ public CustomExtValCoreConfiguration()
+ {
+ ExtValContext.getContext().addGlobalProperty(ExtValRendererProxy.KEY,
+ CustomExtValRendererProxy.class.getName(), true);
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValCoreConfiguration.class.getName(), CustomExtValCoreConfiguration.class.getName());
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public Class<? extends ExtValRendererProxy> rendererProxy()
+ {
+ return Custom2ExtValRendererProxy.class;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+ public void testRendererProxyDefault()
+ {
+ RenderKit kit = facesContext.getRenderKit();
+ Renderer renderer = kit.getRenderer("javax.faces.Input", "javax.faces.Text");
+ assertEquals("test", renderer.convertClientId(facesContext, "test"));
+ }
+
+ public void testRendererProxyWebXml()
+ {
+ RenderKit kit = facesContext.getRenderKit();
+ Renderer renderer = kit.getRenderer("javax.faces.Input", "javax.faces.Text");
+ assertEquals(WEB_XML, renderer.convertClientId(facesContext, "test"));
+ }
+
+ public void testRendererProxyCustomConfig()
+ {
+ RenderKit kit = facesContext.getRenderKit();
+ Renderer renderer = kit.getRenderer("javax.faces.Input", "javax.faces.Text");
+ assertEquals(CUSTOM_CONFIG, renderer.convertClientId(facesContext, "test"));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationRendererProxyTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyAnnotationTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyAnnotationTestCase.java
new file mode 100644
index 0000000..541d990
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyAnnotationTestCase.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import 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.storage.PropertyStorage;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.test.core.config.support.ConstraintSourceAwareBean;
+import org.apache.myfaces.extensions.validator.test.core.config.support.CustomTargetProperty;
+import org.apache.myfaces.extensions.validator.util.ConstraintSourceUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValAnnotationUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationTargetPropertyAnnotationTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationTargetPropertyAnnotationTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public Class<? extends Annotation> targetPropertyAnnotation()
+ {
+ return CustomTargetProperty.class;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testTargetPropertyAnnotationDefault() throws Exception
+ {
+ Method method = ReflectionUtils.getMethod(ConstraintSourceUtils.class, "getTargetPropertyMetaData",
+ PropertyStorage.class, Class.class, String.class);
+ assertNotNull(method);
+ PropertyStorage storage = ReflectionUtils.getPropertyStorage();
+ Annotation target = (Annotation) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ storage, ConstraintSourceAwareBean.class, "property3");
+
+ assertEquals("test1", ExtValAnnotationUtils.extractValueOf(target, Object.class));
+
+ assertNull(ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method, storage,
+ ConstraintSourceAwareBean.class, "property4"));
+ }
+
+ public void testTargetPropertyAnnotationCustomConfig() throws Exception
+ {
+ Method method = ReflectionUtils.getMethod(ConstraintSourceUtils.class, "getTargetPropertyMetaData",
+ PropertyStorage.class, Class.class, String.class);
+ assertNotNull(method);
+ PropertyStorage storage = ReflectionUtils.getPropertyStorage();
+ Annotation target = (Annotation) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ storage, ConstraintSourceAwareBean.class, "property4");
+
+ assertEquals("test2", ExtValAnnotationUtils.extractValueOf(target, Object.class));
+
+ assertNull(ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method, storage,
+ ConstraintSourceAwareBean.class, "property3"));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationTargetPropertyAnnotationTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase.java
new file mode 100644
index 0000000..37a4ff2
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+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.storage.PropertyStorage;
+import org.apache.myfaces.extensions.validator.core.validation.ConstraintSource;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.test.core.config.support.ConstraintSourceAwareBean;
+import org.apache.myfaces.extensions.validator.test.core.config.support.CustomConstraintSource;
+import org.apache.myfaces.extensions.validator.test.core.config.support.CustomTargetPropertyId;
+import org.apache.myfaces.extensions.validator.util.ConstraintSourceUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValAnnotationUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public Class<? extends Annotation> targetPropertyIdAnnotation()
+ {
+ return CustomTargetPropertyId.class;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testTargetPropertyIdAnnotationDefault() throws Exception
+ {
+ Method method = ReflectionUtils.getMethod(ConstraintSourceUtils.class, "getTargetPropertyMetaData",
+ PropertyStorage.class, Class.class, String.class);
+ assertNotNull(method);
+ PropertyStorage propertyStorage = ReflectionUtils.getPropertyStorage();
+ Annotation target = (Annotation) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ propertyStorage, ConstraintSourceAwareBean.class, "property5");
+
+ assertEquals(ConstraintSource.class.getName(), ((Class) ExtValAnnotationUtils.extractValueOf(target,
+ Object.class)).getName());
+
+ assertNull(ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ propertyStorage, ConstraintSourceAwareBean.class, "property6"));
+ }
+
+ public void testTargetPropertyIdAnnotationCustomConfig() throws Exception
+ {
+ Method method = ReflectionUtils.getMethod(ConstraintSourceUtils.class, "getTargetPropertyMetaData",
+ PropertyStorage.class, Class.class, String.class);
+ assertNotNull(method);
+ PropertyStorage propertyStorage = ReflectionUtils.getPropertyStorage();
+ Annotation target = (Annotation) ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ propertyStorage, ConstraintSourceAwareBean.class, "property6");
+
+ assertEquals(CustomConstraintSource.class.getName(), ((Class) ExtValAnnotationUtils.extractValueOf(target,
+ Object.class)).getName());
+
+ assertNull(ReflectionUtils.invokeMethodOfClass(ConstraintSourceUtils.class, method,
+ propertyStorage, ConstraintSourceAwareBean.class, "property5"));
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationTargetPropertyIdAnnotationTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTestCase.java
new file mode 100644
index 0000000..76db952
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationTestCase.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config;
+
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public abstract class ExtValCoreConfigurationTestCase extends
+ AbstractExValCoreTestCase
+{
+
+ public ExtValCoreConfigurationTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected boolean needXmlParameters()
+ {
+ return getName().contains("Xml");
+ }
+
+ protected boolean needCustomConfig()
+ {
+ return !getName().contains("Xml") && !getName().contains("Default");
+ }
+
+ @Override
+ /*
+ * Made the method final because we do
+ */
+ protected final void invokeStartupListeners()
+ {
+ super.invokeStartupListeners();
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationValidateEmptyFieldsTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationValidateEmptyFieldsTestCase.java
new file mode 100644
index 0000000..dec2bb5
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationValidateEmptyFieldsTestCase.java
@@ -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 java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+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.initializer.component.AbstractHtmlCoreComponentsComponentInitializer;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCoreConfigurationValidateEmptyFieldsTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationValidateEmptyFieldsTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomComponentInitializer extends AbstractHtmlCoreComponentsComponentInitializer
+ {
+
+ @Override
+ protected void configureRequiredAttribute(FacesContext facesContext, UIComponent uiComponent,
+ Map<String, Object> metaData)
+ {
+
+ }
+
+ @Override
+ public boolean validateEmptyFields()
+ {
+ return super.validateEmptyFields();
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter("javax.faces.VALIDATE_EMPTY_FIELDS", "false");
+ }
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+ @Override
+ public boolean validateEmptyFields()
+ {
+ return false;
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void testValidateEmptyFieldsDefault()
+ {
+ CustomComponentInitializer initializer = new CustomComponentInitializer();
+ assertTrue(initializer.validateEmptyFields());
+ }
+
+ public void testValidateEmptyFieldsWebXml()
+ {
+ CustomComponentInitializer initializer = new CustomComponentInitializer();
+ assertFalse(initializer.validateEmptyFields());
+ }
+
+ public void testValidateEmptyFieldsCustomConfig()
+ {
+ CustomComponentInitializer initializer = new CustomComponentInitializer();
+ assertFalse(initializer.validateEmptyFields());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationValidateEmptyFieldsTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationViolationSeverityTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationViolationSeverityTestCase.java
new file mode 100644
index 0000000..b5dcbef
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/ExtValCoreConfigurationViolationSeverityTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * 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.ExtValContext;
+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 ExtValCoreConfigurationViolationSeverityTestCase extends ExtValCoreConfigurationTestCase
+{
+ public ExtValCoreConfigurationViolationSeverityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
+ {
+ if (needCustomConfig())
+ {
+
+ return new DefaultExtValCoreConfiguration()
+ {
+
+ @Override
+ public Class violationSeverity()
+ {
+ return CustomViolationSeverity.class;
+ }
+
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static interface CustomViolationSeverity
+ {
+
+ }
+
+ public void testViolationSeverityDefault()
+ {
+ assertEquals(ViolationSeverity.class.getName(), ((Class) ExtValContext.getContext().getGlobalProperty(
+ ViolationSeverity.class.getName())).getName());
+ }
+
+ public void testViolationSeverityCustomConfig()
+ {
+ assertEquals(CustomViolationSeverity.class.getName(), ((Class) ExtValContext.getContext().getGlobalProperty(
+ ViolationSeverity.class.getName())).getName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCoreConfigurationViolationSeverityTestCase.class);
+ }
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAware2MetaDataBean.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAware2MetaDataBean.java
new file mode 100644
index 0000000..e720eb1
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAware2MetaDataBean.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config.support;
+
+public class ConstraintSourceAware2MetaDataBean
+{
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareBean.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareBean.java
new file mode 100644
index 0000000..a66b6da
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareBean.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config.support;
+
+import org.apache.myfaces.extensions.validator.core.validation.ConstraintSource;
+import org.apache.myfaces.extensions.validator.core.validation.IgnoreConstraintSource;
+import org.apache.myfaces.extensions.validator.core.validation.TargetProperty;
+import org.apache.myfaces.extensions.validator.core.validation.TargetPropertyId;
+
+@ConstraintSource(ConstraintSourceAwareMetaDataBean.class)
+public class ConstraintSourceAwareBean
+{
+ @IgnoreConstraintSource
+ private String property1;
+
+ @CustomIgnoreConstraintSource
+ private String property2;
+
+ @TargetProperty(value="test1")
+ private String property3;
+
+ @CustomTargetProperty(value="test2")
+ private String property4;
+
+ @TargetPropertyId(value=ConstraintSource.class)
+ private String property5;
+
+ @CustomTargetPropertyId(value=CustomConstraintSource.class)
+ private String property6;
+
+ public String getProperty1()
+ {
+ return property1;
+ }
+
+ public void setProperty1(String property1)
+ {
+ this.property1 = property1;
+ }
+
+ @CustomConstraintSource(ConstraintSourceAware2MetaDataBean.class)
+ public String getProperty2()
+ {
+ return property2;
+ }
+
+ public void setProperty2(String property2)
+ {
+ this.property2 = property2;
+ }
+}
+
+
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareMetaDataBean.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareMetaDataBean.java
new file mode 100644
index 0000000..89e29f4
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/ConstraintSourceAwareMetaDataBean.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config.support;
+
+public class ConstraintSourceAwareMetaDataBean
+{
+
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomConstraintSource.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomConstraintSource.java
new file mode 100644
index 0000000..3d02597
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomConstraintSource.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config.support;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+@Target({TYPE, FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+@UsageInformation(UsageCategory.API)
+public @interface CustomConstraintSource
+{
+ Class value();
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomIgnoreConstraintSource.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomIgnoreConstraintSource.java
new file mode 100644
index 0000000..0438430
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomIgnoreConstraintSource.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config.support;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+@UsageInformation(UsageCategory.API)
+public @interface CustomIgnoreConstraintSource
+{
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetProperty.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetProperty.java
new file mode 100644
index 0000000..628f159
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetProperty.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config.support;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+public @interface CustomTargetProperty
+{
+ String value();
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetPropertyId.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetPropertyId.java
new file mode 100644
index 0000000..db91caf
--- /dev/null
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/config/support/CustomTargetPropertyId.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.config.support;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Target({FIELD, METHOD})
+@Retention(RUNTIME)
+@Documented
+public @interface CustomTargetPropertyId
+{
+ Class<? extends Annotation> value();
+}
diff --git a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/stage/IndependentProjectStageTestCase.java b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/stage/IndependentProjectStageTestCase.java
index 2583a75..faffa29 100644
--- a/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/stage/IndependentProjectStageTestCase.java
+++ b/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/stage/IndependentProjectStageTestCase.java
@@ -44,12 +44,11 @@
return new TestSuite(IndependentProjectStageTestCase.class);
}
+
@Override
- protected void setUp() throws Exception
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
{
- super.setUp();
-
- ExtValCoreConfiguration.use(new DefaultExtValCoreConfiguration()
+ return new DefaultExtValCoreConfiguration()
{
@Override
public ProjectStageResolver projectStageResolver()
@@ -76,7 +75,8 @@
if (!(independentProjectStageName == null || "".equals(independentProjectStageName)))
{
- ProjectStageName independentResult = ProjectStage.createStageName(independentProjectStageName.trim());
+ ProjectStageName independentResult = ProjectStage
+ .createStageName(independentProjectStageName.trim());
//check jsf stage values first
ProjectStageName result = ProjectStage.createStageName(independentProjectStageName.trim());
@@ -89,8 +89,8 @@
}
//check custom stage values
- if (ProjectStage.createStageName(CUSTOM_DEV).equals(independentResult) ||
- ProjectStage.createStageName(CUSTOM_TEST).equals(independentResult))
+ if (ProjectStage.createStageName(CUSTOM_DEV).equals(independentResult)
+ || ProjectStage.createStageName(CUSTOM_TEST).equals(independentResult))
{
return ProjectStage.createStage(independentResult);
}
@@ -100,7 +100,7 @@
}
};
}
- }, true);
+ };
}
private String resolveProjectStageName(String parameterName)
diff --git a/test-modules/core-tests/src/test/resources/org/apache/myfaces/extensions/validator/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCaseCustomConfig.properties b/test-modules/core-tests/src/test/resources/org/apache/myfaces/extensions/validator/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCaseCustomConfig.properties
new file mode 100644
index 0000000..b47e3f3
--- /dev/null
+++ b/test-modules/core-tests/src/test/resources/org/apache/myfaces/extensions/validator/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCaseCustomConfig.properties
@@ -0,0 +1 @@
+UnitTest=org.apache.myfaces.extensions.validator.test.core.config.ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase$Custom2ValidationStrategy
diff --git a/test-modules/core-tests/src/test/resources/org/apache/myfaces/extensions/validator/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCaseWebXml.properties b/test-modules/core-tests/src/test/resources/org/apache/myfaces/extensions/validator/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCaseWebXml.properties
new file mode 100644
index 0000000..80c9091
--- /dev/null
+++ b/test-modules/core-tests/src/test/resources/org/apache/myfaces/extensions/validator/core/config/ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCaseWebXml.properties
@@ -0,0 +1 @@
+UnitTest=org.apache.myfaces.extensions.validator.test.core.config.ExtValCoreConfigurationCustomStaticValidationStrategyMappingSourceTestCase$CustomValidationStrategy
diff --git a/test-modules/pom.xml b/test-modules/pom.xml
index 3bc37e2..4d482d8 100644
--- a/test-modules/pom.xml
+++ b/test-modules/pom.xml
@@ -51,6 +51,7 @@
<module>core-tests</module>
<module>property-validation-tests</module>
<module>bean-validation-tests</module>
+ <module>trinidad-component-support-tests</module>
</modules>
<dependencies>
@@ -173,6 +174,7 @@
<exclude>**/TestUtils.java</exclude>
<exclude>**/*Bean.java</exclude>
</excludes>
+ <useSystemClassLoader>true</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationCustomTestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationCustomTestCase.java
new file mode 100644
index 0000000..cf9db67
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationCustomTestCase.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.config;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.baseval.DefaultExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.baseval.ExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValBaseValidationConfigurationCustomTestCase extends ExtValBaseValidationConfigurationTestCase
+{
+
+ public ExtValBaseValidationConfigurationCustomTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomExtValBaseValidationModuleConfiguration extends
+ DefaultExtValBaseValidationModuleConfiguration
+ {
+
+ @Override
+ public boolean deactivateJpaBasedValidation()
+ {
+
+ return true;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needCustomConfig())
+ {
+ addInitParameter(ExtValBaseValidationModuleConfiguration.class.getName(),
+ CustomExtValBaseValidationModuleConfiguration.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValBaseValidationModuleConfiguration getCustomBaseValidationModuleConfiguration()
+ {
+ // Don't specify the custom config here. We explicitly want to test the
+ // web.xml parameter.
+ return null;
+ }
+
+ public void testExtValBaseValidationModuleConfigurationCustomDefault()
+ {
+ assertFalse(ExtValBaseValidationModuleConfiguration.get().deactivateJpaBasedValidation());
+ }
+
+ public void testExtValBaseValidationModuleConfigurationCustomCustomConfig()
+ {
+ assertTrue(ExtValBaseValidationModuleConfiguration.get().deactivateJpaBasedValidation());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValBaseValidationConfigurationCustomTestCase.class);
+ }
+}
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationDeactivateJpaBasedValidationTestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationDeactivateJpaBasedValidationTestCase.java
new file mode 100644
index 0000000..90f91ff
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationDeactivateJpaBasedValidationTestCase.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.config;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.baseval.DefaultExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.baseval.ExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfiguration;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfigurationNames;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValBaseValidationConfigurationDeactivateJpaBasedValidationTestCase extends
+ ExtValBaseValidationConfigurationTestCase
+{
+
+ public ExtValBaseValidationConfigurationDeactivateJpaBasedValidationTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_JPA_BASED_VALIDATION", "true");
+
+ }
+ }
+
+ @Override
+ protected ExtValBaseValidationModuleConfiguration getCustomBaseValidationModuleConfiguration()
+ {
+ return new DefaultExtValBaseValidationModuleConfiguration()
+ {
+
+ @Override
+ public boolean deactivateJpaBasedValidation()
+ {
+ return true;
+ }
+
+ };
+ }
+
+ public void testExtValBaseValidationConfigurationDeactivateJpaBasedValidationDefault()
+ {
+ List<StaticConfiguration<String, String>> configs = ExtValContext.getContext().getStaticConfiguration(
+ StaticConfigurationNames.META_DATA_TO_VALIDATION_STRATEGY_CONFIG);
+ assertEquals(1, configs.size());
+ }
+
+ public void testExtValBaseValidationConfigurationDeactivateJpaBasedValidationWebXml()
+ {
+ List<StaticConfiguration<String, String>> configs = ExtValContext.getContext().getStaticConfiguration(
+ StaticConfigurationNames.META_DATA_TO_VALIDATION_STRATEGY_CONFIG);
+ assertEquals(0, configs.size());
+ }
+
+ public void testExtValBaseValidationConfigurationDeactivateJpaBasedValidationCustomConfig()
+ {
+ List<StaticConfiguration<String, String>> configs = ExtValContext.getContext().getStaticConfiguration(
+ StaticConfigurationNames.META_DATA_TO_VALIDATION_STRATEGY_CONFIG);
+ assertEquals(0, configs.size());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValBaseValidationConfigurationDeactivateJpaBasedValidationTestCase.class);
+ }
+
+}
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationJpaValidationErrorMessagesTestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationJpaValidationErrorMessagesTestCase.java
new file mode 100644
index 0000000..6b24d28
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationJpaValidationErrorMessagesTestCase.java
@@ -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.propval.config;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.baseval.DefaultExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.baseval.ExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.baseval.message.resolver.JpaValidationErrorMessageResolver;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValBaseValidationConfigurationJpaValidationErrorMessagesTestCase extends
+ ExtValBaseValidationConfigurationTestCase
+{
+
+ private static final String WEB_XML = "Web.XML";
+ private static final String CUSTOM_CONFIG = "Custom config";
+
+ public ExtValBaseValidationConfigurationJpaValidationErrorMessagesTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class VisibleJpaValidationErrorMessageResolver extends JpaValidationErrorMessageResolver
+ {
+
+ @Override
+ public String getCustomBaseName()
+ {
+ return super.getCustomBaseName();
+ }
+
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".JPA_VALIDATION_ERROR_MESSAGES", WEB_XML);
+
+ }
+ }
+
+ @Override
+ protected ExtValBaseValidationModuleConfiguration getCustomBaseValidationModuleConfiguration()
+ {
+ return new DefaultExtValBaseValidationModuleConfiguration()
+ {
+
+ @Override
+ public String jpaValidationErrorMessages()
+ {
+ return CUSTOM_CONFIG;
+ }
+
+ };
+ }
+
+ public void testExtValBaseValidationConfigurationJpaValidationErrorMessagesDefault()
+ {
+ VisibleJpaValidationErrorMessageResolver messageResolver = new VisibleJpaValidationErrorMessageResolver();
+ assertNull(messageResolver.getCustomBaseName());
+ }
+
+ public void testExtValBaseValidationConfigurationJpaValidationErrorMessagesWebXml()
+ {
+ VisibleJpaValidationErrorMessageResolver messageResolver = new VisibleJpaValidationErrorMessageResolver();
+ assertEquals(WEB_XML, messageResolver.getCustomBaseName());
+ }
+
+ public void testExtValBaseValidationConfigurationJpaValidationErrorMessagesCustomConfig()
+ {
+ VisibleJpaValidationErrorMessageResolver messageResolver = new VisibleJpaValidationErrorMessageResolver();
+ assertEquals(CUSTOM_CONFIG, messageResolver.getCustomBaseName());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValBaseValidationConfigurationJpaValidationErrorMessagesTestCase.class);
+ }
+
+}
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationTestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationTestCase.java
new file mode 100644
index 0000000..af16389
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValBaseValidationConfigurationTestCase.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.config;
+
+import org.apache.myfaces.extensions.validator.PropertyValidationModuleStartupListener;
+import org.apache.myfaces.extensions.validator.baseval.DefaultExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.baseval.ExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValModuleConfiguration;
+import org.apache.myfaces.extensions.validator.crossval.DefaultExtValCrossValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.crossval.ExtValCrossValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public abstract class ExtValBaseValidationConfigurationTestCase extends AbstractExValCoreTestCase
+{
+
+ public ExtValBaseValidationConfigurationTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected boolean needXmlParameters()
+ {
+ return getName().contains("Xml");
+ }
+
+ protected boolean needCustomConfig()
+ {
+ return !getName().contains("Xml") && !getName().contains("Default");
+ }
+
+ @Override
+ /*
+ * Made the method final because we do
+ */
+ protected final void invokeStartupListeners()
+ {
+ super.invokeStartupListeners();
+ new PropertyValidationModuleStartupListener()
+ {
+ private static final long serialVersionUID = -3861810605160281884L;
+
+ @Override
+ protected void initModuleConfig()
+ {
+ ExtValBaseValidationModuleConfiguration
+ .use(new DefaultExtValBaseValidationModuleConfiguration(), false);
+ ExtValCrossValidationModuleConfiguration.use(new DefaultExtValCrossValidationModuleConfiguration(),
+ false);
+ }
+
+ @Override
+ protected void init()
+ {
+ initModuleConfig();
+ super.init();
+ }
+ }.init();
+ }
+
+ @Override
+ protected final ExtValModuleConfiguration[] getCustomConfigObjects()
+ {
+ if (needCustomConfig())
+ {
+ ExtValModuleConfiguration[] result = new ExtValModuleConfiguration[]
+ { getCustomBaseValidationModuleConfiguration() };
+ if (result.length == 1 && result[0] == null)
+ {
+ // test don't want to specify a custom configuration.
+ return null;
+ } else
+ {
+ return result;
+ }
+ } else
+ {
+ return null;
+ }
+ }
+
+ abstract protected ExtValBaseValidationModuleConfiguration getCustomBaseValidationModuleConfiguration();
+
+}
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationCustomTestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationCustomTestCase.java
new file mode 100644
index 0000000..c22b69b
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationCustomTestCase.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.config;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.crossval.DefaultExtValCrossValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.crossval.ExtValCrossValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCrossValidationConfigurationCustomTestCase extends ExtValCrossValidationConfigurationTestCase
+{
+
+ public ExtValCrossValidationConfigurationCustomTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomExtValCrossValidationModuleConfiguration extends
+ DefaultExtValCrossValidationModuleConfiguration
+ {
+
+ @Override
+ public boolean deactivateCrossvalidation()
+ {
+ return true;
+ }
+
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needCustomConfig())
+ {
+ addInitParameter(ExtValCrossValidationModuleConfiguration.class.getName(),
+ CustomExtValCrossValidationModuleConfiguration.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValCrossValidationModuleConfiguration getCustomCrossValidationModuleConfiguration()
+ {
+ // Don't specify the custom config here. We explicitly want to test the
+ // web.xml parameter.
+ return null;
+ }
+
+ public void testExtValCrossValidationModuleConfigurationCustomDefault()
+ {
+ assertFalse(ExtValCrossValidationModuleConfiguration.get().deactivateCrossvalidation());
+ }
+
+ public void testExtValCrossValidationModuleConfigurationCustomCustomConfig()
+ {
+ assertTrue(ExtValCrossValidationModuleConfiguration.get().deactivateCrossvalidation());
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCrossValidationConfigurationCustomTestCase.class);
+ }
+}
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationDeactivateCrossvalidationTestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationDeactivateCrossvalidationTestCase.java
new file mode 100644
index 0000000..cdd7927
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationDeactivateCrossvalidationTestCase.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.config;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.FactoryFinder;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.webapp.FacesServlet;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.crossval.DefaultExtValCrossValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.crossval.ExtValCrossValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValCrossValidationConfigurationDeactivateCrossvalidationTestCase extends
+ ExtValCrossValidationConfigurationTestCase
+{
+
+ public ExtValCrossValidationConfigurationDeactivateCrossvalidationTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_CROSSVALIDATION", "true");
+
+ }
+ }
+
+ @Override
+ protected ExtValCrossValidationModuleConfiguration getCustomCrossValidationModuleConfiguration()
+ {
+ return new DefaultExtValCrossValidationModuleConfiguration()
+ {
+
+ @Override
+ public boolean deactivateCrossvalidation()
+ {
+ return true;
+ }
+
+ };
+ }
+
+ public void testExtValBaseValidationConfigurationDeactivateCrossvalidationDefault()
+ {
+ executeBeforePhaseOfCrossValidationPhaseListener();
+ // PhaseIdPhaseListener from core and CrossValidationPhaseListener
+ assertEquals(2, getPhaseListeners().size());
+ }
+
+ public void testExtValBaseValidationConfigurationDeactivateCrossvalidationWebXml()
+ {
+ executeBeforePhaseOfCrossValidationPhaseListener();
+
+ // PhaseIdPhaseListener from core
+ assertEquals(1, getPhaseListeners().size());
+ }
+
+ public void testExtValBaseValidationConfigurationDeactivateCrossvalidationCustomConfig()
+ {
+ executeBeforePhaseOfCrossValidationPhaseListener();
+
+ // PhaseIdPhaseListener from core
+ assertEquals(1, getPhaseListeners().size());
+
+ }
+
+ private void executeBeforePhaseOfCrossValidationPhaseListener()
+ {
+ for (PhaseListener listener : getPhaseListeners())
+ {
+ listener.beforePhase(new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, getLifeCycle()));
+ }
+ }
+
+ private Lifecycle getLifeCycle()
+ {
+ LifecycleFactory factory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ String id = facesContext.getExternalContext().getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR);
+ if (id == null)
+ {
+ id = LifecycleFactory.DEFAULT_LIFECYCLE;
+ }
+ return factory.getLifecycle(id);
+ }
+
+ private List<PhaseListener> getPhaseListeners()
+ {
+ LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+
+ String currentId;
+ Lifecycle currentLifecycle;
+ Iterator lifecycleIds = lifecycleFactory.getLifecycleIds();
+ assert lifecycleIds.hasNext();
+ currentId = (String) lifecycleIds.next();
+ currentLifecycle = lifecycleFactory.getLifecycle(currentId);
+ return Arrays.asList(currentLifecycle.getPhaseListeners());
+
+ }
+
+ public static Test suite()
+ {
+
+ return new ClassLoaderTestSuite(ExtValCrossValidationConfigurationDeactivateCrossvalidationTestCase.class);
+ }
+
+}
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationTestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationTestCase.java
new file mode 100644
index 0000000..41f65a2
--- /dev/null
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/config/ExtValCrossValidationConfigurationTestCase.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.config;
+
+import org.apache.myfaces.extensions.validator.PropertyValidationModuleStartupListener;
+import org.apache.myfaces.extensions.validator.baseval.DefaultExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.baseval.ExtValBaseValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValModuleConfiguration;
+import org.apache.myfaces.extensions.validator.crossval.DefaultExtValCrossValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.crossval.ExtValCrossValidationModuleConfiguration;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public abstract class ExtValCrossValidationConfigurationTestCase extends AbstractExValCoreTestCase
+{
+
+ public ExtValCrossValidationConfigurationTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected boolean needXmlParameters()
+ {
+ return getName().contains("Xml");
+ }
+
+ protected boolean needCustomConfig()
+ {
+ return !getName().contains("Xml") && !getName().contains("Default");
+ }
+
+ @Override
+ /*
+ * Made the method final because we do
+ */
+ protected final void invokeStartupListeners()
+ {
+ super.invokeStartupListeners();
+ new PropertyValidationModuleStartupListener()
+ {
+ private static final long serialVersionUID = -3861810605160281884L;
+
+ @Override
+ protected void initModuleConfig()
+ {
+ ExtValBaseValidationModuleConfiguration
+ .use(new DefaultExtValBaseValidationModuleConfiguration(), false);
+ ExtValCrossValidationModuleConfiguration.use(new DefaultExtValCrossValidationModuleConfiguration(),
+ false);
+ }
+
+ @Override
+ protected void init()
+ {
+ initModuleConfig();
+ super.init();
+ }
+ }.init();
+ }
+
+ @Override
+ protected final ExtValModuleConfiguration[] getCustomConfigObjects()
+ {
+ if (needCustomConfig())
+ {
+ ExtValModuleConfiguration[] result = new ExtValModuleConfiguration[]
+ { getCustomCrossValidationModuleConfiguration() };
+ if (result.length == 1 && result[0] == null)
+ {
+ // test don't want to specify a custom configuration.
+ return null;
+ } else
+ {
+ return result;
+ }
+ } else
+ {
+ return null;
+ }
+ }
+
+ abstract protected ExtValCrossValidationModuleConfiguration getCustomCrossValidationModuleConfiguration();
+
+}
diff --git a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/constraintsource/ConstraintSourceAwareValidation6TestCase.java b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/constraintsource/ConstraintSourceAwareValidation6TestCase.java
index 217a8ca..d19cb64 100644
--- a/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/constraintsource/ConstraintSourceAwareValidation6TestCase.java
+++ b/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/constraintsource/ConstraintSourceAwareValidation6TestCase.java
@@ -31,11 +31,11 @@
return new ConstraintSourceAware6Bean();
}
+
@Override
- protected void setUp() throws Exception
+ protected ExtValCoreConfiguration getCustomExtValCoreConfiguration()
{
- super.setUp();
- ExtValCoreConfiguration.use(new DefaultExtValCoreConfiguration() {
+ return new DefaultExtValCoreConfiguration() {
@Override
public Class<? extends Annotation> constraintSourceAnnotation()
{
@@ -59,7 +59,7 @@
{
return CustomTargetPropertyId.class;
}
- }, true);
+ };
}
public void testCustomAnnotations1()
diff --git a/test-modules/trinidad-component-support-tests/pom.xml b/test-modules/trinidad-component-support-tests/pom.xml
new file mode 100644
index 0000000..2b10495
--- /dev/null
+++ b/test-modules/trinidad-component-support-tests/pom.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>jar</packaging>
+
+ <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+ <artifactId>myfaces-extval-trinidad-support-tests</artifactId>
+
+ <name>MyFaces Extensions-Validator Trinidad Component-Support-Tests</name>
+ <version>1.2.4-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+ <artifactId>test-modules-project</artifactId>
+ <version>1.2.4-SNAPSHOT</version>
+ </parent>
+
+ <!-- Is there a way to synchronize this value with the component support module POM -->
+ <properties>
+ <trinidad.version>1.2.9</trinidad.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+ <artifactId>myfaces-extval-base-test-infrastructure</artifactId>
+ <version>1.2.4-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+ <artifactId>myfaces-extval-core-tests</artifactId>
+ <version>1.2.4-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.component-support-modules</groupId>
+ <artifactId>myfaces-extval-trinidad-support</artifactId>
+ <version>1.2.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.trinidad</groupId>
+ <artifactId>trinidad-api</artifactId>
+ <version>${trinidad.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.trinidad</groupId>
+ <artifactId>trinidad-impl</artifactId>
+ <version>${trinidad.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/AbstractTrinidadSupportTestCase.java b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/AbstractTrinidadSupportTestCase.java
new file mode 100644
index 0000000..defc7c9
--- /dev/null
+++ b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/AbstractTrinidadSupportTestCase.java
@@ -0,0 +1,53 @@
+/*
+ * 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.trinidad;
+
+import org.apache.myfaces.extensions.validator.test.base.AbstractExValTestCase;
+import org.apache.myfaces.extensions.validator.trinidad.startup.TrinidadModuleStartupListener;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public abstract class AbstractTrinidadSupportTestCase extends AbstractExValTestCase
+{
+
+ public AbstractTrinidadSupportTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void invokeStartupListeners()
+ {
+ new TrinidadModuleStartupListener(){
+ private static final long serialVersionUID = 423076920926752646L;
+
+ @Override
+ protected void init()
+ {
+ super.init();
+ }
+ }.init();
+
+ }
+
+}
diff --git a/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationCustomTestCase.java b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationCustomTestCase.java
new file mode 100644
index 0000000..1cdf22a
--- /dev/null
+++ b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationCustomTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * 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.trinidad.config;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.trinidad.DefaultExtValTrinidadSupportModuleConfiguration;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadSupportModuleConfiguration;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValTrinidadSupportModuleConfigurationCustomTestCase extends
+ ExtValTrinidadSupportModuleConfigurationTestCase
+{
+
+ public ExtValTrinidadSupportModuleConfigurationCustomTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomExtValTrinidadSupportModuleConfiguration extends
+ DefaultExtValTrinidadSupportModuleConfiguration
+ {
+
+ @Override
+ public boolean deactivateClientSideValidation()
+ {
+ return true;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needCustomConfig())
+ {
+ addInitParameter(ExtValTrinidadSupportModuleConfiguration.class.getName(),
+ CustomExtValTrinidadSupportModuleConfiguration.class.getName());
+
+ }
+ }
+
+ @Override
+ protected ExtValTrinidadSupportModuleConfiguration getCustomTrinidadSupportModuleConfiguration()
+ {
+ // Don't specify the custom config here. We explicitly want to test the
+ // web.xml parameter.
+ return null;
+ }
+
+ public void testExtValTrinidadSupportModuleConfigurationCustomDefault()
+ {
+ assertFalse(ExtValTrinidadSupportModuleConfiguration.get().deactivateClientSideValidation());
+ }
+
+ public void testExtValTrinidadSupportModuleConfigurationCustomCustomConfig()
+ {
+ assertTrue(ExtValTrinidadSupportModuleConfiguration.get().deactivateClientSideValidation());
+
+ }
+
+ public static Test suite()
+ {
+ return new ClassLoaderTestSuite(ExtValTrinidadSupportModuleConfigurationCustomTestCase.class);
+ }
+
+}
diff --git a/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase.java b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase.java
new file mode 100644
index 0000000..9346da0
--- /dev/null
+++ b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * 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.trinidad.config;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.initializer.component.ComponentInitializer;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.trinidad.DefaultExtValTrinidadSupportModuleConfiguration;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadSupportModuleConfiguration;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase extends
+ ExtValTrinidadSupportModuleConfigurationTestCase
+{
+
+ public ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomExtValTrinidadSupportModuleConfiguration extends
+ DefaultExtValTrinidadSupportModuleConfiguration
+ {
+
+ @Override
+ public boolean deactivateClientSideValidation()
+ {
+ return true;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_CLIENT_SIDE_TRINIDAD_VALIDATION",
+ "true");
+
+ }
+ }
+
+ @Override
+ protected ExtValTrinidadSupportModuleConfiguration getCustomTrinidadSupportModuleConfiguration()
+ {
+ return new CustomExtValTrinidadSupportModuleConfiguration();
+ }
+
+ public void testDeactivateClientSideValidationDefault()
+ {
+ List<ComponentInitializer> compInitializer = ExtValContext.getContext().getComponentInitializers();
+ assertEquals(1, compInitializer.size());
+
+ }
+
+ public void testDeactivateClientSideValidationWebXml()
+ {
+ List<ComponentInitializer> compInitializer = ExtValContext.getContext().getComponentInitializers();
+ assertEquals(0, compInitializer.size());
+ }
+
+ public void testDeactivateClientSideValidationCustomConfig()
+ {
+ List<ComponentInitializer> compInitializer = ExtValContext.getContext().getComponentInitializers();
+ assertEquals(0, compInitializer.size());
+ }
+
+ public static Test suite()
+ {
+ return new ClassLoaderTestSuite(
+ ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase.class);
+
+ }
+
+}
diff --git a/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase.java b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase.java
new file mode 100644
index 0000000..a140da7
--- /dev/null
+++ b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase.java
@@ -0,0 +1,104 @@
+/*
+ * 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.trinidad.config;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.interceptor.RendererInterceptor;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.trinidad.DefaultExtValTrinidadSupportModuleConfiguration;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadSupportModuleConfiguration;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase extends
+ ExtValTrinidadSupportModuleConfigurationTestCase
+{
+
+ public ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomExtValTrinidadSupportModuleConfiguration extends
+ DefaultExtValTrinidadSupportModuleConfiguration
+ {
+
+ @Override
+ public boolean deactivateCoreOutputLabelInitialization()
+ {
+ return true;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX
+ + ".DEACTIVATE_TRINIDAD_CORE_OUTPUT_LABEL_INITIALIZATION", "true");
+
+ }
+ }
+
+ @Override
+ protected ExtValTrinidadSupportModuleConfiguration getCustomTrinidadSupportModuleConfiguration()
+ {
+ return new CustomExtValTrinidadSupportModuleConfiguration();
+ }
+
+ public void testDeactivateCoreOutputLabelInitializationDefault()
+ {
+ List<RendererInterceptor> interceptors = ExtValContext.getContext().getRendererInterceptors();
+ // Default ValidationInterceptor from core and Trinidad one.
+ assertEquals(2, interceptors.size());
+ }
+
+ public void testDeactivateCoreOutputLabelInitializationWebXml()
+ {
+ List<RendererInterceptor> interceptors = ExtValContext.getContext().getRendererInterceptors();
+ // only Default ValidationInterceptor from core .
+ assertEquals(1, interceptors.size());
+ }
+
+ public void testDeactivateCoreOutputLabelInitializationCustomConfig()
+ {
+ List<RendererInterceptor> interceptors = ExtValContext.getContext().getRendererInterceptors();
+ // only Default ValidationInterceptor from core .
+ assertEquals(1, interceptors.size());
+ }
+
+ public static Test suite()
+ {
+ return new ClassLoaderTestSuite(
+ ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase.class);
+
+ }
+
+}
diff --git a/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase.java b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase.java
new file mode 100644
index 0000000..3341d71
--- /dev/null
+++ b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase.java
@@ -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.trinidad.config;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.interceptor.ValidationExceptionInterceptor;
+import org.apache.myfaces.extensions.validator.test.base.util.ClassLoaderTestSuite;
+import org.apache.myfaces.extensions.validator.trinidad.DefaultExtValTrinidadSupportModuleConfiguration;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadSupportModuleConfiguration;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase extends
+ ExtValTrinidadSupportModuleConfigurationTestCase
+{
+
+ public ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static class CustomExtValTrinidadSupportModuleConfiguration extends
+ DefaultExtValTrinidadSupportModuleConfiguration
+ {
+
+ @Override
+ public boolean deactivateValidationExceptionInterceptor()
+ {
+ return true;
+ }
+
+ }
+
+ protected void addInitializationParameters()
+ {
+ super.addInitializationParameters();
+ if (needXmlParameters())
+ {
+ addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX
+ + ".DEACTIVATE_TRINIDAD_VALIDATION_EXCEPTION_INTERCEPTOR", "true");
+
+ }
+ }
+
+ @Override
+ protected ExtValTrinidadSupportModuleConfiguration getCustomTrinidadSupportModuleConfiguration()
+ {
+ return new CustomExtValTrinidadSupportModuleConfiguration();
+ }
+
+ public void testDeactivateValidationExceptionInterceptorDefault()
+ {
+ List<ValidationExceptionInterceptor> interceptors = ExtValContext.getContext()
+ .getValidationExceptionInterceptors();
+ // ViolationSeverityValidationExceptionInterceptor and
+ // HtmlCoreComponentsValidationExceptionInterceptor from core and
+ // trinidad one.
+ assertEquals(4, interceptors.size());
+ }
+
+ public void testDeactivateValidationExceptionInterceptorWebXml()
+ {
+ List<ValidationExceptionInterceptor> interceptors = ExtValContext.getContext()
+ .getValidationExceptionInterceptors();
+ // ViolationSeverityValidationExceptionInterceptor and
+ // HtmlCoreComponentsValidationExceptionInterceptor from core.
+ assertEquals(3, interceptors.size());
+ }
+
+ public void testDeactivateValidationExceptionInterceptorCustomConfig()
+ {
+ List<ValidationExceptionInterceptor> interceptors = ExtValContext.getContext()
+ .getValidationExceptionInterceptors();
+ // ViolationSeverityValidationExceptionInterceptor and
+ // HtmlCoreComponentsValidationExceptionInterceptor from core.
+ assertEquals(3, interceptors.size());
+ }
+
+ public static Test suite()
+ {
+ return new ClassLoaderTestSuite(
+ ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase.class);
+
+ }
+
+}
diff --git a/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationTestCase.java b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationTestCase.java
new file mode 100644
index 0000000..acbfa79
--- /dev/null
+++ b/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationTestCase.java
@@ -0,0 +1,81 @@
+/*
+ * 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.trinidad.config;
+
+import org.apache.myfaces.extensions.validator.core.ExtValModuleConfiguration;
+import org.apache.myfaces.extensions.validator.test.trinidad.AbstractTrinidadSupportTestCase;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadSupportModuleConfiguration;
+
+/**
+ *
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public abstract class ExtValTrinidadSupportModuleConfigurationTestCase extends AbstractTrinidadSupportTestCase
+{
+
+ public ExtValTrinidadSupportModuleConfigurationTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected boolean needXmlParameters()
+ {
+ return getName().contains("Xml");
+ }
+
+ protected boolean needCustomConfig()
+ {
+ return !getName().contains("Xml") && !getName().contains("Default");
+ }
+
+ @Override
+ /*
+ * Made the method final because we do setup by the getCustomConfigObjects
+ */
+ protected final void invokeStartupListeners()
+ {
+ super.invokeStartupListeners();
+ }
+
+ @Override
+ protected final ExtValModuleConfiguration[] getCustomConfigObjects()
+ {
+ if (needCustomConfig())
+ {
+ ExtValModuleConfiguration[] result = new ExtValModuleConfiguration[]
+ { getCustomTrinidadSupportModuleConfiguration() };
+ if (result.length == 1 && result[0] == null)
+ {
+ // test don't want to specify a custom configuration.
+ return null;
+ } else
+ {
+ return result;
+ }
+ } else
+ {
+ return null;
+ }
+ }
+
+ abstract protected ExtValTrinidadSupportModuleConfiguration getCustomTrinidadSupportModuleConfiguration();
+
+}
diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/message/resolver/JpaValidationErrorMessageResolver.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/message/resolver/JpaValidationErrorMessageResolver.java
index 5aff2af..35e1995 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/message/resolver/JpaValidationErrorMessageResolver.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/message/resolver/JpaValidationErrorMessageResolver.java
@@ -23,6 +23,7 @@
import org.apache.myfaces.extensions.validator.core.ExtValContext;
import org.apache.myfaces.extensions.validator.internal.UsageInformation;
import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
/**
* @author Gerhard Petracek
@@ -40,8 +41,8 @@
private static final String CUSTOM_BASE_NAME =
ExtValBaseValidationModuleConfiguration.get().jpaValidationErrorMessages();
- private static final String BASE_NAME = JpaValidationErrorMessageResolver.class
- .getPackage().getName().replace(".message.resolver", ".message.bundle")+ ".jpa_messages";
+ private static final String BASE_NAME = ClassUtils.getPackageName(JpaValidationErrorMessageResolver.class).replace(
+ ".message.resolver", ".message.bundle")+ ".jpa_messages";
protected String getCustomBaseName()
{
diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/ExtValCrossValidationModuleConfiguration.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/ExtValCrossValidationModuleConfiguration.java
index 2dfc830..57702f5 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/ExtValCrossValidationModuleConfiguration.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/ExtValCrossValidationModuleConfiguration.java
@@ -52,5 +52,5 @@
* web.xml config
*/
- abstract boolean deactivateCrossvalidation();
+ public abstract boolean deactivateCrossvalidation();
}