gov.nih.nci.ncicb.cadsr.ProcessMultipleFilesTestCase.java Source code

Java tutorial

Introduction

Here is the source code for gov.nih.nci.ncicb.cadsr.ProcessMultipleFilesTestCase.java

Source

/*L
 * Copyright Oracle Inc, SAIC-F.
 *
 * Distributed under the OSI-approved BSD 3-Clause License.
 * See http://ncip.github.com/cadsr-bulk-loader/LICENSE.txt for details.
 */

package gov.nih.nci.ncicb.cadsr;

import gov.nih.nci.ncicb.cadsr.bulkloader.BulkLoadProcessResult;
import gov.nih.nci.ncicb.cadsr.bulkloader.CaDSRBulkLoadProcessor;
import gov.nih.nci.ncicb.cadsr.bulkloader.ui.UIReportWriter;
import gov.nih.nci.ncicb.cadsr.bulkloader.ui.UIReportWriterImpl;
import gov.nih.nci.ncicb.cadsr.bulkloader.util.FileUtil;
import gov.nih.nci.ncicb.cadsr.bulkloader.util.SpringBeansUtil;

import java.io.File;
import java.io.IOException;
import java.util.Properties;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ProcessMultipleFilesTestCase extends gov.nih.nci.ncicb.cadsr.bulkloader.util.MainTestCase {

    private static String[] XML_IP_FILES = { "/gov/nih/nci/ncicb/cadsr/8_6_4.xml",
            "/gov/nih/nci/ncicb/cadsr/8_7.xml" };
    private static String dataURL = "/gov/nih/nci/ncicb/cadsr/2files.xls";

    @Override
    protected void containerSetUp() throws Exception {
        // TODO Auto-generated method stub

    }

    @Override
    protected boolean requiresDatabase() {
        return true;
    }

    @Override
    protected boolean runInRealContainer() {
        return false;
    }

    public void setUp() {
        try {
            super.setUp();
            FileUtil fileUtil = new FileUtil();
            fileUtil.copyFilesToWorkingDir(WORKING_IN_DIR, WORKING_OUT_DIR, XML_IP_FILES);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public ProcessMultipleFilesTestCase() {
        super("ProcessMultipleFilesTestCase", ProcessMultipleFilesTestCase.class, dataURL);
    }

    public void testProcessor() {
        Properties props = new Properties();
        props.put("db.url", getPropertyManager().getUnitDataSourceURL());
        props.put("db.username", getPropertyManager().getUnitDataSourceUser());
        props.put("db.password", getPropertyManager().getUnitDataSourcePassword());

        SpringBeansUtil.getInstance().initialize(props);

        CaDSRBulkLoadProcessor blProcessor = SpringBeansUtil.getInstance().getBulkLoadProcessor();

        BulkLoadProcessResult[] processResults = blProcessor.process(WORKING_IN_DIR, WORKING_OUT_DIR, true);
        assertNotNull(processResults);
        assertTrue(processResults.length == 2);
        for (BulkLoadProcessResult result : processResults) {
            assertTrue(result.getLoadResult().isSuccessful());
        }

    }

}