mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
23.04.2016 86b9cc7dc474e75940d538ecf1e252ef191bc111
OPENDJ-1342 Migrate AVA, RDN, and DN classes: Fix change in behaviour for DN.toString()

DN.toString() now returns the raw dn provided in DN.valueOf()
while it used to return a somewhat normalized view of the raw DN.
4 files modified
33 ■■■■ changed files
opendj-server-legacy/src/test/java/org/forgerock/opendj/adapter/server3x/AdaptersTestCase.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/types/TestSubtreeSpecification.java 19 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/forgerock/opendj/adapter/server3x/AdaptersTestCase.java
@@ -408,7 +408,7 @@
        // No differences expected.
        assertThat(Entries.diffEntries(original, expectedEntry).getModifications()).isEmpty();
        assertThat(srEntry.getName().toString()).isEqualTo("uid=user.1,o=test");
        assertThat((Object) srEntry.getName()).isEqualTo(DN.valueOf("uid=user.1,o=test"));
        assertThat(srEntry.getAttributeCount()).isEqualTo(7);
        assertThat(srEntry.getAttribute("description").firstValueAsString()).isEqualTo(
                "This is the description for Aaren Atp.");
@@ -552,7 +552,7 @@
                connection.searchSingleEntry(Requests.newSearchRequest(
                        "uid=user.1, o=test", SearchScope.BASE_OBJECT, "(uid=user.1)"));
        assertThat(srEntry).isNotNull();
        assertThat(srEntry.getName().toString()).isEqualTo("uid=user.1,o=test");
        assertThat((Object) srEntry.getName()).isEqualTo(DN.valueOf("uid=user.1,o=test"));
        connection.close();
    }
@@ -863,7 +863,7 @@
        assertThat(reader.isEntry()).isTrue();
        final SearchResultEntry entry = reader.readEntry();
        assertThat(entry).isNotNull();
        assertThat(entry.getName().toString()).isEqualTo("uid=user.1,o=test");
        assertThat((Object) entry.getName()).isEqualTo(DN.valueOf("uid=user.1,o=test"));
        assertThat(reader.hasNext()).isFalse();
    }
opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java
@@ -301,7 +301,7 @@
        "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
    c.addExpectedAttribute("ds-cfg-attribute-type", "description");
    c.addExpectedAttribute("ds-cfg-rotation-policy",
        "cn=LDAP Connection Handler,cn=connection handlers,cn=config");
        "cn=LDAP Connection Handler,cn=connection handlers, cn=config");
    ManagementContext ctx = LDAPManagementContext.createFromContext(c);
    TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
@@ -329,8 +329,8 @@
        "cn=test child 2,cn=test children,cn=test parent 1,cn=test parents,cn=config");
    c.importLDIF(TEST_LDIF);
    c.addExpectedModification("ds-cfg-rotation-policy",
        "cn=LDAPS Connection Handler,cn=connection handlers,cn=config",
        "cn=JMX Connection Handler,cn=connection handlers,cn=config");
        "cn=LDAPS Connection Handler,cn=connection handlers, cn=config",
        "cn=JMX Connection Handler,cn=connection handlers, cn=config");
    ManagementContext ctx = LDAPManagementContext.createFromContext(c);
    TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
    TestChildCfgClient child = parent.getTestChild("test child 2");
opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
@@ -248,7 +248,7 @@
  @Test(dataProvider = "testDNs")
  public void testToString(String rawDN, String unused, String stringDN) throws Exception {
    DN dn = DN.valueOf(rawDN);
    assertEquals(dn.toString(), stringDN);
    assertEquals(dn.toString(), rawDN);
  }
opendj-server-legacy/src/test/java/org/opends/server/types/TestSubtreeSpecification.java
@@ -27,24 +27,21 @@
@SuppressWarnings("javadoc")
public final class TestSubtreeSpecification extends SubtreeSpecificationTestCase {
  /** Cached root DN. */
  private DN rootDN = DN.rootDN();
  @DataProvider
  public Object[][] valueOfData() {
    return new Object[][] {
      { "{}", "{ }" },
      { "  {    }    ", "{ }" },
      { "{ base \"dc=sun, dc=com\" }",
        "{ base \"dc=sun,dc=com\" }" },
        "{ base \"dc=sun, dc=com\" }" },
      { "{base \"dc=sun, dc=com\"}",
        "{ base \"dc=sun,dc=com\" }" },
      { "{ base \"dc=sun, dc=com\", " + "specificationFilter item:ds-config-rootDN }",
        "{ base \"dc=sun,dc=com\", " + "specificationFilter item:ds-config-rootDN }" },
        "{ base \"dc=sun, dc=com\" }" },
      { "{ base \"dc=sun, dc=com\", specificationFilter item:ds-config-rootDN }",
        "{ base \"dc=sun, dc=com\", specificationFilter item:ds-config-rootDN }" },
      { "{ base \"dc=sun, dc=com\", minimum 0 , maximum 10, "
          + "specificExclusions {chopBefore:\"o=abc\", "
          + "chopAfter:\"o=xyz\"} , specificationFilter not:not:item:foo }",
        "{ base \"dc=sun,dc=com\", "
        "{ base \"dc=sun, dc=com\", "
          + "specificExclusions { chopBefore:\"o=abc\", "
          + "chopAfter:\"o=xyz\" }, maximum 10, specificationFilter "
          + "not:not:item:foo }" },
@@ -61,13 +58,13 @@
      { "{ specificationFilter or:{item:top, item:foo, and:{item:one, item:two}} }",
        "{ specificationFilter or:{item:top, item:foo, and:{item:one, item:two}} }" },
      { "{ base \"dc=sun, dc=com\", specificationFilter \"(objectClass=*)\" }",
        "{ base \"dc=sun,dc=com\", specificationFilter \"(objectClass=*)\" }" },
        "{ base \"dc=sun, dc=com\", specificationFilter \"(objectClass=*)\" }" },
    };
  }
  @Test(dataProvider = "valueOfData")
  public void testValueOf(String specification, String expected) throws Exception {
    SubtreeSpecification ss = SubtreeSpecification.valueOf(rootDN, specification);
    SubtreeSpecification ss = SubtreeSpecification.valueOf(DN.rootDN(), specification);
    assertEquals(ss.toString(), expected);
  }
@@ -117,7 +114,7 @@
  @Test(dataProvider = "isWithinScopeData")
  public void testIsWithinScope(String dnString, String value, boolean expected) throws Exception {
    DN dn = DN.valueOf(dnString);
    SubtreeSpecification ss = SubtreeSpecification.valueOf(rootDN, value);
    SubtreeSpecification ss = SubtreeSpecification.valueOf(DN.rootDN(), value);
    assertEquals(ss.isWithinScope(createEntry(dn, getObjectClasses())), expected);
  }
}