@Test public void testGetLeaves() throws Exception { Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); final CatalogTree catalogTree = new CatalogTree(null, new DefaultAppContext(""), null); List<InvDataset> datasets = new ArrayList<InvDataset>(); InvCatalog catalog = new InvCatalogImpl("catalogName", "1.0", new URI("http://x.y")); final InvDataset rootDataset = createDataset(catalog, "first", "OPENDAP"); rootDataset.getDatasets().add(createDataset(catalog, "second", "OPENDAP")); rootDataset.getDatasets().add(createDataset(catalog, "third", "OPENDAP")); datasets.add(rootDataset); catalogTree.setNewRootDatasets(datasets); OpendapLeaf[] leaves = catalogTree.getLeaves(); Arrays.sort(leaves, new Comparator<OpendapLeaf>() { @Override public int compare(OpendapLeaf o1, OpendapLeaf o2) { return o1.getName().compareTo(o2.getName()); } }); assertEquals(2, leaves.length); assertEquals("second", leaves[0].getName()); assertEquals("third", leaves[1].getName()); }