Polish Spring Data Solr integration
This commit is contained in:
@@ -38,7 +38,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Tests for {@link JpaRepositoriesAutoConfiguration}.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -83,9 +83,9 @@ public class JpaRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableJpaRepositories(basePackageClasses = org.springframework.boot.autoconfigure.data.alt.CityJpaRepository.class, excludeFilters = {
|
||||
@Filter(type = FilterType.ASSIGNABLE_TYPE, value = CityMongoDbRepository.class),
|
||||
@Filter(type = FilterType.ASSIGNABLE_TYPE, value = CitySolrRepository.class) })
|
||||
@TestAutoConfigurationPackage(City.class)
|
||||
@Filter(type = FilterType.ASSIGNABLE_TYPE, value = CityMongoDbRepository.class),
|
||||
@Filter(type = FilterType.ASSIGNABLE_TYPE, value = CitySolrRepository.class) })
|
||||
@TestAutoConfigurationPackage(City.class)
|
||||
protected static class CustomConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2012-2014 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,10 +15,6 @@
|
||||
*/
|
||||
package org.springframework.boot.autoconfigure.data;
|
||||
|
||||
import static org.hamcrest.core.IsInstanceOf.*;
|
||||
import static org.hamcrest.core.IsNull.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrServer;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
||||
import org.junit.Test;
|
||||
@@ -32,7 +28,13 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
|
||||
|
||||
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
||||
import static org.hamcrest.core.IsNull.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SolrRepositoriesAutoConfiguration}
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class SolrRepositoriesAutoConfigurationTests {
|
||||
@@ -41,23 +43,22 @@ public class SolrRepositoriesAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultRepositoryConfiguration() {
|
||||
|
||||
initContext(TestConfiguration.class);
|
||||
|
||||
assertThat(this.context.getBean(CityRepository.class), notNullValue());
|
||||
assertThat(this.context.getBean(SolrServer.class), instanceOf(HttpSolrServer.class));
|
||||
assertThat(this.context.getBean(SolrServer.class),
|
||||
instanceOf(HttpSolrServer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoRepositoryConfiguration() {
|
||||
|
||||
initContext(EmptyConfiguration.class);
|
||||
assertThat(this.context.getBean(SolrServer.class), instanceOf(HttpSolrServer.class));
|
||||
assertThat(this.context.getBean(SolrServer.class),
|
||||
instanceOf(HttpSolrServer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
|
||||
|
||||
initContext(CustomizedConfiguration.class);
|
||||
assertThat(this.context.getBean(CitySolrRepository.class), notNullValue());
|
||||
}
|
||||
@@ -65,7 +66,8 @@ public class SolrRepositoriesAutoConfigurationTests {
|
||||
private void initContext(Class<?> configClass) {
|
||||
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(configClass, SolrAutoConfiguration.class, SolrRepositoriesAutoConfiguration.class,
|
||||
this.context.register(configClass, SolrAutoConfiguration.class,
|
||||
SolrRepositoriesAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.data.solr;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
@@ -29,7 +30,7 @@ public class City {
|
||||
private @Indexed String name;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
@@ -37,7 +38,7 @@ public class City {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2012-2014 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.data.solr;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
Reference in New Issue
Block a user