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/10/03 19:34:25 UTC
[39/65] [abbrv] jena git commit: JENA-1397: Rename java packages
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBinaryDataFile.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBinaryDataFile.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBinaryDataFile.java
new file mode 100644
index 0000000..c5a9af8
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBinaryDataFile.java
@@ -0,0 +1,85 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.atlas.lib.StrUtils ;
+import org.apache.jena.dboe.base.file.BinaryDataFile;
+import org.junit.After ;
+import org.junit.Before ;
+import org.junit.Test ;
+
+import static org.junit.Assert.* ;
+
+public abstract class AbstractTestBinaryDataFile {
+ private BinaryDataFile file ;
+ protected abstract BinaryDataFile createBinaryDataFile() ;
+
+ static final String stringData = "Hello world\n";
+ static final byte[] data = StrUtils.asUTF8bytes(stringData) ;
+
+ // Default action.
+ protected void releaseBinaryDataFile(BinaryDataFile file) {
+ file.close() ;
+ }
+
+ @Before public void before() {
+ file = createBinaryDataFile() ;
+ file.open();
+ file.truncate(0) ;
+ }
+
+ @After public void after() {
+ releaseBinaryDataFile(file) ;
+ }
+
+ @Test public void basic_open() {
+ assertTrue(file.isOpen()) ;
+ }
+
+ @Test public void basic_open_close() {
+ assertTrue(file.isOpen()) ;
+ file.close() ;
+ assertFalse(file.isOpen()) ;
+ }
+
+ @Test public void writeread_01() {
+ assertEquals(0, file.length()) ;
+ }
+
+ @Test public void writeread_02() {
+ assertEquals(0, file.length()) ;
+ file.write(data);
+ assertNotEquals(0, file.length()) ;
+ assertEquals(data.length, file.length()) ;
+ }
+
+ @Test public void writeread_03() {
+ long x = file.write(data);
+ byte[] data2 = new byte[data.length+100] ;
+ int x1 = file.read(x, data2) ;
+ assertEquals(data.length, x1) ;
+ int x2 = file.read(data.length, data2) ;
+ assertEquals(-1, x2) ;
+ }
+
+
+
+}
+
+
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBlockAccessFixedSize.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBlockAccessFixedSize.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBlockAccessFixedSize.java
new file mode 100644
index 0000000..20a97d5
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBlockAccessFixedSize.java
@@ -0,0 +1,104 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.junit.Assert ;
+
+import static org.apache.jena.dboe.test.BufferTestLib.sameValue;
+
+import org.apache.jena.dboe.base.block.Block;
+import org.apache.jena.dboe.base.file.BlockAccess;
+import org.apache.jena.dboe.base.file.FileException;
+import org.junit.After ;
+import org.junit.Before ;
+import org.junit.Test ;
+
+public abstract class AbstractTestBlockAccessFixedSize extends Assert
+{
+ // Fixed block tests.
+
+ int blkSize ;
+
+ protected AbstractTestBlockAccessFixedSize(int blkSize)
+ {
+ this.blkSize = blkSize ;
+ }
+
+ protected abstract BlockAccess make() ;
+ protected static Block data(BlockAccess file, int len)
+ {
+ Block b = file.allocate(len) ;
+ for (int i = 0 ; i < len ; i++ )
+ b.getByteBuffer().put((byte)(i&0xFF)) ;
+ return b ;
+ }
+
+ private BlockAccess file ;
+ @Before public void before() { file = make() ; }
+ @After public void after() { file.close() ; }
+
+ @Test public void fileaccess_01()
+ {
+ assertTrue(file.isEmpty()) ;
+ }
+
+ @Test public void fileaccess_02()
+ {
+ Block b = data(file, blkSize) ;
+ file.write(b) ;
+ }
+
+ @Test public void fileaccess_03()
+ {
+ Block b1 = data(file, blkSize) ;
+ file.write(b1) ;
+ long x = b1.getId() ;
+ Block b9 = file.read(x) ;
+ assertNotSame(b1, b9) ;
+ assertTrue(sameValue(b1, b9)) ;
+ b9 = file.read(x) ;
+ assertNotSame(b1, b9) ;
+ assertTrue(sameValue(b1, b9)) ;
+ }
+
+ @Test public void fileaccess_04()
+ {
+ Block b1 = data(file, blkSize) ;
+ Block b2 = data(file, blkSize) ;
+ file.write(b1) ;
+ file.write(b2) ;
+
+ long x = b1.getId() ;
+ Block b8 = file.read(b1.getId()) ;
+ Block b9 = file.read(b1.getId()) ;
+ assertNotSame(b8, b9) ;
+ assertTrue(b8.getId() == b9.getId()) ;
+ }
+
+ @Test(expected=FileException.class)
+ public void fileaccess_05()
+ {
+ Block b1 = data(file, 10) ;
+ Block b2 = data(file, 20) ;
+ file.write(b1) ;
+
+ // Should not work. b2 not written.
+ Block b2a = file.read(b2.getId()) ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBlockAccessVarSize.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBlockAccessVarSize.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBlockAccessVarSize.java
new file mode 100644
index 0000000..076a69b
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestBlockAccessVarSize.java
@@ -0,0 +1,51 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import static org.apache.jena.dboe.test.BufferTestLib.*;
+
+import org.apache.jena.dboe.base.block.Block;
+import org.apache.jena.dboe.base.file.BlockAccess;
+import org.junit.Test ;
+
+public abstract class AbstractTestBlockAccessVarSize extends AbstractTestBlockAccessFixedSize
+{
+ protected AbstractTestBlockAccessVarSize()
+ {
+ super(25) ;
+ }
+
+ @Test
+ public void fileaccess_50()
+ {
+ BlockAccess file = make() ;
+ Block b1 = data(file, 10) ;
+ Block b2 = data(file, 20) ;
+ file.write(b1) ;
+ file.write(b2) ;
+
+ Block b1a = file.read(b1.getId()) ;
+ Block b2a = file.read(b2.getId()) ;
+
+ assertNotSame(b1a, b1) ;
+ assertNotSame(b2a, b2) ;
+ sameValue(b1, b1a) ;
+ sameValue(b2, b2a) ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestChannel.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestChannel.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestChannel.java
new file mode 100644
index 0000000..b987952
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/AbstractTestChannel.java
@@ -0,0 +1,145 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import java.nio.ByteBuffer ;
+
+import org.junit.Assert ;
+import org.apache.jena.dboe.base.file.BufferChannel;
+import org.junit.After ;
+import org.junit.Before ;
+import org.junit.Test ;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TS_File.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TS_File.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TS_File.java
new file mode 100644
index 0000000..4022be7
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TS_File.java
@@ -0,0 +1,49 @@
+/*
+ * 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.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataFileWriteBufferedFile.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataFileWriteBufferedFile.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataFileWriteBufferedFile.java
new file mode 100644
index 0000000..5580414
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataFileWriteBufferedFile.java
@@ -0,0 +1,36 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.dboe.base.file.BinaryDataFile;
+import org.apache.jena.dboe.base.file.BinaryDataFileRandomAccess;
+import org.apache.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataFileWriteBufferedMem.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataFileWriteBufferedMem.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataFileWriteBufferedMem.java
new file mode 100644
index 0000000..418cf9f
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataFileWriteBufferedMem.java
@@ -0,0 +1,32 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.dboe.base.file.BinaryDataFile;
+import org.apache.jena.dboe.base.file.BinaryDataFileMem;
+import org.apache.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataMem.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataMem.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataMem.java
new file mode 100644
index 0000000..2f344c8
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataMem.java
@@ -0,0 +1,32 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.dboe.base.file.BinaryDataFile;
+import org.apache.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataRAF.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataRAF.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataRAF.java
new file mode 100644
index 0000000..4ead628
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataRAF.java
@@ -0,0 +1,34 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.dboe.base.file.BinaryDataFile;
+import org.apache.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataRAFInitial.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataRAFInitial.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataRAFInitial.java
new file mode 100644
index 0000000..1dca8a2
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBinaryDataRAFInitial.java
@@ -0,0 +1,59 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.atlas.RuntimeIOException ;
+import org.apache.jena.dboe.base.file.BinaryDataFileRandomAccess;
+import org.junit.Test ;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessByteArray.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessByteArray.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessByteArray.java
new file mode 100644
index 0000000..0bf23ed
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessByteArray.java
@@ -0,0 +1,33 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.dboe.base.file.BlockAccess;
+import org.apache.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessDirect.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessDirect.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessDirect.java
new file mode 100644
index 0000000..41310b5
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessDirect.java
@@ -0,0 +1,45 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.dboe.ConfigTestDBOE;
+import org.apache.jena.dboe.base.file.BlockAccess;
+import org.apache.jena.dboe.base.file.BlockAccessDirect;
+import org.junit.AfterClass ;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessMapped.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessMapped.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessMapped.java
new file mode 100644
index 0000000..b4d5e29
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessMapped.java
@@ -0,0 +1,49 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.dboe.ConfigTestDBOE;
+import org.apache.jena.dboe.base.file.BlockAccess;
+import org.apache.jena.dboe.base.file.BlockAccessMapped;
+import org.junit.AfterClass ;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessMem.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessMem.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessMem.java
new file mode 100644
index 0000000..6e3c29a
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestBlockAccessMem.java
@@ -0,0 +1,38 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.dboe.base.file.BlockAccess;
+import org.apache.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestChannelFile.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestChannelFile.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestChannelFile.java
new file mode 100644
index 0000000..a83d113
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestChannelFile.java
@@ -0,0 +1,39 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.dboe.ConfigTestDBOE;
+import org.apache.jena.dboe.base.file.BufferChannel;
+import org.apache.jena.dboe.base.file.BufferChannelFile;
+import org.junit.AfterClass ;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestChannelMem.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestChannelMem.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestChannelMem.java
new file mode 100644
index 0000000..edca957
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestChannelMem.java
@@ -0,0 +1,35 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import org.apache.jena.dboe.base.file.BufferChannel;
+import org.apache.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestMetaFile.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestMetaFile.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestMetaFile.java
new file mode 100644
index 0000000..f51a55f
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestMetaFile.java
@@ -0,0 +1,75 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import java.io.File ;
+
+import org.junit.Assert ;
+import org.apache.jena.dboe.ConfigTestDBOE;
+import org.apache.jena.dboe.base.file.MetaFile;
+import org.apache.jena.dboe.sys.Names;
+import org.junit.After ;
+import org.junit.Before ;
+import org.junit.Test ;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java
new file mode 100644
index 0000000..9c72c71
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestProcessFileLock.java
@@ -0,0 +1,108 @@
+/*
+ * 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.jena.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.apache.jena.dboe.base.file.AlreadyLocked;
+import org.apache.jena.dboe.base.file.ProcessFileLock;
+import org.apache.jena.dboe.sys.Names;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestSegmentedMemBuffer.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestSegmentedMemBuffer.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestSegmentedMemBuffer.java
new file mode 100644
index 0000000..16dc8ce
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/file/TestSegmentedMemBuffer.java
@@ -0,0 +1,160 @@
+/*
+ * 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.jena.dboe.base.file;
+
+import java.nio.ByteBuffer ;
+import java.util.Arrays ;
+
+import org.apache.jena.dboe.base.file.SegmentedMemBuffer;
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/record/TS_Record.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/record/TS_Record.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/record/TS_Record.java
new file mode 100644
index 0000000..8ce1a2d
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/record/TS_Record.java
@@ -0,0 +1,35 @@
+/*
+ * 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.jena.dboe.base.record;
+
+import org.apache.jena.dboe.base.buffer.TestPtrBuffer;
+import org.apache.jena.dboe.base.buffer.TestRecordBuffer;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/record/TestRecord.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/record/TestRecord.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/record/TestRecord.java
new file mode 100644
index 0000000..1f1fa40
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/record/TestRecord.java
@@ -0,0 +1,79 @@
+/*
+ * 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.jena.dboe.base.record;
+
+import static org.apache.jena.dboe.test.RecordLib.intToRecord;
+import static org.apache.jena.dboe.test.RecordLib.recordToInt;
+
+import org.apache.jena.dboe.base.record.Record;
+import org.junit.Assert ;
+import org.junit.Test;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/recordfile/TS_RecordFile.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/recordfile/TS_RecordFile.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/recordfile/TS_RecordFile.java
new file mode 100644
index 0000000..c949b98
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/recordfile/TS_RecordFile.java
@@ -0,0 +1,32 @@
+/*
+ * 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.jena.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/3d456654/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/recordfile/TestRecordBufferPage.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/recordfile/TestRecordBufferPage.java b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/recordfile/TestRecordBufferPage.java
new file mode 100644
index 0000000..0a6e769
--- /dev/null
+++ b/jena-db/jena-dboe-base/src/test/java/org/apache/jena/dboe/base/recordfile/TestRecordBufferPage.java
@@ -0,0 +1,125 @@
+/*
+ * 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.jena.dboe.base.recordfile;
+
+import org.junit.Assert ;
+import org.apache.jena.dboe.base.block.BlockMgr;
+import org.apache.jena.dboe.base.block.BlockMgrFactory;
+import org.apache.jena.dboe.base.buffer.RecordBuffer;
+import org.apache.jena.dboe.base.record.Record;
+import org.apache.jena.dboe.base.record.RecordFactory;
+import org.apache.jena.dboe.base.recordbuffer.RecordBufferPage;
+import org.apache.jena.dboe.base.recordbuffer.RecordBufferPageMgr;
+import org.apache.jena.dboe.sys.SystemIndex;
+import org.junit.AfterClass ;
+import org.junit.BeforeClass ;
+import org.junit.Test ;
+
+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/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/ConfigTestDBOE.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/ConfigTestDBOE.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/ConfigTestDBOE.java
deleted file mode 100644
index 2e7fb81..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/ConfigTestDBOE.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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;
-
-import org.apache.jena.atlas.lib.FileOps ;
-import org.seaborne.dboe.sys.Sys ;
-
-public class ConfigTestDBOE
-{
- private static String testingDataRoot = "testing" ;
- // Place under target
- private static final String testingDir = "target/dboe-testing" ;
- static boolean nonDeleteableMMapFiles = Sys.isWindows ;
-
- static boolean initialized = false ;
-
- private static void init()
- {
- FileOps.ensureDir("target") ;
- FileOps.ensureDir(testingDir) ;
- initialized = true ;
- }
-
- private static int count = 0 ;
-
- public static void setTestingDataRoot(String dir) { testingDataRoot = dir ; }
- public static String getTestingDataRoot() { return testingDataRoot ; }
-
- /** return a directory */
- public static final String getCleanDir() {
- init() ;
- String dir = nonDeleteableMMapFiles ? getTestingDirUnique() : getTestingDir() ;
- FileOps.ensureDir(dir);
- FileOps.clearDirectory(dir) ;
- return dir ;
- }
- /** Get a empty directory name that has not been used before in this JVM */
-
- private static final String getTestingDirUnique()
- {
- init() ;
- String dn = testingDir+"/D-"+(++count) ;
- FileOps.ensureDir(dn) ;
- FileOps.clearDirectory(dn) ;
- return dn ;
- }
-
- public static final String getTestingDir()
- {
- init() ;
- return testingDir ;
- }
-
- public static final void deleteTestingDir()
- {
- if ( ! FileOps.exists(testingDir) )
- return ;
- FileOps.clearDirectory(testingDir) ;
- FileOps.deleteSilent(testingDir) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/TC_DBOE_IO.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/TC_DBOE_IO.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/TC_DBOE_IO.java
deleted file mode 100644
index 6a8bd21..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/TC_DBOE_IO.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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;
-
-import org.apache.log4j.Level ;
-import org.apache.log4j.Logger ;
-import org.junit.AfterClass ;
-import org.junit.BeforeClass ;
-import org.junit.runner.RunWith ;
-import org.junit.runners.Suite ;
-import org.seaborne.dboe.base.block.FileMode ;
-import org.seaborne.dboe.base.block.TS_Block ;
-import org.seaborne.dboe.base.buffer.TS_Buffer ;
-import org.seaborne.dboe.base.file.TS_File ;
-import org.seaborne.dboe.base.record.TS_Record ;
-import org.seaborne.dboe.base.recordfile.TS_RecordFile ;
-import org.seaborne.dboe.sys.SystemIndex ;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {
- TS_Block.class
- , TS_File.class
- , TS_Buffer.class
- , TS_Record.class
- , TS_RecordFile.class
-} )
-
-public class TC_DBOE_IO {
- static {
- if ( false )
- SystemIndex.setFileMode(FileMode.direct) ;
- }
-
- @BeforeClass static public void beforeClass()
- {
- //org.apache.log4j.LogManager.resetConfiguration() ;
- //org.apache.log4j.PropertyConfigurator.configure("log4j.properties") ;
- Logger.getLogger("org.apache.jena.tdb.info").setLevel(Level.WARN) ;
- //Logger.getLogger("com.hp.hpl.jena.tdb.exec").setLevel(Level.WARN) ;
- }
-
- @AfterClass static public void afterClass() {
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/AbstractTestBlockMgr.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/AbstractTestBlockMgr.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/AbstractTestBlockMgr.java
deleted file mode 100644
index 5b2f6fb..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/AbstractTestBlockMgr.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.block ;
-
-import java.nio.ByteBuffer ;
-
-import static org.apache.jena.atlas.lib.ByteBufferLib.fill ;
-import org.junit.Assert ;
-import org.junit.After ;
-import org.junit.Before ;
-import org.junit.Test ;
-import org.seaborne.dboe.base.block.Block ;
-import org.seaborne.dboe.base.block.BlockMgr ;
-
-public abstract class AbstractTestBlockMgr extends Assert {
- static final public int BlkSize = 256 ;
-
- protected BlockMgr blockMgr = null ;
-
- @Before
- public void before() {
- blockMgr = make() ;
- blockMgr.beginUpdate() ;
- }
-
- @After
- public void after() {
- if ( blockMgr != null ) {
- blockMgr.endUpdate() ;
- blockMgr.close() ;
- }
- }
-
- @Test
- public void file01() {
- long x = blockMgr.allocLimit() ;
- assertTrue("First allocLimit : " + x, x >= 0) ;
- // Assume no recycling.
- Block block = blockMgr.allocate(BlkSize) ;
- assertTrue("Block inside allocate boundary", block.getId() >= x) ;
- ByteBuffer bb = block.getByteBuffer() ;
- fill(bb, (byte)1) ;
- blockMgr.write(block) ;
- blockMgr.release(block) ;
- }
-
- @Test
- public void file02() {
- Block block = blockMgr.allocate(BlkSize) ;
- ByteBuffer bb = block.getByteBuffer() ;
- fill(bb, (byte)1) ;
- long id = block.getId() ;
- blockMgr.write(block) ;
- blockMgr.release(block) ;
-
- Block block2 = blockMgr.getRead(id) ;
- ByteBuffer bb2 = block2.getByteBuffer() ;
- assertEquals(bb2.capacity(), BlkSize) ;
- assertEquals(bb2.get(0), (byte)1) ;
- assertEquals(bb2.get(BlkSize - 1), (byte)1) ;
- blockMgr.release(block2) ;
- }
-
- @Test
- public void file03() {
- Block block = blockMgr.allocate(BlkSize) ;
- ByteBuffer bb = block.getByteBuffer() ;
- fill(bb, (byte)2) ;
- long id = block.getId() ;
- blockMgr.write(block) ;
- blockMgr.release(block) ;
-
- Block block2 = blockMgr.getRead(id) ;
- ByteBuffer bb2 = block2.getByteBuffer() ;
- assertEquals(bb2.capacity(), BlkSize) ;
- assertEquals(bb2.get(0), (byte)2) ;
- assertEquals(bb2.get(BlkSize - 1), (byte)2) ;
- blockMgr.release(block2) ;
- }
-
- @Test
- public void multiAccess01() {
- Block block1 = blockMgr.allocate(BlkSize) ;
- Block block2 = blockMgr.allocate(BlkSize) ;
- long id1 = block1.getId() ;
- long id2 = block2.getId() ;
-
- ByteBuffer bb1 = block1.getByteBuffer() ;
- ByteBuffer bb2 = block2.getByteBuffer() ;
-
- fill(bb1, (byte)1) ;
- fill(bb2, (byte)2) ;
-
- blockMgr.write(block1) ;
- blockMgr.write(block2) ;
- blockMgr.release(block1) ;
- blockMgr.release(block2) ;
-
- Block block3 = blockMgr.getRead(id1) ;
- Block block4 = blockMgr.getRead(id2) ;
-
- ByteBuffer bb_1 = block3.getByteBuffer() ;
- ByteBuffer bb_2 = block4.getByteBuffer() ;
-
- contains(bb_1, (byte)1) ;
- contains(bb_2, (byte)2) ;
-
- blockMgr.release(block3) ;
- blockMgr.release(block4) ;
- }
-
- protected abstract BlockMgr make() ;
-
- protected static void contains(ByteBuffer bb, byte fillValue) {
- for ( int i = 0 ; i < bb.limit() ; i++ )
- assertEquals("Index: " + i, bb.get(i), fillValue) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TS_Block.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TS_Block.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TS_Block.java
deleted file mode 100644
index c3d45e8..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TS_Block.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.block;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {
- TestBlockMgrMem.class
- , TestBlockMgrDirect.class
- , TestBlockMgrMapped.class
- , TestBlockMgrTracked.class
-})
-
-
-public class TS_Block
-{}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrDirect.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrDirect.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrDirect.java
deleted file mode 100644
index c7719fc..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrDirect.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.block;
-
-import org.apache.jena.atlas.lib.FileOps ;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.seaborne.dboe.ConfigTestDBOE ;
-import org.seaborne.dboe.base.block.BlockMgr ;
-import org.seaborne.dboe.base.block.BlockMgrFactory ;
-import org.seaborne.dboe.base.block.BlockMgrFileAccess ;
-import org.seaborne.dboe.base.file.BlockAccess ;
-import org.seaborne.dboe.base.file.BlockAccessDirect ;
-
-public class TestBlockMgrDirect extends AbstractTestBlockMgr
-{
- static final String filename = ConfigTestDBOE.getTestingDir()+"/block-mgr" ;
-
- @BeforeClass static public void remove1() { FileOps.delete(filename) ; }
- @AfterClass static public void remove2() { FileOps.delete(filename) ; }
-
- @Override
- protected BlockMgr make()
- {
- // Make directly - no wrapper, no cache, no free block mgt.
- FileOps.delete(filename) ;
- BlockAccess file = new BlockAccessDirect(filename, BlkSize) ;
- BlockMgr mgr = new BlockMgrFileAccess(file, BlkSize) ;
- if ( BlockMgrFactory.AddTracker )
- mgr = BlockMgrFactory.tracker(mgr) ;
- return mgr ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrMapped.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrMapped.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrMapped.java
deleted file mode 100644
index c15d1a5..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrMapped.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.block;
-
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.atlas.logging.LogCtl ;
-import org.junit.After ;
-import org.junit.AfterClass ;
-import org.junit.BeforeClass ;
-import org.seaborne.dboe.ConfigTestDBOE ;
-import org.seaborne.dboe.base.block.BlockMgr ;
-import org.seaborne.dboe.base.block.BlockMgrFileAccess ;
-import org.seaborne.dboe.base.file.BlockAccess ;
-import org.seaborne.dboe.base.file.BlockAccessMapped ;
-
-public class TestBlockMgrMapped extends AbstractTestBlockMgr
-{
- static boolean logging = false ;
-
- static { if ( logging ) LogCtl.setLog4j() ; }
-
- static final String filename = ConfigTestDBOE.getTestingDir()+"/block-mgr" ;
-
- // Windows is iffy about deleting memory mapped files.
-
- @After public void after1() { clearBlockMgr() ; }
-
- private void clearBlockMgr()
- {
- if ( blockMgr != null )
- {
- blockMgr.close() ;
- FileOps.deleteSilent(filename) ;
- blockMgr = null ;
- }
- }
-
- @BeforeClass static public void remove1() { FileOps.deleteSilent(filename) ; }
- @AfterClass static public void remove2() { FileOps.deleteSilent(filename) ; }
-
- @Override
- protected BlockMgr make()
- {
- clearBlockMgr() ;
- BlockAccess file = new BlockAccessMapped(filename, BlkSize) ;
- return new BlockMgrFileAccess(file, BlkSize) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrMem.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrMem.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrMem.java
deleted file mode 100644
index 15c7950..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrMem.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.block;
-
-import org.seaborne.dboe.base.block.BlockMgr ;
-import org.seaborne.dboe.base.block.BlockMgrFactory ;
-
-
-public class TestBlockMgrMem extends AbstractTestBlockMgr
-{
- @Override
- protected BlockMgr make()
- { return BlockMgrFactory.createMem("mem", BlkSize) ; }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrTracked.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrTracked.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrTracked.java
deleted file mode 100644
index a4e71cf..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/block/TestBlockMgrTracked.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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.block;
-
-import java.nio.ByteBuffer ;
-
-import org.junit.AfterClass ;
-import org.junit.Assert ;
-import org.junit.BeforeClass ;
-import org.junit.Test ;
-
-public class TestBlockMgrTracked extends Assert
-{
- // Mainly testing the tracking
-
- static boolean b ;
-
- @BeforeClass
- static public void beforeClass()
- {
- b = BlockMgrTracker.verbose ;
- BlockMgrTracker.verbose = false ;
- }
-
- @AfterClass
- static public void afterClass()
- {
- BlockMgrTracker.verbose = b ;
- }
-
- @Test public void track_01()
- {
- BlockMgr mgr = BlockMgrFactory.createMem("BPTRecord", 4) ;
- mgr = BlockMgrFactory.tracker(mgr) ;
- mgr.beginUpdate() ;
- Block block = mgr.allocate(4) ;
- ByteBuffer bb = block.getByteBuffer() ;
- bb.putInt(0,1234) ;
- mgr.write(block) ;
- mgr.release(block) ;
- // -----
- Block block2 = mgr.getRead(block.getId()) ;
- ByteBuffer bb2 = block2.getByteBuffer() ;
- assertArrayEquals(bb.array(), bb2.array()) ;
- mgr.release(block2) ;
- mgr.endUpdate() ;
- }
-
- // Multiple overlapping read operations.
- static BlockMgr setup()
- {
- BlockMgr mgr = BlockMgrFactory.createMem("BPTRecord", 4) ;
- mgr = BlockMgrFactory.tracker(mgr) ;
- return mgr ;
- }
-
- static void write(BlockMgr mgr, int value)
- {
- mgr.beginUpdate() ;
- Block block = mgr.allocate(4) ;
- ByteBuffer bb = block.getByteBuffer() ;
- bb.putInt(0,value) ;
- mgr.write(block) ;
- mgr.release(block) ;
- mgr.endUpdate() ;
- }
-
- @Test public void track_02()
- {
- BlockMgr mgr = setup() ;
- write(mgr, 1234) ;
- write(mgr, 5678) ;
-
- mgr.beginRead() ;
- mgr.beginRead() ;
-
- Block b0 = mgr.getRead(0) ;
- Block b1 = mgr.getRead(1) ;
-
- mgr.release(b1) ;
- mgr.release(b0) ;
-
- mgr.endRead() ;
- mgr.endRead() ;
- }
-
- @Test(expected=BlockException.class)
- public void track_03()
- {
- BlockMgr mgr = setup() ;
- write(mgr, 1234) ;
- write(mgr, 5678) ;
-
- mgr.beginRead() ;
- Block b0 = mgr.getWrite(0) ;
- mgr.endRead() ;
- }
-
- @Test(expected=BlockException.class)
- public void track_04()
- {
- BlockMgr mgr = setup() ;
- write(mgr, 1234) ;
- mgr.beginRead() ;
- Block b0 = mgr.getRead(0) ;
- mgr.promote(b0) ;
- mgr.endRead() ;
- }
-
- @Test(expected=BlockException.class)
- public void track_05()
- {
- BlockMgr mgr = setup() ;
- mgr.beginRead() ;
- mgr.endUpdate() ;
- }
-
- @Test(expected=BlockException.class)
- public void track_06()
- {
- BlockMgr mgr = setup() ;
- mgr.beginUpdate() ;
- mgr.endRead() ;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/3d456654/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/buffer/TS_Buffer.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/buffer/TS_Buffer.java b/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/buffer/TS_Buffer.java
deleted file mode 100644
index 7825a25..0000000
--- a/jena-db/jena-dboe-base/src/test/java/org/seaborne/dboe/base/buffer/TS_Buffer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.buffer;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {
- TestRecordBuffer.class
- , TestPtrBuffer.class
-})
-
-
-public class TS_Buffer
-{}