/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.mk.wrapper;

import static org.junit.Assert.assertEquals;
import org.apache.jackrabbit.mk.MultiMkTestBase;
import org.apache.jackrabbit.mk.index.IndexWrapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

/**
 * Test the index wrapper.
 */
@RunWith(Parameterized.class)
public class IndexWrapperTest extends MultiMkTestBase {

    private String head;

    public IndexWrapperTest(String url) {
        super(url);
    }

    @Before
    public void setUp() throws Exception {
        super.setUp();
        mk = new IndexWrapper(mk);
    }

    @Test
    public void prefix() {
        if (!isSimpleKernel(mk)) {
            return;
        }
        head = mk.commit("/index", "+ \"prefix:x\": {}", head, "");
        head = mk.commit("/", "+ \"n1\": { \"value\":\"a:no\" }", head, "");
        head = mk.commit("/", "+ \"n2\": { \"value\":\"x:yes\" }", head, "");
        head = mk.commit("/", "+ \"n3\": { \"value\":\"x:a\" }", head, "");
        head = mk.commit("/", "+ \"n4\": { \"value\":\"x:a\" }", head, "");
        String empty = mk.getNodes("/index/prefix:x?x:no", head);
        assertEquals("[]", empty);
        String yes = mk.getNodes("/index/prefix:x?x:yes", head);
        assertEquals("[\"/n2/value\"]", yes);
        String a = mk.getNodes("/index/prefix:x?x:a", head);
        assertEquals("[\"/n3/value\",\"/n4/value\"]", a);
    }

    @Test
    public void propertyUnique() {
        if (!isSimpleKernel(mk)) {
            return;
        }
        head = mk.commit("/index", "+ \"property:id,unique\": {}", head, "");
        head = mk.commit("/", "+ \"n1\": { \"value\":\"empty\" }", head, "");
        head = mk.commit("/", "+ \"n2\": { \"id\":\"1\" }", head, "");
        String empty = mk.getNodes("/index/property:id,unique?0", head);
        assertEquals("[]", empty);
        String one = mk.getNodes("/index/property:id,unique?1", head);
        assertEquals("[\"/n2\"]", one);
    }

    @Test
    public void propertyNonUnique() {
        if (!isSimpleKernel(mk)) {
            return;
        }
        head = mk.commit("/index", "+ \"property:ref\": {}", head, "");
        head = mk.commit("/", "+ \"n1\": { \"ref\":\"a\" }", head, "");
        head = mk.commit("/", "+ \"n2\": { \"ref\":\"b\" }", head, "");
        head = mk.commit("/", "+ \"n3\": { \"ref\":\"b\" }", head, "");
        String empty = mk.getNodes("/index/property:ref?no", head);
        assertEquals("[]", empty);
        String one = mk.getNodes("/index/property:ref?a", head);
        assertEquals("[\"/n1\"]", one);
        String two = mk.getNodes("/index/property:ref?b", head);
        assertEquals("[\"/n2\",\"/n3\"]", two);
    }

}

@@ -916,31 +916,31 @@
 bbit.mk.
-MultiMkTestBase
+api.MicroKernel
 ;%0Aimport
@@ -1000,431 +1000,308 @@
 org.
-junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0A%0A/**%0A * Test the index wrapper.%0A */%0A@RunWith(Parameterized.class)%0Apublic class IndexWrapperTest extends MultiMkTestBase %7B%0A%0A    private String head;%0A%0A    public IndexWrapperTest(String url) %7B%0A        super(url);%0A    %7D%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        super.setUp();%0A        mk = new 
+apache.jackrabbit.mk.simple.SimpleKernelImpl;%0Aimport org.junit.Test;%0A%0A/**%0A * Test the index wrapper.%0A */%0Apublic class IndexWrapperTest %7B%0A%0A    // TODO: Remove SimpleKernelImpl-specific assumptions from the test%0A    private final MicroKernel mk =%0A            new IndexWrapper(new SimpleKernelImpl(%22mem:
 Inde
@@ -1312,19 +1312,42 @@
 pper
-(mk
+Test%22)
 );%0A
+%0A
     
-%7D
+private String head;
 %0A%0A  
@@ -1385,73 +1385,8 @@
 ) %7B%0A
-        if (!isSimpleKernel(mk)) %7B%0A            return;%0A        %7D%0A
     
@@ -2143,73 +2143,8 @@
 ) %7B%0A
-        if (!isSimpleKernel(mk)) %7B%0A            return;%0A        %7D%0A
     
@@ -2644,73 +2644,8 @@
 ) %7B%0A
-        if (!isSimpleKernel(mk)) %7B%0A            return;%0A        %7D%0A
     

Implement a test suite for the MicroKernel