use of org.apache.directory.api.ldap.model.ldif.LdifControl in project directory-ldap-api by apache.
the class LdifEntryTest method testLdifEntryChangeTypeModddnWithControls.
/**
* Test a ModDN changeType LdifEntry with controls
* @throws Exception
*/
@Test
public void testLdifEntryChangeTypeModddnWithControls() throws Exception {
String ldif = "control: 1.2.840.113556.1.4.805 true\n" + "control: 1.2.840.113556.1.4.806 false: test\n" + "changetype: moddn\n" + "newrdn: cn=app2\n" + "deleteoldrdn: 1\n";
LdifEntry ldifEntry = new LdifEntry("cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif);
assertNotNull(ldifEntry);
assertEquals(ChangeType.ModDn, ldifEntry.getChangeType());
assertNull(ldifEntry.getEntry());
assertEquals("cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName());
assertTrue(ldifEntry.isLdifChange());
assertEquals("cn=app2", ldifEntry.getNewRdn());
assertTrue(ldifEntry.isDeleteOldRdn());
assertNull(ldifEntry.getNewSuperior());
assertTrue(ldifEntry.hasControls());
LdifControl ldifControl = ldifEntry.getControl("1.2.840.113556.1.4.805");
assertNotNull(ldifControl);
assertEquals("1.2.840.113556.1.4.805", ldifControl.getOid());
assertTrue(ldifControl.isCritical());
assertNull(ldifControl.getValue());
ldifControl = ldifEntry.getControl("1.2.840.113556.1.4.806");
assertNotNull(ldifControl);
assertEquals("1.2.840.113556.1.4.806", ldifControl.getOid());
assertFalse(ldifControl.isCritical());
assertNotNull(ldifControl.getValue());
assertEquals("test", Strings.utf8ToString(ldifControl.getValue()));
}
use of org.apache.directory.api.ldap.model.ldif.LdifControl in project directory-ldap-api by apache.
the class LdifEntryTest method testLdifParserChangeTypeDeleteWithControl.
/**
* Test a Delete changeType LdifEntry with one control
*
* @throws Exception
*/
@Test
public void testLdifParserChangeTypeDeleteWithControl() throws Exception {
String ldif = "# Delete an entry. The operation will attach the LDAPv3\n" + "# Tree Delete Control defined in [9]. The criticality\n" + "# field is \"true\" and the controlValue field is\n" + "# absent, as required by [9].\n" + "control: 1.2.840.113556.1.4.805 true\n" + "changetype: delete\n";
LdifEntry ldifEntry = new LdifEntry("ou=Product Development, dc=airius, dc=com", ldif);
assertNotNull(ldifEntry);
assertEquals(ChangeType.Delete, ldifEntry.getChangeType());
assertNull(ldifEntry.getEntry());
assertEquals("ou=Product Development, dc=airius, dc=com", ldifEntry.getDn().getName());
assertTrue(ldifEntry.hasControls());
LdifControl ldifControl = ldifEntry.getControl("1.2.840.113556.1.4.805");
assertNotNull(ldifControl);
assertEquals("1.2.840.113556.1.4.805", ldifControl.getOid());
assertTrue(ldifControl.isCritical());
assertNull(ldifControl.getValue());
}
use of org.apache.directory.api.ldap.model.ldif.LdifControl in project directory-ldap-api by apache.
the class LdifEntryTest method testLdifEntryChangeTypeAddWithControls.
/**
* Test a Add changeType LdifEntry with controls
* @throws Exception
*/
@Test
public void testLdifEntryChangeTypeAddWithControls() throws Exception {
String ldif = "control: 1.2.840.113556.1.4.805 true\n" + "control: 1.2.840.113556.1.4.806 false: test\n" + "changetype: add\n" + "cn: app1\n" + "objectClass: top\n" + "objectClass: apApplication\n" + "displayName: app1 \n" + "dependencies:\n" + "envVars:";
LdifEntry ldifEntry = new LdifEntry("cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif);
assertNotNull(ldifEntry);
assertEquals(ChangeType.Add, ldifEntry.getChangeType());
assertNotNull(ldifEntry.getEntry());
assertEquals("cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName());
assertTrue(ldifEntry.isLdifChange());
Attribute attr = ldifEntry.get("displayname");
assertTrue(attr.contains("app1"));
assertTrue(ldifEntry.hasControls());
LdifControl ldifControl = ldifEntry.getControl("1.2.840.113556.1.4.805");
assertNotNull(ldifControl);
assertEquals("1.2.840.113556.1.4.805", ldifControl.getOid());
assertTrue(ldifControl.isCritical());
assertNull(ldifControl.getValue());
ldifControl = ldifEntry.getControl("1.2.840.113556.1.4.806");
assertNotNull(ldifControl);
assertEquals("1.2.840.113556.1.4.806", ldifControl.getOid());
assertFalse(ldifControl.isCritical());
assertNotNull(ldifControl.getValue());
assertEquals("test", Strings.utf8ToString(ldifControl.getValue()));
}
Aggregations