Package org.kiwiproject.eureka.junit
Class EurekaServerExtension
- java.lang.Object
-
- org.kiwiproject.eureka.junit.EurekaServerExtension
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.Extension
public class EurekaServerExtension extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback
JUnit Jupiter extension that starts a local Eureka testing server before any test has run, and stops the server after all tests have (successfully or otherwise) completed.
-
-
Field Summary
Fields Modifier and Type Field Description static StringEUREKA_API_BASE_PATHThe base path at which the testing Eureka server will respond to requests.
-
Constructor Summary
Constructors Constructor Description EurekaServerExtension()EurekaServerExtension(String basePath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterAll(org.junit.jupiter.api.extension.ExtensionContext context)voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context)voidclearRegisteredApps()Helper method to accessEmbeddedEurekaServer#getRegistry()'sclearRegisteredApps().longgetHeartbeatCount()Helper method to accessEmbeddedEurekaServer#getRegistry()'sgetHeartbeatCount().com.netflix.discovery.shared.ApplicationgetRegisteredApplication(String appId)Helper method to accessEmbeddedEurekaServer#getRegistry()'sgetRegisteredApplication(appId).List<com.netflix.discovery.shared.Application>getRegisteredApplications()Helper method to accessEmbeddedEurekaServer#getRegistry()'sregisteredApplications().booleanisApplicationRegistered(String appId)Helper method to accessEmbeddedEurekaServer#getRegistry()'sisApplicationRegistered(appId).voidregisterApplication(String appName, String instanceId, String vipAddress, String status)Helper method to accessEmbeddedEurekaServer#getRegistry()'sregisterApplication(appName, instanceId, vipAddress, status).
-
-
-
Field Detail
-
EUREKA_API_BASE_PATH
public static final String EUREKA_API_BASE_PATH
The base path at which the testing Eureka server will respond to requests.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EurekaServerExtension
public EurekaServerExtension()
-
EurekaServerExtension
public EurekaServerExtension(String basePath)
-
-
Method Detail
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback
-
clearRegisteredApps
public void clearRegisteredApps()
Helper method to accessEmbeddedEurekaServer#getRegistry()'sclearRegisteredApps().
-
registerApplication
public void registerApplication(String appName, String instanceId, String vipAddress, String status)
Helper method to accessEmbeddedEurekaServer#getRegistry()'sregisterApplication(appName, instanceId, vipAddress, status).- Parameters:
appName- the application nameinstanceId- instance ID of the applicationvipAddress- the Eureka VIP addressstatus- the status value, a value fromInstanceInfo.InstanceStatus
-
getRegisteredApplications
public List<com.netflix.discovery.shared.Application> getRegisteredApplications()
Helper method to accessEmbeddedEurekaServer#getRegistry()'sregisteredApplications().- Returns:
- a List of
Application
-
getRegisteredApplication
public com.netflix.discovery.shared.Application getRegisteredApplication(String appId)
Helper method to accessEmbeddedEurekaServer#getRegistry()'sgetRegisteredApplication(appId).- Parameters:
appId- the application ID- Returns:
- the registered
Application
-
isApplicationRegistered
public boolean isApplicationRegistered(String appId)
Helper method to accessEmbeddedEurekaServer#getRegistry()'sisApplicationRegistered(appId).- Parameters:
appId- the application ID- Returns:
- true if and only if there is an application registered having the given ID
-
getHeartbeatCount
public long getHeartbeatCount()
Helper method to accessEmbeddedEurekaServer#getRegistry()'sgetHeartbeatCount().- Returns:
- the number of heartbeats since the application was registered with Eureka
-
-