directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r684011 - in /directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree: AvlTreeMarshallerTest.java AvlTreePerfTest.java AvlTreeTest.java
Date Fri, 08 Aug 2008 16:11:28 GMT
Author: kayyagari
Date: Fri Aug  8 09:11:27 2008
New Revision: 684011

URL: http://svn.apache.org/viewvc?rev=684011&view=rev
Log:
cleaned up the files created during test
controlled the console output through logging

Modified:
    directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java
    directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java
    directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java

Modified: directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java?rev=684011&r1=684010&r2=684011&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java
(original)
+++ directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java
Fri Aug  8 09:11:27 2008
@@ -33,6 +33,7 @@
 import java.io.Serializable;
 import java.util.Comparator;
 
+import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -93,7 +94,7 @@
     
     static AvlTree<Integer> savedTree;
     
-    File treeFile = new File( System.getProperty( "java.io.tmpdir" ) + File.separator + "avl.tree");
+    static File treeFile = new File( System.getProperty( "java.io.tmpdir" ) + File.separator
+ "avl.tree");
     
     private static final Logger LOG = LoggerFactory.getLogger( AvlTreeMarshallerTest.class.getSimpleName()
);
 
@@ -115,13 +116,14 @@
     }
 
     
-    /**
-     * TODO Fix me.
-     *
-     * @throws IOException
-     */
+    @AfterClass
+    public static void deleteFiles()
+    {
+        treeFile.delete();
+    }
+    
+    
     @Test
-    @Ignore ( "Remove operation is deleting more keys than it should." )
     public void testRemoveBug() throws IOException
     {
         Comparator<Long> comparator = new Comparator<Long>() 
@@ -393,8 +395,11 @@
         
         savedTree = tree; // to reference in other tests
         
-        LOG.debug("saved tree\n--------");
-        tree.printTree();
+        if( LOG.isDebugEnabled() )
+        {
+            LOG.debug("saved tree\n--------");
+            tree.printTree();
+        }
         
         assertTrue( true );
     }
@@ -410,8 +415,11 @@
         
         AvlTree<Integer> unmarshalledTree = treeMarshaller.deserialize( data );
         
-        LOG.debug("\nunmarshalled tree\n---------------");
-        unmarshalledTree.printTree();
+        if( LOG.isDebugEnabled() )
+        {
+            LOG.debug("\nunmarshalled tree\n---------------");
+            unmarshalledTree.printTree();
+        }
         
         assertTrue( savedTree.getRoot().getKey() == unmarshalledTree.getRoot().getKey() );
 
@@ -429,8 +437,11 @@
         unmarshalledTree.insert( 0 );
         assertTrue( 0 == unmarshalledTree.getFirst().getKey() );
         
-        LOG.debug("\nmodified tree after unmarshalling\n---------------");
-        unmarshalledTree.printTree();
+        if( LOG.isDebugEnabled() )
+        {
+            LOG.debug("\nmodified tree after unmarshalling\n---------------");
+            unmarshalledTree.printTree();
+        }
         
         assertNotNull(unmarshalledTree.getFirst());
         assertNotNull(unmarshalledTree.getLast());
@@ -485,4 +496,4 @@
             return id;
         }
     }
-}
\ No newline at end of file
+}

Modified: directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java?rev=684011&r1=684010&r2=684011&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java
(original)
+++ directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreePerfTest.java
Fri Aug  8 09:11:27 2008
@@ -29,8 +29,11 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -44,10 +47,10 @@
 {
     AvlTree<Integer> tree;
     
-    String tempDir = System.getProperty( "java.io.tmpdir" );
+    static String tempDir = System.getProperty( "java.io.tmpdir" );
    
-    File setSerialFile = new File( tempDir + File.separator + "hashset.ser" );
-    File treeSerialFile = new File( tempDir + File.separator + "avltree.ser" );
+    static File setSerialFile = new File( tempDir + File.separator + "hashset.ser" );
+    static File treeSerialFile = new File( tempDir + File.separator + "avltree.ser" );
     
     Set<Integer> set;
     
@@ -66,6 +69,7 @@
     
     AvlTreeMarshaller<Integer> treeMarshaller = new AvlTreeMarshaller<Integer>(
comparator, new IntegerKeyMarshaller() );
 
+    private final static Logger LOG = LoggerFactory.getLogger( AvlTreePerfTest.class );
     
     @Before
     public void createTree()
@@ -86,6 +90,14 @@
     }
     
     
+    @AfterClass
+    public static void deleteFiles()
+    {
+        setSerialFile.delete();
+        treeSerialFile.delete();
+    }
+    
+    
     @Test
     public void testRBTreeInsertPerf()
     {
@@ -98,7 +110,7 @@
         
         end = System.nanoTime();
      
-        System.out.println( "total time for inserting " + numKeys + " items into the RBTree-->"
+  getTime( start, end ) );
+        LOG.info( "total time for inserting " + numKeys + " items into the RBTree-->"
+  getTime( start, end ) );
         
     }
 
