Project

General

Profile

1 7547 tao
package edu.ucsb.nceas.metacat.index;
2
3
import static org.junit.Assert.assertEquals;
4
import static org.junit.Assert.assertTrue;
5
6
import java.io.File;
7
import java.io.FileInputStream;
8
import java.io.InputStream;
9
import java.util.List;
10
11
12
13
import org.junit.Test;
14
15
public class SolrIndexTest {
16
17
    private static final String SYSTEMMETAFILEPATH = "src/test/resources/eml-system-meta-example.xml";
18
    private static final String EMLFILEPATH = "src/test/resources/eml-example.xml";
19
20
    /**
21
     * Test building index for an insert.
22
     */
23
    @Test
24
    public void testInsert() throws Exception {
25
       SolrIndex solrIndex = generateSolrIndex();
26
       InputStream systemInputStream = new FileInputStream(new File(SYSTEMMETAFILEPATH));
27
       InputStream emlInputStream = new FileInputStream(new File(EMLFILEPATH));
28
       String id = "urn:uuid:606a19dd-b531-4bf4-b5a5-6d06c3d39098";
29
       solrIndex.insert(id, systemInputStream, emlInputStream);
30
31
    }
32
33
    private SolrIndex generateSolrIndex() throws Exception {
34
        ApplicationController controller = new ApplicationController();
35
        List<SolrIndex> list = controller.getSolrIndexes();
36
        SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]);
37
        SolrIndex index = solrIndexesarray[0];
38
        return index;
39
    }
40
}