use of org.talend.sdk.component.container.ContainerListener in project component-runtime by Talend.
the class ContainerManagerTest method listeners.
@Test
void listeners(final TempJars jars) {
final Collection<String> states = new ArrayList<>();
final ContainerListener listener = new ContainerListener() {
@Override
public void onCreate(final Container container) {
states.add("deploy #" + container.getId());
}
@Override
public void onClose(final Container container) {
states.add("undeploy #" + container.getId());
}
};
try (final ContainerManager manager = createDefaultManager().registerListener(listener)) {
assertEquals(emptyList(), states);
try (final Container container = manager.builder(createZiplockJar(jars).getAbsolutePath()).create()) {
assertEquals(1, states.size());
}
assertEquals(2, states.size());
manager.unregisterListener(listener);
try (final Container container = manager.builder(createZiplockJar(jars).getAbsolutePath()).create()) {
assertEquals(2, states.size());
}
assertEquals(2, states.size());
}
assertEquals(2, states.size());
}
Aggregations