Package org.ops4j.pax.exam

Examples of org.ops4j.pax.exam.TimeoutException


    }

    public void waitForState(final long bundleId, final int state, final RelativeTimeout timeout) {
        Bundle bundle = bundleContext.getBundle(bundleId);
        if (bundle == null || (timeout.isNoWait() && (bundle == null || bundle.getState() < state))) {
            throw new TimeoutException("There is no waiting timeout set and bundle has state '"
                + bundleStateToString(bundle) + "' not '" + bundleStateToString(state)
                + "' as expected");
        }
        long startedTrying = System.currentTimeMillis();
        do {
            bundle = bundleContext.getBundle(bundleId);
            try {
                Thread.sleep(50);
            }
            catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                break;
            }
        }
        while ((bundle == null || bundle.getState() < state)
            && (timeout.isNoTimeout() || System.currentTimeMillis() < startedTrying
                + timeout.getValue()));

        if (bundle == null || bundle.getState() < state) {
            throw new TimeoutException("Timeout passed and bundle has state '"
                + bundleStateToString(bundle.getState()) + "' not '" + bundleStateToString(state)
                + "' as expected");
        }
    }
View Full Code Here

TOP

Related Classes of org.ops4j.pax.exam.TimeoutException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.