Package org.apache.jackrabbit.mk.api

Examples of org.apache.jackrabbit.mk.api.MicroKernel


*/
public class PropertyIndexTest {

    @Test
    public void test() {
        MicroKernel mk = new MicroKernelImpl();
        Indexer indexer = Indexer.getInstance(mk);
        indexer.init();
        PropertyIndex index = indexer.createPropertyIndex("id", true);

        String head = mk.getHeadRevision();

        // meta data
        String meta = mk.getNodes(Indexer.INDEX_CONFIG_PATH, head, 1, 0, -1, null);
        Assert.assertEquals("{\":childNodeCount\":2,\":data\":{\":childNodeCount\":0}," +
                "\"property@id,unique\":{\":childNodeCount\":1,\":data\":{}}}", meta);

        String oldHead = head;

        Assert.assertEquals(null, index.getPath("1", head));

        head = mk.commit("/", "+\"test\" : {\"id\":\"1\"}", head, null);
        head = mk.commit("/", "+\"test2\" : {\"id\":\"2\"}", head, null);

        Assert.assertEquals("/test", index.getPath("1", head));
        Assert.assertEquals("/test2", index.getPath("2", head));

        Assert.assertEquals("/test", index.getPath("1", oldHead));
        Assert.assertEquals("/test2", index.getPath("2", oldHead));

        Assert.assertEquals("/test", index.getPath("1", head));
        Assert.assertEquals("/test2", index.getPath("2", head));

        head = mk.commit("/", "-\"test2\"", head, null);
        head = mk.commit("/test", "+\"test\" : {\"id\":\"3\"}", head, null);

        Assert.assertEquals("/test/test", index.getPath("3", head));

        // Recreate the indexer
        indexer = Indexer.getInstance(mk);
        indexer.init();
        index = indexer.createPropertyIndex("id", true);
        head = mk.getHeadRevision();
        Assert.assertEquals("/test/test", index.getPath("3", head));
        Assert.assertEquals(null, index.getPath("0", head));

        Assert.assertEquals("/test", index.getPath("1", head));
        head = mk.commit("/", "^ \"test/id\": 100", head, null);
        Assert.assertEquals(null, index.getPath("1", head));
        Assert.assertEquals("/test", index.getPath("100", head));

        Assert.assertEquals("/test/test", index.getPath("3", head));
        head = mk.commit("/", "- \"test\"", head, null);
        Assert.assertEquals(null, index.getPath("100", head));
        Assert.assertEquals(null, index.getPath("3", head));
    }
View Full Code Here


*/
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));
    }
View Full Code Here

    @Override
    public Object addingService(ServiceReference reference) {
        Object service = context.getService(reference);
        if (service instanceof MicroKernel) {
            MicroKernel kernel = (MicroKernel) service;
            KernelNodeStore store = new KernelNodeStore(kernel);
            services.put(reference, context.registerService(
                    NodeStore.class.getName(),
                    store,
                    new Properties()));
View Full Code Here

    private KernelNodeStore store;

    @Before
    public void setup() {
        MicroKernel mk = new MicroKernelImpl();
        store = new KernelNodeStore(mk);
        // initialize node types & index definitions
        OakInitializer.initialize(store, new InitialContent(),
                CompositeIndexEditorProvider
                        .compose(new ArrayList<IndexEditorProvider>()));
View Full Code Here

            List<CommitHook> hooks = new ArrayList<CommitHook>();
            hooks.add(new DefaultTypeEditor());
            hooks.add(new ValidatingHook(validatorProvider));
            // hooks.add(new LuceneEditor());

            MicroKernel kernel = (MicroKernel) service;
            services.put(reference, context.registerService(
                    ContentRepository.class.getName(),
                    new ContentRepositoryImpl(
                            kernel, indexProvider, new CompositeHook(hooks)),
                    new Properties()));
View Full Code Here

                branchRevision = null;
                currentRoot = null;
                return committed;
            }
            else {
                MicroKernel kernel = store.getKernel();
                String mergedRevision = kernel.merge(branchRevision, null);
                branchRevision = null;
                currentRoot = null;
                return store.getRootState(mergedRevision);
            }
        }
View Full Code Here

        return node;
    }

    private void commit(String jsop) {
        MicroKernel kernel = store.getKernel();
        if (branchRevision == null) {
            // create the branch if this is the first commit
            branchRevision = kernel.branch(headRevision);
        }

        branchRevision = kernel.commit("", jsop, branchRevision, null);
        currentRoot = store.getRootState(branchRevision);
        committed = currentRoot;
    }
View Full Code Here

*/
public class PrefixIndexTest {

    @Test
    public void test() {
        MicroKernel mk = new MicroKernelImpl();
        Indexer indexer = new Indexer(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));
    }
View Full Code Here

    private void runTest(AbstractTest test, String name, String microKernel) {
        if (microKernelPattern.matcher(microKernel).matches()
                && testPattern.matcher(test.toString()).matches()) {

            MicroKernel mk = null;
            RepositoryImpl repository;
            try {

                mk = createMicroKernel(microKernel);
                repository = createRepository(mk);
View Full Code Here

        try {
            MongoUtil.initDatabase(mongoConnection);
            NodeStore nodeStore = new NodeStoreMongo(mongoConnection);
            BlobStore blobStore = new BlobStoreMongo(mongoConnection);

            MicroKernel mk = new MongoMicroKernel(nodeStore, blobStore);
            for (int i = 0; i < cluster.length; i++) {
                cluster[i] = mk;
            }
        } catch (Exception e) {
            Assert.fail(e.getMessage());
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mk.api.MicroKernel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.