Updated test names and moved document add code to @Before method. (#1187)

* Solr w Apache SolrJ

* Solr w Apache SolrJ

* updated test names and moved add to @before method
This commit is contained in:
Nancy Bosecker 2017-02-16 19:59:06 -08:00 committed by KevinGilmore
parent 6b0e59afac
commit 935b815ad4
1 changed files with 8 additions and 8 deletions

View File

@ -18,24 +18,24 @@ import org.junit.Test;
public class SolrJavaIntegrationTest { public class SolrJavaIntegrationTest {
private HttpSolrClient solr; private HttpSolrClient solr;
private SolrInputDocument document;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
solr = new HttpSolrClient("http://localhost:8983/solr/bigboxstore"); solr = new HttpSolrClient("http://localhost:8983/solr/bigboxstore");
solr.setParser(new XMLResponseParser()); solr.setParser(new XMLResponseParser());
}
document = new SolrInputDocument();
@Test
public void givenAdd_thenVerifyAdded() throws SolrServerException, IOException {
SolrInputDocument document = new SolrInputDocument();
document.addField("id", "123456"); document.addField("id", "123456");
document.addField("name", "Kenmore Dishwasher"); document.addField("name", "Kenmore Dishwasher");
document.addField("price", "599.99"); document.addField("price", "599.99");
solr.add(document); solr.add(document);
solr.commit(); solr.commit();
}
@Test
public void whenAdd_thenVerifyAdded() throws SolrServerException, IOException {
SolrQuery query = new SolrQuery(); SolrQuery query = new SolrQuery();
query.set("q", "id:123456"); query.set("q", "id:123456");
@ -53,7 +53,7 @@ public class SolrJavaIntegrationTest {
} }
@Test @Test
public void givenDelete_thenVerifyDeleted() throws SolrServerException, IOException { public void whenDelete_thenVerifyDeleted() throws SolrServerException, IOException {
solr.deleteById("123456"); solr.deleteById("123456");
solr.commit(); solr.commit();