*/
public class PrefixIndexTest {
@Test
public void test() {
MicroKernel mk = new MicroKernelImpl();
Indexer indexer = Indexer.getInstance(mk);
indexer.init();
PrefixIndex index = indexer.createPrefixIndex("d:");
String head = mk.getHeadRevision();
// meta data
String meta = mk.getNodes(Indexer.INDEX_CONFIG_PATH, head, 1, 0, -1, null);
Assert.assertEquals("{\":childNodeCount\":2,\"prefix@d:\":" +
"{\":childNodeCount\":1,\":data\":{}},\":data\":{\":childNodeCount\":0}}", meta);
Assert.assertEquals("", getPathList(index, "d:1", head));
head = mk.commit("/", "+\"test\" : {\"blob\":\"d:1\"}", head, null);
head = mk.commit("/", "+\"test2\" : {\"blob2\":\"d:2\"}", head, null);
Assert.assertEquals("/test/blob", getPathList(index, "d:1", head));
Assert.assertEquals("/test2/blob2", getPathList(index, "d:2", head));
head = mk.commit("/", "^\"test2/blob2\" : null", head, null);
Assert.assertEquals("", getPathList(index, "d:2", head));
head = mk.commit("/", "^\"test2/blob2\" : \"d:2\" ", head, null);
Assert.assertEquals("/test2/blob2", getPathList(index, "d:2", head));
head = mk.commit("/", "+\"test3\" : {\"blob3\":\"d:1\"}", head, null);
head = mk.commit("/", "+\"test4\" : {\"blob4\":\"d:2\"}", head, null);
Assert.assertEquals("/test/blob, /test3/blob3", getPathList(index, "d:1", head));
Assert.assertEquals("/test2/blob2, /test4/blob4", getPathList(index, "d:2", head));
head = mk.commit("/", "+\"test5\" : {\"blobs\":[\"a:0\",\"d:2\"]}", head, null);
head = mk.commit("/", "+\"test6\" : {\"data\":[true, false, null, 1, -1]}", head, null);
Assert.assertEquals("/test2/blob2, /test4/blob4, /test5/blobs", getPathList(index, "d:2", head));
head = mk.commit("/", "+\"test7\" : {\"a\":\"d:4\", \"b\":\"d:4\"}", head, null);
Assert.assertEquals("/test7/a, /test7/b", getPathList(index, "d:4", head));
head = mk.commit("/", "^\"test7/a\" : null", head, null);
Assert.assertEquals("/test7/b", getPathList(index, "d:4", head));
}