java.lang.Object
com.github.mjeanroy.junit.servers.engine.Servers

public final class Servers extends Object
Static utilities for server instantiation and configuration.
  • Method Details

    • instantiate

      public static EmbeddedServer<?> instantiate(Class<?> klass)
      Instantiate jetty or tomcat embedded server.

      Server configuration is automatically read on static field / methods available on given class (i.e field or method annotated with TestServerConfiguration annotation).

      Server implementation is automatically detected (jetty or tomcat) with classpath detection.

      Parameters:
      klass - Class to inspect.
      Returns:
      Embedded server.
    • instantiate

      public static <T extends AbstractConfiguration> EmbeddedServer<T> instantiate(T configuration)
      Instantiate jetty or tomcat embedded server.

      Configuration is an optional parameter and can be null. If configuration is null, empty constructor will be used to instantiate embedded server. Otherwise, constructor with one parameter (configuration) will be used.

      Server implementation is automatically detected (jetty or tomcat) with classpath detection.

      Type Parameters:
      T - Type of configuration.
      Parameters:
      configuration - Optional configuration.
      Returns:
      Embedded server.
    • findConfiguration

      public static <T extends AbstractConfiguration> T findConfiguration(Class<?> klass)
      Find configuration object on static field / method on running class. Configuration is read from static method or static field annotated with TestServerConfiguration annotation.
      Type Parameters:
      T - Type of configuration.
      Parameters:
      klass - Class to inspect.
      Returns:
      Configuration.