Class 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 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:
        beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
      • afterAll

        public void afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
      • clearRegisteredApps

        public void clearRegisteredApps()
        Helper method to access EmbeddedEurekaServer#getRegistry()'s clearRegisteredApps().
      • registerApplication

        public void registerApplication​(String appName,
                                        String instanceId,
                                        String vipAddress,
                                        String status)
        Helper method to access EmbeddedEurekaServer#getRegistry()'s registerApplication(appName, instanceId, vipAddress, status).
        Parameters:
        appName - the application name
        instanceId - instance ID of the application
        vipAddress - the Eureka VIP address
        status - the status value, a value from InstanceInfo.InstanceStatus
      • getRegisteredApplications

        public List<com.netflix.discovery.shared.Application> getRegisteredApplications()
        Helper method to access EmbeddedEurekaServer#getRegistry()'s registeredApplications().
        Returns:
        a List of Application
      • getRegisteredApplication

        public com.netflix.discovery.shared.Application getRegisteredApplication​(String appId)
        Helper method to access EmbeddedEurekaServer#getRegistry()'s getRegisteredApplication(appId).
        Parameters:
        appId - the application ID
        Returns:
        the registered Application
      • isApplicationRegistered

        public boolean isApplicationRegistered​(String appId)
        Helper method to access EmbeddedEurekaServer#getRegistry()'s isApplicationRegistered(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 access EmbeddedEurekaServer#getRegistry()'s getHeartbeatCount().
        Returns:
        the number of heartbeats since the application was registered with Eureka