diff --git a/pom.xml b/pom.xml index 7eabecaa..54c97b37 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,6 @@ neo4j rest redis - solr web diff --git a/solr/example/Readme.md b/solr/example/Readme.md deleted file mode 100644 index 0701b69a..00000000 --- a/solr/example/Readme.md +++ /dev/null @@ -1,10 +0,0 @@ -# Spring Data Solr - Examples - -In order to run this example a 6.5+ [Solr Server](http://lucene.apache.org/solr/downloads.html) and [Maven](http://maven.apache.org/download.cgi) are required. - -### Running Solr -```emacs -:solr> ./bin/solr start -e techproducts -``` - -Access via [localhost:8983/solr/](http://localhost:8983/solr/#/techproducts) diff --git a/solr/example/pom.xml b/solr/example/pom.xml deleted file mode 100644 index 27b2399c..00000000 --- a/solr/example/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - - - org.springframework.data.examples - spring-data-solr-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-solr-example - Spring Data Solr - Example - - - - ${project.groupId} - spring-data-solr-example-utils - ${project.version} - test - - - - diff --git a/solr/example/src/main/java/example/springdata/solr/product/Product.java b/solr/example/src/main/java/example/springdata/solr/product/Product.java deleted file mode 100644 index 331852c5..00000000 --- a/solr/example/src/main/java/example/springdata/solr/product/Product.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr.product; - -import java.util.List; - -import lombok.Builder; -import lombok.Value; - -import org.springframework.data.annotation.Id; -import org.springframework.data.geo.Point; -import org.springframework.data.solr.core.mapping.Indexed; -import org.springframework.data.solr.core.mapping.SolrDocument; -import org.springframework.data.solr.repository.Score; - -/** - * Document representing a {@link Product} and its attributes matching the fields defined in the example solr schema. - * - * @author Christoph Strobl - * @author Oliver Gierke - */ -@Value -@Builder -@SolrDocument(collection = "techproducts") -public class Product { - - private @Id String id; - private @Indexed String name; - private @Indexed(name = "cat") List category; - private @Indexed(name = "store") Point location; - private @Indexed String description; - private @Indexed boolean inStock; - private @Indexed Integer popularity; - private @Score Float score; -} diff --git a/solr/example/src/main/java/example/springdata/solr/product/ProductRepository.java b/solr/example/src/main/java/example/springdata/solr/product/ProductRepository.java deleted file mode 100644 index 1bf73b50..00000000 --- a/solr/example/src/main/java/example/springdata/solr/product/ProductRepository.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr.product; - -import java.util.List; - -import org.springframework.data.domain.Pageable; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.solr.core.query.result.HighlightPage; -import org.springframework.data.solr.repository.Boost; -import org.springframework.data.solr.repository.Highlight; -import org.springframework.data.solr.repository.Query; - -/** - * Repository definition for {@link Product}. - * - * @author Christoph Strobl - */ -public interface ProductRepository extends ProductRepositoryCustom, CrudRepository { - - /** - * Find documents with matching description, highlighting context within a 20 char range around the hit. - * - * @param description - * @param page - * @return - */ - @Highlight(fragsize = 20, snipplets = 3) - HighlightPage findByDescriptionStartingWith(String description, Pageable page); - - /** - * Find the first 10 documents with a match in name or description. Boosting score for search hits in name by 2 sorts - * documents by relevance. - * - * @param name - * @param description - * @return - */ - @Query - List findTop10ByNameOrDescription(@Boost(2) String name, String description); -} diff --git a/solr/example/src/main/java/example/springdata/solr/product/ProductRepositoryCustom.java b/solr/example/src/main/java/example/springdata/solr/product/ProductRepositoryCustom.java deleted file mode 100644 index d2a980bc..00000000 --- a/solr/example/src/main/java/example/springdata/solr/product/ProductRepositoryCustom.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr.product; - -import org.springframework.data.repository.Repository; -import org.springframework.data.solr.core.query.result.Cursor; - -/** - * Custom repository implementation to show special solr functions without {@link Repository} abstraction. - * - * @author Christoph Strobl - */ -interface ProductRepositoryCustom { - - /** - * Use a {@link Cursor} to scroll through documents in index.
- * NOTE: Requires at least Solr 4.7. - * - * @return - */ - Cursor findAllUsingCursor(); -} diff --git a/solr/example/src/main/java/example/springdata/solr/product/ProductRepositoryImpl.java b/solr/example/src/main/java/example/springdata/solr/product/ProductRepositoryImpl.java deleted file mode 100644 index bc0aebe7..00000000 --- a/solr/example/src/main/java/example/springdata/solr/product/ProductRepositoryImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr.product; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Sort; -import org.springframework.data.solr.core.SolrTemplate; -import org.springframework.data.solr.core.query.SimpleQuery; -import org.springframework.data.solr.core.query.result.Cursor; - -/** - * Implementation of {@link ProductRepositoryCustom}. - * - * @author Christoph Strobl - * @author Oliver Gierke - */ -class ProductRepositoryImpl implements ProductRepositoryCustom { - - @Autowired SolrTemplate solrTemplate; - - /* - * (non-Javadoc) - * @see example.springdata.solr.ProductRepositoryCustom#findAllUsingCursor() - */ - @Override - public Cursor findAllUsingCursor() { - - // NOTE: Using Cursor requires to sort by an unique field - return solrTemplate.queryForCursor("techproducts", new SimpleQuery("*:*").addSort(Sort.by("id")), Product.class); - } -} diff --git a/solr/example/src/test/java/example/springdata/solr/AdvancedSolrRepositoryTests.java b/solr/example/src/test/java/example/springdata/solr/AdvancedSolrRepositoryTests.java deleted file mode 100644 index 4860623a..00000000 --- a/solr/example/src/test/java/example/springdata/solr/AdvancedSolrRepositoryTests.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; -import static org.springframework.data.solr.core.query.Criteria.*; -import static org.springframework.data.solr.core.query.ExistsFunction.*; - -import example.springdata.solr.product.Product; -import example.springdata.solr.product.ProductRepository; -import example.springdata.solr.test.util.RequiresSolrServer; - -import java.time.Duration; -import java.util.Arrays; -import java.util.Optional; - -import javax.annotation.PostConstruct; - -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.solr.core.SolrOperations; -import org.springframework.data.solr.core.query.Function; -import org.springframework.data.solr.core.query.Query; -import org.springframework.data.solr.core.query.SimpleQuery; -import org.springframework.data.solr.core.query.result.HighlightPage; -import org.springframework.data.solr.repository.Boost; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Christoph Strobl - * @author Oliver Gierke - * @author Mark Paluch - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = SolrTestConfiguration.class) -public class AdvancedSolrRepositoryTests { - - public static @ClassRule RequiresSolrServer requiresRunningServer = RequiresSolrServer.onLocalhost().withCollection("techproducts"); - - @Configuration - static class Config { - - @PostConstruct - protected void doInitTestData(CrudRepository repository) { - - Product playstation = Product.builder().id("id-1").name("Playstation") - .description("The Sony playstation was the top selling gaming system in 1994.").popularity(5).build(); - Product playstation2 = Product.builder().id("id-2").name("Playstation Two") - .description("Playstation two is the successor of playstation in 2000.").build(); - Product superNES = Product.builder().id("id-3").name("Super Nintendo").popularity(3).build(); - Product nintendo64 = Product.builder().id("id-4").name("N64").description("Nintendo 64").popularity(2).build(); - - repository.saveAll(Arrays.asList(playstation, playstation2, superNES, nintendo64)); - } - } - - @Autowired ProductRepository repository; - @Autowired SolrOperations operations; - - /** - * {@link HighlightPage} holds next to the entities found also information about where a match was found within the - * document. This allows to fine grained display snipplets of data containing the matching term in context. - */ - @Test - public void annotationBasedHighlighting() { - - HighlightPage products = repository.findByDescriptionStartingWith("play", PageRequest.of(0, 10)); - - products.getHighlighted().forEach(entry -> entry.getHighlights().forEach(highligh -> System.out - .println(entry.getEntity().getId() + " | " + highligh.getField() + ":\t" + highligh.getSnipplets()))); - } - - /** - * Using {@link Boost} allows to influence scoring at query time. In this case we want hits in {@code Product#name} to - * count twice as much as such in {@code Product#description}. - */ - @Test - public void annotationBasedBoosting() { - repository.findTop10ByNameOrDescription("Nintendo", "Nintendo").forEach(System.out::println); - } - - /** - * Using {@link Function} in queries has no influence on restricting results as all documents will match the function. - * Though it does influence document score. In this sample documents not having popularity assigned will be sorted to - * the end of the list. - */ - @Test - public void influcenceScoreWithFunctions() { - - Query query = new SimpleQuery(where(exists("popularity"))).addProjectionOnFields("*", "score"); - - operations.queryForPage("techproducts", query, Product.class).forEach(System.out::println); - } - - /** - * Using {@link SolrOperations#getById(java.io.Serializable, Class)} allows reading uncommitted documents from the - * update log. - */ - @Test - public void useRealtimeGetToReadUncommitedDocuments() throws InterruptedException { - - Product xbox = Product.builder().id("id-5").name("XBox").description("Microsift XBox").popularity(2).build(); - Query query = new SimpleQuery(where("id").is(xbox.getId())); - - // add document but delay commit for 3 seconds - operations.saveBean("techproducts", xbox, Duration.ofSeconds(3)); - - // document will not be returned hence not yet committed to the index - assertThat(operations.queryForObject("techproducts", query, Product.class), is(Optional.empty())); - - // realtime-get fetches uncommitted document - assertThat(operations.getById("techproducts", xbox.getId(), Product.class), notNullValue()); - - // wait a little so that changes get committed to the index - normal query will now be able to find the document. - Thread.sleep(3010); - assertThat(operations.queryForObject("techproducts", query, Product.class).isPresent(), is(true)); - } -} diff --git a/solr/example/src/test/java/example/springdata/solr/BasicSolrRepositoryTests.java b/solr/example/src/test/java/example/springdata/solr/BasicSolrRepositoryTests.java deleted file mode 100644 index e1d50927..00000000 --- a/solr/example/src/test/java/example/springdata/solr/BasicSolrRepositoryTests.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr; - -import example.springdata.solr.product.ProductRepository; -import example.springdata.solr.test.util.RequiresSolrServer; - -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Christoph Strobl - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = SolrTestConfiguration.class) -public class BasicSolrRepositoryTests { - - public static @ClassRule RequiresSolrServer requiresRunningServer = RequiresSolrServer.onLocalhost().withCollection("techproducts"); - - @Autowired ProductRepository repository; - - /** - * Finds all entries using a single request. - */ - @Test - public void findAll() { - repository.findAll().forEach(System.out::println); - } - - /** - * Pages through all entries using cursor marks. Have a look at the Solr console output to see iteration steps. - */ - @Test - public void findAllUsingDeepPagination() { - repository.findAllUsingCursor().forEachRemaining(System.out::println); - } -} diff --git a/solr/example/src/test/java/example/springdata/solr/SolrTestConfiguration.java b/solr/example/src/test/java/example/springdata/solr/SolrTestConfiguration.java deleted file mode 100644 index 646d244d..00000000 --- a/solr/example/src/test/java/example/springdata/solr/SolrTestConfiguration.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr; - -import example.springdata.solr.product.Product; - -import java.util.stream.IntStream; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; - -import org.apache.solr.client.solrj.impl.HttpSolrClient; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.solr.core.SolrTemplate; - -/** - * @author Christoph Strobl - * @author Oliver Gierke - */ -@SpringBootApplication -public class SolrTestConfiguration { - - @Autowired CrudRepository repo; - - public @Bean SolrTemplate solrTemplate() { - return new SolrTemplate(new HttpSolrClient.Builder().withBaseSolrUrl("http://localhost:8983/solr").build()); - } - - /** - * Remove test data when context is shut down. - */ - public @PreDestroy void deleteDocumentsOnShutdown() { - repo.deleteAll(); - } - - /** - * Initialize Solr instance with test data once context has started. - */ - public @PostConstruct void initWithTestData() { - doInitTestData(repo); - } - - protected void doInitTestData(CrudRepository repository) { - - IntStream.range(0, 100) - .forEach(index -> repository.save(Product.builder().id("p-" + index).name("foobar").build())); - } -} diff --git a/solr/example/src/test/resources/application.properties b/solr/example/src/test/resources/application.properties deleted file mode 100644 index bac6605c..00000000 --- a/solr/example/src/test/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -logging.level.root=WARN diff --git a/solr/managed-schema/Readme.md b/solr/managed-schema/Readme.md deleted file mode 100644 index 3f3ca624..00000000 --- a/solr/managed-schema/Readme.md +++ /dev/null @@ -1,11 +0,0 @@ -# Spring Data Solr - Managed Schema Examples - -In order to run this example a 6.5+ [Solr Server](http://lucene.apache.org/solr/downloads.html) and [Maven](http://maven.apache.org/download.cgi) are required. - -### Running Solr -```emacs -:solr> ./bin/solr start -e schemaless -``` - -Access via [localhost:8983/solr/](http://localhost:8983/solr/#/gettingstarted). -Fields available at [../schema/fields](http://localhost:8983/solr/gettingstarted/schema/fields) \ No newline at end of file diff --git a/solr/managed-schema/pom.xml b/solr/managed-schema/pom.xml deleted file mode 100644 index e0ecfee8..00000000 --- a/solr/managed-schema/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - - - org.springframework.data.examples - spring-data-solr-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-solr-managed-schema-example - Spring Data Solr - Managed schema examples - - - - ${project.groupId} - spring-data-solr-example-utils - ${project.version} - test - - - - diff --git a/solr/managed-schema/src/main/java/example/springdata/solr/product/ManagedProduct.java b/solr/managed-schema/src/main/java/example/springdata/solr/product/ManagedProduct.java deleted file mode 100644 index f762b7b5..00000000 --- a/solr/managed-schema/src/main/java/example/springdata/solr/product/ManagedProduct.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr.product; - -import lombok.Data; - -import java.util.List; - -import org.springframework.data.annotation.Id; -import org.springframework.data.solr.core.mapping.Indexed; -import org.springframework.data.solr.core.mapping.SolrDocument; - -/** - * Document representing a Product and its attributes that are propagated to the solr schema on first save of entity. - * - * @author Christoph Strobl - */ -@SolrDocument(solrCoreName = "gettingstarted") -@Data -public class ManagedProduct { - - private @Id String id; - private @Indexed(type = "text_general") String name; - private @Indexed(name = "cat", type = "string") List category; - private @Indexed boolean inStock; - - @Override - public String toString() { - return "Product [id=" + id + ", name=" + name + ", category=" + category + ", inStock=" + inStock + "]"; - } -} diff --git a/solr/managed-schema/src/main/java/example/springdata/solr/product/ProductRepository.java b/solr/managed-schema/src/main/java/example/springdata/solr/product/ProductRepository.java deleted file mode 100644 index e1c70f96..00000000 --- a/solr/managed-schema/src/main/java/example/springdata/solr/product/ProductRepository.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr.product; - -import org.springframework.data.repository.CrudRepository; - -/** - * Repository definition for {@link ManagedProduct}. - * - * @author Christoph Strobl - */ -public interface ProductRepository extends CrudRepository { - -} diff --git a/solr/managed-schema/src/test/java/example/springdata/solr/SolrRepositoryTests.java b/solr/managed-schema/src/test/java/example/springdata/solr/SolrRepositoryTests.java deleted file mode 100644 index d5bc5ff3..00000000 --- a/solr/managed-schema/src/test/java/example/springdata/solr/SolrRepositoryTests.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr; - -import example.springdata.solr.product.ManagedProduct; -import example.springdata.solr.product.ProductRepository; -import example.springdata.solr.test.util.RequiresSolrServer; - -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Christoph Strobl - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class SolrRepositoryTests { - - public static @ClassRule RequiresSolrServer requiresRunningServer = RequiresSolrServer.onLocalhost().withCollection("gettingstarted"); - - @Autowired ProductRepository repo; - - /** - * Adds missing fields to the schema.
- * By default the fields {@literal id} and {@literal _version_} are present.
- * Check fields using - * ../solr/gettingstarted/schema/fields
- *
- * NOTE: requires Solr to run in managed schema mode. - */ - @Test - public void triggerSchemaUpdateOnFirstSave() { - - ManagedProduct p = new ManagedProduct(); - p.setId("p-1"); - repo.save(p); - - Iterable all = repo.findAll(); - for (ManagedProduct product : all) { - System.out.println(product); - } - } -} diff --git a/solr/managed-schema/src/test/java/example/springdata/solr/SolrTestConfiguration.java b/solr/managed-schema/src/test/java/example/springdata/solr/SolrTestConfiguration.java deleted file mode 100644 index 0e9d8cb4..00000000 --- a/solr/managed-schema/src/test/java/example/springdata/solr/SolrTestConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr; - -import example.springdata.solr.product.ProductRepository; - -import javax.annotation.PreDestroy; - -import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.impl.HttpSolrClient; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.solr.repository.config.EnableSolrRepositories; - -/** - * {@link Configuration} class enabling schema support for Apache Solr.
- *
- * NOTE: Requires solr to run in managed schema mode. Run Solr with - * {@code ./bin/solr start -e schemaless}. - * - * @author Christoph Strobl - */ -@SpringBootApplication -@EnableSolrRepositories(schemaCreationSupport = true) -public class SolrTestConfiguration { - - @Autowired ProductRepository repo; - - public @Bean SolrClient solrClient() { - return new HttpSolrClient.Builder().withBaseSolrUrl("http://localhost:8983/solr").build(); - } - - /** - * Remove test data when context is shut down. - */ - public @PreDestroy void deleteDocumentsOnShutdown() { - repo.deleteAll(); - } -} diff --git a/solr/managed-schema/src/test/resources/application.properties b/solr/managed-schema/src/test/resources/application.properties deleted file mode 100644 index bac6605c..00000000 --- a/solr/managed-schema/src/test/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -logging.level.root=WARN diff --git a/solr/pom.xml b/solr/pom.xml deleted file mode 100644 index ea9d12be..00000000 --- a/solr/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - 4.0.0 - - spring-data-solr-examples - pom - - - org.springframework.data.examples - spring-data-examples - 2.0.0.BUILD-SNAPSHOT - - - Spring Data Solr - Examples - Sample projects for Spring Data Solr - https://projects.spring.io/spring-data-solr - - - util - example - managed-schema - - - - - - org.springframework.boot - spring-boot-starter-data-solr - - - - diff --git a/solr/util/pom.xml b/solr/util/pom.xml deleted file mode 100644 index 75cc65f4..00000000 --- a/solr/util/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - 4.0.0 - - - org.springframework.data.examples - spring-data-solr-examples - 2.0.0.BUILD-SNAPSHOT - - - spring-data-solr-example-utils - Spring Data Solr - Example utilities - - - - junit - junit - - - diff --git a/solr/util/src/main/java/example/springdata/solr/test/util/RequiresSolrServer.java b/solr/util/src/main/java/example/springdata/solr/test/util/RequiresSolrServer.java deleted file mode 100644 index 43812dc9..00000000 --- a/solr/util/src/main/java/example/springdata/solr/test/util/RequiresSolrServer.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2014-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package example.springdata.solr.test.util; - -import java.io.IOException; - -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.hamcrest.core.Is; -import org.junit.Assume; -import org.junit.AssumptionViolatedException; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; -import org.springframework.lang.Nullable; -import org.springframework.util.StringUtils; - -/** - * {@link TestRule} implementation using {@link CloseableHttpClient} to check if Solr is running by sending - * {@literal GET} request to {@literal /admin/info/system}. - * - * @author Christoph Strobl - */ -public class RequiresSolrServer implements TestRule { - - private static final String PING_PATH = "/admin/info/system"; - - private final String baseUrl; - private final @Nullable String collection; - - private RequiresSolrServer(String baseUrl) { - this(baseUrl, null); - } - - private RequiresSolrServer(String baseUrl, @Nullable String collection) { - - this.baseUrl = baseUrl; - this.collection = collection; - } - - public static RequiresSolrServer onLocalhost() { - return new RequiresSolrServer("http://localhost:8983/solr"); - } - - public RequiresSolrServer withCollection(String collection) { - return new RequiresSolrServer(baseUrl, collection); - } - - @Override - public Statement apply(Statement base, Description description) { - return new Statement() { - - @Override - public void evaluate() throws Throwable { - - checkServerRunning(); - base.evaluate(); - } - }; - } - - private void checkServerRunning() { - - try (CloseableHttpClient client = HttpClientBuilder.create().build()) { - - String url = StringUtils.hasText(collection) ? baseUrl + "/" + collection + "/select?q=*:*" : baseUrl + PING_PATH; - - CloseableHttpResponse response = client.execute(new HttpGet(url)); - if (response != null && response.getStatusLine() != null) { - Assume.assumeThat(response.getStatusLine().getStatusCode(), Is.is(200)); - } - } catch (IOException e) { - throw new AssumptionViolatedException("SolrServer does not seem to be running", e); - } - } - -}