Search in sources :

Example 91 with Attribute

use of org.apache.directory.api.ldap.model.entry.Attribute in project directory-ldap-api by apache.

the class SchemaAwareModificationSerializationTest method testSerializationModificationREMOVE.

@Test
public void testSerializationModificationREMOVE() throws ClassNotFoundException, IOException, LdapInvalidAttributeValueException {
    Attribute attribute = new DefaultAttribute("cn", cnAT);
    attribute.add("test1", "test2");
    DefaultModification mod = new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, attribute);
    Modification modSer = deserializeValue(serializeValue(mod));
    assertEquals(mod, modSer);
}
Also used : DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) Modification(org.apache.directory.api.ldap.model.entry.Modification) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) Attribute(org.apache.directory.api.ldap.model.entry.Attribute) DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) Test(org.junit.Test)

Example 92 with Attribute

use of org.apache.directory.api.ldap.model.entry.Attribute in project directory-ldap-api by apache.

the class LdifAttributesReaderTest method testLdifParser.

@Test
public void testLdifParser() throws LdapLdifException, LdapInvalidAttributeValueException, IOException {
    String ldif = "cn: app1\n" + "objectClass: top\n" + "objectClass: apApplication\n" + "displayName: app1   \n" + "dependencies:\n" + "envVars:";
    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry(ldif);
    assertNotNull(entry);
    Attribute attr = entry.get("cn");
    assertTrue(attr.contains("app1"));
    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)

Example 93 with Attribute

use of org.apache.directory.api.ldap.model.entry.Attribute in project directory-ldap-api by apache.

the class LdifAttributesReaderTest method testLdifVersionStart.

@Test
public void testLdifVersionStart() throws LdapLdifException, IOException {
    String ldif = "cn: app1\n" + "objectClass: top\n" + "objectClass: apApplication\n" + "displayName:   app1   \n" + "dependencies:\n" + "envVars:";
    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry(ldif);
    assertEquals(1, reader.getVersion());
    assertNotNull(entry);
    Attribute attr = entry.get("displayname");
    assertTrue(attr.contains("app1"));
    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)

Example 94 with Attribute

use of org.apache.directory.api.ldap.model.entry.Attribute in project directory-ldap-api by apache.

the class LdifAttributesReaderTest method testLdifParserMultiLineEntries.

@Test
public void testLdifParserMultiLineEntries() throws LdapLdifException, IOException {
    String ldif = "#comment\n" + "cn: app1#another comment\n" + "objectClass: top\n" + "objectClass: apAppli\n" + " cation\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("app1#another comment"));
    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)

Example 95 with Attribute

use of org.apache.directory.api.ldap.model.entry.Attribute in project directory-ldap-api by apache.

the class LdifAttributesReaderTest method testLdifParserBase64MultiLine.

@Test
public void testLdifParserBase64MultiLine() throws LdapLdifException, IOException {
    String ldif = "#comment\n" + "cn:: RW1tYW51ZWwg\n" + " TMOpY2hhcm55ICA=\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

Attribute (org.apache.directory.api.ldap.model.entry.Attribute)269 Test (org.junit.Test)180 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)168 Entry (org.apache.directory.api.ldap.model.entry.Entry)94 Modification (org.apache.directory.api.ldap.model.entry.Modification)56 Value (org.apache.directory.api.ldap.model.entry.Value)52 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)46 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)35 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)23 EncoderException (org.apache.directory.api.asn1.EncoderException)20 ByteBuffer (java.nio.ByteBuffer)18 DecoderException (org.apache.directory.api.asn1.DecoderException)18 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)18 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)18 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)18 SearchResultEntry (org.apache.directory.api.ldap.model.message.SearchResultEntry)18 LdapInvalidAttributeValueException (org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException)16 LdifEntry (org.apache.directory.api.ldap.model.ldif.LdifEntry)16 ModifyRequest (org.apache.directory.api.ldap.model.message.ModifyRequest)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13