JAVA-31141:- Fix spring-cloud-eureka-feign-client-integration-test - ServiceDiscoveryBooksClientLiveTest (#16407)

This commit is contained in:
Amit Pandey 2024-04-17 14:45:48 +05:30 committed by GitHub
parent 1f2c8a5c3d
commit f36ab6c06b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 2 deletions

View File

@ -79,7 +79,7 @@
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId> <artifactId>testcontainers</artifactId>
<version>1.14.3</version> <version>${testcontainers.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -108,6 +108,7 @@
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
<wiremock.version>3.3.1</wiremock.version> <wiremock.version>3.3.1</wiremock.version>
<junit-jupiter.version>5.10.2</junit-jupiter.version> <junit-jupiter.version>5.10.2</junit-jupiter.version>
<testcontainers.version>1.17.3</testcontainers.version>
</properties> </properties>
</project> </project>

View File

@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@EnableConfigurationProperties @EnableConfigurationProperties
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = { MockBookServiceConfig.class }, initializers = { EurekaContainerConfig.Initializer.class }) @ContextConfiguration(classes = { MockBookServiceConfig.class })
class ServiceDiscoveryBooksClientLiveTest { class ServiceDiscoveryBooksClientLiveTest {
@Autowired @Autowired
@ -39,6 +39,11 @@ class ServiceDiscoveryBooksClientLiveTest {
await().atMost(60, SECONDS).until(() -> eurekaClient.getApplications().size() > 0); await().atMost(60, SECONDS).until(() -> eurekaClient.getApplications().size() > 0);
} }
/**
* Please ensure that Eureka is running on port , 8761 for this test to pass.
* The EurekaServerApplication.main in spring-cloud-eureka-server project can be
* run to make an Eureka Server available.
*/
@Test @Test
public void whenGetBooks_thenTheCorrectBooksAreReturned() { public void whenGetBooks_thenTheCorrectBooksAreReturned() {
List<Book> books = booksClient.getBooks(); List<Book> books = booksClient.getBooks();

View File

@ -1,3 +1,8 @@
spring: spring:
application: application:
name: books-service name: books-service
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}