Revision 8353
Added by Jing Tao about 11 years ago
metacat-index/src/test/java/edu/ucsb/nceas/metacat/index/IndexGeneratorIT.java | ||
---|---|---|
1 |
package edu.ucsb.nceas.metacat.index; |
|
2 |
|
|
3 |
import static org.junit.Assert.assertTrue; |
|
4 |
|
|
5 |
import java.io.File; |
|
6 |
import java.io.FileInputStream; |
|
7 |
import java.io.IOException; |
|
8 |
import java.io.InputStream; |
|
9 |
import java.io.StringWriter; |
|
10 |
import java.io.Writer; |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import org.apache.solr.client.solrj.SolrServer; |
|
15 |
import org.apache.solr.client.solrj.SolrServerException; |
|
16 |
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; |
|
17 |
import org.apache.solr.client.solrj.response.QueryResponse; |
|
18 |
import org.apache.solr.common.params.SolrParams; |
|
19 |
import org.apache.solr.core.CoreContainer; |
|
20 |
import org.apache.solr.core.SolrCore; |
|
21 |
import org.apache.solr.request.LocalSolrQueryRequest; |
|
22 |
import org.apache.solr.response.SolrQueryResponse; |
|
23 |
import org.apache.solr.response.XMLResponseWriter; |
|
24 |
import org.apache.solr.servlet.SolrRequestParsers; |
|
25 |
import org.dataone.service.types.v1.SystemMetadata; |
|
26 |
import org.dataone.service.util.TypeMarshaller; |
|
27 |
import org.junit.Before; |
|
28 |
import org.junit.Test; |
|
29 |
|
|
30 |
public class IndexGeneratorIT { |
|
31 |
/** |
|
32 |
* Test building index for an insert. |
|
33 |
*/ |
|
34 |
@Test |
|
35 |
public void testGenerateAll() throws Exception { |
|
36 |
SolrIndex solrIndex = generateSolrIndex(); |
|
37 |
SystemMetadataEventListener systeMetaListener = new SystemMetadataEventListener(solrIndex); |
|
38 |
systeMetaListener.start(); |
|
39 |
IndexGeneratorTimerTask generator = new IndexGeneratorTimerTask(solrIndex); |
|
40 |
generator.indexAll(); |
|
41 |
String result = SolrIndexIT.doQuery(solrIndex.getSolrServer()); |
|
42 |
systeMetaListener.stop(); |
|
43 |
} |
|
44 |
|
|
45 |
private SolrIndex generateSolrIndex() throws Exception { |
|
46 |
String springConfigFile = "/index-processor-context.xml"; |
|
47 |
String metacatPropertyFile = null; //in this test, we use the test.properties file rather than metacat.properties file. so set it to be null. |
|
48 |
ApplicationController controller = new ApplicationController(springConfigFile, metacatPropertyFile); |
|
49 |
controller.initialize(); |
|
50 |
List<SolrIndex> list = controller.getSolrIndexes(); |
|
51 |
SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]); |
|
52 |
SolrIndex index = solrIndexesarray[0]; |
|
53 |
//SolrServer solrServer = SolrServerFactory.createSolrServer(); |
|
54 |
//index.setSolrServer(solrServer); |
|
55 |
return index; |
|
56 |
} |
|
57 |
} |
metacat-index/src/test/java/edu/ucsb/nceas/metacat/index/IndexGeneratorTimerTaskIT.java | ||
---|---|---|
1 |
package edu.ucsb.nceas.metacat.index; |
|
2 |
|
|
3 |
import static org.junit.Assert.assertTrue; |
|
4 |
|
|
5 |
import java.io.File; |
|
6 |
import java.io.FileInputStream; |
|
7 |
import java.io.IOException; |
|
8 |
import java.io.InputStream; |
|
9 |
import java.io.StringWriter; |
|
10 |
import java.io.Writer; |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import org.apache.solr.client.solrj.SolrServer; |
|
15 |
import org.apache.solr.client.solrj.SolrServerException; |
|
16 |
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; |
|
17 |
import org.apache.solr.client.solrj.response.QueryResponse; |
|
18 |
import org.apache.solr.common.params.SolrParams; |
|
19 |
import org.apache.solr.core.CoreContainer; |
|
20 |
import org.apache.solr.core.SolrCore; |
|
21 |
import org.apache.solr.request.LocalSolrQueryRequest; |
|
22 |
import org.apache.solr.response.SolrQueryResponse; |
|
23 |
import org.apache.solr.response.XMLResponseWriter; |
|
24 |
import org.apache.solr.servlet.SolrRequestParsers; |
|
25 |
import org.dataone.service.types.v1.SystemMetadata; |
|
26 |
import org.dataone.service.util.TypeMarshaller; |
|
27 |
import org.junit.Before; |
|
28 |
import org.junit.Test; |
|
29 |
|
|
30 |
public class IndexGeneratorTimerTaskIT { |
|
31 |
/** |
|
32 |
* Test building index for an insert. |
|
33 |
*/ |
|
34 |
@Test |
|
35 |
public void testGenerateAll() throws Exception { |
|
36 |
SolrIndex solrIndex = generateSolrIndex(); |
|
37 |
SystemMetadataEventListener systeMetaListener = new SystemMetadataEventListener(solrIndex); |
|
38 |
systeMetaListener.start(); |
|
39 |
IndexGeneratorTimerTask generator = new IndexGeneratorTimerTask(solrIndex); |
|
40 |
generator.indexAll(); |
|
41 |
String result = SolrIndexIT.doQuery(solrIndex.getSolrServer()); |
|
42 |
systeMetaListener.stop(); |
|
43 |
} |
|
44 |
|
|
45 |
private SolrIndex generateSolrIndex() throws Exception { |
|
46 |
String springConfigFile = "/index-processor-context.xml"; |
|
47 |
String metacatPropertyFile = null; //in this test, we use the test.properties file rather than metacat.properties file. so set it to be null. |
|
48 |
ApplicationController controller = new ApplicationController(springConfigFile, metacatPropertyFile); |
|
49 |
controller.initialize(); |
|
50 |
List<SolrIndex> list = controller.getSolrIndexes(); |
|
51 |
SolrIndex[] solrIndexesarray = list.toArray(new SolrIndex[list.size()]); |
|
52 |
SolrIndex index = solrIndexesarray[0]; |
|
53 |
//SolrServer solrServer = SolrServerFactory.createSolrServer(); |
|
54 |
//index.setSolrServer(solrServer); |
|
55 |
return index; |
|
56 |
} |
|
57 |
} |
Also available in: Unified diff
Renamed the test class.