<commit_before>package org.apache.jackrabbit.mongomk.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import org.apache.jackrabbit.mongomk.BaseMongoMicroKernelTest;
import org.junit.Test;

/**
 * Tests for {@link MongoMicroKernel#commit(String, String, String, String)}
 * with emphasis on remove node and property operations.
 */
public class MongoMKCommitRemoveTest extends BaseMongoMicroKernelTest {

    @Test
    public void removeSingleNode() throws Exception {
        mk.commit("/", "+\"a\" : {}", null, null);

        long childCount = mk.getChildNodeCount("/", null);
        assertEquals(1, childCount);

        mk.commit("/", "-\"a\"", null, null);
        childCount = mk.getChildNodeCount("/", null);
        assertEquals(0, childCount);
    }

    @Test
    public void removeNonExistentNode() throws Exception {
        try {
            mk.commit("/", "-\"a\"", null, null);
            fail("Exception expected");
        } catch (Exception expected) {}
    }
}<commit_msg>Added test cases for OAK-507<commit_after>package org.apache.jackrabbit.mongomk.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.apache.jackrabbit.mongomk.BaseMongoMicroKernelTest;
import org.junit.Ignore;
import org.junit.Test;

/**
 * Tests for {@link MongoMicroKernel#commit(String, String, String, String)}
 * with emphasis on remove node and property operations.
 */
public class MongoMKCommitRemoveTest extends BaseMongoMicroKernelTest {

    @Test
    public void removeSingleNode() throws Exception {
        mk.commit("/", "+\"a\" : {}", null, null);

        long childCount = mk.getChildNodeCount("/", null);
        assertEquals(1, childCount);

        mk.commit("/", "-\"a\"", null, null);
        childCount = mk.getChildNodeCount("/", null);
        assertEquals(0, childCount);
    }

    @Test
    public void removeNonExistentNode() throws Exception {
        try {
            mk.commit("/", "-\"a\"", null, null);
            fail("Exception expected");
        } catch (Exception expected) {}
    }

    @Test
    @Ignore("OAK-507") // FIXME
    public void removeNodeTwice() throws Exception {
        String base = mk.commit("", "+\"/a\":{}", null, null);
        mk.commit("", "-\"/a\"", base, null);
        assertTrue(mk.nodeExists("/a", base));
        mk.commit("", "-\"/a\"", base, null);
    }

    @Test
    public void removeAndAddNode() throws Exception {
        String base = mk.commit("", "+\"/a\":{}", null, null);
        mk.commit("", "-\"/a\"", base, null);
        assertTrue(mk.nodeExists("/a", base));
        mk.commit("", "+\"/a\":{}", base, null);
    }
}
{'fraction_non_alphanumeric': 0.1636763090443061, 'fraction_numerical': 0.003661662394727206, 'mean_word_length': 2.942279942279942, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5111382', 'n_tokens_mistral': 824, 'n_tokens_neox': 794, 'n_words': 201}