コード例 #1
0
  /**
   * Test to write a record excluding all operational attributes setExcludeAllOperationalAttributes
   * is false. All lines must be written plus an empty line.
   *
   * @throws Exception If the test failed unexpectedly.
   */
  @Test
  public void testSetExcludeAllOperationalAttributesFalse() throws Exception {
    final List<String> actual = new ArrayList<>();
    final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual);

    final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord());
    writer.setExcludeAllOperationalAttributes(false);
    writer.writeChangeRecord(changeRequest);
    writer.close();

    assertThat(actual.get(0)).isEqualTo("dn: uid=scarter,ou=People,dc=example,dc=com");
    assertThat(actual.size()).isEqualTo(14);
    assertThat(actual.get(13)).isEqualTo("");
  }
コード例 #2
0
  /**
   * Test to write a record excluding all operational attributes setExcludeAllOperationalAttributes
   * is forced to true.
   *
   * @throws Exception If the test failed unexpectedly.
   */
  @Test
  public void testSetExcludeAllOperationalAttributesTrue() throws Exception {
    final List<String> actual = new ArrayList<>();
    final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual);

    final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord());
    writer.setExcludeAllOperationalAttributes(true);
    writer.writeChangeRecord(changeRequest);
    writer.close();

    assertThat(actual.get(0)).isEqualTo("dn: uid=scarter,ou=People,dc=example,dc=com");
    for (String line : actual) {
      assertThat(line).doesNotContain("entryUUID");
      assertThat(line).doesNotContain("entryDN");
    }
    assertThat(actual.size()).isEqualTo(10);
  }