jvanzyl 2002/07/14 16:29:24
Added: src/plugins-build/struts/src/test/java/org/apache/maven/struts
ActionTest.java FormBeanTest.java ForwardTest.java
Struts10WarFileTest.java
Log:
o moved to plugin
Revision Changes Path
1.1
jakarta-turbine-maven/src/plugins-build/struts/src/test/java/org/apache/maven/struts/ActionTest.java
Index: ActionTest.java
===================================================================
package org.apache.maven.struts;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import junit.framework.TestCase;
/**
* Unit tests for {@link Action}
* @author dion
* @version $Id: ActionTest.java,v 1.1 2002/07/14 23:29:24 jvanzyl Exp $
*/
public class ActionTest extends TestCase
{
/** the instance being tested */
private Action instance;
/** Creates a new instance of ActionTest
* @param testName the name of the test
*/
public ActionTest(String testName)
{
super(testName);
}
/**
* Initialize per test data
* @throws Exception when there is an unexpected problem
*/
public void setUp() throws Exception
{
instance = new Action();
}
/** test the constructor sets all properties to null
* @throws Exception when any error occurs
*/
public void testConstructor() throws Exception
{
assertNotNull("Instance wasn't created", instance);
assertNull("ClassName property isn't null", instance.getClassName());
assertNull("Name property isn't null", instance.getName());
assertNull("Scope property isn't null", instance.getScope());
assertNull("Type property isn't null", instance.getType());
assertNull("Unknown property isn't null", instance.getUnknown());
assertNull("Validate property isn't null", instance.getValidate());
}
/** test the className property is working
* @throws Exception when any error occurs
*/
public void testClassName() throws Exception
{
testConstructor();
String className = "dummyClassName";
instance.setClassName(className);
assertEquals("ClassName property setter or getter failed", className,
instance.getClassName());
}
/** test the name property is working
* @throws Exception when any error occurs
*/
public void testName() throws Exception
{
testConstructor();
String name = "dummyName";
instance.setName(name);
assertEquals("Name property setter or getter failed", name,
instance.getName());
}
/** test the name property is working
* @throws Exception when any error occurs
*/
public void testPath() throws Exception
{
testConstructor();
String path = "/dummy";
instance.setPath(path);
assertEquals("Path property setter or getter failed", path,
instance.getPath());
}
/** test the scope property is working
* @throws Exception when any error occurs
*/
public void testScope() throws Exception
{
testConstructor();
String scope = "dummyScope";
instance.setScope(scope);
assertEquals("Scope property setter or getter failed", scope,
instance.getScope());
}
/** test the type property is working
* @throws Exception when any error occurs
*/
public void testType() throws Exception
{
testConstructor();
String type = "dummyType";
instance.setType(type);
assertEquals("Type property setter or getter failed", type,
instance.getType());
}
/** test the unknown property is working
* @throws Exception when any error occurs
*/
public void testUnknown() throws Exception
{
testConstructor();
String unknown = "true";
instance.setUnknown(unknown);
assertEquals("Unknown property setter or getter failed", unknown,
instance.getUnknown());
}
/** test the unknown property is working
* @throws Exception when any error occurs
*/
public void testValidate() throws Exception
{
testConstructor();
String validate = "true";
instance.setValidate(validate);
assertEquals("Validate property setter or getter failed", validate,
instance.getValidate());
}
}
1.1
jakarta-turbine-maven/src/plugins-build/struts/src/test/java/org/apache/maven/struts/FormBeanTest.java
Index: FormBeanTest.java
===================================================================
package org.apache.maven.struts;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import junit.framework.TestCase;
/**
* Unit tests for {@link FormBean}
* @author dion
* @version $Id: FormBeanTest.java,v 1.1 2002/07/14 23:29:24 jvanzyl Exp $
*/
public class FormBeanTest extends TestCase
{
/** the instance being tested */
private FormBean instance;
/** Creates a new instance of FormBeanTest
* @param testName the name of the test
*/
public FormBeanTest(String testName)
{
super(testName);
}
/**
* Initialize per test data
* @throws Exception when there is an unexpected problem
*/
public void setUp() throws Exception
{
instance = new FormBean();
}
/** test the constructor sets all properties to null
* @throws Exception when any error occurs
*/
public void testConstructor() throws Exception
{
assertNotNull("Instance wasn't created", instance);
assertNull("ClassName property isn't null", instance.getClassName());
assertNull("Name property isn't null", instance.getName());
assertNull("Type property isn't null", instance.getType());
}
/** test the className property is working
* @throws Exception when any error occurs
*/
public void testClassName() throws Exception
{
assertNotNull("Instance wasn't created", instance);
assertNull("ClassName property isn't null", instance.getClassName());
String className = "dummyClassName";
instance.setClassName(className);
assertEquals("ClassName property setter or getter failed", className,
instance.getClassName());
}
/** test the name property is working
* @throws Exception when any error occurs
*/
public void testName() throws Exception
{
assertNotNull("Instance wasn't created", instance);
assertNull("Name property isn't null", instance.getName());
String name = "dummyName";
instance.setName(name);
assertEquals("Name property setter or getter failed", name,
instance.getName());
}
/** test the type property is working
* @throws Exception when any error occurs
*/
public void testType() throws Exception
{
assertNotNull("Instance wasn't created", instance);
assertNull("Type property isn't null", instance.getType());
String type = "dummyType";
instance.setType(type);
assertEquals("Type property setter or getter failed", type,
instance.getType());
}
}
1.1
jakarta-turbine-maven/src/plugins-build/struts/src/test/java/org/apache/maven/struts/ForwardTest.java
Index: ForwardTest.java
===================================================================
package org.apache.maven.struts;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import junit.framework.TestCase;
/**
* Unit tests for the {@link Forward} class
*
* @author dion
* @version $Id: ForwardTest.java,v 1.1 2002/07/14 23:29:24 jvanzyl Exp $
*/
public class ForwardTest extends TestCase
{
/** the instance being tested */
private Forward instance;
/** Creates a new instance of Struts10WarFileTest
* @param testName the name of the test
*/
public ForwardTest(String testName)
{
super(testName);
}
/**
* Initialize per test data
* @throws Exception when there is an unexpected problem
*/
public void setUp() throws Exception
{
instance = new Forward();
}
/** test the constructor
* @throws Exception when there is an unexpected problem
*/
public void testConstructor() throws Exception
{
assertNotNull("instance not created", instance);
assertNull("name property is not null", instance.getName());
assertNull("className property is not null", instance.getClassName());
assertNull("path property is not null", instance.getPath());
assertNull("redirect property is not null", instance.getRedirect());
}
/** test the name property
* @throws Exception when there is an unexpected problem
*/
public void testName() throws Exception
{
testConstructor();
String dummy = "dummyName";
instance.setName(dummy);
assertEquals("set or get failed", dummy, instance.getName());
}
/** test the class name property
* @throws Exception when there is an unexpected problem
*/
public void testClassName() throws Exception
{
testConstructor();
String dummy = "dummyClassName";
instance.setClassName(dummy);
assertEquals("set or get failed", dummy, instance.getClassName());
}
/** test the path property
* @throws Exception when there is an unexpected problem
*/
public void testPath() throws Exception
{
testConstructor();
String dummy = "dummyPath";
instance.setPath(dummy);
assertEquals("set or get failed", dummy, instance.getPath());
}
/** test the redirect property
* @throws Exception when there is an unexpected problem
*/
public void testRedirect() throws Exception
{
testConstructor();
String dummy = "dummyRedirect";
instance.setRedirect(dummy);
assertEquals("set or get failed", dummy, instance.getRedirect());
}
}
1.1
jakarta-turbine-maven/src/plugins-build/struts/src/test/java/org/apache/maven/struts/Struts10WarFileTest.java
Index: Struts10WarFileTest.java
===================================================================
package org.apache.maven.struts;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import java.io.IOException;
import java.util.List;
import junit.framework.TestCase;
import org.apache.maven.TestConstantsTest;
/**
* Unit tests for {@link Struts10WarFile}
*
* @author dion
* @version $Id: Struts10WarFileTest.java,v 1.1 2002/07/14 23:29:24 jvanzyl Exp $
*/
public class Struts10WarFileTest extends TestCase {
/** instance to be tested */
private Struts10WarFile instance;
/** test war file */
private String testWarFileName;
/** Creates a new instance of Struts10WarFileTest
* @param testName the name of the test
*/
public Struts10WarFileTest(java.lang.String testName) {
super(testName);
}
/**
* Initialize per test data
* @throws Exception when there is an unexpected problem
*/
public void setUp() throws Exception
{
String baseDir = System.getProperty("basedir");
assertNotNull("The system property basedir was not defined.", baseDir);
testWarFileName = baseDir + TestConstantsTest.STRUTS_DIR +
"struts-example.war";
}
/** Test that the constructor succeeds
* @throws Exception when there is an unexpected problem
*/
public void testConstructor() throws Exception
{
try
{
instance = new Struts10WarFile(testWarFileName);
}
catch (IOException ioe)
{
fail("There was an error reading the test war file");
}
}
/** test that the config is defaulted correctly
* @throws Exception when there is an unexpected problem
*/
public void testDefaultConfig() throws Exception
{
testConstructor();
assertEquals("Default config isn't WEB-INF/struts-config.xml",
Struts10WarFile.DEFAULT_CONFIG,
instance.getConfig());
}
/** test the the config property works
* @throws Exception when there is an unexpected problem
*/
public void testConfig() throws Exception
{
testDefaultConfig();
String dummyConfig = "WEB-INF/struts.xml";
instance.setConfig(dummyConfig);
assertEquals("Set or get for config failed", dummyConfig,
instance.getConfig());
}
/** test retrieving the struts config as a JarEntry
* @throws Exception when there is an unexpected problem
*/
public void testConfigEntry() throws Exception
{
testConstructor();
assertNotNull("config entry was null", instance.getStrutsConfigEntry());
}
/** test the retrieval of form beans
* @throws Exception when there is an unexpected problem
*/
public void testFormBeans() throws Exception
{
testConstructor();
assertEquals("Number of form beans returned was wrong", 3,
instance.getFormBeans().size());
List formBeans = instance.getFormBeans();
assertEquals("first form bean isn't logonForm", "logonForm",
((FormBean)formBeans.get(0)).getName());
assertEquals("second form bean isn't registrationForm",
"registrationForm",
((FormBean)formBeans.get(1)).getName());
assertEquals("third form bean isn't subscriptionForm",
"subscriptionForm",
((FormBean)formBeans.get(2)).getName());
assertEquals("form beans type is not default",
"org.apache.struts.action.ActionFormBean",
instance.getFormBeansType());
}
/** test the retrieval of actions
* @throws Exception when there is an unexpected problem
*/
public void testActions() throws Exception
{
testConstructor();
assertEquals("Number of actions returned was wrong", 14,
instance.getActions().size());
List actions = instance.getActions();
String[] types = new String[]
{
"org.apache.struts.webapp.example.EditRegistrationAction",
"org.apache.struts.webapp.example.EditSubscriptionAction",
"org.apache.struts.webapp.example.LogoffAction",
"org.apache.struts.webapp.example.LogonAction",
"org.apache.struts.webapp.example.SaveRegistrationAction",
"org.apache.struts.webapp.example.SaveSubscriptionAction",
null,
"org.apache.struts.actions.AddFormBeanAction",
"org.apache.struts.actions.AddForwardAction",
"org.apache.struts.actions.AddMappingAction",
"org.apache.struts.actions.ReloadAction",
"org.apache.struts.actions.RemoveFormBeanAction",
"org.apache.struts.actions.RemoveForwardAction",
"org.apache.struts.actions.RemoveMappingAction"
};
for (int index = 0; index < types.length; index++)
{
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());
assertEquals("Wrong number of forwards found", 3,
instance.getForwards().size());
String[] names = new String[] {"logoff", "logon", "success"};
Forward forward = null;
List forwards = instance.getForwards();
for (int index = 0; index < names.length; index++)
{
forward = (Forward) forwards.get(index);
assertEquals("Forward number " + index + " isn't "+ names[index],
names[index], forward.getName());
}
}
/** test the action servlet name property
* @throws Exception when there is an unexpected problem
*/
public void testActionServletName() throws Exception
{
testConstructor();
assertEquals("default action servlet name is not 'action'", "action",
Struts10WarFile.DEFAULT_ACTIONSERVLET_NAME);
String dummy = "dummyName";
instance.setActionServletName(dummy);
assertEquals("action servlet name property get or set failed", dummy,
instance.getActionServletName());
}
/** test the action servlet pattern method
* @throws Exception when there is an unexpected problem
*/
public void testActionServletPattern() throws Exception
{
testConstructor();
assertEquals("action servlet pattern is wrong", "*.do",
instance.getActionServletPattern());
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>