use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class SchemaAwareEntryTest method createEntry.
/**
* Helper method which creates an entry with 4 attributes.
*/
private Entry createEntry() {
try {
Entry entry = new DefaultEntry(exampleDn);
Attribute attrOC = new DefaultAttribute("objectClass", "top", "person");
Attribute attrCN = new DefaultAttribute("cn", "test1", "test2");
Attribute attrSN = new DefaultAttribute("sn", "Test1", "Test2");
Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, BYTES2);
entry.put(attrOC, attrCN, attrSN, attrPWD);
return entry;
} catch (LdapException ne) {
// Do nothing
return null;
}
}
use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class SchemaAwareEntryTest method testHasObjectClass.
/**
* Test method for hasObjectClass( String )
*/
@Test
public void testHasObjectClass() throws LdapException {
Entry entry = new DefaultEntry(exampleDn);
assertFalse(entry.containsAttribute("objectClass"));
assertFalse(entry.hasObjectClass("top"));
entry.add(new DefaultAttribute("objectClass", "top", "person"));
assertTrue(entry.hasObjectClass("top"));
assertTrue(entry.hasObjectClass("person"));
assertFalse(entry.hasObjectClass("inetorgperson"));
assertFalse(entry.hasObjectClass((String) null));
assertFalse(entry.hasObjectClass(""));
}
use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class SchemaAwareEntryTest method testDefaultClientEntry.
/**
* Test method for DefaultEntry()
*/
@Test
public void testDefaultClientEntry() {
Entry entry = new DefaultEntry();
assertNotNull(entry);
assertEquals(Dn.EMPTY_DN, entry.getDn());
assertEquals(0, entry.size());
}
use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class SchemaAwareEntryTest method testContainsStringStringArray.
/**
* Test method for contains( String, String... )
*/
@Test
public void testContainsStringStringArray() throws LdapException {
Entry entry = new DefaultEntry(exampleDn);
assertFalse(entry.containsAttribute("objectClass"));
Attribute attrOC = new DefaultAttribute("objectClass", "top", "person");
Attribute attrCN = new DefaultAttribute("cn", "test1", "test2");
Attribute attrSN = new DefaultAttribute("sn", "Test1", "Test2", (String) null);
Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, BYTES2);
entry.add(attrOC, attrCN, attrSN, attrPWD);
assertTrue(entry.contains("OBJECTCLASS", "top", "person"));
assertTrue(entry.contains(" cn ", "test1", "test2"));
assertTrue(entry.contains("Sn", "Test1", "Test2", (String) null));
assertTrue(entry.contains(" userPASSWORD ", "ab", "b"));
assertFalse(entry.contains("OBJECTCLASS", "PERSON"));
assertFalse(entry.contains(" cn ", "test1", "test3"));
assertFalse(entry.contains("Sn", "Test"));
assertFalse(entry.contains(" userPASSWORD ", (String) null));
}
use of org.apache.directory.api.ldap.model.entry.DefaultEntry in project directory-ldap-api by apache.
the class SchemaAwareEntryTest method testSerializeEntryWithNoDN.
/**
* Test the serialization of an entry with no Dn
*/
@Test
public void testSerializeEntryWithNoDN() throws LdapException, IOException, ClassNotFoundException {
byte[] password = Strings.getBytesUtf8("secret");
Entry entry = new DefaultEntry();
entry.add("ObjectClass", "top", "person");
entry.add("cn", "test1");
entry.add("userPassword", password);
Entry entrySer = deserializeValue(serializeValue(entry));
assertEquals(entry, entrySer);
}
Aggregations