コード例 #1
0
 @Test(dependsOnMethods = "testAddDocument")
 public void testBasicQuery() throws SolrServerException {
   SolrServer server = solrServerFactory.getServer();
   SolrParams params = new SolrQuery("*:*");
   SolrDocumentList results = server.query(params).getResults();
   assertTrue(results.getNumFound() > 0, "didn't return any results");
 }
コード例 #2
0
 @Test(dependsOnMethods = {"testGetServer"})
 public void testBadQuery() throws SolrServerException {
   SolrServer server = solrServerFactory.getServer();
   SolrParams params = new SolrQuery("text that is not found");
   QueryResponse response = server.query(params);
   assertEquals(0L, response.getResults().getNumFound());
 }
コード例 #3
0
 @Test(dependsOnMethods = "testBasicQuery", dataProvider = "documentMap")
 public void testIdQuery(Map<String, String[]> document) throws SolrServerException {
   String id = document.get("id")[0];
   SolrServer server = solrServerFactory.getServer();
   SolrParams params = new SolrQuery("id:" + id);
   SolrDocumentList results = server.query(params).getResults();
   assertEquals(results.getNumFound(), 1, "didn't find article by id");
 }
コード例 #4
0
  @Test(dependsOnMethods = "testAddDocument", dataProvider = "documentMap")
  public void testMultiValuedField(Map<String, String[]> document) throws Exception {
    String value1 = document.get("alternate_title")[0];
    String value2 = document.get("alternate_title")[1];

    Long numFound =
        solrServerFactory
            .getServer()
            .query(new SolrQuery("alternate_title:" + value1))
            .getResults()
            .getNumFound();
    assertTrue(numFound > 0l, "query didn't work on multivalued field");

    numFound =
        solrServerFactory
            .getServer()
            .query(new SolrQuery("alternate_title:" + value2))
            .getResults()
            .getNumFound();
    assertTrue(numFound > 0l, "query didn't work on multivalued field");
  }
コード例 #5
0
 @Test(
     dataProvider = "documentMap",
     dependsOnMethods = {"testGetServer"})
 public void testAddDocument(Map<String, String[]> document) throws Exception {
   solrServerFactory.addDocument(document);
 }
コード例 #6
0
 @Test
 public void testGetServer() throws SolrServerException {
   SolrServer server = solrServerFactory.getServer();
   assertNotNull(server, "created null server");
 }
コード例 #7
0
 @AfterClass
 public void tearDown() throws Exception {
   solrServerFactory.tearDown();
 }