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 [4/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...
Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModuleMetaDataExtractionInterceptorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModuleMetaDataExtractionInterceptorTestCase.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModuleMetaDataExtractionInterceptorTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModuleMetaDataExtractionInterceptorTestCase.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.ValidationModuleAware;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.interceptor.MetaDataExtractionInterceptor;
+import org.apache.myfaces.extensions.validator.PropertyValidationModuleKey;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.framework.Assert;
+
+import java.util.List;
+
+public class RegistrationModuleMetaDataExtractionInterceptorTestCase extends AbstractExValCoreTestCase
+{
+ /**
+ * Construct a new instance of the test.
+ *
+ * @param name Name of the test.
+ */
+ public RegistrationModuleMetaDataExtractionInterceptorTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(RegistrationModuleMetaDataExtractionInterceptorTestCase.class);
+ }
+
+ public void testModulePropertyValidationInterceptorInitialization()
+ {
+ resetExtValContext();
+
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestGlobalPropertyValidationInterceptor());
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestGlobalMetaDataExtractionInterceptor1000());
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestModuleMetaDataExtractionInterceptor2());
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestModuleMetaDataExtractionInterceptor3());
+ ExtValContext.getContext().addMetaDataExtractionInterceptor(new TestGlobalMetaDataExtractionInterceptor1());
+
+ checkGlobalOnlyPropertyValidationInterceptors();
+ checkModuleAwarePropertyValidationInterceptorsWithTestModule();
+ checkModuleAwarePropertyValidationInterceptorsWithPropertyValidationModule();
+ }
+
+ private void checkGlobalOnlyPropertyValidationInterceptors()
+ {
+ List<MetaDataExtractionInterceptor> result = ExtValContext.getContext().getMetaDataExtractionInterceptors();
+
+ int resultLength = 3;
+ Assert.assertEquals(resultLength, result.size());
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestGlobalMetaDataExtractionInterceptor1.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(TestGlobalMetaDataExtractionInterceptor1000.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestGlobalPropertyValidationInterceptor.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ private void checkModuleAwarePropertyValidationInterceptorsWithTestModule()
+ {
+ List<MetaDataExtractionInterceptor> result = ExtValContext.getContext().getMetaDataExtractionInterceptorsFor(TestModule.class);
+
+ int resultLength = 5;
+ Assert.assertTrue(result.size() == resultLength);
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertTrue(result.get(i) instanceof TestGlobalMetaDataExtractionInterceptor1);
+ break;
+ case 1:
+ Assert.assertTrue(result.get(i) instanceof TestModuleMetaDataExtractionInterceptor2);
+ break;
+ case 2:
+ Assert.assertTrue(result.get(i) instanceof TestModuleMetaDataExtractionInterceptor3);
+ break;
+ case 3:
+ Assert.assertTrue(result.get(i) instanceof TestGlobalMetaDataExtractionInterceptor1000);
+ break;
+ case 4:
+ Assert.assertTrue(result.get(i) instanceof TestGlobalPropertyValidationInterceptor);
+ break;
+ }
+ }
+ }
+
+ private void checkModuleAwarePropertyValidationInterceptorsWithPropertyValidationModule()
+ {
+ List<MetaDataExtractionInterceptor> result = ExtValContext.getContext().getMetaDataExtractionInterceptorsFor(PropertyValidationModuleKey.class);
+
+ int resultLength = 4;
+ Assert.assertTrue(result.size() == resultLength);
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestGlobalMetaDataExtractionInterceptor1.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(TestModuleMetaDataExtractionInterceptor2.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestGlobalMetaDataExtractionInterceptor1000.class, result.get(i).getClass());
+ break;
+ case 3:
+ Assert.assertEquals(TestGlobalPropertyValidationInterceptor.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ class TestGlobalPropertyValidationInterceptor implements MetaDataExtractionInterceptor
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+ }
+
+ @InvocationOrder(1)
+ class TestGlobalMetaDataExtractionInterceptor1 implements MetaDataExtractionInterceptor
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+ }
+
+ @InvocationOrder(2)
+ class TestModuleMetaDataExtractionInterceptor2 implements MetaDataExtractionInterceptor, ValidationModuleAware
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+
+ public String[] getModuleKeys()
+ {
+ return new String[] {PropertyValidationModuleKey.class.getName(), TestModule.class.getName()};
+ }
+ }
+
+ @InvocationOrder(3)
+ class TestModuleMetaDataExtractionInterceptor3 implements MetaDataExtractionInterceptor, ValidationModuleAware
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+
+ public String[] getModuleKeys()
+ {
+ return new String[] {TestModule.class.getName()};
+ }
+ }
+
+ class TestModule
+ {
+ }
+
+ @InvocationOrder(1000)
+ class TestGlobalMetaDataExtractionInterceptor1000 implements MetaDataExtractionInterceptor
+ {
+ public void afterExtracting(PropertyInformation propertyInformation)
+ {
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModulePropertyValidationInterceptorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModulePropertyValidationInterceptorTestCase.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModulePropertyValidationInterceptorTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationModulePropertyValidationInterceptorTestCase.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.ValidationModuleAware;
+import org.apache.myfaces.extensions.validator.core.interceptor.PropertyValidationInterceptor;
+import org.apache.myfaces.extensions.validator.PropertyValidationModuleKey;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.framework.Assert;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import java.util.List;
+import java.util.Map;
+
+public class RegistrationModulePropertyValidationInterceptorTestCase extends AbstractExValCoreTestCase
+{
+ /**
+ * Construct a new instance of the test.
+ *
+ * @param name Name of the test.
+ */
+ public RegistrationModulePropertyValidationInterceptorTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(RegistrationModulePropertyValidationInterceptorTestCase.class);
+ }
+
+ public void testModulePropertyValidationInterceptorInitialization()
+ {
+ resetExtValContext();
+
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestGlobalPropertyValidationInterceptor());
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestGlobalPropertyValidationInterceptor1000());
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestModulePropertyValidationInterceptor2());
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestModulePropertyValidationInterceptor3());
+ ExtValContext.getContext().addPropertyValidationInterceptor(new TestGlobalPropertyValidationInterceptor1());
+
+ checkGlobalOnlyPropertyValidationInterceptors();
+ checkModuleAwarePropertyValidationInterceptorsWithTestModule();
+ checkModuleAwarePropertyValidationInterceptorsWithPropertyValidationModule();
+ }
+
+ private void checkGlobalOnlyPropertyValidationInterceptors()
+ {
+ List<PropertyValidationInterceptor> result = ExtValContext.getContext().getPropertyValidationInterceptors();
+
+ int resultLength = 3;
+ Assert.assertEquals(resultLength, result.size());
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestGlobalPropertyValidationInterceptor1.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(TestGlobalPropertyValidationInterceptor1000.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestGlobalPropertyValidationInterceptor.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ private void checkModuleAwarePropertyValidationInterceptorsWithTestModule()
+ {
+ List<PropertyValidationInterceptor> result = ExtValContext.getContext().getPropertyValidationInterceptorsFor(TestModule.class);
+
+ int resultLength = 5;
+ Assert.assertTrue(result.size() == resultLength);
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertTrue(result.get(i) instanceof TestGlobalPropertyValidationInterceptor1);
+ break;
+ case 1:
+ Assert.assertTrue(result.get(i) instanceof TestModulePropertyValidationInterceptor2);
+ break;
+ case 2:
+ Assert.assertTrue(result.get(i) instanceof TestModulePropertyValidationInterceptor3);
+ break;
+ case 3:
+ Assert.assertTrue(result.get(i) instanceof TestGlobalPropertyValidationInterceptor1000);
+ break;
+ case 4:
+ Assert.assertTrue(result.get(i) instanceof TestGlobalPropertyValidationInterceptor);
+ break;
+ }
+ }
+ }
+
+ private void checkModuleAwarePropertyValidationInterceptorsWithPropertyValidationModule()
+ {
+ List<PropertyValidationInterceptor> result = ExtValContext.getContext().getPropertyValidationInterceptorsFor(PropertyValidationModuleKey.class);
+
+ int resultLength = 4;
+ Assert.assertTrue(result.size() == resultLength);
+
+ for(int i = 0; i < resultLength; i++)
+ {
+ switch (i)
+ {
+ case 0:
+ Assert.assertEquals(TestGlobalPropertyValidationInterceptor1.class, result.get(i).getClass());
+ break;
+ case 1:
+ Assert.assertEquals(TestModulePropertyValidationInterceptor2.class, result.get(i).getClass());
+ break;
+ case 2:
+ Assert.assertEquals(TestGlobalPropertyValidationInterceptor1000.class, result.get(i).getClass());
+ break;
+ case 3:
+ Assert.assertEquals(TestGlobalPropertyValidationInterceptor.class, result.get(i).getClass());
+ break;
+ }
+ }
+ }
+
+ class TestGlobalPropertyValidationInterceptor implements PropertyValidationInterceptor
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+ }
+
+ @InvocationOrder(1)
+ class TestGlobalPropertyValidationInterceptor1 implements PropertyValidationInterceptor
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+ }
+
+ @InvocationOrder(2)
+ class TestModulePropertyValidationInterceptor2 implements PropertyValidationInterceptor, ValidationModuleAware
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+
+ public String[] getModuleKeys()
+ {
+ return new String[] {PropertyValidationModuleKey.class.getName(), TestModule.class.getName()};
+ }
+ }
+
+ @InvocationOrder(3)
+ class TestModulePropertyValidationInterceptor3 implements PropertyValidationInterceptor, ValidationModuleAware
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+
+ public String[] getModuleKeys()
+ {
+ return new String[] {TestModule.class.getName()};
+ }
+ }
+
+ class TestModule
+ {
+ }
+
+ @InvocationOrder(1000)
+ class TestGlobalPropertyValidationInterceptor1000 implements PropertyValidationInterceptor
+ {
+ public boolean beforeValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ return true;
+ }
+
+ public void afterValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject, Map<String, Object> properties)
+ {
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationRendererInterceptorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationRendererInterceptorTestCase.java?rev=832716&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationRendererInterceptorTestCase.java (added)
+++ myfaces/extensions/validator/trunk/test-modules/property-validation-tests/src/test/java/org/apache/myfaces/extensions/validator/test/propval/interceptor/RegistrationRendererInterceptorTestCase.java Wed Nov 4 12:06:57 2009
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.test.propval.interceptor;
+
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.interceptor.RendererInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.AbstractRendererInterceptor;
+import org.apache.myfaces.extensions.validator.core.interceptor.ValidationInterceptor;
+import org.apache.myfaces.extensions.validator.PropertyValidationInterceptor;
+import org.apache.myfaces.extensions.validator.test.core.AbstractExValCoreTestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.framework.Assert;
+
+import java.util.List;
+
+public class RegistrationRendererInterceptorTestCase extends AbstractExValCoreTestCase
+{
+ /**
+ * Construct a new instance of the test.
+ *
+ * @param name Name of the test.
+ */
+ public RegistrationRendererInterceptorTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(RegistrationRendererInterceptorTestCase.class);
+ }
+
+ @SuppressWarnings({"ConstantConditions"})
+ public void testRendererInterceptorInitialization()
+ {
+ ExtValContext.getContext().registerRendererInterceptor(new TestComponentInitializer());
+ ExtValContext.getContext().registerRendererInterceptor(new TestComponentInitializer1());
+ ExtValContext.getContext().registerRendererInterceptor(new TestComponentInitializer2());
+
+ List<RendererInterceptor> result = ExtValContext.getContext().getRendererInterceptors();
+
+ int resultLength = 4;
+ Assert.assertEquals(resultLength, result.size());
+
+ RendererInterceptor tmp;
+ for(int i = 0; i < resultLength; i++)
+ {
+ tmp = result.get(i);
+ assertTrue(tmp instanceof TestComponentInitializer ||
+ tmp instanceof ValidationInterceptor || /*due to a junit issue*/
+ tmp instanceof PropertyValidationInterceptor);
+ }
+ }
+
+ class TestComponentInitializer extends AbstractRendererInterceptor
+ {
+ }
+
+ class TestComponentInitializer1 extends TestComponentInitializer
+ {
+ }
+
+ class TestComponentInitializer2 extends TestComponentInitializer
+ {
+ }
+}
\ No newline at end of file