⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jbmenutest.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
字号:
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.unittests.struts.service.beans;

import opiam.admin.faare.PropertiesManager;
import opiam.admin.faare.struts.service.beans.JBMenu;
import opiam.admin.faare.struts.service.beans.JBMenuElement;
import opiam.admin.faare.unittests.TestResult;
import opiam.admin.faare.unittests.TestUtils;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.log4j.Logger;

import java.util.ArrayList;
import java.util.List;


/**
 * Test of JMenu class.
 */
public class JBMenuTest extends TestCase
{
    /** Instance of logger. */
    private static Logger _logger = Logger.getLogger(JBMenuTest.class);

    /** Instance of the trace class. */
    private static TestUtils _test = new TestUtils(_logger);

    /** Instance of JBMenu. */
    private JBMenu jbMenu = new JBMenu();

    /**
     * Creates a new JBMenuTest object.
     *
     * @param arg0  Parameter.
     */
    public JBMenuTest(String arg0)
    {
        super(arg0);

        try
        {
            PropertiesManager.getInstance();
        }
        catch (Exception e)
        {
            StringBuffer msg = new StringBuffer();
            msg.append("JBMenuTest constructor error");
            msg.append(TestUtils.NEXT);
            msg.append(e.toString());
            _test.displayResultError(msg.toString());
        }
    }

    /**
     * Method of the tests suite.
     *
     * @return Tests result.
     */
    public static Test suite()
    {
        TestSuite suite = new TestSuite();

        suite.addTest(new JBMenuTest("testBegin"));

        suite.addTest(new JBMenuTest("testGetName"));
        suite.addTest(new JBMenuTest("testAddElement"));

        suite.addTest(new JBMenuTest("testEnd"));

        return suite;
    }

    /**
     * Main method of the test class.
     *
     * @param args  Sets of the parameters.
     */
    public static void main(String[] args)
    {
        junit.textui.TestRunner.run(suite());
    }

    /**
     * Method to indicate the beginning of the class test.
     *
     */
    public static void testBegin()
    {
        //  To initialize the tests statement
        TestResult.getInstance().setInitiator("JBMenuTest");

        _test.displayHeaderClass("JBMenuTest");
        assertTrue(true);
    }

    /**
     * Method to indicate the end of the class test.
     *
     */
    public static void testEnd()
    {
        _test.displayFooterClass(null);
        assertTrue(true);

        // To display the tests statement
        _test.displayTestStatement("JBMenuTest");
    }

    /**
     * Test the methods: setName and getName.
     *
     */
    public void testGetName()
    {
        _test.displayHeaderMethod("testGetName");

        try
        {
            String expected = "horizontal_menu";
            jbMenu.setName("horizontal_menu");

            String result = jbMenu.getName();

            if (expected.equals(result))
            {
                _test.displayResultSuccess(null);
            }
            else
            {
                _test.displayResultFailure(null);
            }
        }
        catch (Exception ex)
        {
            StringBuffer msg = new StringBuffer();
            msg.append("Exception : ");
            msg.append(TestUtils.NEXT);
            msg.append(ex.toString());
            _test.displayResultError(msg.toString());
        }

        _test.displayFooterMethod("testGetName");
    }

    /**
     * Test the methods: addElement and getElements.
     *
     */
    public void testAddElement()
    {
        _test.displayHeaderMethod("testAddElement");

        try
        {
            List aelements = new ArrayList();
            List results = new ArrayList();

            JBMenuElement element1 = new JBMenuElement();
            aelements.add(element1);

            jbMenu.addElement(element1);
            results = jbMenu.getElements();

            if (aelements.size() == results.size())
            {
                _test.displayResultSuccess(null);
            }
            else
            {
                _test.displayResultFailure(null);
            }
        }
        catch (Exception ex)
        {
            StringBuffer msg = new StringBuffer();
            msg.append("Exception : ");
            msg.append(TestUtils.NEXT);
            msg.append(ex.toString());
            _test.displayResultError(msg.toString());
        }

        _test.displayFooterMethod("testAddElement");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -