From d490b91c9284e2c2bad4b91e178a62f94d3bce09 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 12 Jun 2020 12:13:20 +0530 Subject: [PATCH] JAVA-1848: Moved apache-solrj to apache-libraries --- apache-solrj/README.md | 7 -- apache-solrj/pom.xml | 30 ----- .../com/baeldung/solrjava/ProductBean.java | 44 ------- .../solrjava/SolrJavaIntegration.java | 56 --------- apache-solrj/src/main/resources/logback.xml | 13 --- .../baeldung/solrjava/SolrJavaLiveTest.java | 108 ------------------ 6 files changed, 258 deletions(-) delete mode 100644 apache-solrj/README.md delete mode 100644 apache-solrj/pom.xml delete mode 100644 apache-solrj/src/main/java/com/baeldung/solrjava/ProductBean.java delete mode 100644 apache-solrj/src/main/java/com/baeldung/solrjava/SolrJavaIntegration.java delete mode 100644 apache-solrj/src/main/resources/logback.xml delete mode 100644 apache-solrj/src/test/java/com/baeldung/solrjava/SolrJavaLiveTest.java diff --git a/apache-solrj/README.md b/apache-solrj/README.md deleted file mode 100644 index 803db393e9..0000000000 --- a/apache-solrj/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Apache Solrj - -This module contains articles about Apache Solrj - -### Relevant Articles: - -- [Guide to Solr in Java with Apache Solrj](https://www.baeldung.com/apache-solrj) \ No newline at end of file diff --git a/apache-solrj/pom.xml b/apache-solrj/pom.xml deleted file mode 100644 index 165cd9571b..0000000000 --- a/apache-solrj/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - 4.0.0 - apache-solrj - 0.0.1-SNAPSHOT - apache-solrj - jar - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - org.apache.solr - solr-solrj - ${org.apache.solr.solr-solrj.version} - - - - - 6.4.0 - - - \ No newline at end of file diff --git a/apache-solrj/src/main/java/com/baeldung/solrjava/ProductBean.java b/apache-solrj/src/main/java/com/baeldung/solrjava/ProductBean.java deleted file mode 100644 index 14eea8f2f9..0000000000 --- a/apache-solrj/src/main/java/com/baeldung/solrjava/ProductBean.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.solrjava; - -import org.apache.solr.client.solrj.beans.Field; - -public class ProductBean { - - String id; - String name; - String price; - - public ProductBean(String id, String name, String price) { - super(); - this.id = id; - this.name = name; - this.price = price; - } - - public String getId() { - return id; - } - - @Field("id") - protected void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - @Field("name") - protected void setName(String name) { - this.name = name; - } - - public String getPrice() { - return price; - } - - @Field("price") - protected void setPrice(String price) { - this.price = price; - } -} diff --git a/apache-solrj/src/main/java/com/baeldung/solrjava/SolrJavaIntegration.java b/apache-solrj/src/main/java/com/baeldung/solrjava/SolrJavaIntegration.java deleted file mode 100644 index c55e1c9ada..0000000000 --- a/apache-solrj/src/main/java/com/baeldung/solrjava/SolrJavaIntegration.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.solrjava; - -import java.io.IOException; - -import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.impl.HttpSolrClient; -import org.apache.solr.client.solrj.impl.XMLResponseParser; -import org.apache.solr.common.SolrInputDocument; - -public class SolrJavaIntegration { - - private HttpSolrClient solrClient; - - public SolrJavaIntegration(String clientUrl) { - - solrClient = new HttpSolrClient.Builder(clientUrl).build(); - solrClient.setParser(new XMLResponseParser()); - } - - public void addProductBean(ProductBean pBean) throws IOException, SolrServerException { - - solrClient.addBean(pBean); - solrClient.commit(); - } - - public void addSolrDocument(String documentId, String itemName, String itemPrice) throws SolrServerException, IOException { - - SolrInputDocument document = new SolrInputDocument(); - document.addField("id", documentId); - document.addField("name", itemName); - document.addField("price", itemPrice); - solrClient.add(document); - solrClient.commit(); - } - - public void deleteSolrDocumentById(String documentId) throws SolrServerException, IOException { - - solrClient.deleteById(documentId); - solrClient.commit(); - } - - public void deleteSolrDocumentByQuery(String query) throws SolrServerException, IOException { - - solrClient.deleteByQuery(query); - solrClient.commit(); - } - - protected HttpSolrClient getSolrClient() { - return solrClient; - } - - protected void setSolrClient(HttpSolrClient solrClient) { - this.solrClient = solrClient; - } - -} diff --git a/apache-solrj/src/main/resources/logback.xml b/apache-solrj/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/apache-solrj/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/apache-solrj/src/test/java/com/baeldung/solrjava/SolrJavaLiveTest.java b/apache-solrj/src/test/java/com/baeldung/solrjava/SolrJavaLiveTest.java deleted file mode 100644 index eaf0271b55..0000000000 --- a/apache-solrj/src/test/java/com/baeldung/solrjava/SolrJavaLiveTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.baeldung.solrjava; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; - -import org.apache.solr.client.solrj.SolrQuery; -import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.response.QueryResponse; -import org.apache.solr.common.SolrDocument; -import org.apache.solr.common.SolrDocumentList; -import org.junit.Before; -import org.junit.Test; - -public class SolrJavaLiveTest { - - private SolrJavaIntegration solrJavaIntegration; - - @Before - public void setUp() throws Exception { - - solrJavaIntegration = new SolrJavaIntegration("http://localhost:8983/solr/bigboxstore"); - solrJavaIntegration.addSolrDocument("123456", "Kenmore Dishwasher", "599.99"); - } - - @Test - public void whenAdd_thenVerifyAddedByQueryOnId() throws SolrServerException, IOException { - - SolrQuery query = new SolrQuery(); - query.set("q", "id:123456"); - QueryResponse response = null; - - response = solrJavaIntegration.getSolrClient().query(query); - - SolrDocumentList docList = response.getResults(); - assertEquals(1, docList.getNumFound()); - - for (SolrDocument doc : docList) { - assertEquals("Kenmore Dishwasher", (String) doc.getFieldValue("name")); - assertEquals((Double) 599.99, (Double) doc.getFieldValue("price")); - } - } - - @Test - public void whenAdd_thenVerifyAddedByQueryOnPrice() throws SolrServerException, IOException { - - SolrQuery query = new SolrQuery(); - query.set("q", "price:599.99"); - QueryResponse response = null; - - response = solrJavaIntegration.getSolrClient().query(query); - - SolrDocumentList docList = response.getResults(); - assertEquals(1, docList.getNumFound()); - - for (SolrDocument doc : docList) { - assertEquals("123456", (String) doc.getFieldValue("id")); - assertEquals((Double) 599.99, (Double) doc.getFieldValue("price")); - } - } - - @Test - public void whenAdd_thenVerifyAddedByQuery() throws SolrServerException, IOException { - - SolrDocument doc = solrJavaIntegration.getSolrClient().getById("123456"); - assertEquals("Kenmore Dishwasher", (String) doc.getFieldValue("name")); - assertEquals((Double) 599.99, (Double) doc.getFieldValue("price")); - } - - @Test - public void whenAddBean_thenVerifyAddedByQuery() throws SolrServerException, IOException { - - ProductBean pBean = new ProductBean("888", "Apple iPhone 6s", "299.99"); - solrJavaIntegration.addProductBean(pBean); - - SolrDocument doc = solrJavaIntegration.getSolrClient().getById("888"); - assertEquals("Apple iPhone 6s", (String) doc.getFieldValue("name")); - assertEquals((Double) 299.99, (Double) doc.getFieldValue("price")); - } - - @Test - public void whenDeleteById_thenVerifyDeleted() throws SolrServerException, IOException { - - solrJavaIntegration.deleteSolrDocumentById("123456"); - - SolrQuery query = new SolrQuery(); - query.set("q", "id:123456"); - QueryResponse response = solrJavaIntegration.getSolrClient().query(query); - - SolrDocumentList docList = response.getResults(); - assertEquals(0, docList.getNumFound()); - } - - @Test - public void whenDeleteByQuery_thenVerifyDeleted() throws SolrServerException, IOException { - - solrJavaIntegration.deleteSolrDocumentByQuery("name:Kenmore Dishwasher"); - - SolrQuery query = new SolrQuery(); - query.set("q", "id:123456"); - QueryResponse response = null; - - response = solrJavaIntegration.getSolrClient().query(query); - - SolrDocumentList docList = response.getResults(); - assertEquals(0, docList.getNumFound()); - } -}