You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by rd...@apache.org on 2011/05/30 10:38:54 UTC

svn commit: r1129058 [13/13] - in /myfaces/extensions/validator/branches/branch_for_jsf_2_0: ./ test-modules/ test-modules/base-test-infrastructure/ test-modules/base-test-infrastructure/src/ test-modules/base-test-infrastructure/src/test/ test-modules...

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,92 @@
+/*
+ * 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 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.trinidad.DefaultExtValTrinidadSupportModuleConfiguration;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadSupportModuleConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValTrinidadSupportModuleConfigurationDeactivateClientSideValidationTestCase extends
+        ExtValTrinidadSupportModuleConfigurationTestCase
+{
+
+    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();
+    }
+
+    @Test
+    public void testDeactivateClientSideValidationDefault()
+    {
+        List<ComponentInitializer> compInitializer = ExtValContext.getContext().getComponentInitializers();
+        Assert.assertEquals(1, compInitializer.size());
+
+    }
+
+    @Test
+    public void testDeactivateClientSideValidationWebXml()
+    {
+        List<ComponentInitializer> compInitializer = ExtValContext.getContext().getComponentInitializers();
+        Assert.assertEquals(0, compInitializer.size());
+    }
+
+    @Test
+    public void testDeactivateClientSideValidationCustomConfig()
+    {
+        List<ComponentInitializer> compInitializer = ExtValContext.getContext().getComponentInitializers();
+        Assert.assertEquals(0, compInitializer.size());
+    }
+
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,94 @@
+/*
+ * 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 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.trinidad.DefaultExtValTrinidadSupportModuleConfiguration;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadSupportModuleConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValTrinidadSupportModuleConfigurationDeactivateCoreOutputLabelInitializationTestCase extends
+        ExtValTrinidadSupportModuleConfigurationTestCase
+{
+
+    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();
+    }
+
+    @Test
+    public void testDeactivateCoreOutputLabelInitializationDefault()
+    {
+        List<RendererInterceptor> interceptors = ExtValContext.getContext().getRendererInterceptors();
+        // Default ValidationInterceptor from core and Trinidad one.
+        Assert.assertEquals(2, interceptors.size());
+    }
+
+    @Test
+    public void testDeactivateCoreOutputLabelInitializationWebXml()
+    {
+        List<RendererInterceptor> interceptors = ExtValContext.getContext().getRendererInterceptors();
+        // only Default ValidationInterceptor from core .
+        Assert.assertEquals(1, interceptors.size());
+    }
+
+    @Test
+    public void testDeactivateCoreOutputLabelInitializationCustomConfig()
+    {
+        List<RendererInterceptor> interceptors = ExtValContext.getContext().getRendererInterceptors();
+        // only Default ValidationInterceptor from core .
+        Assert.assertEquals(1, interceptors.size());
+    }
+
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase.java Mon May 30 08:38:45 2011
@@ -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.trinidad.config;
+
+import java.util.List;
+
+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.trinidad.DefaultExtValTrinidadSupportModuleConfiguration;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadSupportModuleConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+public class ExtValTrinidadSupportModuleConfigurationDeactivateValidationExceptionInterceptorTestCase extends
+        ExtValTrinidadSupportModuleConfigurationTestCase
+{
+
+    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();
+    }
+
+    @Test
+    public void testDeactivateValidationExceptionInterceptorDefault()
+    {
+        List<ValidationExceptionInterceptor> interceptors = ExtValContext.getContext()
+                .getValidationExceptionInterceptors();
+        // ViolationSeverityValidationExceptionInterceptor and
+        // HtmlCoreComponentsValidationExceptionInterceptor from core and
+        // trinidad one.
+        Assert.assertEquals(4, interceptors.size());
+    }
+
+    @Test
+    public void testDeactivateValidationExceptionInterceptorWebXml()
+    {
+        List<ValidationExceptionInterceptor> interceptors = ExtValContext.getContext()
+                .getValidationExceptionInterceptors();
+        // ViolationSeverityValidationExceptionInterceptor and
+        // HtmlCoreComponentsValidationExceptionInterceptor from core.
+        Assert.assertEquals(3, interceptors.size());
+    }
+
+    @Test
+    public void testDeactivateValidationExceptionInterceptorCustomConfig()
+    {
+        List<ValidationExceptionInterceptor> interceptors = ExtValContext.getContext()
+                .getValidationExceptionInterceptors();
+        // ViolationSeverityValidationExceptionInterceptor and
+        // HtmlCoreComponentsValidationExceptionInterceptor from core.
+        Assert.assertEquals(3, interceptors.size());
+    }
+
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationTestCase.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/config/ExtValTrinidadSupportModuleConfigurationTestCase.java Mon May 30 08:38:45 2011
@@ -0,0 +1,85 @@
+/*
+ * 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;
+import org.apache.myfaces.test.runners.NamedRunner;
+import org.apache.myfaces.test.runners.TestPerClassLoaderRunner;
+import org.junit.runner.RunWith;
+
+/**
+ * 
+ * @author Rudy De Busscher
+ * since v4
+ *
+ */
+@RunWith(value = TestPerClassLoaderRunner.class)
+public abstract class ExtValTrinidadSupportModuleConfigurationTestCase extends AbstractTrinidadSupportTestCase
+{
+
+    protected String getName()
+    {
+        return NamedRunner.getTestMethodName();
+    }
+
+    protected boolean needXmlParameters()
+    {
+        return getName().contains("Xml");
+    }
+
+    protected boolean needCustomConfig()
+    {
+        return !getName().contains("Xml") && !getName().contains("Default");
+    }
+
+    @Override
+    /*
+     * Made the method final because we do 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();
+
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/initializer/DataBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/initializer/DataBean.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/initializer/DataBean.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/initializer/DataBean.java Mon May 30 08:38:45 2011
@@ -0,0 +1,84 @@
+/*
+ * 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.initializer;
+
+import org.apache.myfaces.extensions.validator.baseval.annotation.Length;
+import org.apache.myfaces.extensions.validator.baseval.annotation.Required;
+import org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIf;
+
+import javax.persistence.Id;
+
+/**
+ * @author Rudy De Busscher
+ */
+public class DataBean
+{
+    @Id
+    @Length(maximum = 20)
+    private String property1;
+
+    @RequiredIf(valueOf = "property1")
+    private String property2;
+
+    @Required
+    private String property3;
+
+    private String property4;
+
+    public String getProperty1()
+    {
+        return property1;
+    }
+
+    public void setProperty1(String property1)
+    {
+        this.property1 = property1;
+    }
+
+    public String getProperty2()
+    {
+        return property2;
+    }
+
+    public void setProperty2(String property2)
+    {
+        this.property2 = property2;
+    }
+
+    public String getProperty3()
+    {
+        return property3;
+    }
+
+    public void setProperty3(String property3)
+    {
+        this.property3 = property3;
+    }
+
+    public String getProperty4()
+    {
+        return property4;
+    }
+
+    public void setProperty4(String property4)
+    {
+        this.property4 = property4;
+    }
+
+}

Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/initializer/TrinidadComponentInitializerTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/initializer/TrinidadComponentInitializerTest.java?rev=1129058&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/initializer/TrinidadComponentInitializerTest.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/test-modules/trinidad-component-support-tests/src/test/java/org/apache/myfaces/extensions/validator/test/trinidad/initializer/TrinidadComponentInitializerTest.java Mon May 30 08:38:45 2011
@@ -0,0 +1,194 @@
+/*
+ * 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.initializer;
+
+import org.apache.myfaces.extensions.validator.PropertyValidationModuleStartupListener;
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.test.trinidad.AbstractTrinidadSupportTestCase;
+import org.apache.myfaces.trinidad.component.core.CoreForm;
+import org.apache.myfaces.trinidad.component.core.input.CoreInputHidden;
+import org.apache.myfaces.trinidad.component.core.input.CoreInputText;
+import org.apache.myfaces.trinidad.component.core.output.CoreOutputLabel;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Rudy De Busscher
+ */
+public class TrinidadComponentInitializerTest extends AbstractTrinidadSupportTestCase
+{
+    private CoreInputText inputComponent;
+
+    private CoreInputHidden inputHidden;
+
+    private CoreOutputLabel outputLabel;
+
+    private DataBean bean;
+
+    @Override
+    protected void invokeStartupListeners()
+    {
+        // We use the property validation module, so initialize it to have the strategies.
+        new PropertyValidationModuleStartupListener()
+        {
+            private static final long serialVersionUID = 423076920926752646L;
+
+            @Override
+            protected void init()
+            {
+                super.initModuleConfig();
+                super.init();
+            }
+        }.init();
+        super.invokeStartupListeners();
+    }
+
+
+    @Override
+    public void setUpTestCase()
+    {
+
+
+        super.setUpTestCase();
+
+        CoreForm form = new CoreForm();
+        facesContext.getViewRoot().getChildren().add(form);
+
+        outputLabel = new CoreOutputLabel();
+        //outputLabel.setParent(form);
+        // For Trinidad we shouldn't set the parent our selves, it gives errors when running from SureFire.
+        form.getChildren().add(outputLabel);
+
+        inputComponent = new CoreInputText();
+        inputComponent.setId("input");
+        form.getChildren().add(inputComponent);
+
+        inputHidden = new CoreInputHidden();
+        inputHidden.setId("hidden");
+        form.getChildren().add(inputHidden);
+
+
+        bean = new DataBean();
+        facesContext.getExternalContext().getRequestMap().put("testBean", bean);
+
+    }
+
+    @Test
+    public void testInitializerStrong() throws Exception
+    {
+        createValueBinding(inputComponent, "value", "#{testBean.property1}");
+        outputLabel.setFor("input");
+        outputLabel.encodeAll(facesContext);
+        Assert.assertTrue(outputLabel.isShowRequired());
+
+        inputComponent.encodeAll(facesContext);
+        Assert.assertTrue(inputComponent.isRequired());
+    }
+
+    @Test
+    public void testInitializerRequiredIf() throws Exception
+    {
+        bean.setProperty1("X");
+        createValueBinding(inputComponent, "value", "#{testBean.property2}");
+        inputComponent.encodeAll(facesContext);
+        // although at rendering the property1 has a value, it doesn't make it required.
+        // Because at postback, the field could be empty and thus property2 is not required anymore.
+        Assert.assertFalse(inputComponent.isRequired());
+    }
+
+    @Test
+    public void testInitializerWeak() throws Exception
+    {
+        createValueBinding(inputComponent, "value", "#{testBean.property3}");
+        inputComponent.encodeAll(facesContext);
+        Assert.assertTrue(inputComponent.isRequired());
+    }
+
+    @Test
+    public void testInitializerNone() throws Exception
+    {
+        createValueBinding(inputComponent, "value", "#{testBean.property4}");
+        inputComponent.encodeAll(facesContext);
+        Assert.assertFalse(inputComponent.isRequired());
+    }
+
+    @Test
+    public void testInitializerReadOnly() throws Exception
+    {
+        createValueBinding(inputComponent, "value", "#{testBean.property1}");
+        inputComponent.setReadOnly(true);
+        inputComponent.encodeAll(facesContext);
+        Assert.assertFalse(inputComponent.isRequired());
+    }
+
+    @Test
+    public void testInitializerDisabled() throws Exception
+    {
+        createValueBinding(inputComponent, "value", "#{testBean.property1}");
+        inputComponent.setDisabled(true);
+        inputComponent.encodeAll(facesContext);
+        Assert.assertFalse(inputComponent.isRequired());
+    }
+
+    @Test
+    public void testInitializerInputHidden() throws Exception
+    {
+        createValueBinding(inputHidden, "value", "#{testBean.property1}");
+        inputComponent.encodeAll(facesContext);
+        Assert.assertFalse(inputComponent.isRequired());
+    }
+
+    @Test
+    public void testInitializerNotActivated() throws Exception
+    {
+
+        // Here we override it again so that we are back in the defult state of not handling the initialization.
+        DefaultExtValCoreConfiguration.overruleActivateRequiredInitialization(false, true);
+        createValueBinding(inputComponent, "value", "#{testBean.property1}");
+        inputComponent.encodeAll(facesContext);
+        Assert.assertFalse(inputComponent.isRequired());
+    }
+
+    @Test
+    public void testInitializerNoValidationOfEmptyFields() throws Exception
+    {
+
+        // Use temporary a version of the config that specifies that empty fields shouldn't be validated.
+        ExtValCoreConfiguration currentModuleConfig = ExtValCoreConfiguration.get();
+        ExtValCoreConfiguration.use(new DefaultExtValCoreConfiguration()
+        {
+            @Override
+            public boolean validateEmptyFields()
+            {
+                return false;
+            }
+        }, true);
+
+        createValueBinding(inputComponent, "value", "#{testBean.property1}");
+        inputComponent.encodeAll(facesContext);
+        Assert.assertFalse(inputComponent.isRequired());
+
+        // set old initialization back for other test cases.
+        ExtValCoreConfiguration.use(currentModuleConfig, true);
+
+
+    }
+
+}