dion        02/05/23 01:33:19

  Modified:    src/java/org/apache/maven/struts Struts10WarFile.java
                        Struts10WarValidator.java
               src/test/org/apache/maven/struts Struts10WarFileTest.java
  Log:
  - Started validation for global forwards section of the struts config
  - currently only the <global-forwards> type attribute is checked
  
  Revision  Changes    Path
  1.8       +20 -2     
jakarta-turbine-maven/src/java/org/apache/maven/struts/Struts10WarFile.java
  
  Index: Struts10WarFile.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/struts/Struts10WarFile.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Struts10WarFile.java      23 May 2002 07:46:16 -0000      1.7
  +++ Struts10WarFile.java      23 May 2002 08:33:19 -0000      1.8
  @@ -74,7 +74,7 @@
    * Encapsulates a Struts 1.0 War File. Holds functionality to access Struts
    * specific resources and data in the war.
    * @author  dion
  - * @version $Id: Struts10WarFile.java,v 1.7 2002/05/23 07:46:16 dion Exp $
  + * @version $Id: Struts10WarFile.java,v 1.8 2002/05/23 08:33:19 dion Exp $
    */
   public class Struts10WarFile extends WarFile
   {
  @@ -255,7 +255,7 @@
       public String getFormBeansType() throws IOException
       {
           String type = null;
  -        Element formBeans = (Element)getStrutsConfig().selectSingleNode(
  +        Element formBeans = (Element) getStrutsConfig().selectSingleNode(
               "/struts-config/form-beans");
           if (formBeans != null)
           {
  @@ -263,4 +263,22 @@
           }
           return type;
       }
  +    
  +    /** retrieves the type attribute of the &lt;global-forwards&gt; element if
  +     * it exists, or null otherwise
  +     * @return the global-forwards type attribute
  +     * @throws IOException when there are problems reading from the war
  +     */
  +    public String getGlobalForwardsType() throws IOException
  +    {
  +        String type = null;
  +        Element forwards = (Element) getStrutsConfig().selectSingleNode(
  +            "/struts-config/global-forwards");
  +        if (forwards != null)
  +        {
  +            type = forwards.attributeValue("type");
  +        }
  +        return type;
  +    }
  +
    }
  
  
  
  1.6       +20 -1     
jakarta-turbine-maven/src/java/org/apache/maven/struts/Struts10WarValidator.java
  
  Index: Struts10WarValidator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/struts/Struts10WarValidator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Struts10WarValidator.java 22 May 2002 22:41:10 -0000      1.5
  +++ Struts10WarValidator.java 23 May 2002 08:33:19 -0000      1.6
  @@ -74,7 +74,7 @@
    * </ol>
    *
    * @author  dion
  - * @version $Id: Struts10WarValidator.java,v 1.5 2002/05/22 22:41:10 dion Exp $
  + * @version $Id: Struts10WarValidator.java,v 1.6 2002/05/23 08:33:19 dion Exp $
    */
   public class Struts10WarValidator extends WarValidator
   {
  @@ -101,6 +101,7 @@
               validateStrutsConfig(strutsWar);
               validateFormBeans(strutsWar);
               validateActions(strutsWar);
  +            validateForwards(strutsWar);
           }
           catch (IOException ioe)
           {
  @@ -150,6 +151,10 @@
           FormBean bean = null;
           ClassLoader loader = new WarClassLoader(strutsWar, 
               getClass().getClassLoader());
  +        if (strutsWar.getFormBeansType() != null)
  +        {
  +            validateClass(strutsWar.getFormBeansType(), loader);
  +        }
           for (int index = 0; index < formBeans.size(); index++)
           {
               bean = (FormBean) formBeans.get(index);
  @@ -237,6 +242,20 @@
           if (!isBoolean(action.getValidate())) // true or false only
           {
               error("validate attribute is not 'true' or 'false'");
  +        }
  +    }
  +    
  +    /** validate the global forwards in the configuration
  +     * @throws IOException when there are problems reading the war
  +     */
  +    private void validateForwards(Struts10WarFile war) throws IOException
  +    {
  +        info("validating global forwards");
  +        if (war.getGlobalForwardsType() != null)
  +        {
  +            ClassLoader loader = new WarClassLoader(war, getClass().
  +                getClassLoader());
  +            validateClass(war.getGlobalForwardsType(), loader);
           }
       }
   } // end class
  
  
  
  1.5       +12 -1     
jakarta-turbine-maven/src/test/org/apache/maven/struts/Struts10WarFileTest.java
  
  Index: Struts10WarFileTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/test/org/apache/maven/struts/Struts10WarFileTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Struts10WarFileTest.java  23 May 2002 07:46:16 -0000      1.4
  +++ Struts10WarFileTest.java  23 May 2002 08:33:19 -0000      1.5
  @@ -63,7 +63,7 @@
    * Unit tests for {@link Struts10WarFile}
    *
    * @author dion
  - * @version $Id: Struts10WarFileTest.java,v 1.4 2002/05/23 07:46:16 dion Exp $
  + * @version $Id: Struts10WarFileTest.java,v 1.5 2002/05/23 08:33:19 dion Exp $
    */
   public class Struts10WarFileTest extends TestCase {
   
  @@ -193,5 +193,16 @@
               assertEquals("action number " + index + " isn't " + types[index], 
                   types[index], ((Action) actions.get(index)).getType());
           }
  +    }
  +    
  +    /** test the forwards
  +     * @throws Exception when there is an unexpected problem
  +     */
  +    public void testForwards() throws Exception
  +    {
  +        testConstructor();
  +        assertEquals("Global forwards type is not correct",
  +            "org.apache.struts.action.ActionForward",
  +            instance.getGlobalForwardsType());
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to