@@ -121,7 +133,7 @@
         
        end = System.nanoTime();
        
-       System.out.println( "total time took to read an item from set " + getTime( start,
end ) ) ;
+       LOG.info( "total time took to read an item from set " + getTime( start, end ) ) ;
     }
     
     
@@ -142,11 +154,10 @@
         
         end = System.nanoTime();
         
-        System.out.println( "total time took to remove an item from set " + getTime( start,
end ) ) ;
+        LOG.info( "total time took to remove an item from set " + getTime( start, end ) )
;
 
     }
     
-//    Random rnd = new Random( size );
     
     @Test
     public void testAvlTreeInsertPerf()
@@ -160,7 +171,7 @@
 
         end = System.nanoTime();
         
-        System.out.println("total time for inserting " + numKeys + " items into the AVLTree-->"
+ getTime(start, end));
+        LOG.info("total time for inserting " + numKeys + " items into the AVLTree-->"
+ getTime(start, end));
     }
     
     
@@ -183,7 +194,7 @@
         
         end = System.nanoTime();
         
-        System.out.println("total time took to read an item from tree " + getTime( start,
end ) ) ;
+        LOG.info("total time took to read an item from tree " + getTime( start, end ) ) ;
     }
     
     
@@ -204,7 +215,7 @@
         
         end = System.nanoTime();
         
-        System.out.println("total time took to remove an item from AVLTree " + getTime( start,
end ) ) ;
+        LOG.info("total time took to remove an item from AVLTree " + getTime( start, end
) ) ;
 
     }
     
@@ -230,7 +241,7 @@
         
         long end = System.nanoTime();
         
-        System.out.println( "total time taken for serializing HashSet ->" + getTime( start,
end ) );
+        LOG.info( "total time taken for serializing HashSet ->" + getTime( start, end
) );
     }
     
     
@@ -248,7 +259,7 @@
         
         end = System.nanoTime();
         
-        System.out.println("total time taken for reconstructing a serialized HashSet ->"
+ getTime( start, end ) );
+        LOG.info("total time taken for reconstructing a serialized HashSet ->" + getTime(
start, end ) );
     }
     
     
@@ -271,7 +282,7 @@
       
       end = System.nanoTime();
       
-      System.out.println( "total time taken for serializing AVLTree ->" + getTime( start,
end ) );
+      LOG.info( "total time taken for serializing AVLTree ->" + getTime( start, end )
);
     }
 
     
@@ -288,7 +299,7 @@
         tree = (AvlTree<Integer>) treeMarshaller.deserialize( data );
         
         end = System.nanoTime();
-        System.out.println("total time taken for reconstructing a serialized AVLTree ->"
+ getTime( start, end ) );
+        LOG.info("total time taken for reconstructing a serialized AVLTree ->" + getTime(
start, end ) );
     }
     
     

Modified: directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java?rev=684011&r1=684010&r2=684011&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
(original)
+++ directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeTest.java
Fri Aug  8 09:11:27 2008
@@ -20,11 +20,10 @@
 package org.apache.directory.server.core.avltree;
 
 import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.Comparator;
@@ -32,6 +31,8 @@
 
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An AVL tree testcase.
@@ -43,6 +44,8 @@
 {
 
     AvlTree<Integer> tree;
+
+    private static final Logger LOG = LoggerFactory.getLogger( AvlTreeTest.class );
     
     @Before
     public void createTree()
@@ -69,7 +72,10 @@
       tree.remove( 97 ); // remove a non-existing key
       assertTrue( tree.isEmpty() );
       
-      tree.printTree();
+      if( LOG.isDebugEnabled() ) 
+      {
+          tree.printTree();
+      }
     }
     
     
@@ -127,10 +133,16 @@
         tree.insert( 28 );
         tree.insert( 26 );
         
-        tree.printTree();
+        if( LOG.isDebugEnabled() ) 
+        {
+            tree.printTree();
+        }
         
         tree.remove( 24 ); // this causes a single left rotation on node with key 12
-        tree.printTree();
+        if( LOG.isDebugEnabled() ) 
+        { 
+            tree.printTree();
+        }
         assertTrue( tree.getRoot().getLeft().key == 26 );
     }
     
@@ -201,9 +213,9 @@
         tree.insert( 2 );
         tree.insert( 1 );
         
-        System.out.println(getLinkedText());
+        LOG.debug(getLinkedText());
         tree.remove( 2 );
-        System.out.println(getLinkedText());
+        LOG.debug(getLinkedText());
         assertEquals("1,3", getInorderForm());
         
         tree.remove( 1 );
@@ -238,7 +250,10 @@
         assertTrue( 27 == tree.getRoot().key ); // check the root value after double right
rotation
         assertEquals( "21,27,37", getInorderForm() );
         
-        tree.printTree();
+        if( LOG.isDebugEnabled() ) 
+        {
+            tree.printTree();
+        }
     }
 
     @Test



Mime
View raw message