You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2004/04/09 00:53:19 UTC

cvs commit: jakarta-struts/src/test/org/apache/struts/config TestModuleConfig.java

mrdon       2004/04/08 15:53:19

  Modified:    src/share/org/apache/struts/config/impl
                        ModuleConfigImpl.java
               src/test/org/apache/struts/config TestModuleConfig.java
  Log:
  Added a list to store ActionConfigs to ensure when enumerated, they
  are in the order in which they were added.  Also added a test case
  to ensure correct behavior.
  
  PR: 28104
  
  Revision  Changes    Path
  1.13      +16 -6     jakarta-struts/src/share/org/apache/struts/config/impl/ModuleConfigImpl.java
  
  Index: ModuleConfigImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/impl/ModuleConfigImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ModuleConfigImpl.java	8 Apr 2004 22:07:56 -0000	1.12
  +++ ModuleConfigImpl.java	8 Apr 2004 22:53:18 -0000	1.13
  @@ -22,6 +22,7 @@
   
   import java.io.Serializable;
   import java.util.ArrayList;
  +import java.util.List;
   import java.util.HashMap;
   
   import org.apache.struts.config.ActionConfig;
  @@ -59,6 +60,7 @@
           super();
           this.prefix = prefix;
           this.actionConfigs = new HashMap();
  +        this.actionConfigList = new ArrayList();
           this.actionFormBeanClass = "org.apache.struts.action.ActionFormBean";
           this.actionMappingClass = "org.apache.struts.action.ActionMapping";
           this.globalForwardClass = "org.apache.struts.action.ActionForward";
  @@ -180,6 +182,7 @@
           }
           config.setModuleConfig(this);
           actionConfigs.put(config.getPath(), config);
  +        actionConfigList.add(config);
   
       }
   
  @@ -332,8 +335,8 @@
        */
       public ActionConfig[] findActionConfigs() {
   
  -        ActionConfig results[] = new ActionConfig[actionConfigs.size()];
  -        return ((ActionConfig[]) actionConfigs.values().toArray(results));
  +        ActionConfig results[] = new ActionConfig[actionConfigList.size()];
  +        return ((ActionConfig[]) actionConfigList.toArray(results));
   
       }
   
  @@ -528,6 +531,7 @@
           }
           config.setModuleConfig(null);
           actionConfigs.remove(config.getPath());
  +        actionConfigList.remove(config);
   
       }
   
  @@ -625,6 +629,12 @@
        * keyed by the <code>path</code> property.
        */
       protected HashMap actionConfigs = null;
  +    
  +    /**
  +     * The set of action configurations for this module, if any,
  +     * listed in the order in which they are added.
  +     */
  +    protected List actionConfigList = null; 
       
       /**
        * The set of JDBC data source configurations for this
  
  
  
  1.9       +27 -4     jakarta-struts/src/test/org/apache/struts/config/TestModuleConfig.java
  
  Index: TestModuleConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/test/org/apache/struts/config/TestModuleConfig.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestModuleConfig.java	14 Mar 2004 06:23:48 -0000	1.8
  +++ TestModuleConfig.java	8 Apr 2004 22:53:19 -0000	1.9
  @@ -228,4 +228,27 @@
   
        }
   
  +    /**
  +     * Test order of action mappings defined perserved.
  +     */
  +    public void testPreserveActionMappingsOrder() {
  +
  +        parseConfig("-//Apache Software Foundation//DTD Struts Configuration 1.2//EN",
  +             "/org/apache/struts/resources/struts-config_1_2.dtd",
  +                    "/org/apache/struts/config/struts-config.xml");
  +        
  +        String[] paths = new String[] {"/editRegistration", 
  +            "/editSubscription", "/logoff", "/logon", "/saveRegistration", 
  +            "/saveSubscription", "/tour"
  +            };
  +
  +        ActionConfig[] actions = config.findActionConfigs();
  +        for (int x=0; x<paths.length; x++) {
  +            assertTrue("Action config out of order:"+actions[x].getPath(), 
  +                paths[x].equals(actions[x].getPath()));
  +        } 
  +    }
  +
  +
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org