Package net.fp.rp.search.back.extractor

Source Code of net.fp.rp.search.back.extractor.ExtractAllTestSuite

/*
* Copyright (C) 2004 Paul Browne, http://www.firstpartners.net,
* built with the help of Fast-Soft (fastsoftdev@yahoo.com)
*
* released under terms of the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This product includes software developed by the
* Apache Software Foundation (http://www.apache.org)."
*
* This product includes software developed by the
* Spring Framework Project (http://www.springframework.org)."
*
*/
package net.fp.rp.search.back.extractor;

import java.io.FileNotFoundException;

import junit.framework.Test;
import junit.framework.TestSuite;
import net.fp.rp.search.mid.global.Config;
import net.fp.rp.search.plugins.IDataExtractor;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.Log4jConfigurer;


/**
* This is a holder for all extractor test cases in the rp system.
*
* @author Firstpartners.net
* @version 1.1
*/
public abstract class ExtractAllTestSuite {
    /** Default test extractor test context */
    public static final String TEST_EXTRACTOR_CONTEXT = "/appTestContext.xml";

    /** Default application extractor context */
    public static final String APP_CONTEXT = "/appContext.xml";

    /** Application context */
    private static AbstractApplicationContext context;

    /** Extractor context */
    private static AbstractApplicationContext extractorContext;

    /**
     * This will get the suite of test that this class holds.
     *
     * @return All of the tests that this class holds.
     */
    public static Test suite() {
        TestSuite suite = new TestSuite();
        System.setProperty(Config.RP_ROOT, "./junit-tests");

        //initialization of the log4j
        try {
            Log4jConfigurer.initLogging(Config.LOG4J_XML);
        } catch (FileNotFoundException e) {
            e.printStackTrace(System.out);
        }

        //set the context
        context = new ClassPathXmlApplicationContext(APP_CONTEXT);

        //set the extractor context
        extractorContext = new ClassPathXmlApplicationContext(TEST_EXTRACTOR_CONTEXT);

        //get the generic case
        ExtractorTestLists tests = (ExtractorTestLists) extractorContext.getBean(
                "extractorTests");

        for (int i = 0; i < tests.getTests().size(); i++) {
            String testname = (String) tests.getTests().get(i);

            //get the generic case
            ExtractorTestCase extractcase = (ExtractorTestCase) extractorContext.getBean(testname);

            extractcase.setName("test");

            //get the data extractor and set it into generic case
            extractcase.setDataextractor((IDataExtractor) context.getBean(
                    extractcase.getExtractor()));

            //add to the test case to the suite
            suite.addTest(extractcase);
        }

        return suite;
    }
}
TOP

Related Classes of net.fp.rp.search.back.extractor.ExtractAllTestSuite

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.