Directory indexDir = newDirectory();
TaxonomyWriter tw = new DirectoryTaxonomyWriter(indexDir);
tw.addCategory(new CategoryPath("hi", "there"));
tw.commit();
TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir);
ChildrenArrays ca = tr.getChildrenArrays();
assertEquals(3, tr.getSize());
assertEquals(3, ca.getOlderSiblingArray().length);
assertEquals(3, ca.getYoungestChildArray().length);
assertTrue(Arrays.equals(new int[] { 1, 2, -1 }, ca.getYoungestChildArray()));
assertTrue(Arrays.equals(new int[] { -1, -1, -1 }, ca.getOlderSiblingArray()));
tw.addCategory(new CategoryPath("hi", "ho"));
tw.addCategory(new CategoryPath("hello"));
tw.commit();
// Before refresh, nothing changed..
ChildrenArrays newca = tr.getChildrenArrays();
assertSame(newca, ca); // we got exactly the same object
assertEquals(3, tr.getSize());
assertEquals(3, ca.getOlderSiblingArray().length);
assertEquals(3, ca.getYoungestChildArray().length);
// After the refresh, things change: