You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2017/09/28 11:09:01 UTC

[45/50] [abbrv] jena git commit: JENA-1396: Merge //github/afs/mantis as subdirectory jena-db/

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/AbstractTestChannel.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/AbstractTestChannel.java
index 0000000,0000000..ae14bab
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/AbstractTestChannel.java
@@@ -1,0 -1,0 +1,144 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import java.nio.ByteBuffer ;
++
++import org.junit.Assert ;
++import org.junit.After ;
++import org.junit.Before ;
++import org.junit.Test ;
++import org.seaborne.dboe.base.file.BufferChannel ;
++
++public abstract class AbstractTestChannel extends Assert
++{
++    protected abstract BufferChannel open() ;
++    
++    private BufferChannel store ;
++    @Before public void before() { store = open() ; }
++    @After  public void after()  { store.close() ; }
++    
++    static final int blkSize = 100 ;
++    
++    protected static ByteBuffer data(int len)
++    {
++        ByteBuffer b = ByteBuffer.allocate(len) ;
++        for (int i = 0 ; i < len ; i++ )
++            b.put((byte)(i&0xFF)) ;
++        b.clear() ;
++        return b ;
++    }
++    
++    protected static boolean same(ByteBuffer bb1, ByteBuffer bb2)
++    {
++        if ( bb1.capacity() != bb2.capacity() ) return false ;
++        bb1.clear() ;
++        bb2.clear() ;
++        for ( int i = 0 ; i < bb1.capacity() ; i++ )
++            if ( bb1.get(i) != bb2.get(i) ) return false ;
++        return true ;
++    }
++
++    @Test public void storage_01() 
++    {
++        assertEquals(0, store.size()) ;
++    }
++    
++    @Test public void storage_02()
++    {
++        ByteBuffer b = data(blkSize) ;
++        store.write(b) ;
++        long x = store.size() ;
++        assertEquals(blkSize, x) ;
++    }
++
++    @Test public void storage_03()
++    {
++        ByteBuffer b1 = data(blkSize) ;
++        long posn = store.position() ; 
++        store.write(b1) ;
++        ByteBuffer b9 = ByteBuffer.allocate(blkSize) ;
++        int r = store.read(b9, posn) ;
++        assertEquals(blkSize, r) ;
++        assertTrue(same(b1, b9)) ;
++    }
++    
++    @Test public void storage_04()
++    {
++        ByteBuffer b1 = data(blkSize) ;
++        ByteBuffer b2 = data(blkSize/2) ;
++
++        store.write(b2, 0) ;
++        store.write(b1, 0) ;
++        
++        assertEquals(blkSize, store.size()) ;
++        ByteBuffer b9 = ByteBuffer.allocate(5) ;
++        int z = store.read(b9) ;
++        assertEquals(5, z) ;
++    }
++    
++    @Test public void storage_05()
++    {
++        ByteBuffer b1 = data(blkSize) ;
++        ByteBuffer b1a = ByteBuffer.allocate(blkSize) ;
++        ByteBuffer b2 = data(blkSize/2) ;
++        ByteBuffer b2a = ByteBuffer.allocate(blkSize/2) ;
++        store.write(b1) ;
++        store.write(b2) ;
++        store.position(0) ;
++        store.read(b1a) ;
++        assertTrue(same(b1, b1a)) ;
++        store.read(b2a) ;
++        assertTrue(same(b2, b2a)) ;
++    }
++    
++    @Test public void storage_06()
++    {
++        ByteBuffer b1 = data(blkSize) ;
++        store.write(b1) ;
++        store.truncate(0) ;
++        assertEquals(0, store.size()) ;
++        // Check for:
++        // http://bugs.sun.com/view_bug.do?bug_id=6191269
++        assertEquals(0, store.position()) ;
++    }
++    
++    @Test public void storage_07()
++    {
++        ByteBuffer b1 = data(blkSize) ;
++        store.write(b1) ;
++        store.position(10) ;
++        b1.rewind() ;
++        store.write(b1) ;
++        assertEquals(blkSize+10, store.size()) ;
++    }    
++
++    
++    @Test public void storage_08()
++    {
++        ByteBuffer b1 = data(blkSize) ;
++        ByteBuffer b2 = data(blkSize) ;
++        store.write(b1) ;
++        store.write(b2) ;
++        store.position(10) ;
++        b1.rewind() ;
++        store.write(b1) ;
++        assertEquals(2*blkSize, store.size()) ;
++    }    
++
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TS_File.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TS_File.java
index 0000000,0000000..368ffb4
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TS_File.java
@@@ -1,0 -1,0 +1,48 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.junit.runner.RunWith ;
++import org.junit.runners.Suite ;
++
++@RunWith(Suite.class)
++@Suite.SuiteClasses( {
++    TestMetaFile.class
++    , TestSegmentedMemBuffer.class
++    , TestChannelMem.class
++    , TestChannelFile.class
++    
++    , TestBlockAccessMem.class
++    , TestBlockAccessByteArray.class
++    , TestBlockAccessDirect.class
++    , TestBlockAccessMapped.class
++    
++    , TestBinaryDataMem.class
++    , TestBinaryDataFileWriteBufferedMem.class
++    , TestBinaryDataRAFInitial.class
++    , TestBinaryDataRAF.class
++    , TestBinaryDataFileWriteBufferedFile.class
++    
++    , TestProcessFileLock.class
++})
++
++
++public class TS_File
++{
++    public static String FILE = "target/test-read-append-file" ;
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataFileWriteBufferedFile.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataFileWriteBufferedFile.java
index 0000000,0000000..50adda1
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataFileWriteBufferedFile.java
@@@ -1,0 -1,0 +1,35 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.apache.jena.atlas.lib.FileOps ;
++import org.seaborne.dboe.base.file.BinaryDataFile ;
++import org.seaborne.dboe.base.file.BinaryDataFileRandomAccess ;
++import org.seaborne.dboe.base.file.BinaryDataFileWriteBuffered ;
++
++public class TestBinaryDataFileWriteBufferedFile extends AbstractTestBinaryDataFile {
++    public static String FILE = TS_File.FILE ;
++
++    @Override
++    protected BinaryDataFile createBinaryDataFile() {
++        FileOps.delete(FILE);
++        BinaryDataFileRandomAccess file = new BinaryDataFileRandomAccess(FILE) ;
++        return new BinaryDataFileWriteBuffered(file) ;
++    }
++}
++

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataFileWriteBufferedMem.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataFileWriteBufferedMem.java
index 0000000,0000000..69c7f77
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataFileWriteBufferedMem.java
@@@ -1,0 -1,0 +1,31 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.seaborne.dboe.base.file.BinaryDataFile ;
++import org.seaborne.dboe.base.file.BinaryDataFileMem ;
++import org.seaborne.dboe.base.file.BinaryDataFileWriteBuffered ;
++
++public class TestBinaryDataFileWriteBufferedMem extends AbstractTestBinaryDataFile {
++    @Override
++    protected BinaryDataFile createBinaryDataFile() {
++        BinaryDataFileMem file = new BinaryDataFileMem() ;
++        return new BinaryDataFileWriteBuffered(file) ;
++    }
++}
++

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataMem.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataMem.java
index 0000000,0000000..c519029
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataMem.java
@@@ -1,0 -1,0 +1,31 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.seaborne.dboe.base.file.BinaryDataFile ;
++import org.seaborne.dboe.base.file.BinaryDataFileMem ;
++
++public class TestBinaryDataMem extends AbstractTestBinaryDataFile {
++
++    @Override
++    protected BinaryDataFile createBinaryDataFile() {
++        return new BinaryDataFileMem() ;
++    }
++
++}
++

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataRAF.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataRAF.java
index 0000000,0000000..f4ef7fc
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataRAF.java
@@@ -1,0 -1,0 +1,33 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.apache.jena.atlas.lib.FileOps ;
++import org.seaborne.dboe.base.file.BinaryDataFile ;
++import org.seaborne.dboe.base.file.BinaryDataFileRandomAccess ;
++
++public class TestBinaryDataRAF extends AbstractTestBinaryDataFile {
++    public static String FILE = TS_File.FILE ;
++
++    @Override
++    protected BinaryDataFile createBinaryDataFile() {
++        FileOps.delete(FILE);
++        return new BinaryDataFileRandomAccess(FILE) ;
++    }
++}
++

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataRAFInitial.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataRAFInitial.java
index 0000000,0000000..0a572e2
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBinaryDataRAFInitial.java
@@@ -1,0 -1,0 +1,57 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.apache.jena.atlas.RuntimeIOException ;
++import org.junit.Test ;
++import org.seaborne.dboe.base.file.BinaryDataFileRandomAccess ;
++import static org.junit.Assert.* ;
++
++// Additional tests that do not want the @Before/@After of AbstractTestBinaryDataFile
++public class TestBinaryDataRAFInitial  {
++    public static String FILE = TS_File.FILE ;
++    private BinaryDataFileRandomAccess file ;
++
++    @Test public void open_01() { 
++        file = new BinaryDataFileRandomAccess(FILE) ;
++        assertFalse(file.isOpen()) ;
++        file.open();
++        assertTrue(file.isOpen()) ;
++        file.close() ;
++        assertFalse(file.isOpen()) ;
++    }
++    
++    @Test (expected=RuntimeIOException.class)
++    public void open_02() { 
++        file = new BinaryDataFileRandomAccess(FILE) ;
++        file.open();
++        file.close() ;
++        file.sync(); 
++    }
++    
++    @Test (expected=RuntimeIOException.class)
++    public void open_03() { 
++        file = new BinaryDataFileRandomAccess(FILE) ;
++        file.open();
++        file.close() ;
++        file.truncate(0); 
++    }
++
++    
++}
++

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessByteArray.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessByteArray.java
index 0000000,0000000..37881d1
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessByteArray.java
@@@ -1,0 -1,0 +1,32 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.seaborne.dboe.base.file.BlockAccess ;
++import org.seaborne.dboe.base.file.BlockAccessByteArray ;
++
++public class TestBlockAccessByteArray extends AbstractTestBlockAccessVarSize
++{
++
++    @Override
++    protected BlockAccess make()
++    {
++        return new BlockAccessByteArray("test") ;
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessDirect.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessDirect.java
index 0000000,0000000..2b0605f
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessDirect.java
@@@ -1,0 -1,0 +1,44 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.apache.jena.atlas.lib.FileOps ;
++import org.junit.AfterClass ;
++import org.seaborne.dboe.ConfigTestDBOE ;
++import org.seaborne.dboe.base.file.BlockAccess ;
++import org.seaborne.dboe.base.file.BlockAccessDirect ;
++
++public class TestBlockAccessDirect extends AbstractTestBlockAccessFixedSize
++{
++    static String filename = ConfigTestDBOE.getTestingDir()+"/test-file-access-direct" ;
++    
++    static final int BlockSize = 50 ;
++    public TestBlockAccessDirect()
++    {
++        super(BlockSize) ;
++    }
++
++    @AfterClass public static void cleanup() { FileOps.deleteSilent(filename) ; } 
++    
++    @Override
++    protected BlockAccess make()
++    {
++        FileOps.deleteSilent(filename) ;
++        return new BlockAccessDirect(filename, BlockSize) ;
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessMapped.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessMapped.java
index 0000000,0000000..4223ebb
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessMapped.java
@@@ -1,0 -1,0 +1,48 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.apache.jena.atlas.lib.FileOps ;
++import org.junit.AfterClass ;
++import org.seaborne.dboe.ConfigTestDBOE ;
++import org.seaborne.dboe.base.file.BlockAccess ;
++import org.seaborne.dboe.base.file.BlockAccessMapped ;
++
++public class TestBlockAccessMapped extends AbstractTestBlockAccessFixedSize
++{
++    static String filename = ConfigTestDBOE.getTestingDir()+"/test-file-access-mapped" ;
++    
++    static final int BlockSize = 64 ;
++    public TestBlockAccessMapped()
++    {
++        super(BlockSize) ;
++    }
++
++    @AfterClass public static void cleanup() { FileOps.deleteSilent(filename) ; } 
++    
++    static int counter = 0 ;
++    
++    @Override
++    protected BlockAccess make()
++    {
++    	String fn = filename + "-"+(counter++) ;
++    	FileOps.deleteSilent(fn) ;
++        return new BlockAccessMapped(fn, BlockSize) ;
++        
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessMem.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessMem.java
index 0000000,0000000..78a219f
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestBlockAccessMem.java
@@@ -1,0 -1,0 +1,37 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.seaborne.dboe.base.file.BlockAccess ;
++import org.seaborne.dboe.base.file.BlockAccessMem ;
++
++public class TestBlockAccessMem extends AbstractTestBlockAccessFixedSize
++{
++    static final int BlockSize = 50 ;
++    public TestBlockAccessMem()
++    {
++        super(BlockSize) ;
++    }
++
++    @Override
++    protected BlockAccess make()
++    {
++        return new BlockAccessMem("test", BlockSize) ;
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestChannelFile.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestChannelFile.java
index 0000000,0000000..b99dac9
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestChannelFile.java
@@@ -1,0 -1,0 +1,38 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.apache.jena.atlas.lib.FileOps ;
++import org.junit.AfterClass ;
++import org.seaborne.dboe.ConfigTestDBOE ;
++import org.seaborne.dboe.base.file.BufferChannel ;
++import org.seaborne.dboe.base.file.BufferChannelFile ;
++
++public class TestChannelFile extends AbstractTestChannel
++{
++    static String filename = ConfigTestDBOE.getTestingDir()+"/test-storage" ;
++
++    @AfterClass public static void cleanup() { FileOps.deleteSilent(filename) ; } 
++    
++    @Override
++    protected BufferChannel open()
++    {
++        FileOps.deleteSilent(filename) ;
++        return BufferChannelFile.create(filename) ;
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestChannelMem.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestChannelMem.java
index 0000000,0000000..1fb079d
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestChannelMem.java
@@@ -1,0 -1,0 +1,34 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import org.seaborne.dboe.base.file.BufferChannel ;
++import org.seaborne.dboe.base.file.BufferChannelMem ;
++
++
++public class TestChannelMem extends AbstractTestChannel
++{
++    static int counter = 0 ;
++    
++    @Override
++    protected BufferChannel open()
++    {
++        return BufferChannelMem.create("Test-"+(counter++)) ;
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestMetaFile.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestMetaFile.java
index 0000000,0000000..c1427d1
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestMetaFile.java
@@@ -1,0 -1,0 +1,74 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import java.io.File ;
++
++import org.junit.Assert ;
++import org.junit.After ;
++import org.junit.Before ;
++import org.junit.Test ;
++import org.seaborne.dboe.ConfigTestDBOE ;
++import org.seaborne.dboe.base.file.MetaFile ;
++import org.seaborne.dboe.sys.Names ;
++
++public class TestMetaFile extends Assert
++{
++    String testfile = null ;
++    String testfileMeta = null ;
++    
++    @Before public void before()
++    {
++        testfile = ConfigTestDBOE.getTestingDir()+"/file" ;
++        testfileMeta = ConfigTestDBOE.getTestingDir()+"/file."+Names.extMeta ;
++        File f = new File(testfileMeta) ;
++        f.delete() ;
++    }
++    
++    @Test public void meta1()
++    {
++        clear() ;
++        MetaFile f = new MetaFile("META", testfile) ;
++        assertFalse(new File(testfileMeta).exists()) ;
++        f.setProperty("key", "value") ;
++        f.flush() ;
++        assertTrue(new File(f.getFilename()).exists()) ;
++    }
++    
++    @Test public void meta2()
++    {
++        clear() ;
++        MetaFile f = new MetaFile("META", testfile) ;
++        f.setProperty("test.value1", "1") ;
++        f.flush();
++        MetaFile f2 = new MetaFile("META", testfile) ;
++        assertEquals("1", f2.getProperty("test.value1")) ;
++        assertNull(f2.getProperty("test.value.other")) ;
++    }
++
++    // Test MetaBase
++    
++    @After public void afterClass()
++    { clear() ; }
++    
++    private void clear()
++    {
++        File f = new File(testfileMeta) ;
++        f.delete() ;
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestProcessFileLock.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestProcessFileLock.java
index 0000000,0000000..39b0652
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestProcessFileLock.java
@@@ -1,0 -1,0 +1,107 @@@
++/*
++ * 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.seaborne.dboe.base.file;
++
++import static org.junit.Assert.*;
++import static org.junit.Assert.assertFalse;
++import static org.junit.Assert.assertNotSame;
++import static org.junit.Assert.assertSame;
++
++import java.io.File;
++import java.io.IOException;
++
++import org.apache.jena.atlas.lib.FileOps;
++import org.junit.Before;
++import org.junit.BeforeClass;
++import org.junit.Test;
++import org.seaborne.dboe.base.file.ProcessFileLock;
++import org.seaborne.dboe.sys.Names;
++
++public class TestProcessFileLock {
++    // TestLocationLockStoreConnection
++    
++    private static final String DIR  = "target/locktest";
++    private static final String lockfile = DIR+"/"+Names.TDB_LOCK_FILE;
++    
++    
++    @BeforeClass public static void beforeClass() {
++        FileOps.ensureDir(DIR);
++    }
++    
++    @Before public void beforeTest() {
++        File f = new File(lockfile);
++        try {
++            f.delete();
++            f.createNewFile();
++        }
++        catch (IOException e) {
++            e.printStackTrace();
++        }
++    }
++
++    @Test public void process_lock_1() {
++        ProcessFileLock lock = ProcessFileLock.create(lockfile);
++        String fn = new File(lockfile).getAbsolutePath();
++        assertEquals(fn, lock.getPath().toString());
++    }
++    
++    @Test public void process_lock_2() {
++        ProcessFileLock lock1 = ProcessFileLock.create(lockfile);
++        ProcessFileLock lock2 = ProcessFileLock.create(lockfile);
++        assertSame(lock1, lock2);
++    }
++
++    @Test public void process_lock_3() {
++        ProcessFileLock lock1 = ProcessFileLock.create(lockfile);
++        ProcessFileLock.release(lock1);
++        ProcessFileLock lock2 = ProcessFileLock.create(lockfile);
++        assertNotSame(lock1, lock2);
++    }
++    
++    @Test public void process_lock_4() {
++        ProcessFileLock lock = ProcessFileLock.create(lockfile);
++        assertFalse(lock.isLockedHere());
++        lock.lockEx();
++        assertTrue(lock.isLockedHere());
++        lock.unlock();
++        assertFalse(lock.isLockedHere());
++    }
++
++    @Test(expected=AlreadyLocked.class)
++    public void process_lock_5() {
++        ProcessFileLock lock = ProcessFileLock.create(lockfile);
++        lock.lockEx();
++        lock.lockEx();
++    }
++    
++    @Test(expected=AlreadyLocked.class)
++    public void process_lock_6() {
++        ProcessFileLock lock = ProcessFileLock.create(lockfile);
++        lock.lockEx();
++        boolean b = lock.tryLock();
++        assertFalse(b);
++    }
++
++    @Test(expected=AlreadyLocked.class)
++    public void process_lock_7() {
++        ProcessFileLock lock = ProcessFileLock.create(lockfile);
++        lock.tryLock();
++        lock.tryLock();
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestSegmentedMemBuffer.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestSegmentedMemBuffer.java
index 0000000,0000000..c11cd75
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/file/TestSegmentedMemBuffer.java
@@@ -1,0 -1,0 +1,158 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.file;
++
++import java.nio.ByteBuffer ;
++import java.util.Arrays ;
++
++import org.junit.Assert ;
++import org.junit.Test ;
++
++public class TestSegmentedMemBuffer extends Assert {
++    private static byte[] data1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ;  
++    private static byte[] data2 = { 10,11,12 } ;
++    
++    @Test public void membuffer_00() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer() ;
++        assertTrue(space.isOpen()) ;
++        assertEquals(0, space.length()) ;
++        space.close() ;
++        assertFalse(space.isOpen()) ;
++        space.close() ;
++    }
++    
++    @Test public void membuffer_01() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer() ;
++        writeread1(space) ;
++    }
++    
++    @Test public void membuffer_02() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer() ;
++        writeread2(space) ;
++    }
++
++    @Test public void membuffer_03() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer() ;
++        writeread1(space) ;
++        space.truncate(0); 
++        writeread2(space) ;
++    }
++
++    @Test public void membuffer_11() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer(2) ;
++        writeread1(space) ;
++    }
++    
++    @Test public void membuffer_12() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer(2) ;
++        writeread2(space) ;
++    }
++
++    @Test public void membuffer_13() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer(2) ;
++        writeread1(space) ;
++        space.truncate(0); 
++        writeread2(space) ;
++    }
++
++    @Test public void membuffer_21() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer() ;
++        writeread1a(space) ;
++    }
++    
++    @Test public void membuffer_22() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer() ;
++        writeread2a(space) ;
++    }
++
++    @Test public void membuffer_23() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer() ;
++        writeread1(space) ;
++        space.truncate(0); 
++        writeread2a(space) ;
++    }
++
++    @Test public void membuffer_31() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer(2) ;
++        writeread1a(space) ;
++    }
++    
++    @Test public void membuffer_32() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer(2) ;
++        writeread2(space) ;
++    }
++
++    @Test public void membuffer_33() {
++        SegmentedMemBuffer space = new SegmentedMemBuffer(2) ;
++        writeread1a(space) ;
++        space.truncate(0); 
++        writeread2a(space) ;
++    }
++
++    private void writeread1(SegmentedMemBuffer space) {
++        long x = space.length() ;
++        space.write(x, data1) ;
++        assertEquals(x+data1.length, space.length()) ;
++        byte[] bytes2 = new byte[data1.length+10] ;
++        int y = space.read(x, bytes2) ;
++        assertEquals(data1.length, y) ;
++        byte[] bytes3 = Arrays.copyOf(bytes2, y) ;
++        assertArrayEquals(data1, bytes3);
++    }
++    
++    private void writeread2(SegmentedMemBuffer space) {
++        // Offset.
++        space.write(0, data2) ;
++        long x = data2.length ;
++        space.write(x, data1) ;
++        assertEquals(x+data1.length, space.length()) ;
++        byte[] bytes2 = new byte[data1.length+10] ;
++        int y = space.read(x, bytes2) ;
++        assertEquals(data1.length, y) ;
++        byte[] bytes3 = Arrays.copyOf(bytes2, y) ;
++        assertArrayEquals(data1, bytes3);
++    }
++
++    private void writeread1a(SegmentedMemBuffer space) {
++        long x = space.length() ;
++        ByteBuffer bb1 = ByteBuffer.wrap(data1) ;
++        space.write(x, bb1) ;
++        assertEquals(x+data1.length, space.length()) ;
++        ByteBuffer bb2 = ByteBuffer.allocate(data1.length) ;
++        int y = space.read(x, bb2) ;
++        assertEquals(data1.length, y) ;
++        byte[] bytes3 = Arrays.copyOf(bb2.array(), y) ;
++        assertArrayEquals(data1, bytes3);
++    }
++    
++    private void writeread2a(SegmentedMemBuffer space) {
++        // Offset.
++        space.write(0,  ByteBuffer.wrap(data2)) ;
++        long x = data2.length ;
++        ByteBuffer bb1 = ByteBuffer.wrap(data1) ;
++        space.write(x, bb1) ;
++        assertEquals(x+data1.length, space.length()) ;
++        ByteBuffer bb2 = ByteBuffer.allocate(data1.length) ;
++        int y = space.read(x, bb2) ;
++        assertEquals(data1.length, y) ;
++        byte[] bytes3 = Arrays.copyOf(bb2.array(), y) ;
++        assertArrayEquals(data1, bytes3);
++    }
++
++}
++

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/record/TS_Record.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/record/TS_Record.java
index 0000000,0000000..b33eca8
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/record/TS_Record.java
@@@ -1,0 -1,0 +1,34 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.record;
++
++import org.junit.runner.RunWith;
++import org.junit.runners.Suite;
++import org.seaborne.dboe.base.buffer.TestPtrBuffer ;
++import org.seaborne.dboe.base.buffer.TestRecordBuffer ;
++
++@RunWith(Suite.class)
++@Suite.SuiteClasses( {
++    TestRecord.class ,
++    TestPtrBuffer.class ,
++    TestRecordBuffer.class 
++})
++
++
++public class TS_Record
++{}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/record/TestRecord.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/record/TestRecord.java
index 0000000,0000000..a1e14bf
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/record/TestRecord.java
@@@ -1,0 -1,0 +1,77 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.record;
++
++import static org.seaborne.dboe.test.RecordLib.intToRecord ;
++import static org.seaborne.dboe.test.RecordLib.recordToInt ;
++import org.junit.Assert ;
++import org.junit.Test;
++import org.seaborne.dboe.base.record.Record ;
++
++public class TestRecord extends Assert
++{
++    static final public int RecLen = 4 ;
++    
++    @Test public void int1()
++    {
++        Record r = intToRecord(1234, 4) ;
++        int v = recordToInt(r) ;
++        assertEquals(v , 1234) ;
++    }
++    
++    @Test public void int2()
++    {
++        // Negative numbers only work for length 4.
++        Record r = intToRecord(-99, 4) ;
++        int v = recordToInt(r) ;
++        assertEquals(v , -99) ;
++    }
++    
++    @Test public void record1()
++    {
++        Record r1 = intToRecord(1, RecLen) ;
++        Record r2 = intToRecord(1, RecLen) ;
++        assertTrue(Record.keyEQ(r1,r2)) ;
++        assertTrue(Record.keyGE(r1,r2)) ;
++        assertTrue(Record.keyLE(r1,r2)) ;
++        assertFalse(Record.keyLT(r1,r2)) ;
++        assertFalse(Record.keyGT(r1,r2)) ;
++    }
++    
++    @Test public void record2()
++    {
++        Record r1 = intToRecord(1000, RecLen) ;
++        Record r2 = intToRecord(2222, RecLen) ;
++        assertFalse(Record.keyEQ(r1,r2)) ;
++        assertFalse(Record.keyGE(r1,r2)) ;
++        assertTrue(Record.keyLE(r1,r2)) ;
++        assertTrue(Record.keyLT(r1,r2)) ;
++        assertFalse(Record.keyGT(r1,r2)) ;
++    }
++
++    @Test public void record3()
++    {
++        Record r1 = intToRecord(1000, RecLen)  ;
++        Record r2 = intToRecord(0, RecLen) ;
++        assertFalse(Record.keyEQ(r1,r2)) ;
++        assertTrue(Record.keyGE(r1,r2)) ;
++        assertFalse(Record.keyLE(r1,r2)) ;
++        assertFalse(Record.keyLT(r1,r2)) ;
++        assertTrue(Record.keyGT(r1,r2)) ;
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/recordfile/TS_RecordFile.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/recordfile/TS_RecordFile.java
index 0000000,0000000..34821f1
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/recordfile/TS_RecordFile.java
@@@ -1,0 -1,0 +1,31 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.recordfile;
++
++import org.junit.runner.RunWith;
++import org.junit.runners.Suite;
++
++@RunWith(Suite.class)
++@Suite.SuiteClasses( {
++    TestRecordBufferPage.class
++})
++
++public class TS_RecordFile
++{
++
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/recordfile/TestRecordBufferPage.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/recordfile/TestRecordBufferPage.java
index 0000000,0000000..d801e73
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/java/org/seaborne/dboe/base/recordfile/TestRecordBufferPage.java
@@@ -1,0 -1,0 +1,124 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.base.recordfile;
++
++import org.junit.Assert ;
++import org.junit.AfterClass ;
++import org.junit.BeforeClass ;
++import org.junit.Test ;
++import org.seaborne.dboe.base.block.BlockMgr ;
++import org.seaborne.dboe.base.block.BlockMgrFactory ;
++import org.seaborne.dboe.base.buffer.RecordBuffer ;
++import org.seaborne.dboe.base.record.Record ;
++import org.seaborne.dboe.base.record.RecordFactory ;
++import org.seaborne.dboe.base.recordbuffer.RecordBufferPage ;
++import org.seaborne.dboe.base.recordbuffer.RecordBufferPageMgr ;
++import org.seaborne.dboe.sys.SystemIndex ;
++
++public class TestRecordBufferPage extends Assert
++{
++    // Testing: records are 2 bytes, 3 records per block.  
++    
++    static final int TestRecordSize = 2 ;           // Size, in bytes.
++    static final int TestNumRecord  = 3 ;           // Size, in bytes.
++    static RecordFactory factory = new RecordFactory(2, 0) ; 
++    
++    static boolean originalNullOut ; 
++    @BeforeClass static public void beforeClass()
++    {
++        originalNullOut = SystemIndex.getNullOut() ;
++        SystemIndex.setNullOut(true) ;    
++    }
++    
++    @AfterClass static public void afterClass()
++    {
++        SystemIndex.setNullOut(originalNullOut) ;    
++    }
++
++    @Test public void recBufferPage01()
++    {
++        BlockMgr blkMgr = makeBlockMgr() ;
++        blkMgr.beginUpdate() ;
++        RecordBufferPageMgr rpm = new RecordBufferPageMgr(factory, blkMgr) ;
++        RecordBufferPage page = rpm.create() ;
++        fill(page.getRecordBuffer(), 10, 20, 30) ;
++        assertEquals(10, get(page, 0)) ;
++        assertEquals(20, get(page, 1)) ;
++        assertEquals(30, get(page, 2)) ;
++        rpm.release(page) ;
++        blkMgr.endUpdate() ;
++    }
++    
++    @Test public void recBufferPage02()
++    {
++        BlockMgr blkMgr = makeBlockMgr() ;
++        blkMgr.beginUpdate() ;
++        RecordBufferPageMgr rpm = new RecordBufferPageMgr(factory, blkMgr) ;
++        int x = -99 ;
++        {
++            RecordBufferPage page1 = rpm.create() ;
++            fill(page1.getRecordBuffer(), 10, 20, 30) ;
++            x = page1.getId() ;
++            rpm.put(page1) ;
++            page1 = null ;
++        }
++        blkMgr.endUpdate() ;
++        blkMgr.beginRead() ;
++        {
++            RecordBufferPage page2 = rpm.getRead(x) ;
++            assertEquals(10, get(page2, 0)) ;
++            assertEquals(20, get(page2, 1)) ;
++            assertEquals(30, get(page2, 2)) ;
++            rpm.release(page2) ;
++        }
++        blkMgr.endRead() ;
++    }
++
++    
++    private static void fill(RecordBuffer rb, int ... nums)
++    {
++        for ( int num : nums )
++        {
++            Record rec = record( num );
++            rb.add( rec );
++        }
++    }
++    
++    private static int get(RecordBufferPage rbp, int idx) { return get(rbp.getRecordBuffer(), idx) ; } 
++    
++    private static int get(RecordBuffer rb, int idx) 
++    {
++        Record r = rb.get(idx) ;
++        int v = (r.getKey()[0])<<8 | ((r.getKey()[1])&0xFF) ;
++        return v ;
++    }
++    
++    private static Record record(int i)
++    {
++        byte b[] = new byte[]{ 
++            (byte)((i>>8)&0xFF),
++            (byte)(i&0xFF)} ; 
++        Record r = factory.create(b) ;
++        return r ;
++    }
++
++    private static BlockMgr makeBlockMgr()
++    {
++        return BlockMgrFactory.createMem("RecordBuffer", RecordBufferPage.calcBlockSize(factory, TestNumRecord)) ; 
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-base/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --cc jena-db/dboe-base/src/test/resources/log4j.properties
index 0000000,0000000..d6b299a
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-base/src/test/resources/log4j.properties
@@@ -1,0 -1,0 +1,6 @@@
++log4j.rootLogger=INFO, stdlog
++
++log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
++## log4j.appender.stdlog.target=System.err
++log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout
++log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-20c{1} :: %m%n

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/.gitignore
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/.gitignore
index 0000000,0000000..b83d222
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/.gitignore
@@@ -1,0 -1,0 +1,1 @@@
++/target/

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/README.md
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/README.md
index 0000000,0000000..bae93dd
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/README.md
@@@ -1,0 -1,0 +1,1 @@@
++Test support for dboe-index code.

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/pom.xml
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/pom.xml
index 0000000,0000000..b06a773
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/pom.xml
@@@ -1,0 -1,0 +1,54 @@@
++<?xml version="1.0" encoding="utf-8"?>
++<!--
++   Licensed 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.
++ 
++   See the NOTICE file distributed with this work for additional
++   information regarding copyright ownership.
++-->
++
++<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
++  <modelVersion>4.0.0</modelVersion>
++
++  <artifactId>dboe-index-test</artifactId>
++  <packaging>jar</packaging>
++  <name>Mantis (${project.artifactId})</name>
++
++  <parent>
++    <groupId>org.seaborne.mantis</groupId>
++    <artifactId>mantis</artifactId>
++    <version>0.3.1-SNAPSHOT</version>
++  </parent> 
++
++  <dependencies>
++
++    <dependency>
++      <groupId>org.seaborne.mantis</groupId>
++      <artifactId>dboe-index</artifactId>
++      <version>0.3.1-SNAPSHOT</version>
++    </dependency>
++
++    <dependency>
++      <groupId>org.apache.jena</groupId>
++      <artifactId>jena-cmds</artifactId>
++    </dependency>
++
++    <dependency>
++      <!--  Bring junit into scope-compile -->
++      <groupId>junit</groupId>
++      <artifactId>junit</artifactId>
++      <scope>compile</scope>
++    </dependency>
++
++  </dependencies>
++
++</project>

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/TS_Index.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/TS_Index.java
index 0000000,0000000..0fe386d
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/TS_Index.java
@@@ -1,0 -1,0 +1,29 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.index;
++
++import org.junit.runner.RunWith ;
++import org.junit.runners.Suite ;
++
++@RunWith(Suite.class)
++@Suite.SuiteClasses( {
++    TestIndexMem.class
++} )
++
++public class TS_Index
++{ }

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/TestIndexMem.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/TestIndexMem.java
index 0000000,0000000..78f4009
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/TestIndexMem.java
@@@ -1,0 -1,0 +1,34 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.index;
++
++import org.seaborne.dboe.base.record.RecordFactory ;
++import org.seaborne.dboe.index.Index ;
++import org.seaborne.dboe.index.IndexMap ;
++import org.seaborne.dboe.index.test.AbstractTestIndex ;
++
++public class TestIndexMem extends AbstractTestIndex
++{
++    @Override
++    protected Index makeIndex(int kLen, int vLen)
++    {
++        RecordFactory rf = new RecordFactory(kLen, vLen) ;
++        return new IndexMap(rf) ;
++    }
++
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/AbstractTestIndex.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/AbstractTestIndex.java
index 0000000,0000000..75efad7
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/AbstractTestIndex.java
@@@ -1,0 -1,0 +1,159 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.index.test;
++
++import static org.seaborne.dboe.index.test.IndexTestLib.* ;
++import static org.seaborne.dboe.test.RecordLib.intToRecord ;
++import org.junit.Assert ;
++import org.junit.After;
++import org.junit.Test;
++import org.seaborne.dboe.base.record.Record ;
++import org.seaborne.dboe.index.Index ;
++import org.seaborne.dboe.test.RecordLib ;
++
++//import org.apache.jena.tdb.base.record.RecordLib;
++
++public abstract class AbstractTestIndex extends Assert 
++{
++    Index index = null ;
++    
++    @After public void afterTest()
++    { 
++        if ( index != null )
++            index.close();
++        index = null ;
++    }
++    
++    // ---- Overridable maker
++    protected abstract Index makeIndex(int kLen, int vLen) ;
++    
++    @Test public void __basic() {
++        makeIndex(4,0) ;
++    }
++    
++    @Test public void index_ins_0()
++    {
++        // Empty tree
++        int[] keys = {};
++        test(keys) ;
++    }
++    
++    @Test public void index_ins_1()
++    {
++        int[] keys = {1};
++        test(keys) ;
++    }
++    
++    @Test public void index_ins_2()
++    {
++        int[] keys = new int[20] ; 
++        for ( int i = 0 ; i < keys.length ; i++ )
++            keys[i] = i ;
++        test(keys) ;
++    }
++    
++    @Test public void index_ins_3()
++    {
++        int[] keys = new int[20] ; 
++        for ( int i = keys.length-1 ; i >= 0 ; i-- )
++            keys[i] = i ;
++        test(keys) ;
++    }
++
++    @Test public void index_ins_4()
++    {
++        int[] keys = new int[10] ; 
++        for ( int i = 0 ; i < keys.length ; i++ )
++            keys[i] = 1<<i ;
++        test(keys) ;
++    }
++    
++    @Test public void index_ins_5()
++    {
++        int[] keys = new int[10] ; 
++        for ( int i = keys.length-1 ; i >= 0 ; i-- )
++            keys[i] = 1<<i ;
++        test(keys) ;
++    }
++    
++    @Test public void index_find_1()
++    {
++        int[] keys = {1};
++        Index index = test(keys) ;
++        Record r = intToRecord(1, RecordLib.TestRecordLength) ;
++        r = index.find(r) ;
++        assertNotNull(r) ;
++    }
++    
++    @Test public void index_find_2()
++    {
++        int[] keys = {1,2,3,4,5,6,7,8,9};
++        Index index = test(keys) ;
++        Record r = intToRecord(20, RecordLib.TestRecordLength) ;
++        r = index.find(r) ;
++        assertNull(r) ;
++    }
++    
++    @Test public void index_del_1()
++    {
++        int[] keys1 = {0, 1, 2};
++        int[] keys2 = {0, 1, 2};
++        int[] keys3 = {} ;
++        test(keys1, keys2, keys3) ;
++    }
++
++    @Test public void index_del_2()
++    {
++        int[] keys1 = {0, 1, 2};
++        int[] keys2 = {0, 1};
++        int[] keys3 = {2} ;
++        test(keys1, keys2, keys3) ;
++    }
++
++    @Test public void index_del_3()
++    {
++        int[] keys1 = {0, 1, 2};
++        int[] keys2 = {0, 99};
++        int[] keys3 = {2, 1} ;
++        test(keys1, keys2, keys3) ;
++    }
++
++    private Index test(int[] insKeys, int[] delKeys, int[] expected)
++    {
++        index = makeIndex(4,0) ;
++        testInsert(index, insKeys) ;
++        long x = index.size() ;
++        if ( x >= 0 )
++            assertEquals(insKeys.length, x) ;
++        
++        if ( delKeys != null )
++        {
++            testDelete(index, delKeys) ;
++            
++        }
++        
++        if ( expected != null ) 
++            testIndexContents(index, expected) ;
++        return index ;
++    }
++
++    private Index test(int[] keys)
++    {
++        return test(keys, null, keys) ;
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/AbstractTestRangeIndex.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/AbstractTestRangeIndex.java
index 0000000,0000000..ab3f82c
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/AbstractTestRangeIndex.java
@@@ -1,0 -1,0 +1,434 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.index.test ;
++
++import static org.seaborne.dboe.index.test.IndexTestLib.add ;
++import static org.seaborne.dboe.index.test.IndexTestLib.randTest ;
++import static org.seaborne.dboe.index.test.IndexTestLib.testInsert ;
++import static org.seaborne.dboe.index.test.IndexTestLib.testInsertDelete ;
++import static org.seaborne.dboe.test.RecordLib.intToRecord ;
++import static org.seaborne.dboe.test.RecordLib.r ;
++import static org.seaborne.dboe.test.RecordLib.toIntList ;
++
++import java.util.Iterator ;
++import java.util.List ;
++
++import org.junit.Assert ;
++import org.junit.Test ;
++import org.seaborne.dboe.base.record.Record ;
++import org.seaborne.dboe.index.RangeIndex ;
++
++public abstract class AbstractTestRangeIndex extends Assert {
++    // ---- Overridable maker
++    protected RangeIndex makeRangeIndex(int order) {
++        return makeRangeIndex(order, order) ;
++    }
++
++    protected abstract RangeIndex makeRangeIndex(int order, int minRecords) ;
++
++    @Test public void __basic() {
++         makeRangeIndex(4,0) ;
++    }
++    
++    @Test
++    public void tree_ins_0_0() {
++        // Empty tree
++        int[] keys = {} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsert(rIndex, keys) ;
++        assertTrue(rIndex.isEmpty()) ;
++        assertNull(rIndex.minKey()) ;
++        assertNull(rIndex.maxKey()) ;
++    }
++
++    @Test
++    public void tree_ins_0_1() {
++        int[] keys = {0, 1, 2} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsert(rIndex, keys) ;
++        assertFalse(rIndex.isEmpty()) ;
++        assertEquals(0, r(rIndex.minKey())) ;
++        assertEquals(2, r(rIndex.maxKey())) ;
++    }
++
++    @Test
++    public void tree_ins_2_01() {
++        int[] keys = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsert(rIndex, keys) ;
++        assertEquals(0, r(rIndex.minKey())) ;
++        assertEquals(9, r(rIndex.maxKey())) ;
++    }
++
++    @Test
++    public void tree_ins_2_02() {
++        int[] keys = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsert(rIndex, keys) ;
++        assertEquals(0, r(rIndex.minKey())) ;
++        assertEquals(9, r(rIndex.maxKey())) ;
++    }
++
++    @Test
++    public void tree_ins_2_03() {
++        int[] keys = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsert(rIndex, keys) ;
++        assertEquals(0, r(rIndex.minKey())) ;
++        assertEquals(9, r(rIndex.maxKey())) ;
++    }
++
++    @Test
++    public void tree_ins_2_04() {
++        int[] keys = {0, 9, 2, 7, 4, 5, 6, 3, 8, 1} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsert(rIndex, keys) ;
++        assertEquals(0, r(rIndex.minKey())) ;
++        assertEquals(9, r(rIndex.maxKey())) ;
++    }
++
++    @Test
++    public void tree_ins_2_05() {
++        int[] keys = {0, 18, 4, 14, 8, 10, 12, 6, 16, 2} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsert(rIndex, keys) ;
++        assertFalse(rIndex.contains(r(1))) ;
++        assertFalse(rIndex.contains(r(999))) ;
++        assertFalse(rIndex.contains(r(-9))) ;
++        assertFalse(rIndex.contains(r(7))) ;
++        assertEquals(0, r(rIndex.minKey())) ;
++        assertEquals(18, r(rIndex.maxKey())) ;
++    }
++
++    @Test
++    public void tree_del_0_1() {
++        int[] keys1 = {0, 1, 2} ;
++        int[] keys2 = {0, 1, 2} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_0_2() {
++        int[] keys1 = {0, 1, 2} ;
++        int[] keys2 = {2, 1, 0} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_0_3() {
++        int[] keys1 = {0, 1, 2} ;
++        int[] keys2 = {1, 0, 2} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_01() {
++        int[] keys1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        int[] keys2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_02() {
++        int[] keys1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        int[] keys2 = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_03() {
++        int[] keys1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        int[] keys2 = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_04() {
++        int[] keys1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        int[] keys2 = {0, 9, 2, 7, 4, 5, 6, 3, 8, 1} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_05() {
++        int[] keys1 = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} ;
++        int[] keys2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_06() {
++        int[] keys1 = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} ;
++        int[] keys2 = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_07() {
++        int[] keys1 = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} ;
++        int[] keys2 = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_08() {
++        int[] keys1 = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} ;
++        int[] keys2 = {0, 9, 2, 7, 4, 5, 6, 3, 8, 1} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_09() {
++        int[] keys1 = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        int[] keys2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_10() {
++        int[] keys1 = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        int[] keys2 = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_11() {
++        int[] keys1 = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        int[] keys2 = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_del_2_12() {
++        int[] keys1 = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        int[] keys2 = {0, 9, 2, 7, 4, 5, 6, 3, 8, 1} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        testInsertDelete(rIndex, keys1, keys2) ;
++    }
++
++    @Test
++    public void tree_iter_2_01() {
++        int[] keys = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(r(4), r(6))) ;
++        List<Integer> expected = toIntList(4, 5) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_2_02() {
++        int[] keys = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(r(4), r(7))) ;
++        List<Integer> expected = toIntList(4, 5, 6) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_2_03() {
++        int[] keys = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(r(4), null)) ;
++        List<Integer> expected = toIntList(4, 5, 6, 7, 8, 9) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_2_04() {
++        int[] keys = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(null, null)) ;
++        List<Integer> expected = toIntList(keys) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_2_05() {
++        int[] keys = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(null, r(4))) ;
++        List<Integer> expected = toIntList(0, 1, 2, 3) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_2_07() {
++        int[] keys = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(null, r(99))) ;
++        List<Integer> expected = toIntList(keys) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_2_08() {
++        int[] keys = {1, 2, 3, 4, 5, 6, 7, 8, 9} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(r(0), r(99))) ;
++        List<Integer> expected = toIntList(keys) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_2_09() {
++        int[] keys = {1, 2, 3, 4, /* 5, 6, */7, 8, 9, 10, 11} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(r(5), r(7))) ;
++        List<Integer> expected = toIntList() ;
++        assertEquals(expected, x) ;
++    }
++
++    // Root
++    @Test
++    public void tree_iter_0_01() {
++        int[] keys = {1, 2, 3, 4, 5} ;
++        RangeIndex rIndex = makeRangeIndex(5) ;
++        add(rIndex, keys) ;
++        Iterator<Record> iter = rIndex.iterator(r(2), r(4)) ;
++        while ( iter.hasNext() ) 
++            iter.next() ;
++        
++        List<Integer> x = toIntList(rIndex.iterator(r(2), r(4))) ;
++        List<Integer> expected = toIntList(2, 3) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_0_02() {
++        int[] keys = {1, 2, 3, 4, 5} ;
++        RangeIndex rIndex = makeRangeIndex(5) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(null, null)) ;
++        List<Integer> expected = toIntList(keys) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_0_03() {
++        int[] keys = {1, 2, 3, 4, 5} ;
++        RangeIndex rIndex = makeRangeIndex(5) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(r(5), null)) ;
++        List<Integer> expected = toIntList(5) ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_0_04() {
++        int[] keys = {1, 2, 3, 4, 5} ;
++        RangeIndex rIndex = makeRangeIndex(5) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(r(0), r(0))) ;
++        List<Integer> expected = toIntList() ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_iter_0_05() {
++        int[] keys = {1, 2, 3, 4, 5} ;
++        RangeIndex rIndex = makeRangeIndex(5) ;
++        add(rIndex, keys) ;
++        List<Integer> x = toIntList(rIndex.iterator(r(1), r(0))) ;
++        List<Integer> expected = toIntList() ;
++        assertEquals(expected, x) ;
++    }
++
++    @Test
++    public void tree_ret_1() {
++        int[] keys = {1, 2, 3, 4, 5} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        boolean b = rIndex.insert(intToRecord(3)) ;
++        assertFalse(b) ;
++        b = rIndex.insert(intToRecord(9)) ;
++        assertTrue(b) ;
++    }
++
++    @Test
++    public void tree_ret_2() {
++        int[] keys = {1, 2, 3, 4, 5} ;
++        RangeIndex rIndex = makeRangeIndex(2) ;
++        add(rIndex, keys) ;
++        boolean b = rIndex.delete(intToRecord(9)) ;
++        assertFalse(b) ;
++        b = rIndex.insert(intToRecord(1)) ;
++        assertFalse(b) ;
++    }
++
++    @Test
++    public void tree_2_N() {
++        for ( int i = 0 ; i < 10 ; i++ )
++            randTest(makeRangeIndex(2), 999, 20) ;
++    }
++
++    @Test
++    public void tree_3_N() {
++        for ( int i = 0 ; i < 10 ; i++ )
++            randTest(makeRangeIndex(3), 9999, 100) ;
++    }
++
++    @Test public void tree_clear_00()   { testClear(0) ; }
++
++    @Test public void tree_clear_01()   { testClear(5) ; }
++
++    @Test public void tree_clear_02()   { testClear(15) ; }
++
++    @Test public void tree_clear_03()   { testClear(998) ; }
++
++    @Test public void tree_clear_04()   { testClear(999) ; }
++
++    @Test public void tree_clear_05()   { testClear(1000) ; }
++    
++    @Test public void tree_clear_06()   { testClear(1001) ; }
++    
++    @Test public void tree_clear_07()   { testClear(5500) ; }
++
++    protected void testClear(int N) {
++        int[] keys = new int[N] ; // Slice is 1000.
++        for ( int i = 0 ; i < keys.length ; i++ )
++            keys[i] = i ;
++        RangeIndex rIndex = makeRangeIndex(3) ;
++        add(rIndex, keys) ;
++        if ( N > 0 )
++            assertFalse(rIndex.isEmpty()) ;
++        rIndex.clear() ;
++        assertTrue(rIndex.isEmpty()) ;
++    }
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/BaseSoakTest.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/BaseSoakTest.java
index 0000000,0000000..bd5ddf6
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/BaseSoakTest.java
@@@ -1,0 -1,0 +1,140 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.index.test;
++
++import java.util.List ;
++
++import jena.cmd.CmdException ;
++import jena.cmd.CmdGeneral ;
++
++import org.apache.jena.atlas.lib.Lib ;
++import org.apache.jena.atlas.lib.RandomLib ;
++import org.apache.jena.atlas.logging.LogCtl ;
++
++public abstract class BaseSoakTest extends CmdGeneral {
++    static { LogCtl.setLog4j() ; }
++
++    protected final int MinOrder = 2 ;
++    protected final int MinSize  = 1 ;
++    protected int       MaxOrder = -1 ;
++    protected int       MaxSize  = -1 ;
++    protected int       NumTest  = -1 ;
++    
++    protected BaseSoakTest(String[] argv) {
++        super(argv) ;
++    }
++
++    protected abstract void before() ;
++    protected abstract void after() ;
++
++    @Override
++    protected String getSummary() {
++        return "Usage: "+Lib.className(this)+" maxOrder maxSize NumTests" ;
++    }
++
++    @Override
++    protected void processModulesAndArgs() {
++        List<String> args = super.getPositional() ;
++        if ( args.size() != 3 )
++            throw new CmdException("Usage: maxOrder maxSize NumTests") ;
++        
++        try { MaxOrder = Integer.parseInt(args.get(0)) ; }
++        catch (NumberFormatException ex)
++        { throw new CmdException("Bad number for MaxOrder") ; }
++
++        try { MaxSize = Integer.parseInt(args.get(1)) ; }
++        catch (NumberFormatException ex)
++        { throw new CmdException("Bad number for MaxSize") ; }
++
++        try { NumTest = Integer.parseInt(args.get(2)) ; }
++        catch (NumberFormatException ex)
++        { throw new CmdException("Bad number for NumTest") ; }
++    }
++
++    @Override
++    protected void exec() {
++        int successes   = 0 ;
++        int failures    = 0 ;
++
++        // Number of dots.
++        int numOnLine = 50 ;
++        int testsPerTick ;
++        if ( NumTest < 20 )
++            testsPerTick = 5 ;
++        else if ( NumTest < 200 )
++            testsPerTick = 50 ;
++        else 
++            testsPerTick = 500 ;
++        
++        
++        // ---- Format for line counter.
++        int numLines = (int)Math.ceil( ((double)NumTest) / (testsPerTick * numOnLine) ) ;
++        // Start of last line.
++        int z = (numLines-1)*(testsPerTick * numOnLine) ;
++        int digits = 1 ;
++        if ( z > 0 )
++            digits = 1+(int)Math.floor(Math.log10(z));
++        String format = "[%"+digits+"d] " ;
++
++        System.out.printf("TEST : %,d tests : Max Order=%d  Max Items=%,d [tests per tick=%d]\n", NumTest, MaxOrder, MaxSize, testsPerTick) ;
++        
++        before() ;
++        
++        int testCount = 1 ;
++        
++        for ( testCount = 1 ; testCount <= NumTest ; testCount++ ) {
++            if ( testCount % testsPerTick == 0 )
++                System.out.print(".") ;
++            if ( testCount % (testsPerTick * numOnLine) == 0 )
++                System.out.println("") ;
++            if ( testCount % (testsPerTick * numOnLine) == 1 )
++                System.out.printf(format, testCount-1) ;
++
++            int idx = testCount - 1 ;
++            int order = ( MinOrder == MaxOrder ) ? MinOrder : MinOrder + RandomLib.random.nextInt(MaxOrder-MinOrder) ;
++            int size =  ( MinSize  == MaxSize  ) ? MinSize :  MinSize  + RandomLib.random.nextInt(MaxSize-MinSize) ;            try {
++                //System.out.printf("TEST : %,d : Order=%-2d : Size=%d\n", testCount, order, size) ;
++                runOneTest(testCount, order, size) ;
++                successes++ ;
++            }
++            catch (AssertionError | RuntimeException ex) {
++                System.err.printf("-- Fail: (order=%d, size=%d)\n", order, size) ;
++                ex.printStackTrace(System.err) ;
++                System.err.printf("--------------------------\n") ;
++                failures++ ;
++            }
++        }
++        
++        // Did the last loop print a new line?
++        if ( (testCount-1) % (testsPerTick*numOnLine) != 0 )
++            System.out.println();
++            
++        after() ;
++        System.err.flush() ;
++        System.out.flush() ;
++        System.out.printf("DONE : %,d tests : Success=%,d ; Failures=%,d\n", NumTest, successes, failures);
++    }
++
++    protected abstract void runOneTest(int testCount, int order, int size, boolean debug) ;
++
++    protected abstract void runOneTest(int testCount, int order, int size) ;
++
++    @Override
++    protected String getCommandName() { return Lib.className(this) ; } 
++}
++

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/IndexMaker.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/IndexMaker.java
index 0000000,0000000..317639a
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/IndexMaker.java
@@@ -1,0 -1,0 +1,26 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.index.test;
++
++import org.seaborne.dboe.index.Index ;
++
++public interface IndexMaker
++{
++    Index makeIndex() ;
++    String getLabel() ;
++}

http://git-wip-us.apache.org/repos/asf/jena/blob/d9da3592/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/IndexTestGenerator.java
----------------------------------------------------------------------
diff --cc jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/IndexTestGenerator.java
index 0000000,0000000..65b3412
new file mode 100644
--- /dev/null
+++ b/jena-db/dboe-index-test/src/main/java/org/seaborne/dboe/index/test/IndexTestGenerator.java
@@@ -1,0 -1,0 +1,44 @@@
++/*
++ *  Licensed 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.
++ *
++ *  See the NOTICE file distributed with this work for additional
++ *  information regarding copyright ownership.
++ */
++
++package org.seaborne.dboe.index.test;
++
++import org.apache.jena.atlas.lib.RandomLib ;
++import org.apache.jena.atlas.test.ExecGenerator ;
++
++public class IndexTestGenerator implements ExecGenerator
++{
++    int maxNumKeys ;
++    int maxValue ;
++    IndexMaker maker ;
++    
++    public IndexTestGenerator(IndexMaker maker, int maxValue, int maxNumKeys)
++    {
++        if ( maxValue <= maxNumKeys )
++            throw new IllegalArgumentException("RangeIndexTestGenerator: Max value less than number of keys") ;
++        this.maker = maker ;
++        this.maxValue = maxValue ; 
++        this.maxNumKeys = maxNumKeys ;
++    }
++    
++    @Override
++    public void executeOneTest()
++    {
++        int numKeys = RandomLib.random.nextInt(maxNumKeys)+1 ;
++        IndexTestLib.randTest(maker.makeIndex(), maxValue, numKeys) ;
++    }
++}