struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject cvs commit: jakarta-struts/src/test/org/apache/struts/config TestActionConfigMatcher.java
Date Thu, 01 Apr 2004 17:56:47 GMT
mrdon       2004/04/01 09:56:47

  Modified:    src/share/org/apache/struts/config ActionConfigMatcher.java
               src/test/org/apache/struts/config
                        TestActionConfigMatcher.java
  Log:
  Added support for multiple wildcard replacements, added unit test to
  ensure correct behavior
  
  PR: 28105
  
  Revision  Changes    Path
  1.11      +8 -5      jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java
  
  Index: ActionConfigMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ActionConfigMatcher.java	23 Mar 2004 06:27:06 -0000	1.10
  +++ ActionConfigMatcher.java	1 Apr 2004 17:56:47 -0000	1.11
  @@ -196,12 +196,15 @@
           Map.Entry entry;
           StringBuffer key = new StringBuffer("{0}");
           StringBuffer ret = new StringBuffer(val);
  +        String keyTmp;
           int x;
           for (Iterator i = vars.entrySet().iterator(); i.hasNext();) {
               entry = (Map.Entry) i.next();
               key.setCharAt(1, ((String) entry.getKey()).charAt(0));
  -            x = ret.toString().indexOf(key.toString());
  -            if (x > -1) {
  +            keyTmp = key.toString();
  +            
  +            // Replace all instances of the placeholder
  +            while ((x = ret.toString().indexOf(keyTmp)) > -1) {
                   ret.replace(x, x + 3, (String) entry.getValue());
               }
           }
  
  
  
  1.8       +16 -4     jakarta-struts/src/test/org/apache/struts/config/TestActionConfigMatcher.java
  
  Index: TestActionConfigMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/test/org/apache/struts/config/TestActionConfigMatcher.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestActionConfigMatcher.java	14 Mar 2004 06:23:48 -0000	1.7
  +++ TestActionConfigMatcher.java	1 Apr 2004 17:56:47 -0000	1.8
  @@ -152,6 +152,18 @@
           }
           assertTrue("The forward config 'name' cannot be found", found);
       }
  + 
  +    public void testCheckMultipleSubstitutions() {
  +        ActionMapping[] mapping = new ActionMapping[1];
  +        mapping[0] = new ActionMapping();
  +        mapping[0].setPath("/foo*");
  +        mapping[0].setName("name,{1}-{1}");
  +
  +        ActionConfigMatcher matcher = new ActionConfigMatcher(mapping);
  +        ActionConfig m = matcher.match("/fooBar");
  +        
  +        assertTrue("Name hasn't been replaced correctly: "+m.getName(), "name,Bar-Bar".equals(m.getName()));
  +    }
       
       private ActionConfig buildActionConfig(String path) {
           ActionMapping mapping = new ActionMapping();
  
  
  

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


Mime
View raw message