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
Oct 23, 2023
1 parent
0ebaa0f
commit 565c194
Showing
6 changed files
with
181 additions
and
11 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
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
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
87 changes: 87 additions & 0 deletions
87
...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,87 @@ | ||
/* | ||
* Copyright 2013-2022 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
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(); | ||
} | ||
|
||
} |