Skip to content

Commit

Permalink
Fixed non-idempotent test ConfigRefreshTests.verifyGetApplications (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiyaok2 committed Jun 27, 2024
1 parent bf6dafe commit f47e93c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,6 +31,7 @@

/**
* @author Ryan Baxter
* @author Kaiyao Ke
*/
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = RefreshEurekaSampleApplication.class)
class ConfigRefreshTests {
Expand All @@ -42,15 +43,18 @@ class ConfigRefreshTests {
// Mocked in RefreshEurekaSampleApplication
private EurekaClient client;

private static boolean isFirstRun = true;

@Test
// This test is used to verify that getApplications is called the correct number of
// times when a refresh event is fired. The getApplications call in
// EurekaClientConfigurationRefresher.onApplicationEvent
// ensures that the EurekaClient bean is recreated after a refresh event and that we
// reregister the client with the server
void verifyGetApplications() {
if (publisher != null) {
if (publisher != null && isFirstRun) {
publisher.publishEvent(new RefreshScopeRefreshedEvent());
isFirstRun = false;
}
verify(client, times(3)).getApplications();
}
Expand Down

0 comments on commit f47e93c

Please sign in to comment.