#190 - More simplifications for Spring Boot 1.4 M3.
Replaced all occurrences of @SpringApplicationConfiguration with @SpringBootTest. Using SpringRunner instead of @SpringJUnit4ClassRunner now.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 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.
|
||||
@@ -15,22 +15,22 @@
|
||||
*/
|
||||
package example.springdata.solr;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
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(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { SolrTestConfiguration.class })
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SolrRepositoryTests {
|
||||
|
||||
public static @ClassRule RequiresSolrServer requiresRunningServer = RequiresSolrServer.onLocalhost();
|
||||
@@ -40,8 +40,8 @@ public class SolrRepositoryTests {
|
||||
/**
|
||||
* Adds missing fields to the schema. <br />
|
||||
* By default the fields {@literal id} and {@literal _version_} are present. <br />
|
||||
* Check fields using <a
|
||||
* href="http://localhost:8983/solr/collection1/schema/fields">../solr/collection1/schema/fields</a> <br />
|
||||
* Check fields using
|
||||
* <a href="http://localhost:8983/solr/collection1/schema/fields">../solr/collection1/schema/fields</a> <br />
|
||||
* <br />
|
||||
* <strong>NOTE</strong>: requires Solr to run in managed schema mode.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 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.
|
||||
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
import example.springdata.solr.product.ProductRepository;
|
||||
|
||||
/**
|
||||
* {@link Configuration} class enabling schema support for solr.<br />
|
||||
* <br />
|
||||
@@ -34,22 +35,20 @@ import example.springdata.solr.product.ProductRepository;
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@Configuration
|
||||
@SpringBootApplication
|
||||
@EnableSolrRepositories(schemaCreationSupport = true, multicoreSupport = true)
|
||||
public class SolrTestConfiguration {
|
||||
|
||||
@Autowired ProductRepository repo;
|
||||
|
||||
@Bean
|
||||
public SolrClient solrServer() {
|
||||
public @Bean SolrClient solrServer() {
|
||||
return new HttpSolrClient("http://localhost:8983/solr");
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove test data when context is shut down.
|
||||
*/
|
||||
@PreDestroy
|
||||
public void deleteDocumentsOnShutdown() {
|
||||
public @PreDestroy void deleteDocumentsOnShutdown() {
|
||||
repo.deleteAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
logging.level.root=WARN
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d %5p %40.40c:%4L - %m%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="org.springframework.data.solr" level="debug" />
|
||||
|
||||
<root level="warn">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user