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 2003/10/11 01:19:57 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/config ActionConfigMatcher.java

mrdon       2003/10/10 16:19:57

  Modified:    src/test/org/apache/struts/config
                        TestActionConfigMatcher.java
               src/share/org/apache/struts/config ActionConfigMatcher.java
  Log:
  Added more unit tests and fixed a bug they discovered (ExceptionConfigs
  not being copied over)
  
  Revision  Changes    Path
  1.2       +29 -5     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestActionConfigMatcher.java	10 Oct 2003 22:09:26 -0000	1.1
  +++ TestActionConfigMatcher.java	10 Oct 2003 23:19:57 -0000	1.2
  @@ -167,7 +167,10 @@
           configs[0] = mapping;
           ActionConfigMatcher matcher = new ActionConfigMatcher(configs);
           
  -        assertNotNull("ActionConfig should be matched", matcher.match("/fooBar"));
  +        ActionConfig matched = matcher.match("/fooBar");
  +        assertNotNull("ActionConfig should be matched", matched);
  +        assertTrue("ActionConfig should have two action forward", matched.findForwardConfigs().length == 2);
  +        assertTrue("ActionConfig should have two exception forward", matched.findExceptionConfigs().length == 2);
       }
       
       public void testCheckSubstitutionsMatch() {
  @@ -219,12 +222,33 @@
           mapping.setInclude("include,{1}");
           mapping.setInput("input,{1}");
   
  -        ForwardConfig[] fConfigs = mapping.findForwardConfigs();
           ForwardConfig cfg = new ActionForward();
           cfg.setContextRelative(true);
           cfg.setName("name");
           cfg.setPath("path,{1}");
           mapping.addForwardConfig(cfg);
  +        
  +        cfg = new ActionForward();
  +        cfg.setContextRelative(true);
  +        cfg.setName("name2");
  +        cfg.setPath("path2");
  +        mapping.addForwardConfig(cfg);
  + 
  +        ExceptionConfig excfg = new ExceptionConfig();
  +        excfg.setKey("foo");
  +        excfg.setType("foo.Bar");
  +        excfg.setPath("path");
  +        mapping.addExceptionConfig(excfg);
  +
  +        excfg = new ExceptionConfig();
  +        excfg.setKey("foo2");
  +        excfg.setType("foo.Bar2");
  +        excfg.setPath("path2");
  +        mapping.addExceptionConfig(excfg);
  +
  +
  +        mapping.freeze();
  +
           return mapping;
       }
   
  
  
  
  1.2       +8 -0      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ActionConfigMatcher.java	10 Oct 2003 22:03:33 -0000	1.1
  +++ ActionConfigMatcher.java	10 Oct 2003 23:19:57 -0000	1.2
  @@ -203,6 +203,14 @@
               config.removeForwardConfig(fConfigs[x]);
               config.addForwardConfig(cfg);
           }
  +        
  +        ExceptionConfig[] exConfigs = orig.findExceptionConfigs();
  +        for (int x = 0; x < exConfigs.length; x++) {
  +            config.addExceptionConfig(exConfigs[x]);
  +        }
  +        
  +        config.freeze();
  +        
           return config;
       }
   
  
  
  

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