directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1510115 [12/13] - in /directory/mavibot/trunk: ./ mavibot/ mavibot/src/main/java/org/apache/directory/ mavibot/src/main/java/org/apache/directory/mavibot/ mavibot/src/main/java/org/apache/directory/mavibot/btree/ mavibot/src/main/java/org/...
Date Sun, 04 Aug 2013 09:22:58 GMT
Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/StoreTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/StoreTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/StoreTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/StoreTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,460 @@
+/*
+ *  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.directory.mavibot.btree;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+import org.apache.directory.mavibot.btree.PageIO;
+import org.apache.directory.mavibot.btree.RecordManager;
+import org.junit.Test;
+
+
+/**
+ * Test the RecordManager.store() method using reflection
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class StoreTest
+{
+    /**
+     * Test the store( int ) method
+     */
+    @Test
+    public void testInjectInt() throws Exception
+    {
+        File tempFile = File.createTempFile( "mavibot", ".db" );
+        String tempFileName = tempFile.getAbsolutePath();
+        tempFile.deleteOnExit();
+
+        RecordManager recordManager = new RecordManager( tempFileName, 4 * 1024 );
+        Method method = RecordManager.class.getDeclaredMethod( "store", long.class, int.class, PageIO[].class );
+        method.setAccessible( true );
+
+        // Allocate some Pages
+        PageIO[] pageIos = new PageIO[2];
+        pageIos[0] = new PageIO();
+        pageIos[0].setData( ByteBuffer.allocate( recordManager.getPageSize() ) );
+        pageIos[1] = new PageIO();
+        pageIos[1].setData( ByteBuffer.allocate( recordManager.getPageSize() ) );
+
+        // Set the int at the beginning
+        long position = ( Long ) method.invoke( recordManager, 0, 0x12345678, pageIos );
+
+        assertEquals( 4, position );
+        int pos = 12;
+        assertEquals( 0x12, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x34, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x56, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x78, pageIos[0].getData().get( pos++ ) );
+
+        // Set the int at the end of the first page
+        position = ( Long ) method.invoke( recordManager, 4080, 0x12345678, pageIos );
+
+        assertEquals( 4084, position );
+        pos = 4092;
+        assertEquals( 0x12, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x34, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x56, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x78, pageIos[0].getData().get( pos++ ) );
+
+        // Set the int at the end of the first page and overlapping on the second page
+        // 1 byte overlapping
+        position = ( Long ) method.invoke( recordManager, 4081, 0x12345678, pageIos );
+
+        assertEquals( 4085, position );
+        pos = 4093;
+        assertEquals( 0x12, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x34, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x56, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( 0x78, pageIos[1].getData().get( pos++ ) );
+
+        // Set the int at the end of the first page and overlapping on the second page
+        // 2 bytes overlapping
+        position = ( Long ) method.invoke( recordManager, 4082, 0x12345678, pageIos );
+
+        assertEquals( 4086, position );
+        pos = 4094;
+        assertEquals( 0x12, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x34, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( 0x56, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x78, pageIos[1].getData().get( pos++ ) );
+
+        // Set the int at the end of the first page and overlapping on the second page
+        // 3 bytes overlapping
+        position = ( Long ) method.invoke( recordManager, 4083, 0x12345678, pageIos );
+
+        assertEquals( 4087, position );
+        pos = 4095;
+        assertEquals( 0x12, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( 0x34, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x56, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x78, pageIos[1].getData().get( pos++ ) );
+
+        // Set the int at the beginning of the second page
+        position = ( Long ) method.invoke( recordManager, 4084, 0x12345678, pageIos );
+
+        assertEquals( 4088, position );
+        pos = 8;
+        assertEquals( 0x12, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x34, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x56, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x78, pageIos[1].getData().get( pos++ ) );
+    }
+
+
+    /**
+     * Test the store( long ) method
+     */
+    @Test
+    public void testInjectLong() throws Exception
+    {
+        File tempFile = File.createTempFile( "mavibot", ".db" );
+        String tempFileName = tempFile.getAbsolutePath();
+        tempFile.deleteOnExit();
+
+        RecordManager recordManager = new RecordManager( tempFileName, 4 * 1024 );
+        Method method = RecordManager.class.getDeclaredMethod( "store", long.class, long.class, PageIO[].class );
+        method.setAccessible( true );
+
+        // Allocate some Pages
+        PageIO[] pageIos = new PageIO[2];
+        pageIos[0] = new PageIO();
+        pageIos[0].setData( ByteBuffer.allocate( recordManager.getPageSize() ) );
+        pageIos[1] = new PageIO();
+        pageIos[1].setData( ByteBuffer.allocate( recordManager.getPageSize() ) );
+
+        // Set the long at the beginning
+        long position = ( Long ) method.invoke( recordManager, 0, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 8, position );
+        int pos = 12;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[0].getData().get( pos++ ) );
+
+        // Set the long at the end of the first page
+        position = ( Long ) method.invoke( recordManager, 4076, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4084, position );
+        pos = 4088;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[0].getData().get( pos++ ) );
+
+        // Set the long at the end of the first page and overlapping on the second page
+        // 1 byte overlapping
+        position = ( Long ) method.invoke( recordManager, 4077, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4085, position );
+        pos = 4089;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( ( byte ) 0xEF, pageIos[1].getData().get( pos++ ) );
+
+        // Set the long at the end of the first page and overlapping on the second page
+        // 2 bytes overlapping
+        position = ( Long ) method.invoke( recordManager, 4078, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4086, position );
+        pos = 4090;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( ( byte ) 0xCD, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[1].getData().get( pos++ ) );
+
+        // Set the long at the end of the first page and overlapping on the second page
+        // 3 bytes overlapping
+        position = ( Long ) method.invoke( recordManager, 4079, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4087, position );
+        pos = 4091;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[0].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( ( byte ) 0xAB, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[1].getData().get( pos++ ) );
+
+        // Set the long at the end of the first page and overlapping on the second page
+        // 4 byte overlapping
+        position = ( Long ) method.invoke( recordManager, 4080, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4088, position );
+        pos = 4092;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( ( byte ) 0x89, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[1].getData().get( pos++ ) );
+
+        // Set the long at the end of the first page and overlapping on the second page
+        // 5 bytes overlapping
+        position = ( Long ) method.invoke( recordManager, 4081, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4089, position );
+        pos = 4093;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( 0x67, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[1].getData().get( pos++ ) );
+
+        // Set the long at the end of the first page and overlapping on the second page
+        // 6 bytes overlapping
+        position = ( Long ) method.invoke( recordManager, 4082, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4090, position );
+        pos = 4094;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( 0x45, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[1].getData().get( pos++ ) );
+
+        // Set the long at the end of the first page and overlapping on the second page
+        // 7 bytes overlapping
+        position = ( Long ) method.invoke( recordManager, 4083, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4091, position );
+        pos = 4095;
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        pos = 8;
+        assertEquals( 0x23, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[1].getData().get( pos++ ) );
+
+        // Set the long at the beginning of the second page
+        position = ( Long ) method.invoke( recordManager, 4084, 0x0123456789ABCDEFL, pageIos );
+
+        assertEquals( 4092, position );
+        pos = 8;
+        assertEquals( 0x01, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[1].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0x89, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xAB, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xCD, pageIos[1].getData().get( pos++ ) );
+        assertEquals( ( byte ) 0xEF, pageIos[1].getData().get( pos++ ) );
+    }
+
+
+    /**
+     * Test the store( bytes ) method
+     */
+    @Test
+    public void testInjectBytes() throws Exception
+    {
+        File tempFile = File.createTempFile( "mavibot", ".db" );
+        String tempFileName = tempFile.getAbsolutePath();
+        tempFile.deleteOnExit();
+
+        // We use smaller pages
+        RecordManager recordManager = new RecordManager( tempFileName, 32 );
+        Method storeMethod = RecordManager.class.getDeclaredMethod( "store", long.class, byte[].class, PageIO[].class );
+        storeMethod.setAccessible( true );
+
+        // Allocate some Pages
+        PageIO[] pageIos = new PageIO[4];
+        pageIos[0] = new PageIO();
+        pageIos[0].setData( ByteBuffer.allocate( recordManager.getPageSize() ) );
+        pageIos[1] = new PageIO();
+        pageIos[1].setData( ByteBuffer.allocate( recordManager.getPageSize() ) );
+        pageIos[2] = new PageIO();
+        pageIos[2].setData( ByteBuffer.allocate( recordManager.getPageSize() ) );
+        pageIos[3] = new PageIO();
+        pageIos[3].setData( ByteBuffer.allocate( recordManager.getPageSize() ) );
+
+        // We start with 4 bytes
+        byte[] bytes = new byte[]
+            { 0x01, 0x23, 0x45, 0x67 };
+
+        // Set the bytes at the beginning
+        long position = ( Long ) storeMethod.invoke( recordManager, 0L, bytes, pageIos );
+
+        assertEquals( 8, position );
+        int pos = 12;
+        // The byte length
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x04, pageIos[0].getData().get( pos++ ) );
+        // The data
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[0].getData().get( pos++ ) );
+
+        // Set the bytes at the end of the first page
+        position = ( Long ) storeMethod.invoke( recordManager, 12L, bytes, pageIos );
+
+        assertEquals( 20, position );
+        pos = 24;
+        // The byte length
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x04, pageIos[0].getData().get( pos++ ) );
+        // The data
+        assertEquals( 0x01, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x23, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x45, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x67, pageIos[0].getData().get( pos++ ) );
+
+        // Set A full page of bytes in the first page 
+        bytes = new byte[16];
+
+        for ( int i = 0; i < 16; i++ )
+        {
+            bytes[i] = ( byte ) ( i + 1 );
+        }
+
+        position = ( Long ) storeMethod.invoke( recordManager, 0L, bytes, pageIos );
+
+        assertEquals( 20, position );
+        pos = 12;
+        // The byte length
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x10, pageIos[0].getData().get( pos++ ) );
+
+        // The data
+        for ( int i = 0; i < 16; i++ )
+        {
+            assertEquals( ( byte ) ( i + 1 ), pageIos[0].getData().get( pos++ ) );
+        }
+
+        // Write the bytes over 2 pages
+        position = ( Long ) storeMethod.invoke( recordManager, 15L, bytes, pageIos );
+
+        assertEquals( 35, position );
+        pos = 27;
+        // The byte length
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x10, pageIos[0].getData().get( pos++ ) );
+
+        // The data in the first page
+        assertEquals( 1, pageIos[0].getData().get( pos++ ) );
+
+        // and in the second page
+        pos = 8;
+
+        for ( int i = 0; i < 15; i++ )
+        {
+            assertEquals( ( byte ) ( i + 2 ), pageIos[1].getData().get( pos++ ) );
+        }
+
+        // Write the bytes over 4 pages
+        bytes = new byte[80];
+
+        for ( int i = 0; i < 80; i++ )
+        {
+            bytes[i] = ( byte ) ( i + 1 );
+        }
+
+        position = ( Long ) storeMethod.invoke( recordManager, 2L, bytes, pageIos );
+
+        assertEquals( 86, position );
+        pos = 14;
+        // The byte length
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x00, pageIos[0].getData().get( pos++ ) );
+        assertEquals( 0x50, pageIos[0].getData().get( pos++ ) );
+
+        // The data in the first page
+        for ( int i = 0; i < 14; i++ )
+        {
+            assertEquals( ( byte ) ( i + 1 ), pageIos[0].getData().get( pos++ ) );
+        }
+
+        // The data in the second page
+        pos = 8;
+        for ( int i = 14; i < 38; i++ )
+        {
+            assertEquals( ( byte ) ( i + 1 ), pageIos[1].getData().get( pos++ ) );
+        }
+
+        // The data in the third page
+        pos = 8;
+        for ( int i = 38; i < 62; i++ )
+        {
+            assertEquals( ( byte ) ( i + 1 ), pageIos[2].getData().get( pos++ ) );
+        }
+
+        // The data in the forth page
+        pos = 8;
+        for ( int i = 62; i < 80; i++ )
+        {
+            assertEquals( ( byte ) ( i + 1 ), pageIos[3].getData().get( pos++ ) );
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,83 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.BooleanArrayComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the BooleanArrayComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class BooleanArrayComparatorTest
+{
+    @Test
+    public void testBooleanArrayComparator()
+    {
+        BooleanArrayComparator comparator = new BooleanArrayComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+
+        boolean[] b1 = new boolean[]
+            { true, true, true };
+        boolean[] b2 = new boolean[]
+            { true, true, false };
+        boolean[] b3 = new boolean[]
+            { true, false, true };
+        boolean[] b4 = new boolean[]
+            { false, true, true };
+        boolean[] b5 = new boolean[]
+            { true, true };
+
+        // 0
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( new boolean[]
+            {}, new boolean[]
+            {} ) );
+        assertEquals( 0, comparator.compare( b1, b1 ) );
+
+        // -1
+        assertEquals( -1, comparator.compare( null, new boolean[]
+            {} ) );
+        assertEquals( -1, comparator.compare( null, b1 ) );
+        assertEquals( -1, comparator.compare( new boolean[]
+            {}, b1 ) );
+        assertEquals( -1, comparator.compare( new boolean[]
+            {}, b4 ) );
+        assertEquals( -1, comparator.compare( b5, b1 ) );
+        assertEquals( -1, comparator.compare( b5, b3 ) );
+
+        // 1
+        assertEquals( 1, comparator.compare( new boolean[]
+            {}, null ) );
+        assertEquals( 1, comparator.compare( b1, null ) );
+        assertEquals( 1, comparator.compare( b1, new boolean[]
+            {} ) );
+        assertEquals( 1, comparator.compare( b1, b2 ) );
+        assertEquals( 1, comparator.compare( b1, b3 ) );
+        assertEquals( 1, comparator.compare( b1, b4 ) );
+        assertEquals( 1, comparator.compare( b1, b5 ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.BooleanComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the BooleanComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class BooleanComparatorTest
+{
+    @Test
+    public void testBooleanComparator()
+    {
+        BooleanComparator comparator = new BooleanComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( true, true ) );
+        assertEquals( 0, comparator.compare( false, false ) );
+        assertEquals( 1, comparator.compare( false, null ) );
+        assertEquals( 1, comparator.compare( true, null ) );
+        assertEquals( 1, comparator.compare( true, false ) );
+        assertEquals( -1, comparator.compare( null, false ) );
+        assertEquals( -1, comparator.compare( null, true ) );
+        assertEquals( -1, comparator.compare( false, true ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,88 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.ByteArrayComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the ByteArrayComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ByteArrayComparatorTest
+{
+    @Test
+    public void testByteArrayComparator()
+    {
+        ByteArrayComparator comparator = new ByteArrayComparator();
+
+        // Check equality
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( new byte[]
+            {}, new byte[]
+            {} ) );
+        assertEquals( 0, comparator.compare( new byte[]
+            { 0x01, 0x02 }, new byte[]
+            { 0x01, 0x02 } ) );
+
+        // The first byte[] is > the second
+        assertEquals( 1, comparator.compare( new byte[]
+            {}, null ) );
+        assertEquals( 1, comparator.compare( new byte[]
+            { 0x01 }, null ) );
+        assertEquals( 1, comparator.compare( new byte[]
+            { 0x01, 0x02 }, new byte[]
+            { 0x01, 0x01 } ) );
+        assertEquals( 1, comparator.compare( new byte[]
+            { 0x01, 0x02, 0x01 }, new byte[]
+            { 0x01, 0x02 } ) );
+        assertEquals( 1, comparator.compare( new byte[]
+            { 0x01, 0x02 }, new byte[]
+            { 0x01, 0x01, 0x02 } ) );
+
+        // The first byte[] is < the second
+        assertEquals( -1, comparator.compare( null, new byte[]
+            {} ) );
+        assertEquals( -1, comparator.compare( null, new byte[]
+            { 0x01, 0x02 } ) );
+        assertEquals( -1, comparator.compare( null, new byte[]
+            { ( byte ) 0xFF, 0x02 } ) );
+        assertEquals( -1, comparator.compare( new byte[]
+            {}, new byte[]
+            { 0x01, 0x02 } ) );
+        assertEquals( -1, comparator.compare( new byte[]
+            {}, new byte[]
+            { ( byte ) 0xFF, 0x02 } ) );
+        assertEquals( -1, comparator.compare( new byte[]
+            { ( byte ) 0xFF, 0x01 }, new byte[]
+            { 0x01, 0x01, 0x02 } ) );
+        byte[] array = new byte[3];
+        array[0] = 0x01;
+        array[1] = 0x02;
+        assertEquals( -1, comparator.compare( new byte[]
+            { 0x01, 0x02 }, array ) );
+
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,54 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.ByteComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the ByteComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ByteComparatorTest
+{
+    @Test
+    public void testByteComparator()
+    {
+        ByteComparator comparator = new ByteComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( ( byte ) 0x00, ( byte ) 0x00 ) );
+        assertEquals( 0, comparator.compare( ( byte ) 0xFE, ( byte ) 0xFE ) );
+        assertEquals( 1, comparator.compare( ( byte ) 0x01, null ) );
+        assertEquals( 1, comparator.compare( ( byte ) 0x01, ( byte ) 0x00 ) );
+        assertEquals( 1, comparator.compare( ( byte ) 0x00, ( byte ) 0xFF ) );
+        assertEquals( 1, comparator.compare( ( byte ) 0x7F, ( byte ) 0x01 ) );
+        assertEquals( -1, comparator.compare( null, ( byte ) 0x00 ) );
+        assertEquals( -1, comparator.compare( null, ( byte ) 0xFF ) );
+        assertEquals( -1, comparator.compare( ( byte ) 0x00, ( byte ) 0x01 ) );
+        assertEquals( -1, comparator.compare( ( byte ) 0xF0, ( byte ) 0xFF ) );
+        assertEquals( -1, comparator.compare( ( byte ) 0xFF, ( byte ) 0x01 ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,87 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.CharArrayComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the CharArrayComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class CharArrayComparatorTest
+{
+    @Test
+    public void testCharArrayComparator()
+    {
+        CharArrayComparator comparator = new CharArrayComparator();
+
+        // Check equality
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( new char[]
+            {}, new char[]
+            {} ) );
+        assertEquals( 0, comparator.compare( new char[]
+            { 'a', 'b' }, new char[]
+            { 'a', 'b' } ) );
+
+        // The first char[] is > the second
+        assertEquals( 1, comparator.compare( new char[]
+            {}, null ) );
+        assertEquals( 1, comparator.compare( new char[]
+            { 'a' }, null ) );
+        assertEquals( 1, comparator.compare( new char[]
+            { 'a', 'b' }, new char[]
+            { 'a', 'a' } ) );
+        assertEquals( 1, comparator.compare( new char[]
+            { 'a', 'b', 'a' }, new char[]
+            { 'a', 'b' } ) );
+        assertEquals( 1, comparator.compare( new char[]
+            { 'a', 'b' }, new char[]
+            { 'a', 'a', 'b' } ) );
+
+        // The first char[] is < the second
+        assertEquals( -1, comparator.compare( null, new char[]
+            {} ) );
+        assertEquals( -1, comparator.compare( null, new char[]
+            { 'a', 'b' } ) );
+        assertEquals( -1, comparator.compare( null, new char[]
+            { '\uffff', 'b' } ) );
+        assertEquals( -1, comparator.compare( new char[]
+            {}, new char[]
+            { 'a', 'b' } ) );
+        assertEquals( -1, comparator.compare( new char[]
+            {}, new char[]
+            { '\uffff', 'b' } ) );
+        assertEquals( -1, comparator.compare( new char[]
+            { '0', 'a' }, new char[]
+            { 'a', 'a', 'b' } ) );
+        char[] array = new char[3];
+        array[0] = 'a';
+        array[1] = 'b';
+        assertEquals( -1, comparator.compare( new char[]
+            { 'a', 'b' }, array ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,50 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.CharComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the CharComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class CharComparatorTest
+{
+    @Test
+    public void testCharComparator()
+    {
+        CharComparator comparator = new CharComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( 'a', 'a' ) );
+        assertEquals( 0, comparator.compare( '\u00e9', '\u00e9' ) );
+        assertEquals( 1, comparator.compare( 'a', null ) );
+        assertEquals( -1, comparator.compare( 'A', 'a' ) );
+        assertEquals( 1, comparator.compare( 'a', 'A' ) );
+        assertEquals( -1, comparator.compare( null, 'a' ) );
+        assertEquals( -1, comparator.compare( 'a', 'b' ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,87 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.IntArrayComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the IntArrayComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class IntArrayComparatorTest
+{
+    @Test
+    public void testIntArrayComparator()
+    {
+        IntArrayComparator comparator = new IntArrayComparator();
+
+        // Check equality
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( new int[]
+            {}, new int[]
+            {} ) );
+        assertEquals( 0, comparator.compare( new int[]
+            { 1, 2 }, new int[]
+            { 1, 2 } ) );
+
+        // The first int[] is > the second
+        assertEquals( 1, comparator.compare( new int[]
+            {}, null ) );
+        assertEquals( 1, comparator.compare( new int[]
+            { 1 }, null ) );
+        assertEquals( 1, comparator.compare( new int[]
+            { 1, 2 }, new int[]
+            { 1, 1 } ) );
+        assertEquals( 1, comparator.compare( new int[]
+            { 1, 2, 1 }, new int[]
+            { 1, 2 } ) );
+        assertEquals( 1, comparator.compare( new int[]
+            { 1, 2 }, new int[]
+            { 1, 1, 2 } ) );
+
+        // The first int[] is < the second
+        assertEquals( -1, comparator.compare( null, new int[]
+            {} ) );
+        assertEquals( -1, comparator.compare( null, new int[]
+            { 1, 2 } ) );
+        assertEquals( -1, comparator.compare( null, new int[]
+            { -1, 2 } ) );
+        assertEquals( -1, comparator.compare( new int[]
+            {}, new int[]
+            { 1, 2 } ) );
+        assertEquals( -1, comparator.compare( new int[]
+            {}, new int[]
+            { -1, 2 } ) );
+        assertEquals( -1, comparator.compare( new int[]
+            { -1, 1 }, new int[]
+            { 1, 1, 2 } ) );
+        int[] array = new int[3];
+        array[0] = 1;
+        array[1] = 2;
+        assertEquals( -1, comparator.compare( new int[]
+            { 1, 2 }, array ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,52 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.IntComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the IntComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class IntComparatorTest
+{
+    @Test
+    public void testIntComparator()
+    {
+        IntComparator comparator = new IntComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( 1, 1 ) );
+        assertEquals( 0, comparator.compare( -1, -1 ) );
+        assertEquals( 1, comparator.compare( 1, null ) );
+        assertEquals( 1, comparator.compare( 2, 1 ) );
+        assertEquals( 1, comparator.compare( 3, 1 ) );
+        assertEquals( 1, comparator.compare( 1, -1 ) );
+        assertEquals( -1, comparator.compare( null, 1 ) );
+        assertEquals( -1, comparator.compare( 1, 2 ) );
+        assertEquals( -1, comparator.compare( -1, 1 ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,87 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.LongArrayComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the LongArrayComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class LongArrayComparatorTest
+{
+    @Test
+    public void testLongArrayComparator()
+    {
+        LongArrayComparator comparator = new LongArrayComparator();
+
+        // Check equality
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( new long[]
+            {}, new long[]
+            {} ) );
+        assertEquals( 0, comparator.compare( new long[]
+            { 1L, 2L }, new long[]
+            { 1L, 2L } ) );
+
+        // The first long[] is > the second
+        assertEquals( 1, comparator.compare( new long[]
+            {}, null ) );
+        assertEquals( 1, comparator.compare( new long[]
+            { 1L }, null ) );
+        assertEquals( 1, comparator.compare( new long[]
+            { 1L, 2L }, new long[]
+            { 1L, 1L } ) );
+        assertEquals( 1, comparator.compare( new long[]
+            { 1L, 2L, 1L }, new long[]
+            { 1L, 2L } ) );
+        assertEquals( 1, comparator.compare( new long[]
+            { 1L, 2L }, new long[]
+            { 1L, 1L, 2L } ) );
+
+        // The first long[] is < the second
+        assertEquals( -1, comparator.compare( null, new long[]
+            {} ) );
+        assertEquals( -1, comparator.compare( null, new long[]
+            { 1L, 2L } ) );
+        assertEquals( -1, comparator.compare( null, new long[]
+            { -1L, 2L } ) );
+        assertEquals( -1, comparator.compare( new long[]
+            {}, new long[]
+            { 1L, 2L } ) );
+        assertEquals( -1, comparator.compare( new long[]
+            {}, new long[]
+            { -1L, 2L } ) );
+        assertEquals( -1, comparator.compare( new long[]
+            { -1L, 1L }, new long[]
+            { 1L, 1L, 2L } ) );
+        long[] array = new long[3];
+        array[0] = 1L;
+        array[1] = 2L;
+        assertEquals( -1, comparator.compare( new long[]
+            { 1L, 2L }, array ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,52 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.LongComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the LongComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class LongComparatorTest
+{
+    @Test
+    public void testLongComparator()
+    {
+        LongComparator comparator = new LongComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( 1L, 1L ) );
+        assertEquals( 0, comparator.compare( -1L, -1L ) );
+        assertEquals( 1, comparator.compare( 1L, null ) );
+        assertEquals( 1, comparator.compare( 2L, 1L ) );
+        assertEquals( 1, comparator.compare( 3L, 1L ) );
+        assertEquals( 1, comparator.compare( 1L, -1L ) );
+        assertEquals( -1, comparator.compare( null, 1L ) );
+        assertEquals( -1, comparator.compare( 1L, 2L ) );
+        assertEquals( -1, comparator.compare( -1L, 1L ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/RevisionNameComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/RevisionNameComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/RevisionNameComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/RevisionNameComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.RevisionName;
+import org.apache.directory.mavibot.btree.RevisionNameComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the RevisionNameComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class RevisionNameComparatorTest
+{
+    @Test
+    public void testRevisionNameComparator()
+    {
+        RevisionNameComparator comparator = new RevisionNameComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( new RevisionName( 0L, "test" ), new RevisionName( 0L, "test" ) ) );
+        assertEquals( 1, comparator.compare( new RevisionName( 3L, "test" ), new RevisionName( 0L, "test" ) ) );
+        assertEquals( -1, comparator.compare( new RevisionName( 3L, "test" ), new RevisionName( 5L, "test" ) ) );
+        assertEquals( 1, comparator.compare( new RevisionName( 3L, "test2" ), new RevisionName( 3L, "test1" ) ) );
+        assertEquals( -1, comparator.compare( new RevisionName( 3L, "test" ), new RevisionName( 3L, "test2" ) ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,87 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.ShortArrayComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the ShortArrayComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ShortArrayComparatorTest
+{
+    @Test
+    public void testShortArrayComparator()
+    {
+        ShortArrayComparator comparator = new ShortArrayComparator();
+
+        // Check equality
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( new short[]
+            {}, new short[]
+            {} ) );
+        assertEquals( 0, comparator.compare( new short[]
+            { ( short ) 1, ( short ) 2 }, new short[]
+            { ( short ) 1, ( short ) 2 } ) );
+
+        // The first short[] is > the second
+        assertEquals( 1, comparator.compare( new short[]
+            {}, null ) );
+        assertEquals( 1, comparator.compare( new short[]
+            { ( short ) 1 }, null ) );
+        assertEquals( 1, comparator.compare( new short[]
+            { ( short ) 1, ( short ) 2 }, new short[]
+            { ( short ) 1, ( short ) 1 } ) );
+        assertEquals( 1, comparator.compare( new short[]
+            { ( short ) 1, ( short ) 2, ( short ) 1 }, new short[]
+            { ( short ) 1, ( short ) 2 } ) );
+        assertEquals( 1, comparator.compare( new short[]
+            { ( short ) 1, ( short ) 2 }, new short[]
+            { ( short ) 1, ( short ) 1, ( short ) 2 } ) );
+
+        // The first short[] is < the second
+        assertEquals( -1, comparator.compare( null, new short[]
+            {} ) );
+        assertEquals( -1, comparator.compare( null, new short[]
+            { ( short ) 1, ( short ) 2 } ) );
+        assertEquals( -1, comparator.compare( null, new short[]
+            { ( short ) -1, ( short ) 2 } ) );
+        assertEquals( -1, comparator.compare( new short[]
+            {}, new short[]
+            { ( short ) 1, ( short ) 2 } ) );
+        assertEquals( -1, comparator.compare( new short[]
+            {}, new short[]
+            { ( short ) -1, ( short ) 2 } ) );
+        assertEquals( -1, comparator.compare( new short[]
+            { ( short ) -1, ( short ) 1 }, new short[]
+            { ( short ) 1, ( short ) 1, ( short ) 2 } ) );
+        short[] array = new short[3];
+        array[0] = ( short ) 1;
+        array[1] = ( short ) 2;
+        assertEquals( -1, comparator.compare( new short[]
+            { ( short ) 1, ( short ) 2 }, array ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,52 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.ShortComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the ShortComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ShortComparatorTest
+{
+    @Test
+    public void testShortComparator()
+    {
+        ShortComparator comparator = new ShortComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( ( short ) 1, ( short ) 1 ) );
+        assertEquals( 0, comparator.compare( ( short ) -1, ( short ) -1 ) );
+        assertEquals( 1, comparator.compare( ( short ) 1, null ) );
+        assertEquals( 1, comparator.compare( ( short ) 2, ( short ) 1 ) );
+        assertEquals( 1, comparator.compare( ( short ) 3, ( short ) 1 ) );
+        assertEquals( 1, comparator.compare( ( short ) 1, ( short ) -1 ) );
+        assertEquals( -1, comparator.compare( null, ( short ) 1 ) );
+        assertEquals( -1, comparator.compare( ( short ) 1, ( short ) 2 ) );
+        assertEquals( -1, comparator.compare( ( short ) -1, ( short ) 1 ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/StringComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/StringComparatorTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/StringComparatorTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/StringComparatorTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,52 @@
+/*
+ *  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.directory.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.directory.mavibot.btree.comparator.StringComparator;
+import org.junit.Test;
+
+
+/**
+ * Test the StringComparator class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class StringComparatorTest
+{
+    @Test
+    public void testStringComparator()
+    {
+        StringComparator comparator = new StringComparator();
+
+        assertEquals( 0, comparator.compare( null, null ) );
+        assertEquals( 0, comparator.compare( "", "" ) );
+        assertEquals( 0, comparator.compare( "abc", "abc" ) );
+        assertEquals( 1, comparator.compare( "", null ) );
+        assertEquals( 1, comparator.compare( "abc", "" ) );
+        assertEquals( 1, comparator.compare( "ac", "ab" ) );
+        assertEquals( 1, comparator.compare( "abc", "ab" ) );
+        assertEquals( -1, comparator.compare( null, "" ) );
+        assertEquals( -1, comparator.compare( "ab", "abc" ) );
+        assertEquals( -1, comparator.compare( "ab", "abc" ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializerTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializerTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializerTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,60 @@
+/*
+ *  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.directory.mavibot.btree.serializer;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.directory.mavibot.btree.serializer.BooleanSerializer;
+import org.apache.directory.mavibot.btree.serializer.BufferHandler;
+import org.junit.Test;
+
+
+/**
+ * Test the BooleanSerializer class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class BooleanSerializerTest
+{
+    private static BooleanSerializer serializer = new BooleanSerializer();
+
+
+    @Test
+    public void testBooleanSerializer() throws IOException
+    {
+        boolean value = true;
+        byte[] result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x01, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).booleanValue() );
+
+        // ------------------------------------------------------------------
+        value = false;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).booleanValue() );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializerTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializerTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializerTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializerTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,87 @@
+/*
+ *  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.directory.mavibot.btree.serializer;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.directory.mavibot.btree.serializer.BufferHandler;
+import org.apache.directory.mavibot.btree.serializer.ByteArraySerializer;
+import org.junit.Test;
+
+
+/**
+ * Test the BytesSerializer class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ByteArraySerializerTest
+{
+    private static ByteArraySerializer serializer = new ByteArraySerializer();
+
+
+    @Test
+    public void testBytesSerializer() throws IOException
+    {
+        byte[] value = null;
+        byte[] result = serializer.serialize( value );
+
+        assertEquals( 4, result.length );
+        assertEquals( ( byte ) 0xFF, result[0] );
+        assertEquals( ( byte ) 0xFF, result[1] );
+        assertEquals( ( byte ) 0xFF, result[2] );
+        assertEquals( ( byte ) 0xFF, result[3] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ) );
+
+        // ------------------------------------------------------------------
+        value = new byte[]
+            {};
+        result = serializer.serialize( value );
+
+        assertEquals( 4, result.length );
+        assertEquals( ( byte ) 0x00, result[0] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x00, result[2] );
+        assertEquals( ( byte ) 0x00, result[3] );
+
+        assertTrue( Arrays.equals( value, serializer.deserialize( new BufferHandler( result ) ) ) );
+
+        // ------------------------------------------------------------------
+        value = "test".getBytes();
+        result = serializer.serialize( value );
+
+        assertEquals( 8, result.length );
+        assertEquals( ( byte ) 0x00, result[0] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x00, result[2] );
+        assertEquals( ( byte ) 0x04, result[3] );
+        assertEquals( 't', result[4] );
+        assertEquals( 'e', result[5] );
+        assertEquals( 's', result[6] );
+        assertEquals( 't', result[7] );
+
+        assertTrue( Arrays.equals( value, serializer.deserialize( new BufferHandler( result ) ) ) );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteSerializerTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteSerializerTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteSerializerTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,84 @@
+/*
+ *  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.directory.mavibot.btree.serializer;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.directory.mavibot.btree.serializer.BufferHandler;
+import org.apache.directory.mavibot.btree.serializer.ByteSerializer;
+import org.junit.Test;
+
+
+/**
+ * Test the ByteSerializer class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ByteSerializerTest
+{
+    private static ByteSerializer serializer = new ByteSerializer();
+
+
+    @Test
+    public void testByteSerializer() throws IOException
+    {
+        byte value = 0x00;
+        byte[] result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).byteValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x01;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x01, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).byteValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x7F;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x7F, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).byteValue() );
+
+        // ------------------------------------------------------------------
+        value = ( byte ) 0x80;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x80, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).byteValue() );
+
+        // ------------------------------------------------------------------
+        value = ( byte ) 0xFF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0xFF, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).byteValue() );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/CharSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/CharSerializerTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/CharSerializerTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/CharSerializerTest.java Sun Aug  4 09:22:56 2013
@@ -0,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.apache.directory.mavibot.btree.serializer;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.directory.mavibot.btree.serializer.BufferHandler;
+import org.apache.directory.mavibot.btree.serializer.CharSerializer;
+import org.junit.Test;
+
+
+/**
+ * Test the CharSerializer class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class CharSerializerTest
+{
+    private static CharSerializer serializer = new CharSerializer();
+
+
+    @Test
+    public void testCharSerializer() throws IOException
+    {
+        char value = 0x0000;
+        byte[] result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).charValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x0001;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x01, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).charValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x00FF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0xFF, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).charValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x0100;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x01, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).charValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x7FFF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0xFF, result[1] );
+        assertEquals( ( byte ) 0x7F, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).charValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x8000;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x80, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).charValue() );
+
+        // ------------------------------------------------------------------
+        value = 0xFFFF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0xFF, result[1] );
+        assertEquals( ( byte ) 0xFF, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).charValue() );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/IntSerializerTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/IntSerializerTest.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/IntSerializerTest.java (added)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/IntSerializerTest.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,165 @@
+/*
+ *  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.directory.mavibot.btree.serializer;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.directory.mavibot.btree.serializer.BufferHandler;
+import org.apache.directory.mavibot.btree.serializer.IntSerializer;
+import org.junit.Test;
+
+
+/**
+ * Test the IntSerializer class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class IntSerializerTest
+{
+    private static IntSerializer serializer = new IntSerializer();
+
+
+    @Test
+    public void testIntSerializer() throws IOException
+    {
+        int value = 0x00000000;
+        byte[] result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[3] );
+        assertEquals( ( byte ) 0x00, result[2] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x00000001;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x01, result[3] );
+        assertEquals( ( byte ) 0x00, result[2] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x000000FF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0xFF, result[3] );
+        assertEquals( ( byte ) 0x00, result[2] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x00000100;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[3] );
+        assertEquals( ( byte ) 0x01, result[2] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x0000FFFF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0xFF, result[3] );
+        assertEquals( ( byte ) 0xFF, result[2] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x00010000;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[3] );
+        assertEquals( ( byte ) 0x00, result[2] );
+        assertEquals( ( byte ) 0x01, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x00FFFFFF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0xFF, result[3] );
+        assertEquals( ( byte ) 0xFF, result[2] );
+        assertEquals( ( byte ) 0xFF, result[1] );
+        assertEquals( ( byte ) 0x00, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x01000000;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[3] );
+        assertEquals( ( byte ) 0x00, result[2] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x01, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x7FFFFFFF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00FF, result[3] );
+        assertEquals( ( byte ) 0x00FF, result[2] );
+        assertEquals( ( byte ) 0x00FF, result[1] );
+        assertEquals( ( byte ) 0x7F, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0x80000000;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0x00, result[3] );
+        assertEquals( ( byte ) 0x00, result[2] );
+        assertEquals( ( byte ) 0x00, result[1] );
+        assertEquals( ( byte ) 0x80, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+
+        // ------------------------------------------------------------------
+        value = 0xFFFFFFFF;
+        result = serializer.serialize( value );
+
+        assertEquals( ( byte ) 0xFF, result[3] );
+        assertEquals( ( byte ) 0xFF, result[2] );
+        assertEquals( ( byte ) 0xFF, result[1] );
+        assertEquals( ( byte ) 0xFF, result[0] );
+
+        assertEquals( value, serializer.deserialize( new BufferHandler( result ) ).intValue() );
+    }
+}



Mime
View raw message