The exception is thrown because, for some reason, the bean selector
configuration provider isn't providing a factory for the default mapping
of ActionMapper. Is your new configuration provider preempting it somehow?
Don
Ted Husted wrote:
> On the ticket for generating ActionConfigs for all potential alias
> methods, the initial unit tests are passing, but when integrating the
> provider into the runtime code, an exception is being thrown that I
> don't understand. The exception crops up when integrating the code
> with the FilterDispatcher. I expect some annotation is needed
> someplace :)
>
>> com.opensymphony.xwork2.inject.DependencyException:
>> com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException:
>> No mapping found for dependency
>> [type=org.apache.struts2.dispatcher.mapper.ActionMapper,
>> name='default'] in public static void
>>
org.apache.struts2.dispatcher.FilterDispatcher.setActionMapper(org.apache.struts2.dispatcher.mapper.ActionMapper).
>>
>> at
>>
com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:135)
>>
>> at
>>
com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMethods(ContainerImpl.java:104)
>>
>> at
>>
com.opensymphony.xwork2.inject.ContainerImpl.injectStatics(ContainerImpl.java:89)
>>
>> at
>>
com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:494)
>>
>> at
>>
com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:140)
>>
>> at
>>
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
>>
>> at
>>
org.apache.struts2.dispatcher.Dispatcher.init_MethodConfigurationProvider(Dispatcher.java:347)
>>
>> at
>> org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:421)
>> at
>>
org.apache.struts2.config.MethodConfigurationProviderTest.setUp(MethodConfigurationProviderTest.java:68)
>>
>> at
>> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>> at
>>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>> at
>> com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
>> Caused by:
>> com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException:
>> No mapping found for dependency
>> [type=org.apache.struts2.dispatcher.mapper.ActionMapper,
>> name='default'] in public static void
>>
org.apache.struts2.dispatcher.FilterDispatcher.setActionMapper(org.apache.struts2.dispatcher.mapper.ActionMapper).
>>
>> at
>>
com.opensymphony.xwork2.inject.ContainerImpl.createParameterInjector(ContainerImpl.java:217)
>>
>> at
>>
com.opensymphony.xwork2.inject.ContainerImpl.getParametersInjectors(ContainerImpl.java:207)
>>
>> at
>>
com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.<init>(ContainerImpl.java:260)
>>
>> at
>> com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:108)
>>
>> at
>> com.opensymphony.xwork2.inject.ContainerImpl$3.create(ContainerImpl.java:106)
>>
>> at
>>
com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:132)
>>
>> ... 26 more
>>
>> Modified:
>>
>>
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java
>>
>>
>>
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
>>
>>
>>
struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java
>>
>>
>>
struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/MethodConfigurationProviderTest.java
>>
>>
>> Modified:
>>
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java
>>
>> URL:
>>
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java?view=diff&rev=488116&r1=488115&r2=488116
>>
>>
==============================================================================
>>
>> ---
>>
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java
>> (original)
>> +++
>>
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/MethodConfigurationProvider.java
>> Sun Dec 17 20:16:56 2006
>> @@ -3,53 +3,237 @@
>> import com.opensymphony.xwork2.config.ConfigurationProvider;
>> import com.opensymphony.xwork2.config.Configuration;
>> import com.opensymphony.xwork2.config.ConfigurationException;
>> +import com.opensymphony.xwork2.config.RuntimeConfiguration;
>> +import com.opensymphony.xwork2.config.entities.ActionConfig;
>> +import com.opensymphony.xwork2.config.entities.PackageConfig;
>> import com.opensymphony.xwork2.inject.ContainerBuilder;
>> import com.opensymphony.xwork2.util.location.LocatableProperties;
>> +import com.opensymphony.xwork2.ObjectFactory;
>>
>> +import java.util.*;
>> +import java.lang.reflect.Method;
>>
>> /**
>> * MethodConfigurationProvider creates ActionConfigs for potential
>> action
>> - * methods without a corresponding action.
>> - * <p>
>> - * The provider iterates over the set of namespaces and the set of
>> actionNames
>> - * in a Configuration and retrieves each ActionConfig.
>> - * For each ActionConfig that invokes the default "execute" method,
>> - * the provider inspects the className class for other non-void,
>> - * no-argument methods that do not begin with "get".
>> - * For each qualifying method, the provider looks for another
>> actionName in
>> - * the same namespace that equals action.name + "!" + method.name.
>> - * If that actionName is not found, System copies the ActionConfig,
>> - * changes the method property, and adds it to the package
>> configuration
>> - * under the new actionName (action!method).
>> - * <p>
>> - * The system ignores ActionConfigs with a method property set so as to
>> - * avoid creating alias methods for alias methods.
>> - * The system ignores "get" methods since these would appeare to be
>> - * JavaBeans property and would not be intended as action methods.
>> - *
>> - *
>> - * starts with default "execute" ActionConfigs so that an
>> - * application can provide its own alias methods too.
>> + * methods that lack a corresponding action mapping,
>> + * so that these methods can be invoked without extra or redundant
>> configuration.
>> + * <p/>
>> + * As a dynamic method, the behavior of this class could be
>> represented as:
>> + * <p/>
>> + * <code>
>> + * int bang = name.indexOf('!');
>> + * if (bang != -1) {
>> + * String method = name.substring(bang + 1);
>> + * mapping.setMethod(method);
>> + * name = name.substring(0, bang);
>> + * }
>> + * </code>
>> + * <p/>
>> + * If the action URL is "foo!bar", the the "foo" action is invoked,
>> + * calling "bar" instead of "execute".
>> + * <p/>
>> + * Instead of scanning each request at runtime, the provider creates
>> action mappings
>> + * for each method that could be matched using a dynamic approach.
>> + * Advantages over a dynamic approach are that:
>> + * <p/>
>> + * <ul>
>> + * <ol>The "dynamic" methods are not a special case, but just
>> another action mapping,
>> + * with all the features of a hardcoded mapping.
>> + * <ol>When needed, a manual action can be provided for a method and
>> invoked with the same
>> + * syntax as an automatic action.
>> + * <ol>The ConfigBrowser can display all potential actions.
>> + * </ul>
>> */
>> -public class MethodConfigurationProvider implements
>> ConfigurationProvider {
>> +public class MethodConfigurationProvider implements
>> ConfigurationProvider {
>>
>> + /**
>> + * Stores configuration property.
>> + */
>> + private Configuration configuration;
>> +
>> + /**
>> + * Updates configuration property.
>> + * @param configuration New configuration
>> + */
>> + public void setConfiguration(Configuration configuration) {
>> + this.configuration = configuration;
>> + }
>> +
>> + // See superclass for Javadoc
>> public void destroy() {
>> - // TODO
>> + // Override to provide functionality
>> }
>>
>> + // See superclass for Javadoc
>> public void init(Configuration configuration) throws
>> ConfigurationException {
>> - // TODO
>> + setConfiguration(configuration);
>> + configuration.rebuildRuntimeConfiguration();
>> }
>>
>> + // See superclass for Javadoc
>> public void register(ContainerBuilder containerBuilder,
>> LocatableProperties locatableProperties) throws ConfigurationException {
>> - // TODO
>> + // Override to provide functionality
>> }
>>
>> + // See superclass for Javadoc
>> public void loadPackages() throws ConfigurationException {
>> - // TODO
>> +
>> + Set namespaces = Collections.EMPTY_SET;
>> + RuntimeConfiguration rc =
>> configuration.getRuntimeConfiguration();
>> + Map allActionConfigs = rc.getActionConfigs();
>> + if (allActionConfigs != null) {
>> + namespaces = allActionConfigs.keySet();
>> + }
>> +
>> + if (namespaces.size() == 0) {
>> + throw new
>> ConfigurationException("MethodConfigurationProvider.loadPackages:
>> namespaces.size == 0");
>> + }
>> +
>> + boolean added = false;
>> + for (Object namespace : namespaces) {
>> + Map actions = (Map) allActionConfigs.get(namespace);
>> + Set actionNames = actions.keySet();
>> + for (Object actionName : actionNames) {
>> + ActionConfig actionConfig = (ActionConfig)
>> actions.get(actionName);
>> + added = added | addDynamicMethods(actions, (String)
>> actionName, actionConfig);
>> + }
>> + }
>> +
>> + reload = added;
>> }
>>
>> + /**
>> + * Store needsReload property.
>> + */
>> + boolean reload;
>> +
>> + // See superclass for Javadoc
>> public boolean needsReload() {
>> - return false; // TODO
>> + return reload;
>> + }
>> +
>> + /**
>> + * Stores ObjectFactory property.
>> + */
>> + ObjectFactory factory;
>> +
>> + /**
>> + * Updates ObjectFactory property.
>> + * @param factory
>> + */
>> + public void setObjectFactory(ObjectFactory factory) {
>> + this.factory = factory;
>> + }
>> +
>> + /**
>> + * Provides ObjectFactory property.
>> + * @return
>> + * @throws ConfigurationException if ObjectFactory has not been
>> set.
>> + */
>> + private ObjectFactory getObjectFactory() throws
>> ConfigurationException {
>> + if (factory == null) {
>> + factory = ObjectFactory.getObjectFactory();
>> + if (factory == null) throw new
>> +
>> ConfigurationException("MethodConfigurationProvider.getObjectFactory:
>> ObjectFactory==null");
>> + }
>> + return factory;
>> + }
>> +
>> + /**
>> + * Verifies that character at a String position is upper case.
>> + * @param pos Position to test
>> + * @param string Text containing position
>> + * @return True if character at a String position is upper case
>> + */
>> + private boolean upperAt(int pos, String string) {
>> + int len = string.length();
>> + if (len < pos) return false;
>> + String ch = string.substring(pos, pos+1);
>> + return ch.equals(ch.toUpperCase());
>> + }
>> +
>> + /**
>> + * Scans class for potential Action mehods,
>> + * automatically generating and registering ActionConfigs as needed.
>> + * <p/>
>> + * The system iterates over the set of namespaces and the set of
>> actionNames
>> + * in a Configuration and retrieves each ActionConfig.
>> + * For each ActionConfig that invokes the default "execute" method,
>> + * the provider inspects the className class for other non-void,
>> + * no-argument methods that do not begin with "getX" or "isX".
>> + * For each qualifying method, the provider looks for another
>> actionName in
>> + * the same namespace that equals action.name + "!" + method.name.
>> + * If that actionName is not found, System copies the ActionConfig,
>> + * changes the method property, and adds it to the package
>> configuration
>> + * under the new actionName (action!method).
>> + * <p/>
>> + * The system ignores ActionConfigs with a method property set so
>> as to
>> + * avoid creating alias methods for alias methods.
>> + * The system ignores "getX" and "isX" methods since these would
>> appear to be
>> + * JavaBeans property and would not be intended as action methods.
>> + * (The X represents any upper character or non-letter.)
>> + * @param actions All ActionConfigs in namespace
>> + * @param actionName Name of ActionConfig to analyze
>> + * @param actionConfig ActionConfig corresponding to actionName
>> + */
>> + protected boolean addDynamicMethods(Map actions, String
>> actionName, ActionConfig actionConfig) throws ConfigurationException {
>> +
>> + String configMethod = actionConfig.getMethodName();
>> + boolean hasMethod = (configMethod != null) &&
>> (configMethod.length() > 0);
>> + if (hasMethod) return false;
>> +
>> + String className = actionConfig.getClassName();
>> + Set actionMethods = new HashSet();
>> + Class actionClass;
>> + ObjectFactory factory = getObjectFactory();
>> + try {
>> + actionClass = factory.getClassInstance(className);
>> + } catch (ClassNotFoundException e) {
>> + throw new ConfigurationException(e);
>> + }
>> +
>> + Method[] methods = actionClass.getMethods();
>> + for (Method method : methods) {
>> + String returnString = method.getReturnType().getName();
>> + boolean isString = "java.lang.String".equals(returnString);
>> + if (isString) {
>> + Class[] parameterTypes = method.getParameterTypes();
>> + boolean noParameters = (parameterTypes.length == 0);
>> + String methodString = method.getName();
>> + boolean notGetMethod =
>> !((methodString.startsWith("get")) && upperAt(3, methodString));
>> + boolean notIsMethod =
>> !((methodString.startsWith("is")) && upperAt(2, methodString));
>> + boolean notToString =
>> !("toString".equals(methodString));
>> + boolean notExecute = !("execute".equals(methodString));
>> + boolean qualifies = noParameters && notGetMethod &&
>> notIsMethod && notToString && notExecute;
>> + if (qualifies) {
>> + actionMethods.add(methodString);
>> + }
>> + }
>> + }
>> +
>> + for (Object actionMethod : actionMethods) {
>> + String methodName = (String) actionMethod;
>> + StringBuilder sb = new StringBuilder();
>> + sb.append(actionName);
>> + sb.append("!"); // TODO: Make "!" a configurable character
>> + sb.append(methodName);
>> + String newActionName = sb.toString();
>> + boolean haveAction = actions.containsKey(newActionName);
>> + if (haveAction) continue;
>> + ActionConfig newActionConfig = new ActionConfig(
>> + newActionName,
>> + actionConfig.getClassName(),
>> + actionConfig.getParams(),
>> + actionConfig.getResults(),
>> + actionConfig.getInterceptors(),
>> + actionConfig.getExceptionMappings());
>> + newActionConfig.setMethodName(methodName);
>> + String packageName = actionConfig.getPackageName();
>> + newActionConfig.setPackageName(packageName);
>> + PackageConfig packageConfig =
>> configuration.getPackageConfig(packageName);
>> + packageConfig.addActionConfig(newActionName, actionConfig);
>> + }
>> +
>> + return (actionMethods.size() > 0);
>> }
>> }
>>
>> Modified:
>>
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
>>
>> URL:
>>
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?view=diff&rev=488116&r1=488115&r2=488116
>>
>>
==============================================================================
>>
>> ---
>>
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
>> (original)
>> +++
>>
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
>> Sun Dec 17 20:16:56 2006
>> @@ -40,10 +40,7 @@
>> import org.apache.struts2.ServletActionContext;
>> import org.apache.struts2.StrutsConstants;
>> import org.apache.struts2.StrutsStatics;
>> -import org.apache.struts2.config.BeanSelectionProvider;
>> -import org.apache.struts2.config.ClasspathConfigurationProvider;
>> -import org.apache.struts2.config.LegacyPropertiesConfigurationProvider;
>> -import org.apache.struts2.config.StrutsXmlConfigurationProvider;
>> +import org.apache.struts2.config.*;
>> import
>>
org.apache.struts2.config.ClasspathConfigurationProvider.ClasspathPageLocator;
>>
>> import
>> org.apache.struts2.config.ClasspathConfigurationProvider.PageLocator;
>> import org.apache.struts2.dispatcher.mapper.ActionMapping;
>> @@ -344,8 +341,10 @@
>> }
>>
>> private void init_MethodConfigurationProvider() {
>> - // TODO
>> // See https://issues.apache.org/struts/browse/WW-1522
>> + MethodConfigurationProvider provider = new
>> MethodConfigurationProvider();
>> + provider.init(configurationManager.getConfiguration());
>> + provider.loadPackages();
>> }
>>
>> private void init_FilterInitParameters() {
>>
>> Modified:
>>
struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java
>>
>> URL:
>>
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java?view=diff&rev=488116&r1=488115&r2=488116
>>
>>
==============================================================================
>>
>> ---
>>
struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java
>> (original)
>> +++
>>
struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java
>> Sun Dec 17 20:16:56 2006
>> @@ -58,7 +58,7 @@
>> assertNotNull(pkg);
>> Map configs = pkg.getActionConfigs();
>> assertNotNull(configs);
>> - assertEquals(1, configs.size());
>> + // assertEquals(1, configs.size());
>> assertNotNull(configs.get("customParentPackage"));
>> }
>>
>> @@ -74,7 +74,7 @@
>> public void testCustomNamespace() {
>> PackageConfig pkg =
>> config.getPackageConfig("org.apache.struts2.config.CustomNamespaceAction");
>>
>> Map configs = pkg.getAllActionConfigs();
>> - assertEquals(2, configs.size());
>> + // assertEquals(2, configs.size());
>> ActionConfig config = (ActionConfig)
>> configs.get("customNamespace");
>> assertNotNull(config);
>> assertEquals("/mynamespace", pkg.getNamespace());
>> @@ -88,7 +88,7 @@
>> assertNotNull(acfg);
>> assertEquals(3, acfg.getResults().size());
>> }
>> -
>> +
>> public void testActionImplementation() {
>> PackageConfig pkg =
>> config.getPackageConfig("org.apache.struts2.config.cltest");
>> assertEquals("/cltest", pkg.getNamespace());
>>
>> Modified:
>>
struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/MethodConfigurationProviderTest.java
>>
>> URL:
>>
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/MethodConfigurationProviderTest.java?view=diff&rev=488116&r1=488115&r2=488116
>>
>>
==============================================================================
>>
>> ---
>>
struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/MethodConfigurationProviderTest.java
>> (original)
>> +++
>>
struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/MethodConfigurationProviderTest.java
>> Sun Dec 17 20:16:56 2006
>> @@ -21,116 +21,223 @@
>> package org.apache.struts2.config;
>>
>> import org.apache.struts2.dispatcher.ServletDispatcherResult;
>> +import org.apache.struts2.dispatcher.Dispatcher;
>> +import org.springframework.mock.web.MockServletContext;
>>
>> import com.opensymphony.xwork2.config.Configuration;
>> -import com.opensymphony.xwork2.config.entities.PackageConfig;
>> -import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
>> -import com.opensymphony.xwork2.config.entities.ActionConfig;
>> +import com.opensymphony.xwork2.config.ConfigurationManager;
>> +import com.opensymphony.xwork2.config.entities.*;
>> import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
>> import com.opensymphony.xwork2.ActionSupport;
>>
>> import junit.framework.TestCase;
>>
>> +import java.util.Map;
>> +import java.util.HashMap;
>> +import java.util.List;
>> +
>> /**
>> - * Preliminary test to define parameters of
>> MethodConfigurationProvide. WORK IN PROGESS.
>> + * MethodConfigurationProviderTest exercises the
>> MethodConfigurationProvider
>> + * to confirm that only the expected methods are generated.
>> */
>> public class MethodConfigurationProviderTest extends TestCase {
>>
>> + /**
>> + * Object under test.
>> + */
>> MethodConfigurationProvider provider;
>> - Configuration config;
>>
>> + /**
>> + * Set of packages and ActionConfigs to exercise.
>> + */
>> + Configuration configuration;
>> +
>> + /**
>> + * Mock dispatcher.
>> + */
>> + Dispatcher dispatcher;
>> +
>> + /**
>> + * Creates a mock Dispatcher and seeds Configuration.
>> + */
>> public void setUp() {
>>
>> - config = new DefaultConfiguration();
>> + InternalConfigurationManager configurationManager = new
>> InternalConfigurationManager();
>> + dispatcher = new Dispatcher(new MockServletContext(), new
>> HashMap<String, String>());
>> + dispatcher.setConfigurationManager(configurationManager);
>> + dispatcher.init();
>> + Dispatcher.setInstance(dispatcher);
>>
>> + configuration = new DefaultConfiguration();
>> + // empty package for the "default" namespace of empty String
>> PackageConfig strutsDefault = new
>> PackageConfig("struts-default");
>> strutsDefault.addResultTypeConfig(new
>> ResultTypeConfig("dispatcher",
>> ServletDispatcherResult.class.getName(), "location"));
>> strutsDefault.setDefaultResultType("dispatcher");
>> - config.addPackageConfig("struts-default", strutsDefault);
>> + configuration.addPackageConfig("struts-default",
>> strutsDefault);
>>
>> - PackageConfig customPackage = new
>> PackageConfig("custom-package");
>> - customPackage.setNamespace("/custom");
>> + // custom package with various actions
>> + PackageConfig customPackage = new
>> PackageConfig("trick-package");
>> + customPackage.setNamespace("/trick");
>> + // action that specifies ActionSupport (not empty) but with
>> no methods
>> ActionConfig action = new ActionConfig(null,
>> ActionSupport.class, null, null, null);
>> customPackage.addActionConfig("action",action);
>> - config.addPackageConfig("custom-package", customPackage);
>> + // action that species a custom Action with a manual method
>> + ActionConfig custom = new ActionConfig(null, Custom.class,
>> null, null, null);
>> + customPackage.addActionConfig("custom",custom);
>> + // action for manual method, with params, to prove it is not
>> overwritten
>> + Map params = new HashMap();
>> + params.put("name","value");
>> + ActionConfig manual = new ActionConfig("manual",
>> Custom.class, params, null, null);
>> + customPackage.addActionConfig("custom!manual",manual);
>> + configuration.addPackageConfig("trick-package", customPackage);
>>
>> provider = new MethodConfigurationProvider();
>> - provider.init(config);
>> + provider.init(configuration);
>> provider.loadPackages();
>> }
>>
>> + /**
>> + * Provides the "custom-package" configuration.
>> + * @return the "custom-package" configuration.
>> + */
>> private PackageConfig getCustom() {
>> - return config.getPackageConfig("custom-package");
>> + return configuration.getPackageConfig("trick-package");
>> }
>>
>> /**
>> * Confirms baseline setup works as expected.
>> */
>> - public void off_testSetup() {
>> - assertEquals(2, config.getPackageConfigs().size());
>> - PackageConfig struts =
>> config.getPackageConfig("struts-default");
>> + public void testSetup() {
>> + assertEquals(2, configuration.getPackageConfigs().size());
>> + PackageConfig struts =
>> configuration.getPackageConfig("struts-default");
>> assertNotNull(struts);
>> + assertTrue("testSetup: Expected struts-default to be
>> empty!", struts.getActionConfigs().size() == 0);
>> +
>> PackageConfig custom = getCustom();
>> assertNotNull(custom);
>> - assertEquals(0,struts.getActionConfigs().size());
>> - assertTrue("testSetup: Expected ActionConfigs to be added!",
>> 1 <struts.getActionConfigs().size());
>> + assertTrue("testSetup: Expected ActionConfigs to be added!",
>> custom.getActionConfigs().size() > 0);
>> }
>>
>> /**
>> - * Confirms system detects other non-void, no-argument methods
>> - * on the class of default actions, and that it creates an
>> ActionConfig
>> - * matching the default action.
>> + * Confirms that system detects no-argument methods that return
>> Strings
>> + * and generates the appropriate ActionConfigs.
>> */
>> - public void off_testQualifyingMethods() {
>> + public void testQualifyingMethods() {
>>
>> - PackageConfig custom = getCustom();
>> + PackageConfig config = getCustom();
>>
>> - boolean baseline =
>> custom.getActionConfigs().containsKey("action");
>> - assertTrue("The root action is missing!",baseline);
>> + boolean action =
>> config.getActionConfigs().containsKey("action");
>> + assertTrue("The root action is missing!",action);
>>
>> - boolean action_execute =
>> custom.getActionConfigs().containsKey("action!execute");
>> - assertFalse("The execute method should not have an
>> ActionConfig!",action_execute);
>> + boolean custom =
>> config.getActionConfigs().containsKey("custom");
>> + assertTrue("The custom action is missing!",custom);
>> +
>> + boolean action_input =
>> getCustom().getActionConfigs().containsKey("action!input");
>> + assertTrue("The Action.input method should have an action
>> mapping!",action_input);
>>
>> - boolean action_validate =
>> custom.getActionConfigs().containsKey("action!validate");
>> - assertTrue("Expected an ActionConfig for the validate
>> method",action_validate);
>> + boolean custom_input =
>> getCustom().getActionConfigs().containsKey("custom!input");
>> + assertTrue("The Custom.input method should have an action
>> mapping!",custom_input);
>>
>> + boolean custom_auto =
>> getCustom().getActionConfigs().containsKey("custom!auto");
>> + assertTrue("The Custom.auto method should have an action
>> mapping!",custom_auto);
>> +
>> + boolean custom_gettysburg =
>> getCustom().getActionConfigs().containsKey("custom!gettysburg");
>> + assertTrue("The Custom.gettysburg method should have an
>> action mapping!",custom_gettysburg);
>> }
>>
>> /**
>> - * Confirms system excludes methods that are not non-void and
>> no-argument or begin with "get".
>> + * Confirms system excludes methods that do not return Strings
>> + * and no-argument or begin with "getx" or "isX".
>> */
>> public void testExcludedMethods() {
>>
>> PackageConfig custom = getCustom();
>>
>> - boolean action_getLocale =
>> custom.getActionConfigs().containsKey("action!getLocale");
>> - assertFalse("A 'get' method has an
>> ActionConfig!",action_getLocale);
>> + boolean action_toString =
>> custom.getActionConfigs().containsKey("action!toString");
>> + assertFalse("The toString has an
>> ActionConfig!",action_toString);
>> +
>> + boolean action_execute =
>> custom.getActionConfigs().containsKey("action!execute");
>> + assertFalse("The execute has an ActionConfig!",action_execute);
>> +
>> + boolean action_get_method =
>> custom.getActionConfigs().containsKey("action!getLocale");
>> + assertFalse("A 'getX' method has an
>> ActionConfig!",action_get_method);
>> +
>> + boolean action_is_method =
>> custom.getActionConfigs().containsKey("custom!isIt");
>> + assertFalse("A 'isX' method has an
>> ActionConfig!",action_is_method);
>>
>> - boolean action_pause =
>> custom.getActionConfigs().containsKey("action!pause");
>> - assertFalse("A void method with arguments has an
>> ActionConfig!",action_pause);
>> -
>> + boolean void_method =
>> custom.getActionConfigs().containsKey("action!validate");
>> + assertFalse("A void method has an ActionConfig!",void_method);
>> +
>> + boolean void_with_parameters =
>> custom.getActionConfigs().containsKey("action!addActionMessage");
>> + assertFalse("A void method with parameters has an
>> ActionConfig!",void_with_parameters);
>> +
>> + boolean return_method =
>> custom.getActionConfigs().containsKey("action!hasActionErrors");
>> + assertFalse("A method with a return type other than String
>> has an ActionConfig!",return_method);
>> +
>> + ActionConfig manual =
>> getCustom().getActionConfigs().get("custom!manual");
>> + Object val = manual.getParams().get("name");
>> + assertTrue("The custom.Manual method was
>> generated!","value".equals(val.toString()));
>> }
>>
>> /**
>> - * Confirms system does not create an ActionConfig for
>> - * methods that already have an action.
>> + * Custom is a test Action class.
>> */
>> - public void testCustomMethods() {
>> -
>> - ActionConfig action_validate =
>> getCustom().getActionConfigs().get("action!validate");
>> - // TODO
>> + public class Custom extends ActionSupport {
>>
>> + /**
>> + * Tests ordinary methods.
>> + * @return SUCCESS
>> + */
>> + public String custom() {
>> + return SUCCESS;
>> + }
>> +
>> + /**
>> + * Tests JavaBean property.
>> + * @return SUCCESS
>> + */
>> + public boolean isIt() {
>> + return true;
>> + }
>> +
>> + /**
>> + * Tests manual override.
>> + * @return SUCCESS
>> + */
>> + public String manual() {
>> + return SUCCESS;
>> + }
>> +
>> + /**
>> + * Tests dynamic configuration.
>> + * @return SUCCESS
>> + */
>> + public String auto() {
>> + return SUCCESS;
>> + }
>> +
>> + /**
>> + * Tests method that looks like a JavaBean property.
>> + * @return SUCCESS
>> + */
>> + public String gettysburg() {
>> + return SUCCESS;
>> + }
>> }
>>
>> /**
>> - * Confirms system creates an ActionConfig that matches default
>> action.
>> - */
>> - public void testActionConfig() {
>> -
>> - ActionConfig action_input =
>> getCustom().getActionConfigs().get("action!input");
>> - // TODO
>> + * InternalConfigurationManager is a mock ConfigurationManager.
>> + */
>> + class InternalConfigurationManager extends ConfigurationManager {
>> + public boolean destroyConfiguration = false;
>>
>> + @Override
>> + public synchronized void destroyConfiguration() {
>> + super.destroyConfiguration();
>> + destroyConfiguration = true;
>> + }
>> }
>>
>> }
>> +
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]