webwork/src/test/webwork/config XMLActionConfigurationTestCase.java,NONE,1.1 simple-actions.xml,NONE,1.1

[email protected] Sun, 28 Dec 2003 17:16:14 -0800
Newsgroups gmane.comp.java.open-symphony.cvs
Message-ID <[email protected]>
Update of /cvsroot/opensymphony/webwork/src/test/webwork/config
In directory sc8-pr-cvs1:/tmp/cvs-serv13722/src/test/webwork/config

Added Files:
	XMLActionConfigurationTestCase.java simple-actions.xml 
Log Message:
Added testcase from WW-418

--- NEW FILE: XMLActionConfigurationTestCase.java ---
package webwork.config;

import java.util.Iterator;

import junit.framework.TestCase;

/**
 * @author William Jones
 */
public class XMLActionConfigurationTestCase extends TestCase
{
  private XMLActionConfiguration xmlActionConfig;

  protected void setUp() throws Exception
  {
    xmlActionConfig = new XMLActionConfiguration("webwork/config/simple-actions");
  }

  public void testCorrectNumberOfMappingsAreLoaded() throws Exception
  {
    int count = 0;
    Iterator iter = xmlActionConfig.listImpl();
    while(iter.hasNext())
    {
      iter.next();
      count++;
    }
    assertEquals("Number Of Mappings", 8, count);
  }

  public void testSimpleActionViewMappingsAreLoaded() throws Exception
  {
    assertEquals("Login Action Mapping", "security.LoginAction", xmlActionConfig.getImpl("Login.action"));
    assertEquals("Success View Mapping", "/index.jsp", xmlActionConfig.getImpl("Login.success"));
    assertEquals("Success View Mapping", "/login.jsp", xmlActionConfig.getImpl("Login.input"));
  }

  public void testCommandMappingsAreLoaded() throws Exception
  {
    assertEquals("ListUsers Action Mapping", "users.ListUsers", xmlActionConfig.getImpl("ListUsers.action"));
    assertEquals("ListUsers Action Mapping", "/listusers.jsp", xmlActionConfig.getImpl("ListUsers.success"));
    assertEquals("Add User Command Mapping", "/users/adduser.jsp", xmlActionConfig.getImpl("ListUsers!addUser.success"));
    assertEquals("Delete User Command Mapping", "users.ListUsers!deleteUser", xmlActionConfig.getImpl("deleteUserAlias.action"));
  }

  public void testCommandViewMappingsAreLoaded() throws Exception
  {
    assertEquals("Delete User View Mapping", "/users/deleteuser.jsp", xmlActionConfig.getImpl("deleteUserAlias.success"));
  }

  public void testCorrectExceptionsRaisedOnError() throws Exception
  {
    try
    {
      new XMLActionConfiguration("webwork/config/no-such-file");
      fail("Should have thrown IllegalArgumentException");
    }
    catch(IllegalArgumentException e)
    {
      // Expected
    }
  }

  public void testSetImplNotSupported() throws Exception
  {
    try
    {
      xmlActionConfig.setImpl("somename", this);
      fail("Should have thrown UnsupportedOperationException");
    }
    catch(UnsupportedOperationException e)
    {
      // Expected
    }
  }
}

--- NEW FILE: simple-actions.xml ---
<actions>

    <action name="security.LoginAction" alias="Login">
        <view name="success">/index.jsp</view>
        <view name="input">/login.jsp</view>
    </action>

    <action name="users.ListUsers" alias="ListUsers">
       <view name="success">/listusers.jsp</view>
       <command name="deleteUser" alias="deleteUserAlias">
          <view name="success">/users/deleteuser.jsp</view>
       </command>
       <command name="addUser">
          <view name="success"> /users/adduser.jsp </view>
       </command>
    </action>

</actions>



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click