Ignore:
Timestamp:
02/21/13 14:40:39 (11 years ago)
Author:
keeloo
Message:

Added VloConfig? to the importer. Routed importer tests via via the VloConfig? class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/importer/MetadataImporterTest.java

    r1437 r2604  
    11package eu.clarin.cmdi.vlo.importer;
    22
    3 import static org.junit.Assert.assertEquals;
    4 
     3import eu.clarin.cmdi.vlo.FacetConstants;
     4import eu.clarin.cmdi.vlo.config.DataRoot;
     5import eu.clarin.cmdi.vlo.config.VloConfig;
    56import java.io.File;
    67import java.io.IOException;
     
    1011import java.util.Collections;
    1112import java.util.List;
    12 
    1313import org.apache.solr.client.solrj.SolrServerException;
    1414import org.apache.solr.common.SolrInputDocument;
     15import static org.junit.Assert.assertEquals;
    1516import org.junit.Test;
    16 
    17 import eu.clarin.cmdi.vlo.FacetConstants;
    1817
    1918public class MetadataImporterTest extends ImporterTestcase {
     
    236235    private List<SolrInputDocument> importData(File rootFile) throws MalformedURLException {
    237236        final List<SolrInputDocument> result = new ArrayList<SolrInputDocument>();
    238         ImporterConfig config = createConfig(rootFile);
    239         MetadataImporter importer = new MetadataImporter(config) {
     237       
     238        String fileName = VloConfig.class.getResource("/VloConfig.xml").getFile();
     239       
     240        VloConfig testConfig;
     241       
     242        /**
     243         * Problem: at the moment the readTestConfig method is not prepared for
     244         * a message from the importer. May rename readTestConfig to
     245         * readWebAppTestConfig, so that we have space for a
     246         * readImporterTestConfig also.
     247         *
     248         * The best thing would be to have a directory for testing inside the
     249         * package. You can always use an external configuration file for more
     250         * elaborate testing.test directory inside the package.
     251         */
     252
     253        testConfig = VloConfig.readTestConfig(fileName);
     254       
     255        // modify the test configuration a bit
     256       
     257        testConfig = modifyConfig(testConfig, rootFile);
     258       
     259        // ... and also the importer itself
     260       
     261        MetadataImporter importer;
     262        importer = new MetadataImporter(testConfig) {
    240263            @Override
    241264            protected void initSolrServer() throws MalformedURLException {
     
    245268            @Override
    246269            protected void sendDocs() throws SolrServerException, IOException {
    247                 //overriding here so we can test the docs
     270            //overriding here so we can test the docs
    248271                result.addAll(this.docs);
    249272                docs = new ArrayList<SolrInputDocument>();
     
    254277    }
    255278
    256     private ImporterConfig createConfig(File rootFile) {
    257         ImporterConfig config = new ImporterConfig();
     279    private VloConfig modifyConfig(VloConfig config, File rootFile) {
    258280        DataRoot dataRoot = new DataRoot();
    259281        dataRoot.setDeleteFirst(false);//cannot delete not using real solrServer
Note: See TracChangeset for help on using the changeset viewer.