use of com.unboundid.util.ByteStringBuffer in project ldapsdk by pingidentity.
the class LDIFAddChangeRecordTestCase method testConstructor2.
/**
* Tests the second constructor.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor2() throws Exception {
Entry e = new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example");
LDIFAddChangeRecord r = new LDIFAddChangeRecord(e);
assertNotNull(r.getDN());
assertEquals(r.getDN(), "dc=example,dc=com");
assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
assertNotNull(r.getAttributes());
assertEquals(r.getAttributes().length, 2);
AddRequest addRequest = r.toAddRequest();
assertNotNull(addRequest);
assertEquals(addRequest.getDN(), "dc=example,dc=com");
assertEquals(r.getChangeType(), ChangeType.ADD);
String[] ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 5);
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());
assertNotNull(r.getEntryToAdd());
assertEquals(r.getEntryToAdd(), new Entry(r.getDN(), r.getAttributes()));
}
use of com.unboundid.util.ByteStringBuffer in project ldapsdk by pingidentity.
the class LDIFChangeRecordTestCase method testModifyChangeRecordWithMultipleChanges.
/**
* Performs a set of general tests for a modify change record with multiple
* changes.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testModifyChangeRecordWithMultipleChanges() throws Exception {
LDIFModifyChangeRecord r = new LDIFModifyChangeRecord("dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "foo"), new Modification(ModificationType.REPLACE, "o", "example.com"));
assertNotNull(r.getDN());
assertEquals(new DN(r.getDN()), new DN("dc=example,dc=com"));
assertNotNull(r.getParsedDN());
assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
assertEquals(r.getChangeType(), ChangeType.MODIFY);
try {
assertNotNull(r.toEntry());
fail("Expected an exception when trying to convert a modify change " + "record with multiple changes to an entry.");
} catch (LDIFException le) {
// This was expected.
}
assertNotNull(r.toLDIF());
assertFalse(r.toLDIF().length == 0);
assertEquals(LDIFReader.decodeChangeRecord(r.toLDIF()), r);
assertNotNull(r.toLDIF(10));
assertFalse(r.toLDIF(10).length == 0);
assertEquals(LDIFReader.decodeChangeRecord(r.toLDIF(10)), r);
ByteStringBuffer byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer);
assertFalse(byteBuffer.length() == 0);
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer, 10);
assertFalse(byteBuffer.length() == 0);
assertNotNull(r.toLDIFString());
assertNotNull(r.toLDIFString(10));
StringBuilder stringBuffer = new StringBuilder();
r.toLDIFString(stringBuffer);
assertFalse(stringBuffer.length() == 0);
stringBuffer = new StringBuilder();
r.toLDIFString(stringBuffer, 10);
assertFalse(stringBuffer.length() == 0);
assertNotNull(r.toString());
}
use of com.unboundid.util.ByteStringBuffer in project ldapsdk by pingidentity.
the class LDIFModifyChangeRecordTestCase method testConstructor2MultipleModifications.
/**
* Tests the second constructor with multiple modifications.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor2MultipleModifications() throws Exception {
List<Modification> mods = Arrays.asList(new Modification(ModificationType.REPLACE, "description", "foo", "bar"), new Modification(ModificationType.ADD, "objectClass", "extensibleObject"), new Modification(ModificationType.DELETE, "cn"), new Modification(ModificationType.INCREMENT, "intValue", "5"));
LDIFModifyChangeRecord r = new LDIFModifyChangeRecord("dc=example,dc=com", mods);
assertNotNull(r.getDN());
assertEquals(r.getDN(), "dc=example,dc=com");
assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
assertNotNull(r.getModifications());
assertEquals(r.getModifications().length, 4);
ModifyRequest modifyRequest = r.toModifyRequest();
assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
assertEquals(r.getChangeType(), ChangeType.MODIFY);
assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
String[] ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 14);
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());
LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 13);
LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
r.hashCode();
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer);
assertNotNull(byteBuffer.toString());
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer, 10);
assertNotNull(byteBuffer.toString());
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.util.ByteStringBuffer in project ldapsdk by pingidentity.
the class LDIFModifyChangeRecordTestCase method testConstructor3.
/**
* Tests the third constructor.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor3() throws Exception {
Modification[] mods = { new Modification(ModificationType.ADD, "description", "foo") };
ModifyRequest modifyRequest = new ModifyRequest("dc=example,dc=com", mods);
LDIFModifyChangeRecord r = new LDIFModifyChangeRecord(modifyRequest);
assertNotNull(r.getDN());
assertEquals(r.getDN(), "dc=example,dc=com");
assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
assertNotNull(r.getModifications());
assertEquals(r.getModifications().length, 1);
modifyRequest = r.toModifyRequest();
assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
assertEquals(r.getChangeType(), ChangeType.MODIFY);
assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
String[] ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 5);
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());
LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 4);
LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
r.hashCode();
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer);
assertNotNull(byteBuffer.toString());
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer, 10);
assertNotNull(byteBuffer.toString());
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.util.ByteStringBuffer in project ldapsdk by pingidentity.
the class LDIFModifyChangeRecordTestCase method testConstructor2SingleModification.
/**
* Tests the second constructor with a single modification.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testConstructor2SingleModification() throws Exception {
List<Modification> mods = Arrays.asList(new Modification(ModificationType.ADD, "description", "foo"));
LDIFModifyChangeRecord r = new LDIFModifyChangeRecord("dc=example,dc=com", mods);
assertNotNull(r.getDN());
assertEquals(r.getDN(), "dc=example,dc=com");
assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
assertNotNull(r.getModifications());
assertEquals(r.getModifications().length, 1);
ModifyRequest modifyRequest = r.toModifyRequest();
assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
assertEquals(r.getChangeType(), ChangeType.MODIFY);
assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
String[] ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 5);
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());
LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
ldifLines = r.toLDIF();
assertNotNull(ldifLines);
assertEquals(ldifLines.length, 4);
LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
r.hashCode();
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer);
assertNotNull(byteBuffer.toString());
byteBuffer = new ByteStringBuffer();
r.toLDIF(byteBuffer, 10);
assertNotNull(byteBuffer.toString());
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());
}
Aggregations