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

📄 persistenceconfigtest.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.config;

import opiam.admin.faare.PropertiesManager;
import opiam.admin.faare.config.PersistenceConfig;
import opiam.admin.faare.config.javabeans.JBClassDescriptor;
import opiam.admin.faare.config.javabeans.PersistenceDescriptionMap;
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.BasicConfigurator;
import org.apache.log4j.Logger;

import java.util.Iterator;


/**
 *  Tests the loading of the Persistence configuration.
 */
public class PersistenceConfigTest extends TestCase
{
    /** Instance of logger. */
    private static Logger _logger = Logger.getLogger(PersistenceConfigTest.class);

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

    /**
     * Creates a new PersistenceConfigTest object.
     *
     * @param param  Parameter.
     */
    public PersistenceConfigTest(String param)
    {
        super(param);
        BasicConfigurator.configure();
    }

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

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

        // TESTS SET
        suite.addTest(new PersistenceConfigTest("testReadConfig"));

        suite.addTest(new PersistenceConfigTest("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("PersistenceConfigTest");

        _test.displayHeaderClass("PersistenceConfigTest");
        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("PersistenceConfigTest");
    }

    /**
     * Tests the readConfig method.
     *
     */
    public void testReadConfig()
    {
        _test.displayHeaderMethod("testReadConfig");

        try
        {
            PersistenceDescriptionMap persistenceDescriptionMap =
                                          (PersistenceDescriptionMap) PersistenceConfig.getInstance()
                                          .readConfig(this.getClass()
                                          .getResourceAsStream(PropertiesManager.FAARE_MAPPING_FILE));

            if (persistenceDescriptionMap != null)
            {
                Iterator it = persistenceDescriptionMap.getDescMap().keySet()
                                                       .iterator();
                JBClassDescriptor classDesc = null;
                String key = null;

                while (it.hasNext())
                {
                    key = (String) it.next();
                    _test.displayMsg("------------ KEY = " + key);
                    classDesc = (JBClassDescriptor) persistenceDescriptionMap.getDescMap()
                                                                             .get(key);
                    _test.displayMsg(classDesc.toString());
                    _test.displayMsg("--------------------");
                }

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

        _test.displayFooterMethod("testReadConfig");
    }
}

⌨️ 快捷键说明

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