use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.
the class LDIFModifyDNChangeRecordTestCase method testConstructor2WithoutNewSuperior.
/**
* Tests the second constructor without a newSuperior DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor2WithoutNewSuperior() throws Exception {
ModifyDNRequest modifyDNRequest = new ModifyDNRequest("ou=People,dc=example,dc=com", "ou=Users", true);
LDIFModifyDNChangeRecord r = new LDIFModifyDNChangeRecord(modifyDNRequest);
assertNotNull(r.getDN());
assertEquals(r.getDN(), "ou=People,dc=example,dc=com");
assertEquals(r.getParsedDN(), new DN("ou=People,dc=example,dc=com"));
assertNotNull(r.getNewRDN());
assertEquals(r.getNewRDN(), "ou=Users");
assertEquals(r.getParsedNewRDN(), new RDN("ou=Users"));
assertTrue(r.deleteOldRDN());
assertNull(r.getNewSuperiorDN());
assertNull(r.getParsedNewSuperiorDN());
assertEquals(r.getNewDN(), new DN("ou=Users,dc=example,dc=com"));
modifyDNRequest = r.toModifyDNRequest();
assertEquals(modifyDNRequest.getDN(), "ou=People,dc=example,dc=com");
String[] ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 4);
assertEquals(r.getChangeType(), ChangeType.MODIFY_DN);
r.hashCode();
ByteStringBuffer byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer);
assertNotNull(byteBuffer.toString());
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer, 10);
assertNotNull(byteBuffer.toString());
StringBuilder stringBuffer = new StringBuilder();
r.toLDIFString(stringBuffer);
assertNotNull(r.toString());
stringBuffer = new StringBuilder();
r.toLDIFString(stringBuffer, 10);
assertNotNull(r.toString());
assertNotNull(r.toLDIFString());
assertNotNull(r.toLDIFString(10));
assertNotNull(r.toString());
}
use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.
the class LDIFModifyDNChangeRecordTestCase method testConstructor1WithoutNewSuperior.
/**
* Tests the first constructor with a {@code null} newSuperior DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor1WithoutNewSuperior() throws Exception {
LDIFModifyDNChangeRecord r = new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=Users", false, null);
assertNotNull(r.getDN());
assertEquals(r.getDN(), "ou=People,dc=example,dc=com");
assertEquals(r.getParsedDN(), new DN("ou=People,dc=example,dc=com"));
assertNotNull(r.getNewRDN());
assertEquals(r.getNewRDN(), "ou=Users");
assertEquals(r.getParsedNewRDN(), new RDN("ou=Users"));
assertFalse(r.deleteOldRDN());
assertNull(r.getNewSuperiorDN());
assertNull(r.getParsedNewSuperiorDN());
assertEquals(r.getNewDN(), new DN("ou=Users,dc=example,dc=com"));
ModifyDNRequest modifyDNRequest = r.toModifyDNRequest();
assertEquals(modifyDNRequest.getDN(), "ou=People,dc=example,dc=com");
String[] ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 4);
assertEquals(r.getChangeType(), ChangeType.MODIFY_DN);
r.hashCode();
ByteStringBuffer byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer);
assertNotNull(byteBuffer.toString());
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer, 10);
assertNotNull(byteBuffer.toString());
StringBuilder stringBuffer = new StringBuilder();
r.toLDIFString(stringBuffer);
assertNotNull(r.toString());
stringBuffer = new StringBuilder();
r.toLDIFString(stringBuffer, 10);
assertNotNull(r.toString());
assertNotNull(r.toLDIFString());
assertNotNull(r.toLDIFString(10));
assertNotNull(r.toString());
}
use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.
the class LDIFModifyDNChangeRecordTestCase method testConstructor2WithNewSuperior.
/**
* Tests the second constructor with a newSuperior DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor2WithNewSuperior() throws Exception {
ModifyDNRequest modifyDNRequest = new ModifyDNRequest("ou=People,dc=example,dc=com", "ou=Users", false, "o=example.com");
LDIFModifyDNChangeRecord r = new LDIFModifyDNChangeRecord(modifyDNRequest);
assertNotNull(r.getDN());
assertEquals(r.getDN(), "ou=People,dc=example,dc=com");
assertEquals(r.getParsedDN(), new DN("ou=People,dc=example,dc=com"));
assertNotNull(r.getNewRDN());
assertEquals(r.getNewRDN(), "ou=Users");
assertEquals(r.getParsedNewRDN(), new RDN("ou=Users"));
assertFalse(r.deleteOldRDN());
assertNotNull(r.getNewSuperiorDN());
assertEquals(r.getNewSuperiorDN(), "o=example.com");
assertEquals(r.getParsedNewSuperiorDN(), new DN("o=example.com"));
assertEquals(r.getNewDN(), new DN("ou=Users,o=example.com"));
modifyDNRequest = r.toModifyDNRequest();
assertEquals(modifyDNRequest.getDN(), "ou=People,dc=example,dc=com");
String[] ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 5);
assertEquals(r.getChangeType(), ChangeType.MODIFY_DN);
r.hashCode();
ByteStringBuffer byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer);
assertNotNull(byteBuffer.toString());
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer, 10);
assertNotNull(byteBuffer.toString());
StringBuilder stringBuffer = new StringBuilder();
r.toLDIFString(stringBuffer);
assertNotNull(r.toString());
stringBuffer = new StringBuilder();
r.toLDIFString(stringBuffer, 10);
assertNotNull(r.toString());
assertNotNull(r.toLDIFString());
assertNotNull(r.toLDIFString(10));
assertNotNull(r.toString());
}
use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.
the class LDIFControlsTestCase method testModifyDNChangeRecordAsModRDN.
/**
* Tests control behavior for an LDIF modify DN change record using a
* changetype of modrdn.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyDNChangeRecordAsModRDN() throws Exception {
// Decode the modify DN change record from raw strings.
LDIFChangeRecord r = LDIFReader.decodeChangeRecord(generateChangeRecordLines("ou=People,dc=example,dc=com", "modrdn", "newrdn: ou=Users", "deleteoldrdn: 1", "newsuperior: o=example.com"));
assertTrue(r instanceof LDIFModifyDNChangeRecord);
assertNotNull(r.toString());
LDIFModifyDNChangeRecord modifyDNRecord = (LDIFModifyDNChangeRecord) r;
assertEquals(modifyDNRecord.getControls(), controls);
assertDNsEqual(modifyDNRecord.getDN(), "ou=People,dc=example,dc=com");
assertEquals(new RDN(modifyDNRecord.getNewRDN()), new RDN("ou=Users"));
assertTrue(modifyDNRecord.deleteOldRDN());
assertDNsEqual(modifyDNRecord.getNewSuperiorDN(), "o=example.com");
// Generate an LDIF representation from the modify DN change record and
// ensure it decodes to the same thing.
r = LDIFReader.decodeChangeRecord(modifyDNRecord.toLDIF());
assertTrue(r instanceof LDIFModifyDNChangeRecord);
assertNotNull(r.toString());
modifyDNRecord = (LDIFModifyDNChangeRecord) r;
assertEquals(modifyDNRecord.getControls(), controls);
assertDNsEqual(modifyDNRecord.getDN(), "ou=People,dc=example,dc=com");
assertEquals(new RDN(modifyDNRecord.getNewRDN()), new RDN("ou=Users"));
assertTrue(modifyDNRecord.deleteOldRDN());
assertDNsEqual(modifyDNRecord.getNewSuperiorDN(), "o=example.com");
// Write the LDIF representation to a file, read it back, and ensure it
// decodes to the same thing.
final File ldifFile = createTempFile();
assertTrue(ldifFile.delete());
final LDIFWriter writer = new LDIFWriter(ldifFile);
writer.writeChangeRecord(modifyDNRecord);
writer.close();
final LDIFReader reader = new LDIFReader(ldifFile);
r = reader.readChangeRecord();
assertNull(reader.readLDIFRecord());
assertTrue(r instanceof LDIFModifyDNChangeRecord);
assertNotNull(r.toString());
modifyDNRecord = (LDIFModifyDNChangeRecord) r;
assertEquals(modifyDNRecord.getControls(), controls);
assertDNsEqual(modifyDNRecord.getDN(), "ou=People,dc=example,dc=com");
assertEquals(new RDN(modifyDNRecord.getNewRDN()), new RDN("ou=Users"));
assertTrue(modifyDNRecord.deleteOldRDN());
assertDNsEqual(modifyDNRecord.getNewSuperiorDN(), "o=example.com");
final ModifyDNRequest modifyDNRequest = modifyDNRecord.toModifyDNRequest();
assertEquals(modifyDNRequest.getControlList(), controls);
assertDNsEqual(modifyDNRequest.getDN(), "ou=People,dc=example,dc=com");
assertEquals(new RDN(modifyDNRequest.getNewRDN()), new RDN("ou=Users"));
assertTrue(modifyDNRequest.deleteOldRDN());
assertDNsEqual(modifyDNRequest.getNewSuperiorDN(), "o=example.com");
}
use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.
the class LDIFControlsTestCase method testModifyDNChangeRecordAsModDN.
/**
* Tests control behavior for an LDIF modify DN change record using a
* changetype of moddn.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyDNChangeRecordAsModDN() throws Exception {
// Decode the modify DN change record from raw strings.
LDIFChangeRecord r = LDIFReader.decodeChangeRecord(generateChangeRecordLines("ou=People,dc=example,dc=com", "moddn", "newrdn: ou=Users", "deleteoldrdn: 1"));
assertTrue(r instanceof LDIFModifyDNChangeRecord);
assertNotNull(r.toString());
LDIFModifyDNChangeRecord modifyDNRecord = (LDIFModifyDNChangeRecord) r;
assertEquals(modifyDNRecord.getControls(), controls);
assertDNsEqual(modifyDNRecord.getDN(), "ou=People,dc=example,dc=com");
assertEquals(new RDN(modifyDNRecord.getNewRDN()), new RDN("ou=Users"));
assertTrue(modifyDNRecord.deleteOldRDN());
assertNull(modifyDNRecord.getNewSuperiorDN());
// Generate an LDIF representation from the modify DN change record and
// ensure it decodes to the same thing.
r = LDIFReader.decodeChangeRecord(modifyDNRecord.toLDIF());
assertTrue(r instanceof LDIFModifyDNChangeRecord);
assertNotNull(r.toString());
modifyDNRecord = (LDIFModifyDNChangeRecord) r;
assertEquals(modifyDNRecord.getControls(), controls);
assertDNsEqual(modifyDNRecord.getDN(), "ou=People,dc=example,dc=com");
assertEquals(new RDN(modifyDNRecord.getNewRDN()), new RDN("ou=Users"));
assertTrue(modifyDNRecord.deleteOldRDN());
assertNull(modifyDNRecord.getNewSuperiorDN());
// Write the LDIF representation to a file, read it back, and ensure it
// decodes to the same thing.
final File ldifFile = createTempFile();
assertTrue(ldifFile.delete());
final LDIFWriter writer = new LDIFWriter(ldifFile);
writer.writeChangeRecord(modifyDNRecord);
writer.close();
final LDIFReader reader = new LDIFReader(ldifFile);
r = reader.readChangeRecord();
assertNull(reader.readLDIFRecord());
assertTrue(r instanceof LDIFModifyDNChangeRecord);
assertNotNull(r.toString());
modifyDNRecord = (LDIFModifyDNChangeRecord) r;
assertEquals(modifyDNRecord.getControls(), controls);
assertDNsEqual(modifyDNRecord.getDN(), "ou=People,dc=example,dc=com");
assertEquals(new RDN(modifyDNRecord.getNewRDN()), new RDN("ou=Users"));
assertTrue(modifyDNRecord.deleteOldRDN());
assertNull(modifyDNRecord.getNewSuperiorDN());
final ModifyDNRequest modifyDNRequest = modifyDNRecord.toModifyDNRequest();
assertEquals(modifyDNRequest.getControlList(), controls);
assertDNsEqual(modifyDNRequest.getDN(), "ou=People,dc=example,dc=com");
assertEquals(new RDN(modifyDNRequest.getNewRDN()), new RDN("ou=Users"));
assertTrue(modifyDNRequest.deleteOldRDN());
assertNull(modifyDNRequest.getNewSuperiorDN());
}
Aggregations