You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2009/11/04 13:07:01 UTC
svn commit: r832716 [1/4] - in /myfaces/extensions/validator/trunk: ./
test-modules/ test-modules/base-test-infrastructure/
test-modules/base-test-infrastructure/src/
test-modules/base-test-infrastructure/src/test/
test-modules/base-test-infrastructure...
Author: gpetracek
Date: Wed Nov 4 12:06:57 2009
New Revision: 832716
URL: http://svn.apache.org/viewvc?rev=832716&view=rev
Log:
EXTVAL-30 test modules
Added:
myfaces/extensions/validator/trunk/test-modules/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/pom.xml
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplication.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplicationFactory.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockExpressionFactory.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockValueExpression.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMessageResolverFactory.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMetaDataTransformerFactory.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockValidationStrategyFactory.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/MethodUtils.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/TestUtils.java
myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/resources/
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/pom.xml
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/java/
myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/src/test/resources/
myfaces/extensions/validator/trunk/test-modules/core-tests/
myfaces/extensions/validator/trunk/test-modules/core-tests/pom.xml
myfaces/extensions/validator/trunk/test-modules/core-tests/src/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/AbstractExValCoreTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/initializer/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/initializer/RegistrationComponentInitializerTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationMetaDataExtractionInterceptorTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationPropertyValidationInterceptorTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/interceptor/RegistrationValidationExceptionInterceptorTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationMetaDataToValidationStrategyNameMapperTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationValidationStrategyToMessageResolverNameMapperTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/mapper/RegistrationValidationStrategyToMetaDataTransformerNameMapperTestCase.java
myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/resources/
myfaces/extensions/validator/trunk/test-modules/pom.xml
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/pom.xml
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/AbstractPropertyValidationTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/BaseValTestBean.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/BaseValTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/AdditionalValidator.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/ParameterTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestAllowClientSideValidation.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestDenyClientSideValidation.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestPerson.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestPriority.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestPriorityHigh.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestPriorityLow.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestValidationInterceptor.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestValidationStrategyProvider.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/baseval/parameter/TestValidatorProvider.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/CrossValTestBean.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/CrossValTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ELCrossValReverseMessageTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ELCrossValTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/ELCrossValTestDateBean.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/LocalPropertyCrossValReverseMessageTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/LocalPropertyCrossValTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/LocalPropertyCrossValTestDateBean.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValReverseMessageTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValTestDateBean.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/PropertyChainCrossValTestDateSubBean.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/mock/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/crossval/mock/MockEqualsValidationStrategy.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModuleMetaDataExtractionInterceptorTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModulePropertyValidationInterceptorTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationRendererInterceptorTestCase.java
myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/resources/
Modified:
myfaces/extensions/validator/trunk/pom.xml
Modified: myfaces/extensions/validator/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/pom.xml?rev=832716&r1=832715&r2=832716&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/pom.xml (original)
+++ myfaces/extensions/validator/trunk/pom.xml Wed Nov 4 12:06:57 2009
@@ -68,6 +68,7 @@
<module>core</module>
<module>validation-modules</module>
<module>component-support</module>
+ <module>test-modules</module>
<module>examples</module>
</modules>
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/pom.xml?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/pom.xml (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/pom.xml Wed Nov 4 12:06:57 2009
@@ -0,0 +1,38 @@
+<?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-base-test-infrastructure</artifactId>
+
+ <name>MyFaces Extensions-Validator Base-Test-Infrastructure</name>
+ <version>1.2.3-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+ <artifactId>test-modules-project</artifactId>
+ <version>1.2.3-SNAPSHOT</version>
+ </parent>
+
+</project>
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/AbstractExValTestCase.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,298 @@
+/*
+ * 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;
+
+import junit.framework.TestCase;
+import org.apache.shale.test.mock.*;
+import org.apache.shale.test.el.MockExpressionFactory;
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.test.base.mock.ExtValMockApplicationFactory;
+import org.apache.myfaces.extensions.validator.test.base.mock.MockValidationStrategyFactory;
+import org.apache.myfaces.extensions.validator.test.base.mock.MockMessageResolverFactory;
+import org.apache.myfaces.extensions.validator.test.base.mock.MockMetaDataTransformerFactory;
+import org.apache.myfaces.extensions.validator.test.base.util.TestUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.core.renderkit.DefaultRenderKitWrapperFactory;
+import org.apache.myfaces.extensions.validator.core.startup.ExtValStartupListener;
+import org.apache.myfaces.extensions.validator.core.factory.DefaultFactoryFinder;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.shared_impl.config.MyfacesConfig;
+
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.FactoryFinder;
+import javax.faces.el.ValueBinding;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.UIInput;
+import javax.el.ValueExpression;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.io.StringWriter;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Abstract Shale Test base class, which sets up the JSF environment. If the test
+ * overrides <code>setUp()</code> and/or <code>tearDown()</code>, then those
+ * methods but call the overwitten method to insure a valid test environment.
+ */
+@SuppressWarnings("deprecation")
+public abstract class AbstractExValTestCase extends TestCase
+{
+ protected MockApplication application;
+ protected MockServletConfig config;
+ protected MockExternalContext externalContext;
+ protected MockFacesContext facesContext;
+ protected MockFacesContextFactory facesContextFactory;
+ protected MockLifecycle lifecycle;
+ protected MockLifecycleFactory lifecycleFactory;
+ protected RenderKit renderKit;
+ protected MockHttpServletRequest request;
+ protected MockHttpServletResponse response;
+ protected MockServletContext servletContext;
+ protected MockHttpSession session;
+ protected MockExpressionFactory expressionFactory;
+ private ClassLoader threadContextClassLoader;
+
+ /** Response Writer */
+ private MockResponseWriter writer;
+
+ /**
+ * Construct a new instance of the test.
+ *
+ * @param name Name of the test.
+ */
+ public AbstractExValTestCase(String name)
+ {
+ super(name);
+ application = null;
+ config = null;
+ externalContext = null;
+ facesContext = null;
+ facesContextFactory = null;
+ lifecycle = null;
+ lifecycleFactory = null;
+ renderKit = null;
+ request = null;
+ response = null;
+ servletContext = null;
+ session = null;
+ expressionFactory = null;
+ threadContextClassLoader = null;
+ }
+
+ /**
+ * Setup the test environment, including the following:
+ * <ul>
+ * <li>Set the Application Map.</li>
+ * <li>Set a response writer</li>
+ * <li>Add Tomahawk's renderers to the faces context.</li>
+ * </ul>
+ */
+ protected void setUp() throws Exception
+ {
+ threadContextClassLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0], getClass().getClassLoader()));
+ servletContext = new MockServletContext();
+ //for testing the fallback
+ //servletContext.addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_EL_RESOLVER", "true");
+ servletContext.addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_VALIDATION_STRATEGY_FACTORY", MockValidationStrategyFactory.class.getName());
+ servletContext.addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_MESSAGE_RESOLVER_FACTORY", MockMessageResolverFactory.class.getName());
+ servletContext.addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".CUSTOM_META_DATA_TRANSFORMER_FACTORY", MockMetaDataTransformerFactory.class.getName());
+ config = new MockServletConfig(servletContext);
+ session = new MockHttpSession();
+ session.setServletContext(servletContext);
+ request = new MockHttpServletRequest(session);
+ request.setServletContext(servletContext);
+ response = new MockHttpServletResponse();
+ FactoryFinder.releaseFactories();
+ FactoryFinder.setFactory("javax.faces.application.ApplicationFactory", ExtValMockApplicationFactory.class.getName());
+ FactoryFinder.setFactory("javax.faces.context.FacesContextFactory", "org.apache.shale.test.mock.MockFacesContextFactory");
+ FactoryFinder.setFactory("javax.faces.lifecycle.LifecycleFactory", "org.apache.shale.test.mock.MockLifecycleFactory");
+ FactoryFinder.setFactory("javax.faces.render.RenderKitFactory", "org.apache.shale.test.mock.MockRenderKitFactory");
+ externalContext = new MockExternalContext(servletContext, request, response);
+ lifecycleFactory = (MockLifecycleFactory)FactoryFinder.getFactory("javax.faces.lifecycle.LifecycleFactory");
+ lifecycle = (MockLifecycle)lifecycleFactory.getLifecycle("DEFAULT");
+ facesContextFactory = (MockFacesContextFactory)FactoryFinder.getFactory("javax.faces.context.FacesContextFactory");
+ facesContext = (MockFacesContext)facesContextFactory.getFacesContext(servletContext, request, response, lifecycle);
+ externalContext = (MockExternalContext)facesContext.getExternalContext();
+ UIViewRoot root = new UIViewRoot();
+ root.setViewId("/viewId");
+ root.setRenderKitId("HTML_BASIC");
+ facesContext.setViewRoot(root);
+ ApplicationFactory applicationFactory = (ApplicationFactory)FactoryFinder.getFactory("javax.faces.application.ApplicationFactory");
+ application = (MockApplication)applicationFactory.getApplication();
+ facesContext.setApplication(application);
+ RenderKitFactory renderKitFactory = (RenderKitFactory)FactoryFinder.getFactory("javax.faces.render.RenderKitFactory");
+ //Wrap renderers with proper exval wrapper
+ renderKit = new DefaultRenderKitWrapperFactory().create(new MockRenderKit());
+ renderKitFactory.addRenderKit("HTML_BASIC", renderKit);
+
+ // additional setup not provided automatically by the shale mock stuff
+ facesContext.getExternalContext().getApplicationMap().put(MyfacesConfig.class.getName(), new MyfacesConfig());
+ writer = new MockResponseWriter(new StringWriter(), null, null);
+ facesContext.setResponseWriter(writer);
+
+ TestUtils.addDefaultRenderers(facesContext);
+ TestUtils.addDefaultValidators(facesContext);
+
+ expressionFactory = (MockExpressionFactory)application.getExpressionFactory();
+
+ //execute startup listener
+ new ExtValStartupListener() {
+ private static final long serialVersionUID = -3861810605160281884L;
+
+ @Override
+ protected void init()
+ {
+ super.init();
+ }
+ }.init();
+
+ invokeStartupListeners();
+ }
+
+ protected abstract void invokeStartupListeners();
+
+ /**
+ * Tear down the test environment.
+ */
+ protected void tearDown() throws Exception
+ {
+ resetFactoryFinder();
+ resetExtValContext();
+
+ application = null;
+ config = null;
+ externalContext = null;
+ facesContext.release();
+ facesContext = null;
+ lifecycle = null;
+ lifecycleFactory = null;
+ renderKit = null;
+ request = null;
+ response = null;
+ servletContext = null;
+ session = null;
+ FactoryFinder.releaseFactories();
+ Thread.currentThread().setContextClassLoader(threadContextClassLoader);
+ expressionFactory = null;
+ threadContextClassLoader = null;
+ }
+
+ private void resetFactoryFinder()
+ {
+ try
+ {
+ Field factoryMap = DefaultFactoryFinder.class.getDeclaredField("factoryMap");
+ factoryMap.setAccessible(true);
+ factoryMap.set(ExtValContext.getContext().getFactoryFinder(), new HashMap<FactoryNames, Object>());
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalStateException("cannot reset the factory finder", t);
+ }
+ }
+
+ protected void resetExtValContext()
+ {
+ try
+ {
+ Field context = ExtValContext.class.getDeclaredField("extValContext");
+ context.setAccessible(true);
+ context.set(ExtValContext.getContext(), null);
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalStateException("cannot reset the extval-context", t);
+ }
+ }
+
+ protected void checkMessageCount(int expected)
+ {
+ int actual = 0;
+ for(Iterator messages = facesContext.getMessages(); messages.hasNext();)
+ {
+ messages.next();
+ actual++;
+ }
+
+ assertEquals("Complete message count", expected, actual);
+ }
+
+ protected void checkMessageCount(String clientId, int expected)
+ {
+ int actual = 0;
+ for(Iterator messages = facesContext.getMessages(clientId); messages.hasNext();)
+ {
+ messages.next();
+ actual++;
+ }
+
+ assertEquals("Complete message count", expected, actual);
+ }
+
+ /**
+ * Verify the following:
+ * <ul>
+ * <li>id is not null</li>
+ * <li>Response is complete</li>
+ * <li>Responce contains the id</li>
+ * </ul>
+ *
+ * @param id ID to verify
+ */
+ protected void assertIdExists(String id)
+ {
+ assertNotNull("ID is not null", id);
+ assertTrue("Response Complete", facesContext.getResponseComplete());
+ String output = writer.getWriter().toString();
+ assertNotNull("Has output", output);
+ assertTrue("Contains id '" + id + "'", output.indexOf(id) != -1);
+ }
+
+ protected void createValueBinding(UIInput uiInput, String name, String expression)
+ {
+ ValueBinding valueBinding = application.createValueBinding(expression);
+ ValueExpression valueExpression = expressionFactory.createValueExpression(
+ facesContext.getELContext(), expression, Object.class);
+
+ if(uiInput != null)
+ {
+ uiInput.setValueBinding(name, valueBinding);
+ uiInput.setValueExpression(name, valueExpression);
+ }
+ }
+
+ protected void createRequestScopedBean(String name, Object instance)
+ {
+ createValueBinding(null, "value", "#{" + name + "}");
+ facesContext.getExternalContext().getRequestMap().put(name, instance);
+ }
+
+ @SuppressWarnings({"UnusedDeclaration", "unchecked"})
+ protected <T> T resolveBean(String name, Class<T> targetClass)
+ {
+ return (T) ExtValUtils.getELHelper().getBean(name);
+ }
+}
+
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplication.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplication.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplication.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplication.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,71 @@
+/*
+ * 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.mock;
+
+import org.apache.shale.test.mock.MockApplication;
+
+import javax.el.ELContextListener;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.ELException;
+import javax.faces.application.Application;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class ExtValMockApplication extends MockApplication
+{
+ private Application wrapped;
+
+ public ExtValMockApplication()
+ {
+ super();
+ }
+
+ public ExtValMockApplication(Application application)
+ {
+ super();
+ this.wrapped = application;
+ }
+
+ @Override
+ public ELContextListener[] getELContextListeners()
+ {
+ return new ELContextListener[0];
+ }
+
+ @Override
+ public ELResolver getELResolver()
+ {
+ return this.wrapped.getELResolver();
+ }
+
+ @Override
+ public ExpressionFactory getExpressionFactory()
+ {
+ return new ExtValMockExpressionFactory();
+ }
+
+ @Override
+ public Object evaluateExpressionGet(FacesContext facesContext, String expression, Class aClass) throws ELException
+ {
+ return wrapped.evaluateExpressionGet(facesContext, expression, aClass);
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplicationFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplicationFactory.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplicationFactory.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockApplicationFactory.java Wed Nov 4 12:06:57 2009
@@ -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.base.mock;
+
+import org.apache.shale.test.mock.MockApplicationFactory;
+
+import javax.faces.application.Application;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class ExtValMockApplicationFactory extends MockApplicationFactory
+{
+ @Override
+ public Application getApplication()
+ {
+ return new ExtValMockApplication(super.getApplication());
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockExpressionFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockExpressionFactory.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockExpressionFactory.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockExpressionFactory.java Wed Nov 4 12:06:57 2009
@@ -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.base.mock;
+
+import org.apache.shale.test.el.MockExpressionFactory;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class ExtValMockExpressionFactory extends MockExpressionFactory
+{
+ @Override
+ public ValueExpression createValueExpression(ELContext context, String expression, Class expectedType)
+ {
+ return new ExtValMockValueExpression(expression, expectedType);
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockValueExpression.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockValueExpression.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockValueExpression.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/ExtValMockValueExpression.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,203 @@
+/*
+ * 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.mock;
+
+import org.apache.myfaces.extensions.validator.core.el.ExtValELResolver;
+import org.apache.shale.test.el.MockValueExpression;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ */
+//TODO improve
+public class ExtValMockValueExpression extends MockValueExpression
+{
+ private String[] elements = null;
+ private String expression = null;
+ private static final long serialVersionUID = -8588716545619421041L;
+
+ public ExtValMockValueExpression(String expression, Class expectedType)
+ {
+ super(expression, expectedType);
+
+ if (expression == null)
+ {
+ throw new NullPointerException("Expression string cannot be null");
+ }
+
+ this.expression = expression;
+ parse();
+ }
+
+ @Override
+ public Object getValue(ELContext context)
+ {
+ ELResolver resolver = context.getELResolver();
+
+ if (resolver instanceof ExtValELResolver)
+ {
+ return getBase(context, resolver);
+ }
+
+ return super.getValue(context);
+ }
+
+ @Override
+ public void setValue(ELContext context, Object value)
+ {
+ if (context.getELResolver() instanceof ExtValELResolver)
+ {
+ context.getELResolver().setValue(context, getValue(context), elements[elements.length - 1], null);
+ }
+ else
+ {
+ Object base = getBase(context, context.getELResolver());
+ String setter = "set" + createPropertyString();
+
+ try
+ {
+ Method setterMethod = base.getClass().getDeclaredMethod(setter, value != null ? value.getClass() : Object.class);
+ setterMethod.invoke(base, value);
+ }
+ catch (Throwable e)
+ {
+ throw new IllegalStateException();
+ }
+ }
+ }
+
+ @Override
+ public Class getType(ELContext context)
+ {
+ if (context == null)
+ {
+ throw new NullPointerException();
+ }
+
+ Object base = getBase(context, context.getELResolver());
+
+ if (base == null)
+ {
+ return null;
+ }
+ else
+ {
+ String getter = "get" + createPropertyString();
+
+ try
+ {
+ Method getterMethod = base.getClass().getDeclaredMethod(getter);
+ return getterMethod.getReturnType();
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new IllegalStateException();
+ }
+ }
+ }
+
+ private void parse()
+ {
+
+ if (isLiteralText())
+ {
+ elements = new String[0];
+ return;
+ }
+
+ if (expression.startsWith("${") || expression.startsWith("#{"))
+ {
+ if (expression.endsWith("}"))
+ {
+ List names = new ArrayList();
+ StringBuffer expr = new StringBuffer(expression.substring(2, expression.length() - 1).replaceAll(" ", ""));
+ boolean isBlockOn = false;
+ for (int i = expr.length() - 1; i > -1; i--)
+ {
+ if (expr.charAt(i) == ' ')
+ {
+ expr.deleteCharAt(i);
+ }
+ else if (expr.charAt(i) == ']')
+ {
+ expr.deleteCharAt(i);
+ }
+ else if (expr.charAt(i) == '[')
+ {
+ expr.deleteCharAt(i);
+ }
+ else if (expr.charAt(i) == '\'')
+ {
+ if (!isBlockOn)
+ {
+ expr.deleteCharAt(i);
+ }
+ else
+ {
+ names.add(0, expr.substring(i + 1));
+ expr.delete(i, expr.length());
+ }
+ isBlockOn = !isBlockOn;
+ }
+ else if (expr.charAt(i) == '.' && !isBlockOn)
+ {
+ names.add(0, expr.substring(i + 1));
+ expr.delete(i, expr.length());
+ }
+ }
+ if (expr.length() > 0)
+ {
+ names.add(0, expr.toString());
+ }
+
+ elements = (String[]) names.toArray(new String[names.size()]);
+ }
+ else
+ {
+ throw new IllegalArgumentException(expression);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException(expression);
+ }
+
+ }
+
+ public Object getBase(ELContext context, ELResolver resolver)
+ {
+ Object base = null;
+ for (int i = 0; i < elements.length - 1; i++)
+ {
+ base = resolver.getValue(context, base, elements[i]);
+ }
+ return base;
+ }
+
+ private String createPropertyString()
+ {
+ String property = elements[elements.length - 1];
+ return property.substring(0, 1).toUpperCase() + property.substring(1, property.length());
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMessageResolverFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMessageResolverFactory.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMessageResolverFactory.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMessageResolverFactory.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,39 @@
+/*
+ * 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.mock;
+
+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.core.validation.message.resolver.DefaultMessageResolverFactory;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class MockMessageResolverFactory extends DefaultMessageResolverFactory
+{
+ public List<NameMapper<ValidationStrategy>> getRegisteredNameMapperList()
+ {
+ return super.getNameMapperList();
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMetaDataTransformerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMetaDataTransformerFactory.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMetaDataTransformerFactory.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockMetaDataTransformerFactory.java Wed Nov 4 12:06:57 2009
@@ -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.base.mock;
+
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.metadata.transformer.DefaultMetaDataTransformerFactory;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class MockMetaDataTransformerFactory extends DefaultMetaDataTransformerFactory
+{
+ public List<NameMapper<ValidationStrategy>> getRegisteredNameMapperList()
+ {
+ return super.getNameMapperList();
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockValidationStrategyFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockValidationStrategyFactory.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockValidationStrategyFactory.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/mock/MockValidationStrategyFactory.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.mock;
+
+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.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class MockValidationStrategyFactory extends DefaultValidationStrategyFactory
+{
+ @Override
+ public ValidationStrategy create(String metaDataKey)
+ {
+ //force init so that every test-case setup method can add a mock validation strategy via extval java-api
+ ReflectionUtils.tryToInvokeMethod(this,ReflectionUtils.tryToGetMethod(getClass(), "initStaticMappings"));
+ return super.create(metaDataKey);
+ }
+
+ public List<NameMapper<String>> getRegisteredNameMapperList()
+ {
+ return super.getNameMapperList();
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/MethodUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/MethodUtils.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/MethodUtils.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/MethodUtils.java Wed Nov 4 12:06:57 2009
@@ -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.base.util;
+
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ */
+//TODO
+public class MethodUtils
+{
+ private MethodUtils()
+ {
+ }
+
+ public static boolean checkMethodCalled(Class usedClass, String methodName, int callCount)
+ {
+ checkRequiredClass(usedClass);
+
+ return callCount == getMethodCallCount(usedClass, methodName);
+ }
+
+ public static boolean isMethodCalled(Class usedClass, String methodName)
+ {
+ checkRequiredClass(usedClass);
+
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
+ .containsKey(usedClass.getName() + "#" + methodName);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public static void signalMethodCalled(Class usedClass, String methodName)
+ {
+ Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+
+ int methodCallCount = 0;
+ String key = usedClass.getName() + "#" + methodName;
+
+ if(requestMap.containsKey(key))
+ {
+ methodCallCount = (Integer)requestMap.get(key);
+ }
+
+ requestMap.put(key, ++methodCallCount);
+ }
+
+ private static int getMethodCallCount(Class usedClass, String methodName)
+ {
+ Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+
+ String key = usedClass.getName() + "#" + methodName;
+
+ if(requestMap.containsKey(key))
+ {
+ return (Integer)requestMap.get(key);
+ }
+
+ return 0;
+ }
+
+ public static void signalClassUsed(Class mockClass)
+ {
+ FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
+ .put(mockClass.getName() + ":used", true);
+ }
+
+ public static boolean isClassUsed(Class mockClass)
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
+ .containsKey(mockClass.getName() + ":used");
+ }
+
+ private static void checkRequiredClass(Class usedClass)
+ {
+ if (!isClassUsed(usedClass))
+ {
+ throw new IllegalStateException(usedClass.getName() + " not used");
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/TestUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/TestUtils.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/TestUtils.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/base-test-infrastructure/src/test/java/org/apache/myfaces/extensions/validator/test/base/util/TestUtils.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,280 @@
+/*
+ * 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.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.render.RenderKit;
+import javax.faces.render.Renderer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public final class TestUtils
+{
+ /** Default Logger */
+ private static final Log log = LogFactory.getLog(TestUtils.class);
+
+ /** utility class, do not instantiate */
+ private TestUtils()
+ {
+ // utility class, disable instantiation
+ }
+
+ public static void addDefaultValidators(FacesContext facesContext)
+ {
+ addValidator(facesContext,"javax.faces.DoubleRange", "javax.faces.validator.DoubleRangeValidator");
+ addValidator(facesContext,"javax.faces.Length", "javax.faces.validator.LengthValidator");
+ addValidator(facesContext,"javax.faces.LongRange", "javax.faces.validator.LongRangeValidator");
+ }
+
+ public static void addValidator(FacesContext facesContext,
+ String validatorId, String validatorClass)
+ {
+ facesContext.getApplication().addValidator(validatorId, validatorClass);
+ }
+
+ /**
+ * Add all of JSF 1.2 default renderers. Currently this is not tied to
+ * faces-config.xml, so all change to the file MUST also be made here.
+ *
+ * @param facesContext
+ * @todo Do not add renderer if renderer is already added.
+ */
+ public static void addDefaultRenderers(FacesContext facesContext)
+ {
+ // Standard HTML Renderers
+ addRenderer(facesContext, "javax.faces.Command", "javax.faces.Button",
+ "org.apache.myfaces.renderkit.html.HtmlButtonRenderer");
+
+ addRenderer(facesContext, "javax.faces.SelectBoolean",
+ "javax.faces.Checkbox",
+ "org.apache.myfaces.renderkit.html.HtmlCheckboxRenderer");
+
+ addRenderer(facesContext, "javax.faces.SelectMany",
+ "javax.faces.Checkbox",
+ "org.apache.myfaces.renderkit.html.HtmlCheckboxRenderer");
+
+ addRenderer(facesContext, "javax.faces.Form", "javax.faces.Form",
+ "org.apache.myfaces.renderkit.html.HtmlFormRenderer");
+
+ addRenderer(facesContext, "javax.faces.Panel", "javax.faces.Grid",
+ "org.apache.myfaces.renderkit.html.HtmlGridRenderer");
+
+ addRenderer(facesContext, "javax.faces.Panel", "javax.faces.Group",
+ "org.apache.myfaces.renderkit.html.HtmlGroupRenderer");
+
+ addRenderer(facesContext, "javax.faces.Input", "javax.faces.Hidden",
+ "org.apache.myfaces.renderkit.html.HtmlHiddenRenderer");
+
+ addRenderer(facesContext, "javax.faces.Graphic", "javax.faces.Image",
+ "org.apache.myfaces.renderkit.html.HtmlImageRenderer");
+
+ addRenderer(facesContext, "javax.faces.Output", "javax.faces.Label",
+ "org.apache.myfaces.renderkit.html.HtmlLabelRenderer");
+
+ addRenderer(facesContext, "javax.faces.Output", "javax.faces.Link",
+ "org.apache.myfaces.renderkit.html.HtmlLinkRenderer");
+
+ addRenderer(facesContext, "javax.faces.Command", "javax.faces.Link",
+ "org.apache.myfaces.renderkit.html.HtmlLinkRenderer");
+
+ addRenderer(facesContext, "javax.faces.SelectOne",
+ "javax.faces.Listbox",
+ "org.apache.myfaces.renderkit.html.HtmlListboxRenderer");
+
+ addRenderer(facesContext, "javax.faces.SelectMany",
+ "javax.faces.Listbox",
+ "org.apache.myfaces.renderkit.html.HtmlListboxRenderer");
+
+ addRenderer(facesContext, "javax.faces.SelectOne", "javax.faces.Menu",
+ "org.apache.myfaces.renderkit.html.HtmlMenuRenderer");
+
+ addRenderer(facesContext, "javax.faces.SelectMany", "javax.faces.Menu",
+ "org.apache.myfaces.renderkit.html.HtmlMenuRenderer");
+
+ addRenderer(facesContext, "javax.faces.Message", "javax.faces.Message",
+ "org.apache.myfaces.renderkit.html.HtmlMessageRenderer");
+
+ addRenderer(facesContext, "javax.faces.Output", "javax.faces.Format",
+ "org.apache.myfaces.renderkit.html.HtmlFormatRenderer");
+
+ addRenderer(facesContext, "javax.faces.Messages",
+ "javax.faces.Messages",
+ "org.apache.myfaces.renderkit.html.HtmlMessagesRenderer");
+
+ addRenderer(facesContext, "javax.faces.SelectOne", "javax.faces.Radio",
+ "org.apache.myfaces.renderkit.html.HtmlRadioRenderer");
+
+ addRenderer(facesContext, "javax.faces.Input", "javax.faces.Secret",
+ "org.apache.myfaces.renderkit.html.HtmlSecretRenderer");
+
+ addRenderer(facesContext, "javax.faces.Data", "javax.faces.Table",
+ "org.apache.myfaces.renderkit.html.HtmlTableRenderer");
+
+ addRenderer(facesContext, "javax.faces.Input", "javax.faces.Textarea",
+ "org.apache.myfaces.renderkit.html.HtmlTextareaRenderer");
+
+ addRenderer(facesContext, "javax.faces.Input", "javax.faces.Text",
+ "org.apache.myfaces.renderkit.html.HtmlTextRenderer");
+
+ addRenderer(facesContext, "javax.faces.Output", "javax.faces.Text",
+ "org.apache.myfaces.renderkit.html.HtmlTextRenderer");
+ }
+
+ /**
+ * Add a renderer to the FacesContext.
+ *
+ * @param facesContext Faces Context
+ * @param family Componenet Family
+ * @param rendererType Component Type
+ * @param renderClassName Class Name of Renderer
+ */
+ public static void addRenderer(FacesContext facesContext, String family,
+ String rendererType, String renderClassName)
+ {
+ Renderer renderer = (Renderer) newInstance(renderClassName);
+ RenderKit kit = facesContext.getRenderKit();
+ kit.addRenderer(family, rendererType, renderer);
+ }
+
+ /**
+ * Tries a Class.loadClass with the context class loader of the current thread first and
+ * automatically falls back to the ClassUtils class loader (i.e. the loader of the
+ * myfaces.jar lib) if necessary.
+ *
+ * Note: This was copied from org.apache.myfaces.shared.util.ClassUtils
+ *
+ * @param type fully qualified name of a non-primitive non-array class
+ * @return the corresponding Class
+ * @throws NullPointerException if type is null
+ * @throws ClassNotFoundException
+ */
+ private static Class classForName(String type)
+ throws ClassNotFoundException
+ {
+ if (type == null)
+ throw new NullPointerException("type");
+ try
+ {
+ // Try WebApp ClassLoader first
+ return Class.forName(type, false, // do not initialize for faster startup
+ Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException ignore)
+ {
+ // fallback: Try ClassLoader for ClassUtils (i.e. the myfaces.jar lib)
+ return Class.forName(type, false, // do not initialize for faster startup
+ TestUtils.class.getClassLoader());
+ }
+ }
+
+ /**
+ * Same as {@link #classForName(String)}, but throws a RuntimeException
+ * (FacesException) instead of a ClassNotFoundException.
+ *
+ * Note: This was copied from org.apache.myfaces.shared.util.ClassUtils
+ *
+ * @return the corresponding Class
+ * @throws NullPointerException if type is null
+ * @throws javax.faces.FacesException if class not found
+ */
+ private static Class simpleClassForName(String type)
+ {
+ try
+ {
+ return classForName(type);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.error("Class " + type + " not found", e);
+ throw new FacesException(e);
+ }
+ }
+
+ /**
+ * Create an instance of the class with the type of <code>type</code>.
+ *
+ * Note: This was copied from org.apache.myfaces.shared.util.ClassUtils
+ *
+ * @param type Type of new class.
+ * @return Instance of the class <code>type</code>
+ * @throws javax.faces.FacesException
+ */
+ private static Object newInstance(String type) throws FacesException
+ {
+ if (type == null)
+ return null;
+ return newInstance(simpleClassForName(type));
+ }
+
+ /**
+ * Create an instance of the class <code>clazz</code>.
+ *
+ * Note: This was copied from org.apache.myfaces.shared.util.ClassUtils
+ *
+ * @param clazz Class to create an instance of.
+ * @return Instance of the class <code>clazz</code>
+ * @throws javax.faces.FacesException
+ */
+ private static Object newInstance(Class clazz) throws FacesException
+ {
+ try
+ {
+ return clazz.newInstance();
+ }
+ catch (NoClassDefFoundError e)
+ {
+ log.error("Class : " + clazz.getName() + " not found.", e);
+ throw new FacesException(e);
+ }
+ catch (InstantiationException e)
+ {
+ log.error(e.getMessage(), e);
+ throw new FacesException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error(e.getMessage(), e);
+ throw new FacesException(e);
+ }
+ }
+
+ /**
+ * Renderered a component, including it's children, then complete the reponse.
+ *
+ * @param context Faces Context
+ * @param component Component to be rendered.
+ * @throws java.io.IOException Thrown while rendering.
+ */
+ public static void renderComponent(FacesContext context,
+ UIComponent component) throws IOException
+ {
+ Renderer renderer = context.getRenderKit().getRenderer(
+ component.getFamily(), component.getRendererType());
+ renderer.encodeBegin(context, component);
+ renderer.encodeChildren(context, component);
+ renderer.encodeEnd(context, component);
+ context.responseComplete();
+ context.renderResponse();
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/pom.xml?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/pom.xml (added)
+++ myfaces/extensions/validator/trunk/test-modules/bean-validation-tests/pom.xml Wed Nov 4 12:06:57 2009
@@ -0,0 +1,87 @@
+<?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-bean-validation-tests</artifactId>
+
+ <name>MyFaces Extensions-Validator Bean-Validation-Integration-Tests</name>
+ <version>1.2.3-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+ <artifactId>validation-modules-project</artifactId>
+ <version>1.2.3-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <version>1.0.0.GA</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+ <artifactId>myfaces-extval-base-test-infrastructure</artifactId>
+ <version>1.2.3-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.3-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+ <artifactId>myfaces-extval-bean-validation</artifactId>
+ <version>1.2.3-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.0.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ </dependencies>
+</project>
Added: myfaces/extensions/validator/trunk/test-modules/core-tests/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/core-tests/pom.xml?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/pom.xml (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/pom.xml Wed Nov 4 12:06:57 2009
@@ -0,0 +1,47 @@
+<?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-core-tests</artifactId>
+
+ <name>MyFaces Extensions-Validator Core-Tests</name>
+ <version>1.2.3-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+ <artifactId>test-modules-project</artifactId>
+ <version>1.2.3-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.test-modules</groupId>
+ <artifactId>myfaces-extval-base-test-infrastructure</artifactId>
+ <version>1.2.3-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/AbstractExValCoreTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/AbstractExValCoreTestCase.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/AbstractExValCoreTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/AbstractExValCoreTestCase.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import org.apache.myfaces.extensions.validator.test.base.AbstractExValTestCase;
+
+public abstract class AbstractExValCoreTestCase extends AbstractExValTestCase
+{
+ public AbstractExValCoreTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void invokeStartupListeners()
+ {
+
+ }
+}
Added: myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/core-tests/src/test/java/org/apache/myfaces/extensions/validator/test/core/el/ValueBindingExpressionTestCase.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.core.el;
+
+import org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.framework.Assert;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.2
+ */
+public class ValueBindingExpressionTestCase extends AbstractExValCoreTestCase
+{
+ public ValueBindingExpressionTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(ValueBindingExpressionTestCase.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testStandardSyntax() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.property1}");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1.property1}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property1");
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['property1']}");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1['property1']}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property1");
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].property1}");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1['bean2'].property1}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1['bean2']}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getBaseExpression().getExpressionString(), "#{bean1}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property1");
+ }
+
+ public void testStandardSyntaxReplaceProperty() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.property1}");
+
+ valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1.property2}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property2");
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['property1']}");
+
+ valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");
+
+ //TODO restore original syntax
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1.property2}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property2");
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].property1}");
+
+ valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1['bean2'].property2}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1['bean2']}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getBaseExpression().getExpressionString(), "#{bean1}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property2");
+ }
+
+ public void testStandardSyntaxAddProperty() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.bean2}");
+
+ valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1.bean2.property1}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1.bean2}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property1");
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['bean2']}");
+
+ valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1['bean2'].property1}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1['bean2']}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property1");
+
+ valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].bean3}");
+
+ valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{bean1['bean2'].bean3.property1}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{bean1['bean2'].bean3}");
+ Assert.assertEquals(valueBindingExpression
+ .getBaseExpression().getBaseExpression().getExpressionString(), "#{bean1['bean2']}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property1");
+ }
+
+ public void testFaceletsCustomComponentSyntax() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{entity[fieldName]}");
+
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{entity[fieldName]}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{entity}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "fieldName");
+ }
+
+ public void testFaceletsCustomComponentSyntaxReplaceProperty() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{entity[fieldName]}");
+
+ valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "newFieldName");
+
+ //TODO restore original syntax
+ Assert.assertEquals(valueBindingExpression.getExpressionString(), "#{entity.newFieldName}");
+ Assert.assertEquals(valueBindingExpression.getBaseExpression().getExpressionString(), "#{entity}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "newFieldName");
+ }
+
+ public void testComplexMapSyntax() throws Exception
+ {
+ ValueBindingExpression valueBindingExpression
+ = new ValueBindingExpression("#{bean1[bean2[bean3['key1']]].property1}");
+
+ //TODO
+ //assertEquals(valueBindingExpression.getExpressionString(), "#{bean1[bean2[bean3['key1']]].property1}");
+ Assert.assertEquals(valueBindingExpression.getProperty(), "property1");
+ }
+
+}
\ No newline at end of file