Project

General

Profile

« Previous | Next » 

Revision 8119

Added by Jing Tao over 10 years ago

Add a junit test class.

View differences:

metacat-common/src/test/java/edu/ucsb/nceas/metacat/common/query/SolrQueryServiceControllerTest.java
1
package edu.ucsb.nceas.metacat.common.query;
2

  
3
import static org.junit.Assert.assertTrue;
4

  
5
import java.io.IOException;
6
import java.net.MalformedURLException;
7
import java.util.List;
8
import java.util.Map;
9

  
10
import javax.xml.parsers.ParserConfigurationException;
11

  
12
import org.apache.solr.schema.SchemaField;
13
import org.dataone.service.exceptions.NotFound;
14
import org.dataone.service.exceptions.UnsupportedType;
15
import org.junit.Test;
16
import org.xml.sax.SAXException;
17

  
18
public class SolrQueryServiceControllerTest {
19
    /**
20
     * Test get the solr version
21
     * @throws SAXException 
22
     * @throws IOException 
23
     * @throws ParserConfigurationException 
24
     * @throws NotFound 
25
     * @throws UnsupportedType 
26
     */
27
    @Test
28
    public void testGetSolrSpecVersion() throws UnsupportedType, NotFound, ParserConfigurationException, IOException, SAXException {
29
        String version = SolrQueryServiceController.getInstance().getSolrSpecVersion();
30
        assertTrue(version != null);
31
        assertTrue(!version.equals(""));
32
    }
33
    
34
    
35
    /**
36
     * Test get get valid schema fields.
37
     * @throws SAXException 
38
     * @throws IOException 
39
     * @throws ParserConfigurationException 
40
     * @throws NotFound 
41
     * @throws UnsupportedType 
42
     */
43
    @Test
44
    public void testGetValidSchemaFields() throws Exception {
45
       List<String> fields = SolrQueryServiceController.getInstance().getValidSchemaFields();
46
       assertTrue(fields != null);
47
       assertTrue(!fields.isEmpty());
48
    }
49
    
50
    /**
51
     * Test get get valid schema fields.
52
     * @throws SAXException 
53
     * @throws IOException 
54
     * @throws ParserConfigurationException 
55
     * @throws NotFound 
56
     * @throws UnsupportedType 
57
     */
58
    @Test
59
    public void testgetIndexSchemaFields() throws Exception {
60
       Map<String, SchemaField> fields = SolrQueryServiceController.getInstance().getIndexSchemaFields();
61
       assertTrue(fields != null);
62
       assertTrue(!fields.isEmpty());
63
    }
64
}

Also available in: Unified diff