Search in sources :

Example 21 with LdifAttributesReader

use of org.apache.directory.api.ldap.model.ldif.LdifAttributesReader in project directory-ldap-api by apache.

the class LdifAttributesReaderTest method testLdifParserBase64.

@Test
public void testLdifParserBase64() throws LdapLdifException, IOException {
    String ldif = "#comment\n" + "cn:: RW1tYW51ZWwgTMOpY2hhcm55\n" + "objectClass: top\n" + "objectClass: apApplication\n" + "displayName: app1\n" + "serviceType: http\n" + "dependencies:\n" + "httpHeaders:\n" + "startupOptions:\n" + "envVars:";
    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry(ldif);
    assertNotNull(entry);
    Attribute attr = entry.get("cn");
    assertTrue(attr.contains("Emmanuel L\u00e9charny".getBytes(StandardCharsets.UTF_8)));
    attr = entry.get("objectclass");
    assertTrue(attr.contains("top"));
    assertTrue(attr.contains("apApplication"));
    attr = entry.get("displayname");
    assertTrue(attr.contains("app1"));
    attr = entry.get("dependencies");
    assertEquals("", attr.get().getValue());
    attr = entry.get("envvars");
    assertEquals("", attr.get().getValue());
    reader.close();
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) Attribute(org.apache.directory.api.ldap.model.entry.Attribute) LdifAttributesReader(org.apache.directory.api.ldap.model.ldif.LdifAttributesReader) Test(org.junit.Test)

Aggregations

LdifAttributesReader (org.apache.directory.api.ldap.model.ldif.LdifAttributesReader)21 Test (org.junit.Test)20 Entry (org.apache.directory.api.ldap.model.entry.Entry)13 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)9 Attributes (javax.naming.directory.Attributes)6 LdapLdifException (org.apache.directory.api.ldap.model.ldif.LdapLdifException)2 IOException (java.io.IOException)1 LdapInvalidAttributeValueException (org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException)1