| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF Search with null reader is allowed but throws null pointer |
| | | * LDIF Search with null reader is allowed but throws a null pointer |
| | | * exception. |
| | | * |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * Test the search request using a schema and no specifying attribute |
| | | * Tests the search request using a schema and no specifying attribute |
| | | * description. |
| | | * |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * Test the search request using a schema and no specifying attribute |
| | | * Tests the search request using a schema and no specifying attribute |
| | | * description. TypesOnly = true. |
| | | * |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF Search with Schema use : all attributes. |
| | | * LDIF search with schema use : all attributes. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF Search with Schema use : all attributes. Types only. |
| | | * LDIF Search with schema use : all attributes. Types only. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | assertThat(entry.getAttribute("uid")).isNotNull(); |
| | | assertThat(entry.getAttribute("uid").getAttributeDescription()).isNotNull(); |
| | | assertThat(entry.getAttribute("uid")).isEmpty(); |
| | | // The following assert throws an exception because no values contained in, only type. |
| | | // The following assert throws an exception because it contains only |
| | | // attribute descriptions (and not values) are to be returned. |
| | | assertThat(entry.getAttribute("uid").firstValueAsString()).isNull(); |
| | | } |
| | | resultReader.close(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF Search with Schema use filter on uid attribute. |
| | | * LDIF search with schema use filter on uid attribute. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF Search with Schema use filter on uid attribute. |
| | | * LDIF search with schema use filter on uid attribute. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF Search with Schema use with filter not contained in this entry. |
| | | * LDIF search with schema use with filter not contained in this entry. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Verifying LDIF Collection reader. |
| | | * Verifying LDIF collection reader. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * The LDIF newEntryCollectionReader allows a null parameter. |
| | | * The LDIF entry collection reader allows a null parameter. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF newEntryIteratorReader. |
| | | * Tests the LDIF entry iterator reader. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF newEntryIteratorReader doesn't allow null. |
| | | * LDIF entry iterator reader doesn't allow null. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Verify LDIF CopyToChangeRecord is working. |
| | | * Tests the LDIF copy over a change record writer from an LDIF change record reader. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF copyTo - ChangeRecord doesn't allow null parameters. |
| | | * The LDIF copy doesn't allow null parameters. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF copyTo - ChangeRecord doesn't allow a null writer. |
| | | * LDIF copy doesn't allow a null writer. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF copyTo - ChangeRecord doesn't allow a null reader. |
| | | * LDIF copy doesn't allow a null reader. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF copyTo - EntryWriter doesn't allow null. |
| | | * Tests the LDIF copy from an entry reader to a entry writer. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Testing the diff function. Following example from the admin guide. |
| | | * Testing the diff function. The following example is extracted from the admin guide. |
| | | * |
| | | * @see <a |
| | | * href=http://opendj.forgerock.org/doc/admin-guide/index.html#ldif-diff |
| | |
| | | } |
| | | |
| | | /** |
| | | * Testing the diff : entry in source but not in target. |
| | | * Testing the diff : the entry is present in source but not in the target. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Testing the diff : entry in target not in source. The rdn of the |
| | | * Testing the diff : entry is in the target not in the source. The rdn of the |
| | | * following example is completed by ou=People. |
| | | * |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * Diff between two same entries : no modifications expected. |
| | | * Differences between two same entries : no modifications expected. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Differences between two short ldif examples. |
| | | * Differences between two short LDIF examples. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Diff between two same entries : no modifications expected. |
| | | * Differences between two same entries : no modifications expected. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * The patch add successfully an attribute 'manager' to the entry. |
| | | * The patch adds successfully an attribute 'manager' to the entry. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * The patch add two new entries to the original. |
| | | * The patch adds two new entries to the original. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Try to modify an nonexistent entry. The patch throw an error via the |
| | | * Tries to modify a nonexistent entry. The patch throws an error via the |
| | | * listener which is in RejectedChangeRecordListener.OVERWRITE. |
| | | * |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * Testing to delete in entry. |
| | | * Testing to delete an entry. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Testing to delete attributes in an entry. |
| | | * Testing to delete attributes in a selected entry. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Attemp to modify the entry adding uppercase in cn. |
| | | * Attempts to modify the entry adding upper case in cn. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Rename a branch : from ou=People,dc=example,dc=com to ou=Human |
| | | * Renames a branch : from ou=People,dc=example,dc=com to ou=Human |
| | | * Resources,dc=example,dc=com. |
| | | * |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * Rename a branch : from ou=People,dc=example,dc=com to ou=Human |
| | | * Renames a branch : from ou=People,dc=example,dc=com to ou=Human |
| | | * Resources,dc=example,dc=com. In this example deleteoldrdn is set to 0. |
| | | * |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * Apply simple patch to replace/add data to the input. |
| | | * Applies simple patch to replace/add data to the input. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Replace / add postalAdress. |
| | | * Replaces / adds postalAdress. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Test some changes : add/replace/delete... |
| | | * Tests some changes : add/replace/delete... |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * An example for illustrate an LDIFChangeRecordReader containing changes on |
| | | * An example to illustrate an LDIFChangeRecordReader containing changes on |
| | | * previous ldif. |
| | | * |
| | | * @throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * Try to apply a patch which data are not valid. Exception expected. |
| | | * Tries to apply a patch which data are not valid. Exception expected. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * LDIF patch - EntryReader/ChangeRecordReader doesn't allow null. Exception |
| | | * expected. |
| | | * The listener is in FAIL_FAST Mode. On this example, |
| | | * attaching the listener to the patch should throw a decode exception as a |
| | | * wrong DN is used in the modify request. (The entry does not exist). |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @SuppressWarnings("resource") |
| | | @Test(expectedExceptions = DecodeException.class) |
| | | public final void testFailFastPatchOnModifyRequestFailsDueToWrongDN() throws Exception { |
| | | |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.FAIL_FAST; |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | | "dn: uid=scarter,ou=People,dc=example,dc=com", |
| | | "objectClass: person", |
| | | "sn: new user", |
| | | "mail: mail@mailme.org" |
| | | ); |
| | | // @formatter:on |
| | | |
| | | // @formatter:off |
| | | final LDIFChangeRecordReader patch = new LDIFChangeRecordReader( |
| | | "dn: uid=WRONGUID,ou=People,dc=example,dc=com", |
| | | "changetype: modify", |
| | | "add: work-phone", |
| | | "work-phone: 650/506-7000" |
| | | ); |
| | | // @formatter:on |
| | | EntryReader reader = new LDIFEntryReader(); |
| | | try { |
| | | reader = LDIF.patch(input, patch, listener); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The listener is in OVERWRITE Mode. On this example, |
| | | * attaching the listener to the patch should throw a decode exception even |
| | | * if a wrong DN is used in the modify request. (The entry does not exist). |
| | | * No data impacted by the patch, no warning sent. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @SuppressWarnings("resource") |
| | | @Test() |
| | | public final void testOverwritePatchOnModifyRequestSucceedsEvenIfWrongDN() throws Exception { |
| | | |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.OVERWRITE; |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | | "dn: uid=scarter,ou=People,dc=example,dc=com", |
| | | "objectClass: person", |
| | | "sn: new user", |
| | | "mail: mail@mailme.org" |
| | | ); |
| | | // @formatter:on |
| | | |
| | | // @formatter:off |
| | | final LDIFChangeRecordReader patch = new LDIFChangeRecordReader( |
| | | "dn: uid=WRONGUID,ou=People,dc=example,dc=com", |
| | | "changetype: modify", |
| | | "add: work-phone", |
| | | "work-phone: 650/506-7000" |
| | | ); |
| | | // @formatter:on |
| | | EntryReader reader = new LDIFEntryReader(); |
| | | try { |
| | | reader = LDIF.patch(input, patch, listener); |
| | | Entry entry = reader.readEntry(); |
| | | assertThat(entry.getName().toString()).isEqualTo("uid=scarter,ou=People,dc=example,dc=com"); |
| | | assertThat(entry.getAttributeCount()).isEqualTo(3); |
| | | assertThat(entry.getAttribute("objectClass").firstValueAsString()).isEqualTo( |
| | | "person"); |
| | | assertThat(entry.getAttribute("sn").firstValueAsString()).isEqualTo( |
| | | "new user"); |
| | | assertThat(entry.getAttribute("mail").firstValueAsString()).isEqualTo( |
| | | "mail@mailme.org"); |
| | | assertThat(reader.hasNext()).isFalse(); |
| | | assertThat(entry.getAttribute("work-phone")).isNull(); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The listener is in FAIL_FAST Mode. On this example, |
| | | * attaching the listener to the patch should throw a decode exception as a |
| | | * wrong DN is used in the modify DN request. (The entry does not exist). |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @SuppressWarnings("resource") |
| | | @Test(expectedExceptions = DecodeException.class) |
| | | public final void testFailFastPatchOnModifyDNRequestFailsDueToWrongDN() throws Exception { |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.FAIL_FAST; |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | | "dn: uid=scarter,ou=People,dc=example,dc=com", |
| | | "objectClass: person", |
| | | "sn: new user", |
| | | "mail: mail@mailme.org" |
| | | ); |
| | | // @formatter:on |
| | | |
| | | // @formatter:off |
| | | final LDIFChangeRecordReader patch = new LDIFChangeRecordReader( |
| | | "dn: ou=WRONGscarter, dc=example,dc=com", |
| | | "changetype: modrdn", |
| | | "newrdn: ou=Human Resources,dc=example,dc=com", |
| | | "deleteoldrdn: 1" |
| | | ); |
| | | // @formatter:on |
| | | EntryReader reader = new LDIFEntryReader(); |
| | | try { |
| | | reader = LDIF.patch(input, patch, listener); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The listener is in OVERWRITE Mode. On this example, |
| | | * attaching the listener to the patch should not throw a decode exception |
| | | * even if a wrong DN is used in the modify DN request. (Even if the entry |
| | | * does not exist). |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @SuppressWarnings("resource") |
| | | @Test() |
| | | public final void testOverwritePatchOnModifyDNRequestSucceedsEvenWithWrongDN() throws Exception { |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.OVERWRITE; |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | | "dn: uid=scarter,ou=People,dc=example,dc=com", |
| | | "objectClass: person", |
| | | "sn: new user", |
| | | "mail: mail@mailme.org" |
| | | ); |
| | | // @formatter:on |
| | | |
| | | // @formatter:off |
| | | final LDIFChangeRecordReader patch = new LDIFChangeRecordReader( |
| | | "dn: ou=WRONGscarter, dc=example,dc=com", |
| | | "changetype: modrdn", |
| | | "newrdn: ou=Human Resources,dc=example,dc=com", |
| | | "deleteoldrdn: 1" |
| | | ); |
| | | // @formatter:on |
| | | EntryReader reader = new LDIFEntryReader(); |
| | | try { |
| | | reader = LDIF.patch(input, patch, listener); |
| | | Entry entry = reader.readEntry(); |
| | | assertThat(entry.getName().toString()).isEqualTo("uid=scarter,ou=People,dc=example,dc=com"); |
| | | assertThat(entry.getName().toString()).isNotEqualTo("uid=scarter,ou=Human Resources,dc=example,dc=com"); |
| | | assertThat(entry.getAttributeCount()).isEqualTo(3); |
| | | assertThat(entry.getAttribute("objectClass").firstValueAsString()).isEqualTo( |
| | | "person"); |
| | | assertThat(entry.getAttribute("sn").firstValueAsString()).isEqualTo( |
| | | "new user"); |
| | | assertThat(entry.getAttribute("mail").firstValueAsString()).isEqualTo( |
| | | "mail@mailme.org"); |
| | | assertThat(reader.hasNext()).isFalse(); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The listener is in FAIL_FAST Mode. On this example, |
| | | * attaching the listener to the patch should throw a decode exeption as |
| | | * another entry containing the requested change DN already exists. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @SuppressWarnings("resource") |
| | | @Test(expectedExceptions = DecodeException.class) |
| | | public final void testFailFastPatchOnModifyDNRequestFailsDueToDuplicateEntry() throws Exception { |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.FAIL_FAST; |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | | "dn: uid=scarter,ou=People,dc=example,dc=com", |
| | | "objectClass: person", |
| | | "sn: new user", |
| | | "mail: mail@mailme.org", |
| | | "", |
| | | "dn: uid=user.2,ou=People,dc=example,dc=com", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalperson", |
| | | "objectClass: inetorgperson", |
| | | "givenName: Eniko", |
| | | "sn: Eniko", |
| | | "cn: Eniko Atpco", |
| | | "uid: user.2" |
| | | ); |
| | | // @formatter:on |
| | | |
| | | // @formatter:off |
| | | final LDIFChangeRecordReader patch = new LDIFChangeRecordReader( |
| | | "dn: uid=scarter,ou=People,dc=example,dc=com", |
| | | "changetype: moddn", |
| | | "newrdn: uid=user.2,ou=People,dc=example,dc=com", |
| | | "deleteoldrdn: 0" |
| | | ); |
| | | // @formatter:on |
| | | EntryReader reader = new LDIFEntryReader(); |
| | | try { |
| | | reader = LDIF.patch(input, patch, listener); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The listener is in OVERWRITE Mode. On this example, |
| | | * attaching the listener to the patch should not throw a decode exeption |
| | | * even if another entry containing the requested change DN already exists. |
| | | * The DN is overwrited. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @SuppressWarnings("resource") |
| | | @Test() |
| | | public final void testOverwritePatchOnModifyDNRequestSucceedsEvenWithDuplicateEntry() throws Exception { |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.OVERWRITE; |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | | "dn: uid=scarter,ou=People,dc=example,dc=com", |
| | | "objectClass: person", |
| | | "sn: new user", |
| | | "mail: mail@mailme.org", |
| | | "", |
| | | "dn: uid=user.2,ou=People,dc=example,dc=com", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalperson", |
| | | "objectClass: inetorgperson", |
| | | "givenName: Eniko", |
| | | "sn: Eniko", |
| | | "cn: Eniko Atpco", |
| | | "uid: user.2" |
| | | ); |
| | | // @formatter:on |
| | | |
| | | // @formatter:off |
| | | final LDIFChangeRecordReader patch = new LDIFChangeRecordReader( |
| | | "dn: uid=scarter,ou=People,dc=example,dc=com", |
| | | "changetype: moddn", |
| | | "newrdn: uid=user.2,ou=People,dc=example,dc=com", |
| | | "deleteoldrdn: 0" |
| | | ); |
| | | // @formatter:on |
| | | EntryReader reader = new LDIFEntryReader(); |
| | | try { |
| | | reader = LDIF.patch(input, patch, listener); |
| | | Entry entry = reader.readEntry(); |
| | | assertThat(entry.getName().toString()).isEqualTo("uid=user.2,ou=People,dc=example,dc=com"); |
| | | assertThat(entry.getAttributeCount()).isEqualTo(4); |
| | | assertThat(entry.getAttribute("objectClass").firstValueAsString()).isEqualTo( |
| | | "person"); |
| | | assertThat(entry.getAttribute("sn").firstValueAsString()).isEqualTo( |
| | | "new user"); |
| | | assertThat(entry.getAttribute("mail").firstValueAsString()).isEqualTo( |
| | | "mail@mailme.org"); |
| | | assertThat(reader.hasNext()).isFalse(); |
| | | } finally { |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * LDIF patch doesn't allow null. Exception expected. |
| | | * |
| | | * @throws Exception |
| | | */ |