package org.apache.maven.struts;

/* ====================================================================
 *   Copyright 2001-2004 The Apache Software Foundation.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * ====================================================================
 */

import junit.framework.TestCase;

/**
 * Unit tests for {@link FormBean}
 * @author dion
 * @version $Id: FormBeanTest.java,v 1.2 2004/03/02 15:36:14 evenisse 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());
    }
}
