From a6eddee3e11096eb3a14fb62f132252ab73277b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jare=C5=A1?= Date: Thu, 30 Nov 2023 18:48:24 +0100 Subject: [PATCH] fix the test --- .../DeterministicUserBasedRoutingTest.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gateway-service/src/test/java/org/zowe/apiml/acceptance/DeterministicUserBasedRoutingTest.java b/gateway-service/src/test/java/org/zowe/apiml/acceptance/DeterministicUserBasedRoutingTest.java index d65d6a1a77..3b0a7b9769 100644 --- a/gateway-service/src/test/java/org/zowe/apiml/acceptance/DeterministicUserBasedRoutingTest.java +++ b/gateway-service/src/test/java/org/zowe/apiml/acceptance/DeterministicUserBasedRoutingTest.java @@ -16,9 +16,10 @@ import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.message.BasicStatusLine; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.RepeatedTest; -import org.junit.jupiter.api.RepetitionInfo; +import org.junit.jupiter.api.TestInstance; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; @@ -40,11 +41,18 @@ * Verify that the behavior configured for the routing chooses for the same user the same service instance. */ @AcceptanceTest +@TestInstance(TestInstance.Lifecycle.PER_CLASS) class DeterministicUserBasedRoutingTest extends AcceptanceTestWithTwoServices { @Autowired protected LoadBalancerCache cache; + @Override public void prepareApplications() { + // to stop updating before each method + } + + @BeforeAll + public void prepareApplicationsAll() { cache.getLocalCache().clear(); applicationRegistry.clearApplications(); MetadataBuilder defaultBuilder = MetadataBuilder.defaultInstance(); @@ -62,13 +70,7 @@ class GivenAuthenticatedUserAndMoreInstancesOfService { class WhenCallingToServiceMultipleTimes { @RepeatedTest(3) - void thenCallTheSameInstance(RepetitionInfo repetitionInfo) throws IOException { - - // initialize the cache and registry only once on first repetition - if (repetitionInfo.getCurrentRepetition() == 1) { - prepareApplications(); - } - + void thenCallTheSameInstance() throws IOException { Cookie token = securityRequests.validJwtToken(); applicationRegistry.setCurrentApplication(serviceWithCustomConfiguration.getId());