From 6ccc59004b148565e2bf385b951f75c9656af0ab Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 12 Feb 2016 12:15:20 +0100 Subject: [PATCH] #151 - Updated Solr examples to use Solr 5. --- pom.xml | 1 + .../springdata/solr/SolrTestConfiguration.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index b5efee00..bafae607 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,7 @@ 1.1.3 1.8 4.0.8 + 5.4.1 Hopper-BUILD-SNAPSHOT diff --git a/solr/example/src/test/java/example/springdata/solr/SolrTestConfiguration.java b/solr/example/src/test/java/example/springdata/solr/SolrTestConfiguration.java index 2707c2c5..29fe78a5 100644 --- a/solr/example/src/test/java/example/springdata/solr/SolrTestConfiguration.java +++ b/solr/example/src/test/java/example/springdata/solr/SolrTestConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2016 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. @@ -17,10 +17,12 @@ 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.HttpSolrServer; +import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; @@ -30,6 +32,7 @@ import org.springframework.data.solr.core.SolrTemplate; /** * @author Christoph Strobl + * @author Oliver Gierke */ @Configuration @EnableAutoConfiguration @@ -39,7 +42,7 @@ public class SolrTestConfiguration { @Bean public SolrTemplate solrTemplate() { - return new SolrTemplate(new HttpSolrServer("http://localhost:8983/solr"), "collection1"); + return new SolrTemplate(new HttpSolrClient("http://localhost:8983/solr"), "collection1"); } /** @@ -60,8 +63,7 @@ public class SolrTestConfiguration { protected void doInitTestData(CrudRepository repository) { - for (int i = 0; i < 100; i++) { - repository.save(Product.builder().id("p-" + i).name("foobar").build()); - } + IntStream.range(0, 100) + .forEach(index -> repository.save(Product.builder().id("p-" + index).name("foobar").build())); } }