#514 - Fix test setup of Spring Data for Apache Solr examples.
Guard test execution of Spring Data for Apache Solr examples with collection requirement. We now make sure to register required Beans just once and check if a specific collection is available via Apache Solr. Move off deprecated API in Solr example.
This commit is contained in:
committed by
Oliver Drotbohm
parent
557851105c
commit
b6c86c67c8
@@ -28,6 +28,8 @@ 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;
|
||||
@@ -50,15 +52,15 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@SpringBootTest(classes = SolrTestConfiguration.class)
|
||||
public class AdvancedSolrRepositoryTests {
|
||||
|
||||
public static @ClassRule RequiresSolrServer requiresRunningServer = RequiresSolrServer.onLocalhost();
|
||||
public static @ClassRule RequiresSolrServer requiresRunningServer = RequiresSolrServer.onLocalhost().withCollection("techproducts");
|
||||
|
||||
@Configuration
|
||||
static class Config extends SolrTestConfiguration {
|
||||
static class Config {
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
protected void doInitTestData(CrudRepository<Product, String> repository) {
|
||||
|
||||
Product playstation = Product.builder().id("id-1").name("Playstation")
|
||||
@@ -82,7 +84,7 @@ public class AdvancedSolrRepositoryTests {
|
||||
@Test
|
||||
public void annotationBasedHighlighting() {
|
||||
|
||||
HighlightPage<Product> products = repository.findByDescriptionStartingWith("play", new PageRequest(0, 10));
|
||||
HighlightPage<Product> 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())));
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@SpringBootTest(classes = SolrTestConfiguration.class)
|
||||
public class BasicSolrRepositoryTests {
|
||||
|
||||
public static @ClassRule RequiresSolrServer requiresRunningServer = RequiresSolrServer.onLocalhost();
|
||||
public static @ClassRule RequiresSolrServer requiresRunningServer = RequiresSolrServer.onLocalhost().withCollection("techproducts");
|
||||
|
||||
@Autowired ProductRepository repository;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user