Project

General

Profile

1
package edu.ucsb.nceas.metacat.index;
2

    
3
import java.util.List;
4

    
5
import org.junit.Test;
6

    
7
public class IndexGeneratorTimerTaskIT {
8
    /**
9
     * Test building index for an insert.
10
     */
11
    @Test
12
    public void testGenerateAll() throws Exception {
13
        SolrIndex solrIndex = generateSolrIndex();
14
        SystemMetadataEventListener systeMetaListener = new SystemMetadataEventListener(solrIndex);
15
        systeMetaListener.run();
16
        IndexGeneratorTimerTask generator = new IndexGeneratorTimerTask(solrIndex);
17
        generator.indexAll();
18
        String result = SolrIndexIT.doQuery(solrIndex.getSolrServer());
19
        systeMetaListener.stop();
20
    }
21
    
22
    private SolrIndex generateSolrIndex() throws Exception {
23
        String springConfigFile = "/index-processor-context.xml";
24
        String metacatPropertyFile = null; //in this test, we use the test.properties file rather than metacat.properties file. so set it to be null.
25
        ApplicationController controller = new ApplicationController(springConfigFile, metacatPropertyFile);
26
        controller.initialize();
27
        List<SolrIndex> list = controller.getSolrIndexes();
28
        SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]);
29
        SolrIndex index = solrIndexesarray[0];
30
        //SolrServer solrServer = SolrServerFactory.createSolrServer();
31
        //index.setSolrServer(solrServer);
32
        return index;
33
    }
34
}
(3-3/5)