Skip to content

Commit

Permalink
fix the test
Browse files Browse the repository at this point in the history
  • Loading branch information
pj892031 committed Nov 30, 2023
1 parent ff592f5 commit a6eddee
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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());
Expand Down

0 comments on commit a6eddee

Please sign in to comment.