private void assertActiveBundle()

in src/main/java/org/apache/sling/launchpad/webapp/integrationtest/installer/InstallManyBundlesTest.java [89:119]


    private void assertActiveBundle(String bsn, String expectedState, String expectedVersion)
            throws IOException, JsonException {
        final String consoleUrl = HttpTest.HTTP_BASE_URL + "/system/console/bundles/" + bsn + ".json";

        String state = null;
        String version = null;

        final long timeoutMsec = TimeoutsProvider.getInstance().getTimeout(WAIT_ACTIVE_TIMEOUT_MSEC);
        final long endTime = System.currentTimeMillis() + timeoutMsec;
        while (System.currentTimeMillis() < endTime) {
            try {
                final String jsonStr = H.getContent(consoleUrl, HttpTest.CONTENT_TYPE_JSON);
                final JsonObject json = JsonUtil.parseObject(jsonStr);
                state = json.getJsonArray("data").getJsonObject(0).getString("state");
                version = json.getJsonArray("data").getJsonObject(0).getString("version");
                if (expectedState.equalsIgnoreCase(state) && expectedVersion.equalsIgnoreCase(version)) {
                    return;
                }
                Thread.sleep(100);
            } catch (AssertionFailedError dontCare) {
                // Thrown by getContent - might happen before the
                // bundle is installed
            } catch (InterruptedException ignore) {
            }
        }

        fail("Did not get state="
                + expectedState + " and version=" + expectedVersion
                + " within " + timeoutMsec + " msec"
                + ", got " + state + " / " + version);
    }