directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r772403 - in /directory/studio/trunk: ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
Date Wed, 06 May 2009 19:05:26 GMT
Author: seelmann
Date: Wed May  6 19:05:25 2009
New Revision: 772403

URL: http://svn.apache.org/viewvc?rev=772403&view=rev
Log:
Fix for DIRSTUDIO-486 (Include Version Specifier in LDIF export)

Modified:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java
    directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java?rev=772403&r1=772402&r2=772403&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java
(original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/ExportLdifJob.java
Wed May  6 19:05:25 2009
@@ -50,12 +50,14 @@
 import org.apache.directory.studio.ldapbrowser.core.utils.JNDIUtils;
 import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter;
 import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.apache.directory.studio.ldifparser.LdifFormatParameters;
 import org.apache.directory.studio.ldifparser.model.LdifEnumeration;
 import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
 import org.apache.directory.studio.ldifparser.model.container.LdifContentRecord;
 import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
 import org.apache.directory.studio.ldifparser.model.lines.LdifDnLine;
 import org.apache.directory.studio.ldifparser.model.lines.LdifSepLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifVersionLine;
 
 
 /**
@@ -153,7 +155,17 @@
         try
         {
             JndiLdifEnumeration enumeration = search( browserConnection, searchParameter,
monitor );
+            LdifFormatParameters ldifFormatParameters = Utils.getLdifFormatParameters();
 
+            // add version spec
+            LdifVersionLine ldifVersionLine = LdifVersionLine.create();
+            String ldifVersionLineString = ldifVersionLine.toFormattedString( ldifFormatParameters
);
+            bufferedWriter.write( ldifVersionLineString );
+            LdifSepLine ldifSepLine = LdifSepLine.create();
+            String ldifSepLineString = ldifSepLine.toFormattedString( ldifFormatParameters
);
+            bufferedWriter.write( ldifSepLineString );
+
+            // add the records
             while ( !monitor.isCanceled() && !monitor.errorsReported() &&
enumeration.hasNext() )
             {
                 LdifContainer container = enumeration.next();
@@ -175,7 +187,7 @@
                         newRecord.addAttrVal( attrValLines[i] );
                     }
                     newRecord.finish( sepLine );
-                    String s = newRecord.toFormattedString( Utils.getLdifFormatParameters()
);
+                    String s = newRecord.toFormattedString( ldifFormatParameters );
 
                     // String s = record.toFormattedString();
                     bufferedWriter.write( s );

Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java?rev=772403&r1=772402&r2=772403&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
(original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java
Wed May  6 19:05:25 2009
@@ -104,11 +104,13 @@
         eBot.comboBoxWithLabel( "LDIF File:" ).setText( file );
         eBot.button( "Finish" ).click();
 
-        // verify that exported LDIF starts with the Base64 encoded DN
         eBot.sleep( 2000 );
-        String content = FileUtils.readFileToString( new File( file ) );
-        assertTrue( "LDIF must start with Base64 encoded DN.", content
-            .startsWith( "dn:: Y249V29sZmdhbmcgS8O2bGJlbCxvdT11c2VycyxvdT1zeXN0ZW0=" ) );
+        List<String> lines = FileUtils.readLines( new File( file ) );
+        // verify that the first line of exported LDIF is "version: 1"
+        assertEquals( "LDIF must start with version: 1", lines.get( 0 ), "version: 1" );
+        // verify that the third line of exported LDIF is the Base64 encoded DN
+        assertEquals( "Expected Base64 encoded DN", lines.get( 2 ),
+            "dn:: Y249V29sZmdhbmcgS8O2bGJlbCxvdT11c2VycyxvdT1zeXN0ZW0=" );
 
         // delete entry
         SWTBotUtils.asyncClick( eBot, browserTree.contextMenu( "Delete Entry" ), new DefaultCondition()



Mime
View raw message