From 5bcf243fdbba47e231c91dfe26b6330839c2de6f Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Mon, 31 Aug 2020 01:09:36 +0430 Subject: [PATCH 1/2] Revert "Fix the integrations tests in ribbon-client-service" This reverts commit 3e89177d --- .../src/main/resources/application.yml | 1 + .../RibbonRetryFailureIntegrationTest.java | 7 ++----- .../RibbonRetrySuccessIntegrationTest.java | 7 ++----- .../spring/cloud/ribbon/retry/TestUtils.java | 18 ------------------ 4 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/TestUtils.java diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/main/resources/application.yml b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/main/resources/application.yml index a6f67772f2..29d2360793 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/main/resources/application.yml +++ b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/main/resources/application.yml @@ -9,6 +9,7 @@ weather-service: ribbon: eureka: enabled: false + listOfServers: http://localhost:8021, http://localhost:8022 ServerListRefreshInterval: 5000 MaxAutoRetries: 3 MaxAutoRetriesNextServer: 1 diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java index 6a4fe4bd00..0f0a1c4255 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java +++ b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java @@ -10,7 +10,6 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.http.ResponseEntity; -import static com.baeldung.spring.cloud.ribbon.retry.TestUtils.setUpServices; import static org.junit.jupiter.api.Assertions.assertTrue; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = RibbonClientApp.class) @@ -25,10 +24,8 @@ public class RibbonRetryFailureIntegrationTest { @BeforeAll public static void setup() { - weatherServiceInstance1 = startApp(0); - weatherServiceInstance2 = startApp(0); - - setUpServices(weatherServiceInstance1, weatherServiceInstance2); + weatherServiceInstance1 = startApp(8021); + weatherServiceInstance2 = startApp(8022); } @AfterAll diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java index 281f69d0bc..6fdad0f2a9 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java +++ b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java @@ -10,7 +10,6 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.http.ResponseEntity; -import static com.baeldung.spring.cloud.ribbon.retry.TestUtils.setUpServices; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -26,10 +25,8 @@ public class RibbonRetrySuccessIntegrationTest { @BeforeAll public static void setup() { - weatherServiceInstance1 = startApp(0); - weatherServiceInstance2 = startApp(0); - - setUpServices(weatherServiceInstance1, weatherServiceInstance2); + weatherServiceInstance1 = startApp(8021); + weatherServiceInstance2 = startApp(8022); } private static ConfigurableApplicationContext startApp(int port) { diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/TestUtils.java b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/TestUtils.java deleted file mode 100644 index 67c7847cda..0000000000 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/TestUtils.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.spring.cloud.ribbon.retry; - -import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; - -class TestUtils { - - static int getWebAppPort(ConfigurableApplicationContext ctx) { - return ((AnnotationConfigServletWebServerApplicationContext) ctx).getWebServer().getPort(); - } - - static void setUpServices(ConfigurableApplicationContext service1, ConfigurableApplicationContext service2) { - int port1 = getWebAppPort(service1); - int port2 = getWebAppPort(service2); - String serversList = String.format("http://localhost:%d, http://localhost:%d", port1, port2); - System.setProperty("weather-service.ribbon.listOfServers", serversList); - } -} From 5d7035cb19d39878422bda82e1c3b6b545024ec1 Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Mon, 31 Aug 2020 01:25:37 +0430 Subject: [PATCH 2/2] Running two tests sequentially. --- spring-cloud/spring-cloud-ribbon-retry/pom.xml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spring-cloud/spring-cloud-ribbon-retry/pom.xml b/spring-cloud/spring-cloud-ribbon-retry/pom.xml index 5318ea6913..27037d6710 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/pom.xml +++ b/spring-cloud/spring-cloud-ribbon-retry/pom.xml @@ -33,8 +33,20 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + 0 + + + + + Hoxton.SR3 - \ No newline at end of file