Java Code Examples for org.apache.directory.api.ldap.model.ldif.LdifReader#parseLdif()
The following examples show how to use
org.apache.directory.api.ldap.model.ldif.LdifReader#parseLdif() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdifUtilsTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Test public void testConvertEntryNoControls() throws Exception { LdifReader reader = new LdifReader(); String expected = "dn: ou=test\n" + "ObjectClass: top\n" + "ObjectClass: metaTop\n" + "ObjectClass: metaSyntax\n" + "m-oid: 1.2.3.4\n" + "m-description: description\n\n"; List<LdifEntry> entries = reader.parseLdif( expected ); LdifEntry expectedEntry = entries.get( 0 ); LdifEntry entry = new LdifEntry(); entry.setDn( "ou=test" ); entry.addAttribute( "ObjectClass", "top", "metaTop", "metaSyntax" ); entry.addAttribute( "m-oid", "1.2.3.4" ); entry.addAttribute( "m-description", "description" ); String converted = LdifUtils.convertToLdif( entry ); assertNotNull( converted ); entries = reader.parseLdif( converted ); LdifEntry convertedEntry = entries.get( 0 ); assertEquals( expectedEntry, convertedEntry ); reader.close(); }
Example 2
Source File: LdifUtilsTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Test public void testConvertEntryOneControl() throws Exception { LdifReader reader = new LdifReader(); String expected = "dn: ou=test\n" + "control: 2.16.840.1.113730.3.4.2 false\n" + "changetype: add\n" + "ObjectClass: top\n" + "ObjectClass: metaTop\n" + "ObjectClass: metaSyntax\n" + "m-oid: 1.2.3.4\n" + "m-description: description\n\n"; List<LdifEntry> entries = reader.parseLdif( expected ); LdifEntry expectedEntry = entries.get( 0 ); LdifEntry entry = new LdifEntry(); entry.setDn( "ou=test" ); entry.addAttribute( "ObjectClass", "top", "metaTop", "metaSyntax" ); entry.addAttribute( "m-oid", "1.2.3.4" ); entry.addAttribute( "m-description", "description" ); ManageDsaITImpl control = new ManageDsaITImpl(); entry.addControl( control ); String converted = LdifUtils.convertToLdif( entry ); assertNotNull( converted ); entries = reader.parseLdif( converted ); LdifEntry convertedEntry = entries.get( 0 ); assertEquals( expectedEntry, convertedEntry ); reader.close(); }