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.dataone.service.types.v1.SystemMetadata;
|
14
|
import org.dataone.service.util.TypeMarshaller;
|
15
|
import org.junit.Test;
|
16
|
|
17
|
public class SolrIndexTest {
|
18
|
|
19
|
private static final String SYSTEMMETAFILEPATH = "src/test/resources/eml-system-meta-example.xml";
|
20
|
private static final String EMLFILEPATH = "src/test/resources/eml-example.xml";
|
21
|
private static final String id = "urn:uuid:606a19dd-b531-4bf4-b5a5-6d06c3d39098";
|
22
|
|
23
|
/**
|
24
|
* Test building index for an insert.
|
25
|
*/
|
26
|
@Test
|
27
|
public void testInsert() throws Exception {
|
28
|
SolrIndex solrIndex = generateSolrIndex();
|
29
|
//InputStream systemInputStream = new FileInputStream(new File(SYSTEMMETAFILEPATH));
|
30
|
SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromFile(SystemMetadata.class, SYSTEMMETAFILEPATH);
|
31
|
InputStream emlInputStream = new FileInputStream(new File(EMLFILEPATH));
|
32
|
solrIndex.insert(id, systemMetadata, emlInputStream);
|
33
|
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* Test building index for an insert.
|
38
|
*/
|
39
|
@Test
|
40
|
public void testDelete() throws Exception {
|
41
|
SolrIndex solrIndex = generateSolrIndex();
|
42
|
solrIndex.remove(id);
|
43
|
|
44
|
}
|
45
|
|
46
|
private SolrIndex generateSolrIndex() throws Exception {
|
47
|
ApplicationController controller = new ApplicationController();
|
48
|
List<SolrIndex> list = controller.getSolrIndexes();
|
49
|
SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]);
|
50
|
SolrIndex index = solrIndexesarray[0];
|
51
|
return index;
|
52
|
}
|
53
|
}
|
54
|
|