Project

General

Profile

1
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
    private static final String id = "urn:uuid:606a19dd-b531-4bf4-b5a5-6d06c3d39098";
20
    
21
    /**
22
     * Test building index for an insert.
23
     */
24
    @Test
25
    public void testInsert() throws Exception {
26
       SolrIndex solrIndex = generateSolrIndex();
27
       InputStream systemInputStream = new FileInputStream(new File(SYSTEMMETAFILEPATH));
28
       InputStream emlInputStream = new FileInputStream(new File(EMLFILEPATH));
29
       solrIndex.insert(id, systemInputStream, emlInputStream);
30
       
31
    }
32
    
33
    /**
34
     * Test building index for an insert.
35
     */
36
    @Test
37
    public void testDelete() throws Exception {
38
       SolrIndex solrIndex = generateSolrIndex();
39
       solrIndex.remove(id);
40
       
41
    }
42
    
43
    private SolrIndex generateSolrIndex() throws Exception {
44
        ApplicationController controller = new ApplicationController();
45
        List<SolrIndex> list = controller.getSolrIndexes();
46
        SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]);
47
        SolrIndex index = solrIndexesarray[0];
48
        return index;
49
    }
50
}
51

    
(2-2/2)