in src/main/java/org/apache/sling/junit/impl/TestsManagerImpl.java [202:235]
long waitForSystemStartup() {
long elapsedMsec = -1;
if (waitForSystemStartup) {
waitForSystemStartup = false;
final Set<Bundle> bundlesToWaitFor = Stream.of(bundleContext.getBundles())
.filter(not(TestsManagerImpl::isActive).and(not(TestsManagerImpl::isFragment)))
.collect(Collectors.toSet());
// wait max inactivityTimeout after the last bundle became active before giving up
final long startTime = System.currentTimeMillis();
final long startupTimeout = startTime + TimeUnit.SECONDS.toMillis(startupTimeoutSeconds);
while (needToWait(startupTimeout, bundlesToWaitFor)) {
log.info("Waiting for bundles to start: {}", bundlesToWaitFor);
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
bundlesToWaitFor.removeIf(TestsManagerImpl::isActive);
}
elapsedMsec = System.currentTimeMillis() - startTime;
if (!bundlesToWaitFor.isEmpty()) {
log.warn("Waited {} milliseconds but the following bundles are not yet started: {}",
elapsedMsec, bundlesToWaitFor);
} else {
log.info("All bundles are active, starting to run tests.");
}
}
return elapsedMsec;
}