SC

Java library · Testing

TM1 Testcontainers

Test against real Planning Analytics, in Docker

Start a real TM1 server for your tests with one annotation, shared across the test run, and skipped cleanly where Docker or TM1 isn’t available. Add TM1 Web, Planning Analytics Workspace and Cognos security with test users when you need them. No IBM software is included: you supply your own licensed TM1.

API docs Source on GitHub

Pre-release. TM1 Testcontainers isn’t on Maven Central yet. The API docs track the latest code on master, and the version shown in them is a snapshot. To try it before the first release, build it from source.

  1. Add it to your tests.

    Gradle (Kotlin)
    testImplementation("io.skipcheck:tm1-testcontainers:<version>")
  2. Tell it where your TM1 is. The quickest way is the folder holding IBM’s tm1server-…_bundle.tar.gz download, with Docker running:

    Terminal
    TM1_BUNDLE_DIR=~/Downloads ./gradlew test
  3. Write a test.

    Java
    @RequiresTm1
    static class HelloTm1Test {
    
        @Test
        void connects(Tm1ServerContainer server) {
            Tm1Client tm1 = Tm1Client.builder()
                .baseUrl(server.getRestUrl())
                .basicAuth(server.getUsername(), server.getPassword())
                .build();
            try {
                assertNotNull(tm1.session().version().block(Duration.ofSeconds(30)));
            }
            finally {
                tm1.close().block(Duration.ofSeconds(30));
            }
        }
    
    }

Next: the API docs, for your own containers, the sample data and whole environments.

  • @RequiresTm1: a JUnit 5 extension that starts one TM1 server per test run, injects it, and skips when it can’t.
  • Your TM1, your way: from IBM’s download file, a download link, an installed folder or a private image.
  • The whole suite: TM1 Web, Planning Analytics Workspace, an Admin Server with several servers, and Cognos (CAM) or OIDC security with test users.
  • Sample data: start from IBM’s SData sample, or your own database.