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);
}
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();
}
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();
}
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();
}
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();
}
Aggregations