use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class ReadyServiceImplTest method testDifferentReadyMarkerInstances.
@Test
public void testDifferentReadyMarkerInstances() {
ReadyServiceImpl rs = new ReadyServiceImpl();
assertFalse(rs.isReady(new ReadyMarker("test", "id")));
rs.markReady(new ReadyMarker("test", "id"));
assertTrue(rs.isReady(new ReadyMarker("test", "id")));
rs.unmarkReady(new ReadyMarker("test", "id"));
assertFalse(rs.isReady(new ReadyMarker("test", "id")));
}
use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class ReadyServiceImplTest method testTrackersAreInformedOnlyOnMatch.
@Test
public void testTrackersAreInformedOnlyOnMatch() {
ReadyTracker tracker = mock(ReadyTracker.class);
ReadyServiceImpl rs = new ReadyServiceImpl();
rs.registerTracker(tracker, new ReadyMarkerFilter().withType("test"));
rs.markReady(new ReadyMarker("foo", "id"));
verifyNoMoreInteractions(tracker);
rs.markReady(new ReadyMarker("test", "id"));
verify(tracker).onReadyMarkerAdded(isA(ReadyMarker.class));
verifyNoMoreInteractions(tracker);
}
use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class SyntheticBundleInstaller method waitForReadyMarker.
private static void waitForReadyMarker(BundleContext context, String marker, Bundle bundle) {
if (bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null) {
return;
}
long startTime = System.nanoTime();
ServiceReference readyServiceRef = context.getServiceReference(ReadyService.class.getName());
ReadyService readyService = (ReadyService) context.getService(readyServiceRef);
ReadyMarker expected = new ReadyMarker(marker, bundle.getSymbolicName());
while (!readyService.isReady(expected)) {
if (System.nanoTime() - startTime > TimeUnit.SECONDS.toNanos(WAIT_TIMOUT)) {
Assert.fail(MessageFormat.format("Timout waiting for marker {0} at bundle {1}", marker, bundle.getSymbolicName()));
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
context.ungetService(readyServiceRef);
}
use of org.eclipse.smarthome.core.service.ReadyMarker in project smarthome by eclipse.
the class XmlDocumentBundleTracker method unregisterReadyMarker.
private void unregisterReadyMarker(Bundle bundle) {
String bsn = bundle.getSymbolicName();
ReadyMarker readyMarker = bundleReadyMarkerRegistrations.remove(bsn);
if (readyMarker != null) {
readyService.unmarkReady(readyMarker);
}
}
Aggregations