forked from spring-cloud/spring-cloud-netflix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce skipForcedClientInitialization property.
Fixes spring-cloudgh-4152
- Loading branch information
Robert Bleyl
committed
Apr 21, 2023
1 parent
ccb0f5c
commit 3f5bdff
Showing
3 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...a/org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfigurationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.springframework.cloud.netflix.eureka.server; | ||
|
||
import com.netflix.discovery.EurekaClient; | ||
import com.netflix.discovery.EurekaClientConfig; | ||
import com.netflix.eureka.EurekaServerConfig; | ||
import com.netflix.eureka.resources.ServerCodecs; | ||
import com.netflix.eureka.transport.EurekaServerHttpClientFactory; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; | ||
|
||
import static org.mockito.Mockito.never; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class EurekaServerAutoConfigurationTests { | ||
|
||
@Mock | ||
private EurekaServerConfig eurekaServerConfig; | ||
|
||
@Mock | ||
private EurekaClientConfig eurekaClientConfig; | ||
|
||
@Mock | ||
private EurekaClient eurekaClient; | ||
|
||
@Mock | ||
private InstanceRegistryProperties instanceRegistryProperties; | ||
|
||
@Mock | ||
private ServerCodecs serverCodecs; | ||
|
||
@Mock | ||
private EurekaServerHttpClientFactory eurekaServerHttpClientFactory; | ||
|
||
@Mock | ||
private EurekaInstanceConfigBean eurekaInstanceConfigBean; | ||
|
||
@InjectMocks | ||
private EurekaServerAutoConfiguration eurekaServerAutoConfiguration; | ||
|
||
@BeforeEach | ||
void setup() { | ||
when(eurekaServerConfig.getDeltaRetentionTimerIntervalInMs()) | ||
.thenReturn(1L); | ||
} | ||
|
||
@Test | ||
void shouldForceEurekaClientInit() { | ||
eurekaServerAutoConfiguration.peerAwareInstanceRegistry(serverCodecs, | ||
eurekaServerHttpClientFactory, eurekaInstanceConfigBean); | ||
|
||
verify(eurekaClient).getApplications(); | ||
} | ||
|
||
@Test | ||
void shouldNotForceEurekaClientInit() { | ||
when(eurekaInstanceConfigBean.isSkipForcedClientInitialization()) | ||
.thenReturn(true); | ||
|
||
eurekaServerAutoConfiguration.peerAwareInstanceRegistry(serverCodecs, | ||
eurekaServerHttpClientFactory, eurekaInstanceConfigBean); | ||
|
||
verify(eurekaClient, never()).getApplications(); | ||
} | ||
} |