directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1043470 - /directory/apacheds/branches/server-config-annotations/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
Date Wed, 08 Dec 2010 16:06:44 GMT
Author: pamarcelot
Date: Wed Dec  8 16:06:44 2010
New Revision: 1043470

URL: http://svn.apache.org/viewvc?rev=1043470&view=rev
Log:
Improved test for ConfigWriter class.

Modified:
    directory/apacheds/branches/server-config-annotations/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java?rev=1043470&r1=1043469&r2=1043470&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
Wed Dec  8 16:06:44 2010
@@ -21,11 +21,14 @@
 package org.apache.directory.server.config;
 
 
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import org.apache.commons.io.FileUtils;
@@ -127,8 +130,26 @@ public class ConfigWriterTest
             originalConfigEntries.add( ldifReader.next() );
         }
 
+        // Getting the list of entries of generated config
+        List<LdifEntry> generatedConfigEntries = configWriter.getConvertedLdifEntries();
+
         // Comparing the number of entries
-        assertEquals( originalConfigEntries.size(), configWriter.getConvertedLdifEntries().size()
);
+        assertEquals( originalConfigEntries.size(), generatedConfigEntries.size() );
+
+        // Comparing each entry's DN in both lists (which have been sorted before)
+        Comparator<LdifEntry> dnComparator = new Comparator<LdifEntry>()
+        {
+            public int compare( LdifEntry o1, LdifEntry o2 )
+            {
+                return o1.getDn().toString().compareToIgnoreCase( o2.getDn().toString() );
+            }
+        };
+        Collections.sort( originalConfigEntries, dnComparator );
+        Collections.sort( generatedConfigEntries, dnComparator );
+        for ( int i = 0; i < originalConfigEntries.size(); i++ )
+        {
+            assertTrue( originalConfigEntries.get( i ).getDn().getNormName().equals( generatedConfigEntries.get(
i ).getDn().getNormName() ) );
+        }
 
         // Destroying the config partition
         configPartition.destroy();



Mime
View raw message