Examples of MicroKernel


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

    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

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

    public static RepositoryFixture getMemory(final long cacheSize) {
        return new OakRepositoryFixture("Oak-Memory") {
            @Override
            protected Repository[] internalSetUpCluster(int n) throws Exception {
                Repository[] cluster = new Repository[n];
                MicroKernel kernel = new MicroKernelImpl();
                for (int i = 0; i < cluster.length; i++) {
                    Oak oak = new Oak(new KernelNodeStore(kernel, cacheSize));
                    cluster[i] = new Jcr(oak).createRepository();
                }
                return cluster;
View Full Code Here

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

    private NodeState committed;

    KernelNodeStoreBranch(KernelNodeStore store) {
        this.store = store;

        MicroKernel kernel = store.getKernel();
        this.branchRevision = kernel.branch(null);
        this.currentRoot = new KernelNodeState(kernel, getValueFactory(), "/", branchRevision);
        this.base = currentRoot;
        this.committed = currentRoot;
    }
View Full Code Here

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

        return true;
    }

    @Override
    public KernelNodeState merge() throws CommitFailedException {
        MicroKernel kernel = store.getKernel();
        CommitEditor editor = store.getCommitEditor();

        NodeState oldRoot = store.getRoot();
        NodeState toCommit = editor.editCommit(store, oldRoot, currentRoot);
        setRoot(toCommit);

        try {
            String mergedRevision = kernel.merge(branchRevision, null);
            branchRevision = null;
            currentRoot = null;
            committed = null;
            KernelNodeState committed = new KernelNodeState(kernel, getValueFactory(), "/", mergedRevision);
            return committed;
View Full Code Here

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

        return node;
    }

    private void commit(String jsop) {
        MicroKernel kernel = store.getKernel();
        branchRevision = kernel.commit("/", jsop, branchRevision, null);
        currentRoot = new KernelNodeState(kernel, getValueFactory(), "/", branchRevision);
        committed = currentRoot;
    }
View Full Code Here

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_ROOT, head, 1, 0, -1, null);
        Assert.assertEquals("{\":childNodeCount\":1,\"property@id,unique\":{\":childNodeCount\":0}}", 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

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

*/
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_ROOT, head, 1, 0, -1, null);
        Assert.assertEquals("{\":childNodeCount\":1,\"prefix@d:\":{\":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

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

public class LuceneEditorTest {

    @Test
    public void testLucene() throws Exception {
        MicroKernel mk = new MicroKernelImpl();
        KernelNodeStore store = new KernelNodeStore(
                mk, new LuceneEditor("jcr:system", "oak:lucene"));
        Root root = new RootImpl(store, "");
        Tree tree = root.getTree("/");
View Full Code Here

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

    protected NodeState state;

    @Before
    public void setUp() {
        MicroKernel microKernel = new MicroKernelImpl();
        store = new KernelNodeStore(microKernel, createCommitEditor());
        valueFactory = store.getValueFactory();

        state = createInitialState(microKernel);
    }
View Full Code Here

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

    @Before
    public void setup() {
        counter = 0;

        MicroKernel mk1 = new MicroKernelImpl("./target/mk1/" + random.nextInt());
        store1 = new KernelNodeStore(mk1, EmptyEditor.INSTANCE);
        vf = store1.getValueFactory();
        mk1.commit("", "+\"/root\":{}", mk1.getHeadRevision(), "");
        root1 = new RootImpl(store1, null);

        MicroKernel mk2 = new MicroKernelImpl("./target/mk2/" + random.nextInt());
        store2 = new KernelNodeStore(mk2, EmptyEditor.INSTANCE);
        mk2.commit("", "+\"/root\":{}", mk2.getHeadRevision(), "");
        root2 = new RootImpl(store2, null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.