StreamDiscoverer implements Closeable { public String[] getUrls() { return urls.getValue().clone(); } StreamDiscoverer(NetworkTable publisherTable, String cameraName); String[] getUrls(); ReadOnlyProperty<String[]> urlsProperty(); @Override void close();  }
@Test public void testArrayChanges() { final StreamDiscoverer discoverer = new StreamDiscoverer(rootTable, "Camera"); String[] urls = {"foo", "bar"}; rootTable.getEntry("Camera/streams").setStringArray(urls); waitForNtEvents(); assertArrayEquals(urls, discoverer.getUrls()); }
@Test public void testInitiallyEmpty() { final StreamDiscoverer discoverer = new StreamDiscoverer(rootTable, "Camera"); assertArrayEquals(new String[0], discoverer.getUrls(), "Initial URL array should be empty"); }
@Test public void testEmptyWhenIncorrectType() { StreamDiscoverer discoverer = new StreamDiscoverer(rootTable, "Camera"); rootTable.getEntry("Camera/streams").setDouble(12.34); waitForNtEvents(); assertArrayEquals(new String[0], discoverer.getUrls()); }
@Test public void testEmptyWhenTypeChanges() { final StreamDiscoverer discoverer = new StreamDiscoverer(rootTable, "Camera"); String[] urls = {"foo", "bar"}; rootTable.getEntry("Camera/streams").setStringArray(urls); waitForNtEvents(); rootTable.getEntry("Camera/streams").forceSetBoolean(false); waitForNtEvents(); assertArrayEquals(new String[0], discoverer.getUrls()); }