diff --git a/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepositoryTests.java
index e3c96f25f..3a20fe679 100644
--- a/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepositoryTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepositoryTests.java
@@ -22,15 +22,18 @@
import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
+import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
+import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
+import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Young Gu
@@ -39,14 +42,20 @@
* @author Christoph Strobl
* @author Peter-Josef Meisch
*/
-@RunWith(SpringRunner.class)
-@ContextConfiguration("classpath:immutable-repository-test.xml")
+@SpringIntegrationTest
+@ContextConfiguration(classes = { ImmutableElasticsearchRepositoryTests.Config.class })
public class ImmutableElasticsearchRepositoryTests {
+ @Configuration
+ @Import({ ElasticsearchTemplateConfiguration.class })
+ @EnableElasticsearchRepositories(basePackages = { "org.springframework.data.elasticsearch.immutable" },
+ considerNestedRepositories = true)
+ static class Config {}
+
@Autowired ImmutableElasticsearchRepository repository;
@Autowired ElasticsearchOperations operations;
- @Before
+ @BeforeEach
public void before() {
operations.deleteIndex(ImmutableEntity.class);
diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexCustomMethodRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexCustomMethodRepositoryTests.java
index a64bbb73a..3b7273a19 100644
--- a/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexCustomMethodRepositoryTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexCustomMethodRepositoryTests.java
@@ -20,33 +20,42 @@
import lombok.Data;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
+import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
+import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
+import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.elasticsearch.utils.IndexInitializer;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Artur Konczak
* @author Mohsin Husen
* @author Peter-Josef Meisch
*/
-@RunWith(SpringRunner.class)
-@ContextConfiguration("classpath:complex-custom-method-repository-test.xml")
+@SpringIntegrationTest
+@ContextConfiguration(classes = { ComplexCustomMethodRepositoryTests.Config.class })
public class ComplexCustomMethodRepositoryTests {
+ @Configuration
+ @Import({ ElasticsearchTemplateConfiguration.class })
+ @EnableElasticsearchRepositories(
+ basePackages = { "org.springframework.data.elasticsearch.repositories.complex.custommethod.autowiring" },
+ considerNestedRepositories = true)
+ static class Config {}
+
@Autowired private ComplexElasticsearchRepository complexRepository;
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
- @Before
+ @BeforeEach
public void before() {
IndexInitializer.init(elasticsearchTemplate, SampleEntity.class);
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryBaseTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryBaseTests.java
index cb8115db8..7374bfcf2 100644
--- a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryBaseTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryBaseTests.java
@@ -32,7 +32,7 @@
import java.util.UUID;
import java.util.stream.Stream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Version;
@@ -46,6 +46,7 @@
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.core.geo.GeoBox;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
+import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.data.geo.Box;
import org.springframework.data.geo.Distance;
@@ -62,6 +63,7 @@
* @author Peter-Josef Meisch
* @author Rasmus Faber-Espensen
*/
+@SpringIntegrationTest
public abstract class CustomMethodRepositoryBaseTests {
@Autowired private SampleCustomMethodRepository repository;
diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryRestTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryRestTests.java
index 27ed650d8..2089a5f6b 100644
--- a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryRestTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryRestTests.java
@@ -15,26 +15,34 @@
*/
package org.springframework.data.elasticsearch.repositories.custommethod;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
+import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
+import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.elasticsearch.utils.IndexInitializer;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Don Wellington
* @author Mark Paluch
* @author Peter-Josef Meisch
*/
-@RunWith(SpringRunner.class)
-@ContextConfiguration("classpath:custom-method-repository-rest-test.xml")
+@ContextConfiguration(classes = { CustomMethodRepositoryRestTests.Config.class })
public class CustomMethodRepositoryRestTests extends CustomMethodRepositoryBaseTests {
+ @Configuration
+ @Import({ ElasticsearchRestTemplateConfiguration.class })
+ @EnableElasticsearchRepositories(
+ basePackages = { "org.springframework.data.elasticsearch.repositories.custommethod" },
+ considerNestedRepositories = true)
+ static class Config {}
+
@Autowired private ElasticsearchRestTemplate elasticsearchTemplate;
- @Before
+ @BeforeEach
public void before() {
IndexInitializer.init(elasticsearchTemplate, SampleEntity.class);
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryTests.java
index 03700aa34..2a4eb13a4 100644
--- a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryTests.java
@@ -15,26 +15,34 @@
*/
package org.springframework.data.elasticsearch.repositories.custommethod;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
+import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
+import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.elasticsearch.utils.IndexInitializer;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Don Wellington
* @author Mark Paluch
* @author Peter-Josef Meisch
*/
-@RunWith(SpringRunner.class)
-@ContextConfiguration("classpath:custom-method-repository-test.xml")
+@ContextConfiguration(classes = { CustomMethodRepositoryTests.Config.class })
public class CustomMethodRepositoryTests extends CustomMethodRepositoryBaseTests {
+ @Configuration
+ @Import({ ElasticsearchTemplateConfiguration.class })
+ @EnableElasticsearchRepositories(
+ basePackages = { "org.springframework.data.elasticsearch.repositories.custommethod" },
+ considerNestedRepositories = true)
+ static class Config {}
+
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
- @Before
+ @BeforeEach
public void before() {
IndexInitializer.init(elasticsearchTemplate, SampleEntity.class);
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/geo/SpringDataGeoRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/geo/SpringDataGeoRepositoryTests.java
index 5a9d2efca..2ee6fe916 100644
--- a/src/test/java/org/springframework/data/elasticsearch/repositories/geo/SpringDataGeoRepositoryTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/repositories/geo/SpringDataGeoRepositoryTests.java
@@ -26,38 +26,47 @@
import java.util.Locale;
import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.GeoPointField;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
+import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
+import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
+import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.data.elasticsearch.utils.IndexInitializer;
import org.springframework.data.geo.Box;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Point;
import org.springframework.data.geo.Polygon;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Mark Paluch
* @author Christoph Strobl
* @author Peter-Josef Meisch
*/
-@RunWith(SpringRunner.class)
-@ContextConfiguration("classpath:/repository-spring-data-geo-support.xml")
+@SpringIntegrationTest
+@ContextConfiguration(classes = { SpringDataGeoRepositoryTests.Config.class })
public class SpringDataGeoRepositoryTests {
+ @Configuration
+ @Import({ ElasticsearchTemplateConfiguration.class })
+ @EnableElasticsearchRepositories(basePackages = { "org.springframework.data.elasticsearch.repositories.geo" },
+ considerNestedRepositories = true)
+ static class Config {}
+
@Autowired ElasticsearchTemplate template;
@Autowired SpringDataGeoRepository repository;
- @Before
+ @BeforeEach
public void init() {
IndexInitializer.init(template, GeoEntity.class);
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsRepositoryTests.java
index 7c8bbe3e2..034f9955c 100644
--- a/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsRepositoryTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsRepositoryTests.java
@@ -15,11 +15,9 @@
*/
package org.springframework.data.elasticsearch.repository.query.keywords;
-import org.junit.ClassRule;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.data.elasticsearch.ElasticsearchTestConfiguration;
-import org.springframework.data.elasticsearch.junit.junit4.TestNodeResource;
+import org.springframework.context.annotation.Import;
+import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.test.context.ContextConfiguration;
@@ -28,16 +26,13 @@
*
* @author Peter-Josef Meisch
*/
-@ContextConfiguration(classes = { QueryKeywordsRepositoryTests.class, ElasticsearchTestConfiguration.class })
-@Configuration
-@EnableElasticsearchRepositories(considerNestedRepositories = true)
+@ContextConfiguration(classes = { QueryKeywordsRepositoryTests.Config.class})
public class QueryKeywordsRepositoryTests extends QueryKeywordsTests {
- @ClassRule public static TestNodeResource testNodeResource = new TestNodeResource();
-
- // needed by the ElasticsearchTestConfiguration.
- @Bean
- public TestNodeResource nodeResource() {
- return testNodeResource;
- }
+ @Configuration
+ @Import({ ElasticsearchTemplateConfiguration.class })
+ @EnableElasticsearchRepositories(
+ basePackages = { "org.springframework.data.elasticsearch.repository.query.keywords" },
+ considerNestedRepositories = true)
+ static class Config {}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsRestRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsRestRepositoryTests.java
index 382840378..5f73e9e3e 100644
--- a/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsRestRepositoryTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsRestRepositoryTests.java
@@ -15,10 +15,9 @@
*/
package org.springframework.data.elasticsearch.repository.query.keywords;
-import org.junit.ClassRule;
import org.springframework.context.annotation.Configuration;
-import org.springframework.data.elasticsearch.RestElasticsearchTestConfiguration;
-import org.springframework.data.elasticsearch.junit.junit4.TestNodeResource;
+import org.springframework.context.annotation.Import;
+import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.test.context.ContextConfiguration;
@@ -27,10 +26,13 @@
*
* @author Peter-Josef Meisch
*/
-@ContextConfiguration(classes = { QueryKeywordsRestRepositoryTests.class, RestElasticsearchTestConfiguration.class })
-@Configuration
-@EnableElasticsearchRepositories(considerNestedRepositories = true)
+@ContextConfiguration(classes = { QueryKeywordsRestRepositoryTests.Config.class })
public class QueryKeywordsRestRepositoryTests extends QueryKeywordsTests {
- @ClassRule public static TestNodeResource testNodeResource = new TestNodeResource();
+ @Configuration
+ @Import({ ElasticsearchRestTemplateConfiguration.class })
+ @EnableElasticsearchRepositories(
+ basePackages = { "org.springframework.data.elasticsearch.repository.query.keywords" },
+ considerNestedRepositories = true)
+ static class Config {}
}
diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsTests.java
index a1a4df6b9..a70d839c5 100644
--- a/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsTests.java
+++ b/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsTests.java
@@ -28,18 +28,17 @@
import java.util.List;
import java.util.stream.Collectors;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
+import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.data.elasticsearch.utils.IndexInitializer;
-import org.springframework.test.context.junit4.SpringRunner;
/**
* base class for query keyword tests. Implemented by subclasses using ElasticsearchClient and ElasticsearchRestClient
@@ -49,14 +48,14 @@
* @author Christoph Strobl
* @author Peter-Josef Meisch
*/
-@RunWith(SpringRunner.class)
+@SpringIntegrationTest
abstract class QueryKeywordsTests {
@Autowired private ProductRepository repository;
@Autowired private ElasticsearchOperations elasticsearchTemplate;
- @Before
+ @BeforeEach
public void before() {
IndexInitializer.init(elasticsearchTemplate, Product.class);
diff --git a/src/test/resources/complex-custom-method-repository-test.xml b/src/test/resources/complex-custom-method-repository-test.xml
deleted file mode 100644
index 14d470471..000000000
--- a/src/test/resources/complex-custom-method-repository-test.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/test/resources/custom-method-repository-rest-test.xml b/src/test/resources/custom-method-repository-rest-test.xml
deleted file mode 100644
index 76544a06f..000000000
--- a/src/test/resources/custom-method-repository-rest-test.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/test/resources/custom-method-repository-test.xml b/src/test/resources/custom-method-repository-test.xml
deleted file mode 100644
index a1384b753..000000000
--- a/src/test/resources/custom-method-repository-test.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/test/resources/immutable-repository-test.xml b/src/test/resources/immutable-repository-test.xml
deleted file mode 100644
index 897adf938..000000000
--- a/src/test/resources/immutable-repository-test.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/test/resources/repository-spring-data-geo-support.xml b/src/test/resources/repository-spring-data-geo-support.xml
deleted file mode 100644
index 5dafbab32..000000000
--- a/src/test/resources/repository-spring-data-geo-support.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-