Class Tm1WebContainer

java.lang.Object
org.testcontainers.containers.GenericContainer<Tm1WebContainer>
io.skipcheck.tm1.testcontainers.Tm1WebContainer
All Implemented Interfaces:
AutoCloseable, org.testcontainers.containers.Container<Tm1WebContainer>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable

public class Tm1WebContainer extends org.testcontainers.containers.GenericContainer<Tm1WebContainer>
TM1 Web (IBM Planning Analytics Spreadsheet Services) in Docker, for tests, built on the tm1-web image.

TM1 Web lists and logs on to the TM1 servers registered with an Admin Server, so it's started against a Tm1ServerContainer with withTm1Server(Tm1ServerContainer). That container's embedded Admin Server is the one TM1 Web uses. Most tests use RequiresTm1Web, which starts one shared TM1 Web against the shared TM1 server.

try (var tm1 = new Tm1ServerContainer(tm1Source).withSeed(Tm1Seed.SDATA);
		var web = new Tm1WebContainer(webSource).withTm1Server(tm1)) {
	web.start(); // starts tm1 first
	return web.getUrl(); // http://localhost:54321/tm1web/
}

The image contains no IBM software, so every container needs a Tm1WebSource. TM1 Web's default heap here is 1 GB; set the image's TM1_WEB_HEAP with GenericContainer.withEnv(String, String) to change it.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.testcontainers.containers.Container

    org.testcontainers.containers.Container.ExecResult
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.testcontainers.utility.DockerImageName
    The tm1-web image, without a tag.
    static final int
    TM1 Web's HTTP port inside the container.
    static final String
    Overrides the tm1-web image (not used with Tm1WebSource.PrivateImage), e.g.

    Fields inherited from class org.testcontainers.containers.GenericContainer

    CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategy

    Fields inherited from interface org.testcontainers.containers.ContainerState

    STATE_HEALTHY
  • Constructor Summary

    Constructors
    Constructor
    Description
    A container on the default tm1-web image (or TM1_WEB_IMAGE), getting TM1 Web from source.
    Tm1WebContainer(org.testcontainers.utility.DockerImageName image, Tm1WebSource source)
    A container on image, which must be tm1-web or built on it.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
    containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse info)
     
    The Admin Server host TM1 Web is configured with: the TM1 server's address on the network the two share.
    The Admin Server set with withAdminServer(Tm1AdminServerContainer).
    Where TM1 Web comes from.
    The TM1 server set with withTm1Server(Tm1ServerContainer).
    TM1 Web's address as seen from the host, e.g.
    The TM1 Web most tests share: one per test JVM, started on first use with the source Tm1WebSource.discover() finds, against Tm1ServerContainer.shared().
    Lists and logs on to the TM1 servers registered with a separate Admin Server (Tm1ServerContainer.withAdminServer(Tm1AdminServerContainer)), instead of one server's own.
    Points TM1 Web at tm1's Admin Server, and starts tm1 first if it isn't running.

    Methods inherited from class org.testcontainers.containers.GenericContainer

    addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, canBeReused, containerIsCreated, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, stop, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectory

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.testcontainers.containers.Container

    addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBind

    Methods inherited from interface org.testcontainers.containers.ContainerState

    copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close
  • Field Details

    • DEFAULT_IMAGE

      public static final org.testcontainers.utility.DockerImageName DEFAULT_IMAGE
      The tm1-web image, without a tag.
    • WEB_IMAGE

      public static final String WEB_IMAGE
      Overrides the tm1-web image (not used with Tm1WebSource.PrivateImage), e.g. tm1-web:local for a local build. Read as a system property, then an environment variable.
      See Also:
    • HTTP_PORT

      public static final int HTTP_PORT
      TM1 Web's HTTP port inside the container.
      See Also:
  • Constructor Details

    • Tm1WebContainer

      public Tm1WebContainer(Tm1WebSource source)
      A container on the default tm1-web image (or TM1_WEB_IMAGE), getting TM1 Web from source.
      Parameters:
      source - where TM1 Web comes from
    • Tm1WebContainer

      public Tm1WebContainer(org.testcontainers.utility.DockerImageName image, Tm1WebSource source)
      A container on image, which must be tm1-web or built on it.
      Parameters:
      image - the image to run
      source - where TM1 Web comes from
  • Method Details

    • shared

      public static Tm1WebContainer shared()
      The TM1 Web most tests share: one per test JVM, started on first use with the source Tm1WebSource.discover() finds, against Tm1ServerContainer.shared(). Marked reusable, like the shared TM1 server.
      Returns:
      the started shared container
      Throws:
      IllegalStateException - if no TM1 or TM1 Web source is configured
    • withTm1Server

      public Tm1WebContainer withTm1Server(Tm1ServerContainer tm1)
      Points TM1 Web at tm1's Admin Server, and starts tm1 first if it isn't running.

      The two containers have to share a Docker network. A server that isn't started yet and has no network is given one of its own. A server that's already running (such as the shared one) is joined on the network it's on, including Docker's default bridge network.

      Parameters:
      tm1 - the TM1 server whose Admin Server TM1 Web lists servers from
      Returns:
      this container
    • withAdminServer

      public Tm1WebContainer withAdminServer(Tm1AdminServerContainer admin)
      Lists and logs on to the TM1 servers registered with a separate Admin Server (Tm1ServerContainer.withAdminServer(Tm1AdminServerContainer)), instead of one server's own. Takes precedence over the Admin Server of a TM1 server. The two containers share a Docker network, and starting TM1 Web starts the Admin Server first; start the TM1 servers before TM1 Web too, so they're listed.
      Parameters:
      admin - the Admin Server to list servers from
      Returns:
      this container
    • getAdminServer

      public @Nullable Tm1AdminServerContainer getAdminServer()
      The Admin Server set with withAdminServer(Tm1AdminServerContainer).
      Returns:
      the Admin Server, or null if none was set
    • getSource

      public Tm1WebSource getSource()
      Where TM1 Web comes from.
      Returns:
      the source
    • getTm1Server

      public @Nullable Tm1ServerContainer getTm1Server()
      The TM1 server set with withTm1Server(Tm1ServerContainer).
      Returns:
      the server, or null if none was set
    • getUrl

      public String getUrl()
      TM1 Web's address as seen from the host, e.g. http://localhost:54321/tm1web/.
      Returns:
      the URL, ending in /
    • getAdminHost

      public String getAdminHost()
      The Admin Server host TM1 Web is configured with: the TM1 server's address on the network the two share. This is the AdminHost a TM1 Web login, or a TM1 Web URL API link, names.
      Returns:
      the Admin Server host
      Throws:
      IllegalStateException - if no TM1 server was set or the container isn't started yet
    • configure

      protected void configure()
      Overrides:
      configure in class org.testcontainers.containers.GenericContainer<Tm1WebContainer>
    • containerIsStarted

      protected void containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse info)
      Overrides:
      containerIsStarted in class org.testcontainers.containers.GenericContainer<Tm1WebContainer>