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/02/13 23:15:45 UTC
svn commit: r744261 - in
/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator:
./ crossval/
Author: gpetracek
Date: Fri Feb 13 22:15:44 2009
New Revision: 744261
URL: http://svn.apache.org/viewvc?rev=744261&view=rev
Log:
EXTVAL-35 reverse message tests
Added:
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/ELCrossValReverseMessageTestCase.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/LocalPropertyCrossValReverseMessageTestCase.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockEqualsValidationStrategy.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockValidationStrategyFactory.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/PropertyChainCrossValReverseMessageTestCase.java
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/TestUtils.java
Modified:
myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java?rev=744261&r1=744260&r2=744261&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java (original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java Fri Feb 13 22:15:44 2009
@@ -39,6 +39,7 @@
import org.apache.myfaces.extensions.validator.core.renderkit.DefaultRenderKitWrapperFactory;
import org.apache.myfaces.extensions.validator.core.startup.ExtValStartupListener;
import org.apache.myfaces.extensions.validator.crossval.CrossValidationPhaseListener;
+import org.apache.myfaces.extensions.validator.crossval.MockValidationStrategyFactory;
import org.apache.myfaces.extensions.validator.util.TestUtils;
import org.apache.myfaces.extensions.validator.util.ExtValUtils;
import org.apache.myfaces.shared_impl.config.MyfacesConfig;
@@ -118,6 +119,7 @@
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());
config = new MockServletConfig(servletContext);
session = new MockHttpSession();
session.setServletContext(servletContext);
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/ELCrossValReverseMessageTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/ELCrossValReverseMessageTestCase.java?rev=744261&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/ELCrossValReverseMessageTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/ELCrossValReverseMessageTestCase.java Fri Feb 13 22:15:44 2009
@@ -0,0 +1,80 @@
+/*
+ * 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.crossval;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.extensions.validator.crossval.annotation.Equals;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfigurationNames;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticInMemoryConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class ELCrossValReverseMessageTestCase extends ELCrossValTestCase
+{
+ public ELCrossValReverseMessageTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(ELCrossValReverseMessageTestCase.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ StaticInMemoryConfiguration config = new StaticInMemoryConfiguration();
+
+ config.addMapping(Equals.class.getName(), MockEqualsValidationStrategy.class.getName());
+ ExtValContext.getContext().addStaticConfiguration(StaticConfigurationNames.META_DATA_TO_VALIDATION_STRATEGY_CONFIG, config);
+ }
+
+ @Override
+ public void testCrossComponentEqualsValidationCorrect() throws Exception
+ {
+ //don't retest this test-case
+ }
+
+ @Override
+ public void testCrossComponentEqualsValidationFailedValidation() throws Exception
+ {
+ //don't retest this test-case
+ }
+
+ public void testModelAwareCrossEqualsValidationCorrect() throws Exception
+ {
+ super.testModelAwareCrossEqualsValidationCorrect();
+ assertFalse(TestUtils.isMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage"));
+ }
+
+ public void testModelAwareCrossEqualsValidationFailedValidation() throws Exception
+ {
+ super.testModelAwareCrossEqualsValidationFailedValidation();
+ assertTrue(TestUtils.isMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage"));
+ //1x getReverseErrorMessageSummary and 1x getReverseErrorMessageDetail
+ assertTrue(TestUtils.checkMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage", 2));
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/LocalPropertyCrossValReverseMessageTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/LocalPropertyCrossValReverseMessageTestCase.java?rev=744261&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/LocalPropertyCrossValReverseMessageTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/LocalPropertyCrossValReverseMessageTestCase.java Fri Feb 13 22:15:44 2009
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticInMemoryConfiguration;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfigurationNames;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.crossval.annotation.Equals;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class LocalPropertyCrossValReverseMessageTestCase extends LocalPropertyCrossValTestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(LocalPropertyCrossValReverseMessageTestCase.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ StaticInMemoryConfiguration config = new StaticInMemoryConfiguration();
+
+ config.addMapping(Equals.class.getName(), MockEqualsValidationStrategy.class.getName());
+ ExtValContext.getContext().addStaticConfiguration(StaticConfigurationNames.META_DATA_TO_VALIDATION_STRATEGY_CONFIG, config);
+ }
+
+ public LocalPropertyCrossValReverseMessageTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public void testCrossComponentEqualsValidationCorrect() throws Exception
+ {
+ //don't retest this test-case
+ }
+
+ @Override
+ public void testCrossComponentEqualsValidationFailedValidation() throws Exception
+ {
+ //don't retest this test-case
+ }
+
+ @Override
+ public void testModelAwareCrossEqualsValidationCorrect() throws Exception
+ {
+ super.testModelAwareCrossEqualsValidationCorrect();
+ assertFalse(TestUtils.isMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage"));
+ }
+
+ @Override
+ public void testModelAwareCrossEqualsValidationFailedValidation() throws Exception
+ {
+ super.testModelAwareCrossEqualsValidationFailedValidation();
+ assertTrue(TestUtils.isMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage"));
+ //1x getReverseErrorMessageSummary and 1x getReverseErrorMessageDetail
+ assertTrue(TestUtils.checkMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage", 2));
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockEqualsValidationStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockEqualsValidationStrategy.java?rev=744261&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockEqualsValidationStrategy.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockEqualsValidationStrategy.java Fri Feb 13 22:15:44 2009
@@ -0,0 +1,48 @@
+/*
+ * 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.crossval;
+
+import org.apache.myfaces.extensions.validator.crossval.strategy.EqualsStrategy;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class MockEqualsValidationStrategy extends EqualsStrategy
+{
+ public MockEqualsValidationStrategy()
+ {
+ TestUtils.signalClassUsed(getClass());
+ }
+
+ @Override
+ protected String getReverseErrorMessageSummary(Annotation annotation)
+ {
+ TestUtils.signalMethodCalled(getClass(), "reverseMessage");
+ return super.getReverseErrorMessageSummary(annotation);
+ }
+
+ @Override
+ protected String getReverseErrorMessageDetail(Annotation annotation)
+ {
+ TestUtils.signalMethodCalled(getClass(), "reverseMessage");
+ return super.getReverseErrorMessageDetail(annotation);
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockValidationStrategyFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockValidationStrategyFactory.java?rev=744261&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockValidationStrategyFactory.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/MockValidationStrategyFactory.java Fri Feb 13 22:15:44 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval;
+
+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.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class MockValidationStrategyFactory extends DefaultValidationStrategyFactory
+{
+ @Override
+ public ValidationStrategy create(MetaDataEntry metaDataEntry)
+ {
+ //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(metaDataEntry);
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/PropertyChainCrossValReverseMessageTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/PropertyChainCrossValReverseMessageTestCase.java?rev=744261&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/PropertyChainCrossValReverseMessageTestCase.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/PropertyChainCrossValReverseMessageTestCase.java Fri Feb 13 22:15:44 2009
@@ -0,0 +1,79 @@
+/*
+ * 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.crossval;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.myfaces.extensions.validator.crossval.annotation.Equals;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticInMemoryConfiguration;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfigurationNames;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+
+/**
+ * @author Gerhard Petracek
+ */
+public class PropertyChainCrossValReverseMessageTestCase extends PropertyChainCrossValTestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(PropertyChainCrossValReverseMessageTestCase.class);
+ }
+
+ public PropertyChainCrossValReverseMessageTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ StaticInMemoryConfiguration config = new StaticInMemoryConfiguration();
+
+ config.addMapping(Equals.class.getName(), MockEqualsValidationStrategy.class.getName());
+ ExtValContext.getContext().addStaticConfiguration(StaticConfigurationNames.META_DATA_TO_VALIDATION_STRATEGY_CONFIG, config);
+ }
+
+ @Override
+ public void testCrossComponentEqualsValidationCorrect() throws Exception
+ {
+ //don't retest this test-case
+ }
+
+ @Override
+ public void testCrossComponentEqualsValidationFailedValidation() throws Exception
+ {
+ //don't retest this test-case
+ }
+
+ public void testModelAwareCrossEqualsValidationCorrect() throws Exception
+ {
+ super.testModelAwareCrossEqualsValidationCorrect();
+ assertFalse(TestUtils.isMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage"));
+ }
+
+ public void testModelAwareCrossEqualsValidationFailedValidation() throws Exception
+ {
+ super.testModelAwareCrossEqualsValidationFailedValidation();
+ assertTrue(TestUtils.isMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage"));
+ //1x getReverseErrorMessageSummary and 1x getReverseErrorMessageDetail
+ assertTrue(TestUtils.checkMethodCalled(MockEqualsValidationStrategy.class, "reverseMessage", 2));
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/TestUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/TestUtils.java?rev=744261&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/TestUtils.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/TestUtils.java Fri Feb 13 22:15:44 2009
@@ -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.crossval;
+
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ */
+//TODO
+public class TestUtils
+{
+ 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");
+ }
+ }
+}