Class AxonServerContainerUtils

java.lang.Object
org.axonframework.test.server.AxonServerContainerUtils

public class AxonServerContainerUtils extends Object
Utility class for the AxonServerContainer, used to initialize the cluster.
Since:
4.8.0
Author:
Milan Savic, Sara Pelligrini
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final boolean
    Constant boolean specifying that a context supports DCB.
    static final boolean
    Constant boolean specifying that a context does not support DCB.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<String>
    contexts(String hostname, int port)
    Retrieves all the contexts of the Axon Server instance located at the given hostname and port combination.
    static void
    createContext(String hostname, int port, String context, boolean dcbContext)
    Calls the API of Axon Server at the given hostname and (http) port to create a context with the given context name.
    static void
    deleteContext(String hostname, int port, String context)
    Calls the API of Axon Server at the given hostname and (http) port to delete the given context.
    static void
    initCluster(String hostname, int port, boolean shouldBeReused, boolean dcbContext)
    Initialize the cluster of the Axon Server instance located at the given hostname and port combination.
    static List<String>
    internalContexts(String hostname, int port)
    Retrieves all the internal contexts (registered in the RAFT protocol) of the Axon Server instance located at the given hostname and port combination.
    static void
    purgeEventsFromAxonServer(String hostname, int port, String context, boolean dcbContext)
    Calls the API of Axon Server at given hostname and (http) port to purge events of the given context.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DCB_CONTEXT

      public static final boolean DCB_CONTEXT
      Constant boolean specifying that a context supports DCB.
      See Also:
    • NO_DCB_CONTEXT

      public static final boolean NO_DCB_CONTEXT
      Constant boolean specifying that a context does not support DCB.
      See Also:
  • Constructor Details

    • AxonServerContainerUtils

      public AxonServerContainerUtils()
  • Method Details

    • initCluster

      public static void initCluster(String hostname, int port, boolean shouldBeReused, boolean dcbContext) throws IOException
      Initialize the cluster of the Axon Server instance located at the given hostname and port combination.

      Note that this constructs the contexts _admin and default.

      Parameters:
      hostname - The hostname of the Axon Server instance to initiate the cluster for.
      port - The port of the Axon Server instance to initiate the cluster for.
      shouldBeReused - If set to true, ensure the cluster is not accidentally initialized twice.
      dcbContext - A boolean stating whether a DCB or non-DCB context is being created.
      Throws:
      IOException - When there are issues with the HTTP connection to the Axon Server instance at the given hostname and port.
    • contexts

      public static List<String> contexts(String hostname, int port) throws IOException
      Retrieves all the contexts of the Axon Server instance located at the given hostname and port combination.
      Parameters:
      hostname - The hostname of the Axon Server instance to create the given context of.
      port - The port of the Axon Server instance to create the given context of.
      Returns:
      All the contexts of the Axon Server instances located at the given hostname and port combination.
      Throws:
      IOException - When there are issues with the HTTP connection to the Axon Server instance at the given hostname and port.
    • internalContexts

      public static List<String> internalContexts(String hostname, int port) throws IOException
      Retrieves all the internal contexts (registered in the RAFT protocol) of the Axon Server instance located at the given hostname and port combination.
      Parameters:
      hostname - The hostname of the Axon Server instance to create the given context of.
      port - The port of the Axon Server instance to create the given context of.
      Returns:
      All the contexts of the Axon Server instances located at the given hostname and port combination.
      Throws:
      IOException - When there are issues with the HTTP connection to the Axon Server instance at the given hostname and port.
    • purgeEventsFromAxonServer

      public static void purgeEventsFromAxonServer(String hostname, int port, String context, boolean dcbContext) throws IOException
      Calls the API of Axon Server at given hostname and (http) port to purge events of the given context.
      Parameters:
      hostname - The hostname where AxonServer can be reached.
      port - The HTTP port AxonServer listens to for API calls.
      context - The context to purge.
      dcbContext - A boolean stating whether a DCB or non-DCB context is being purged.
      Throws:
      IOException - When an error occurs communicating with Axon Server.
      Since:
      5.0.0
    • deleteContext

      public static void deleteContext(String hostname, int port, String context) throws IOException
      Calls the API of Axon Server at the given hostname and (http) port to delete the given context.
      Parameters:
      hostname - The hostname where Axon Server can be reached.
      port - The HTTP port Axon Server listens to for API calls.
      context - The context to delete.
      Throws:
      IOException - When an error occurs communicating with Axon Server.
    • createContext

      public static void createContext(String hostname, int port, String context, boolean dcbContext) throws IOException
      Calls the API of Axon Server at the given hostname and (http) port to create a context with the given context name. The dcbContext dictates whether the context to be created support DCB, yes or no.
      Parameters:
      hostname - The hostname where Axon Server can be reached.
      port - The HTTP port Axon Server listens to for API calls.
      context - The context to create.
      dcbContext - A boolean stating whether a DCB or non-DCB context is being created.
      Throws:
      IOException - When an error occurs communicating with Axon Server.