Refactor testcontainers service connections
Update restcontainers service connections support so that technology specific `@ServiceConnector` annotations are not longer required. A single `@ServiceConnector` annotation can now be used to create all `ConnectionDetail` beans. Closes gh-35017
This commit is contained in:
@@ -22,14 +22,14 @@ import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.testcontainers.service.connection.neo4j.Neo4jServiceConnection;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
|
||||
@SpringBootTest
|
||||
@Testcontainers
|
||||
class MyIntegrationTests {
|
||||
|
||||
@Container
|
||||
@Neo4jServiceConnection
|
||||
@ServiceConnection
|
||||
static Neo4jContainer<?> neo4j = new Neo4jContainer<>("neo4j:5");
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
package org.springframework.boot.docs.howto.testing.testcontainers.serviceconnection
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.boot.testcontainers.service.connection.neo4j.Neo4jServiceConnection;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry
|
||||
import org.springframework.test.context.DynamicPropertySource
|
||||
import org.testcontainers.containers.Neo4jContainer
|
||||
import org.testcontainers.junit.jupiter.Container
|
||||
import org.testcontainers.junit.jupiter.Testcontainers
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
|
||||
@SpringBootTest
|
||||
@Testcontainers
|
||||
internal class MyIntegrationTests {
|
||||
@@ -37,7 +36,7 @@ internal class MyIntegrationTests {
|
||||
companion object {
|
||||
|
||||
@Container
|
||||
@Neo4jServiceConnection
|
||||
@ServiceConnection
|
||||
var neo4j: Neo4jContainer<*> = Neo4jContainer<Nothing>("neo4j:5")
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user