Class Tm1EnvironmentServers
java.lang.Object
io.skipcheck.tm1.spring.boot.testcontainers.Tm1EnvironmentServers
Wires the TM1 servers of a
PlanningAnalyticsEnvironment into the starter by
name: each server becomes tm1.servers.<name>, so a Spring Boot test gets a
@Qualifier("<name>") client for each. A server named default is the
starter's default server, the one a plain Tm1Client gets.
// Two servers, as tm1.servers.planning and tm1.servers.reporting
@RequiresTm1
@SpringBootTest(classes = ReportingApplication.class)
static class ReportingApplicationTest {
private static PlanningAnalyticsEnvironment environment;
@DynamicPropertySource
static void tm1(DynamicPropertyRegistry registry) {
environment = PlanningAnalyticsEnvironment.builder()
.tm1("planning", tm1 -> tm1.withSeed(Tm1Seed.SDATA))
.tm1("reporting")
.build();
environment.start();
Tm1EnvironmentServers.register(environment, registry);
}
@AfterAll
static void stop() {
environment.close();
}
@Autowired
@Qualifier("planning")
private Tm1Client planning;
@Autowired
@Qualifier("reporting")
private Tm1Client reporting;
@Test
void connectsToBoth() {
assertNotEquals(planning.session().serviceRoot(), reporting.session().serviceRoot());
}
}
Call it from a @DynamicPropertySource method. A
DynamicPropertyRegistrar bean, or @ServiceConnection on an environment
bean, comes too late: the starter reads the names under tm1.servers when it
registers its bean definitions, before any bean exists, and so before the environment
that knows the names. A @DynamicPropertySource method runs before the context
starts, so the names are there. The values are read only when the beans are created,
once the environment has started.
For one server, @ServiceConnection on its Tm1ServerContainer (see the
package) needs no names: it
makes the default server.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidregister(PlanningAnalyticsEnvironment environment, DynamicPropertyRegistry registry) Addstm1.servers.<name>.*for each of the environment's TM1 servers: itsbase-url, and the login its own checks use,userandpassword, withnamespacein Cognos (CAM) security.
-
Method Details
-
register
public static void register(PlanningAnalyticsEnvironment environment, DynamicPropertyRegistry registry) Addstm1.servers.<name>.*for each of the environment's TM1 servers: itsbase-url, and the login its own checks use,userandpassword, withnamespacein Cognos (CAM) security.- Parameters:
environment- the environment, built; it may start laterregistry- the registry of a@DynamicPropertySourcemethod
-