directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1596777 - in /directory/apacheds/trunk/mavibot-partition/src: main/java/org/apache/directory/mavibot/btree/ main/resources/ test/java/org/apache/directory/mavibot/ test/java/org/apache/directory/mavibot/btree/ test/resources/
Date Thu, 22 May 2014 08:29:36 GMT
Author: kayyagari
Date: Thu May 22 08:29:35 2014
New Revision: 1596777

URL: http://svn.apache.org/r1596777
Log:
o added package protected getters for use in tests
o moved the LDIF file to test/resource

Added:
    directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/mavibot/
    directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/mavibot/btree/
    directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilderTest.java
    directory/apacheds/trunk/mavibot-partition/src/test/resources/builder-test.ldif
      - copied unchanged from r1596770, directory/apacheds/trunk/mavibot-partition/src/main/resources/builder-test.ldif
Removed:
    directory/apacheds/trunk/mavibot-partition/src/main/resources/builder-test.ldif
Modified:
    directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java

Modified: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java?rev=1596777&r1=1596776&r2=1596777&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java
(original)
+++ directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilder.java
Thu May 22 08:29:35 2014
@@ -114,6 +114,7 @@ public class MavibotPartitionBuilder
     
     private List<String> indexAttributes = new ArrayList<String>();
     
+    private int totalEntries = 0;
     private static final Logger LOG = LoggerFactory.getLogger( MavibotPartitionBuilder.class
);
 
 
@@ -699,7 +700,9 @@ public class MavibotPartitionBuilder
             sortedDnSet = getDnTuples();
             long sortT1 = System.currentTimeMillis();
 
-            System.out.println( "Completed sorting, total number of entries " + sortedDnSet.size()
+ 
+            totalEntries = sortedDnSet.size();
+            
+            System.out.println( "Completed sorting, total number of entries " + totalEntries
+ 
                 ", time taken : " + ( sortT1 - sortT0 ) + "ms" );
         }
         catch ( Exception e )
@@ -1110,6 +1113,43 @@ public class MavibotPartitionBuilder
         System.out.println( "Total search results " + count );
     }
 
+    
+    /** no qualifier */ int getTotalEntries()
+    {
+        return totalEntries;
+    }
+
+
+    /** no qualifier */ int getNumKeysInNode()
+    {
+        return numKeysInNode;
+    }
+
+
+    /** no qualifier */ RecordManager getRm()
+    {
+        return rm;
+    }
+
+
+    /** no qualifier */ MavibotPartition getPartition()
+    {
+        return partition;
+    }
+
+
+    /** no qualifier */ SchemaManager getSchemaManager()
+    {
+        return schemaManager;
+    }
+
+
+    /** no qualifier */ String getMasterTableName()
+    {
+        return masterTableName;
+    }
+
+
     public static void main( String[] args ) throws Exception
     {
         File outDir = new File( "/tmp/builder" );

Added: directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilderTest.java?rev=1596777&view=auto
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilderTest.java
(added)
+++ directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/mavibot/btree/MavibotPartitionBuilderTest.java
Thu May 22 08:29:35 2014
@@ -0,0 +1,70 @@
+/*
+ *   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 java.io.File;
+import java.io.InputStream;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import static org.junit.Assert.*;
+
+/**
+ * Tests for MavibotPartitionBuilder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MavibotPartitionBuilderTest
+{
+    @Rule
+    public TemporaryFolder folder = new TemporaryFolder();
+    
+    private File outDir;
+    
+    @Before
+    public void init() throws Exception
+    {
+        outDir = folder.newFolder( "MavibotPartitionBuilderTest" );
+    }
+    
+    @Test
+    public void testBulkLoad() throws Exception
+    {
+
+        File file = new File( outDir, "builder-test.ldif" );
+        InputStream in = MavibotPartitionBuilder.class.getClassLoader().getResourceAsStream(
"builder-test.ldif" );
+        FileUtils.copyInputStreamToFile( in, file );
+        in.close();
+
+        MavibotPartitionBuilder builder = new MavibotPartitionBuilder( file.getAbsolutePath(),
outDir.getAbsolutePath() );
+        
+        builder.buildPartition();
+        
+        //test the trees
+        
+        RecordManager rm = builder.getRm();
+        BTree masterTree = rm.getManagedTree( builder.getMasterTableName() );
+        assertEquals( builder.getTotalEntries(), masterTree.getNbElems() );
+    }
+}



Mime
View raw message