Class EmbeddedEurekaServer


  • public class EmbeddedEurekaServer
    extends Object
    Creates, configures, starts and stops an embedded Jetty server running a Eureka Server.

    If using this class outside of EurekaServerExtension then you may want to set the eureka.numberRegistrySyncRetries to zero in the System properties. This will allow the server to spin up quickly an not try to connect to other non-existent Eureka servers. See https://github.com/Netflix/eureka/issues/42#issuecomment-75614903 for dialog on this.

    • Constructor Detail

      • EmbeddedEurekaServer

        public EmbeddedEurekaServer()
      • EmbeddedEurekaServer

        public EmbeddedEurekaServer​(String basePath)
        Creates a new EmbeddedEurekaServer allowing Jetty to pick an available port.
        Parameters:
        basePath - the context path for the Jetty WebAppContext
    • Method Detail

      • start

        public void start()
        Starts the server.
      • stop

        public void stop()
        Stops the server.
        Throws:
        IllegalStateException - when the server is not running.
      • getEurekaPort

        public int getEurekaPort()
        Retrieves the port that the server is listening on.
        Returns:
        the server port.
      • isStarted

        public boolean isStarted()
        Returns whether the server is running or not.
        Returns:
        true if the server is running, false otherwise.
      • isStopped

        public boolean isStopped()