Project

General

Profile

1 7607 tao
package edu.ucsb.nceas.metacat.index;
2
3
import java.util.List;
4
5
import org.junit.Test;
6
7 8353 tao
public class IndexGeneratorTimerTaskIT {
8 7607 tao
    /**
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 8464 leinfelder
        systeMetaListener.run();
16 8352 tao
        IndexGeneratorTimerTask generator = new IndexGeneratorTimerTask(solrIndex);
17 7607 tao
        generator.indexAll();
18
        String result = SolrIndexIT.doQuery(solrIndex.getSolrServer());
19 7610 tao
        systeMetaListener.stop();
20 7607 tao
    }
21
22
    private SolrIndex generateSolrIndex() throws Exception {
23 8130 tao
        String springConfigFile = "/index-processor-context.xml";
24 7784 tao
        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 7607 tao
        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
}