diff options
author | Fredrik Roubert <fredrik@roubert.name> | 2022-05-16 08:07:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 08:07:31 +0300 |
commit | 5251dfb5f83d42f89e0dcbdb65ed14ed5c6ee115 (patch) | |
tree | 5aa5a31ba29e17acf7a8f7d11aa5684e9fa01cfb /tests | |
parent | e3d8183d1b13f450ea9a9e4eda21973220111cb5 (diff) |
DIRSTUDIO-1296: Decode RFC 4517 Postal Address syntax upon export (#32)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java index fcf5291d2..0ff46aa15 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ImportExportTest.java @@ -625,7 +625,9 @@ public class ImportExportTest extends AbstractTestBase store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_CSV_ENCODING, "UTF-8" ); URL url = Platform.getInstanceLocation().getURL(); - final String file = url.getFile() + "ImportExportTest" + server.getType().name() + ".csv"; + final String file = url.getFile() + + "ImportExportShouldPrefixFormulaWithApostropheTest" + + server.getType().name() + ".csv"; browserViewBot.selectEntry( path( GERMAN_UMLAUT_DN ) ); @@ -647,6 +649,44 @@ public class ImportExportTest extends AbstractTestBase /** + * Export to CSV and checks that RFC 4517 Postal Address syntax is decoded. + */ + @ParameterizedTest + @LdapServersSource + public void testExportCsvShouldDecodePostalAddress( TestLdapServer server ) throws Exception + { + connectionsViewBot.createTestConnection( server ); + // set CSV encoding explicit to UTF-8, otherwise platform default encoding would be used + Preferences store = BrowserCorePlugin.getDefault().getPluginPreferences(); + store.setDefault( BrowserCoreConstants.PREFERENCE_FORMAT_CSV_ENCODING, "UTF-8" ); + + URL url = Platform.getInstanceLocation().getURL(); + final String file = url.getFile() + + "ImportExportShouldDecodePostalAddressTest" + + server.getType().name() + ".csv"; + + browserViewBot.selectEntry( path( USER1_DN ) ); + + // export CSV + ExportWizardBot wizardBot = browserViewBot.openExportCsvWizard(); + assertTrue( wizardBot.isVisible() ); + wizardBot.setReturningAttributes( "postalAddress" ); + wizardBot.clickNextButton(); + wizardBot.typeFile( file ); + wizardBot.clickFinishButton(); + wizardBot.waitTillExportFinished( file, 100 ); + + List<String> lines = FileUtils.readLines( new File( file ), StandardCharsets.UTF_8 ); + // verify that the first line is header + assertEquals( "dn,postalAddress", lines.get( 0 ) ); + // verify that the postal address is broken into several lines + assertEquals( "\"uid=user.1,ou=users,dc=example,dc=org\",\"Aaccf Amar", lines.get( 1 ) ); + assertEquals( "27919 Broadway Street", lines.get( 2 ) ); + assertEquals( "Tallahassee, DE 67698\"", lines.get( 3 ) ); + } + + + /** * Test for DIRSTUDIO-1160. * * Attributes silently dropped and not imported when import LDIF and provider is Apache Directory LDAP API. |