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

Jean-Noël Rouvignac
10.48.2016 785bdb7fee8930a9d57679c5712f5e8456128a37
OPENDJ-1342 Migrate AVA, RDN, and DN classes: Removed DN and RDN server classes

- removed DN and RDN server classes
- fixed TestDN and TestRDN:
- removed tests for removed APIs on DN and RDN classes
- fixed compile errors with ambiguous call to isSuperiorOrEqualTo()
- reenabled commented out tests
- removed tests duplicating implementation of DN.toNormalizedByteString()

Removed DN and RDN server classes
2 files deleted
2 files modified
3489 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/types/DN.java 2561 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java 842 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java 35 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java 51 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/DN.java
File was deleted
opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java
File was deleted
opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
@@ -25,12 +25,10 @@
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.RDN;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.pluggable.DnKeyFormat;
import org.opends.server.core.DirectoryServer;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
@@ -188,32 +186,11 @@
   *           If the test failed unexpectedly.
   */
  @Test
  public void testCreateWithMultipleRDNs1() throws Exception {
  public void testCreateWithMultipleRDNs() throws Exception {
    DN dn = DN.rootDN().child(RDN.valueOf("dc=org")).child(RDN.valueOf("dc=opends")).child(RDN.valueOf("dc=foo"));
    assertEquals(dn, DN.valueOf("dc=foo,dc=opends,dc=org"));
  }
  /**
   * Tests the create method.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testCreateWithMultipleRDNs2() throws Exception {
    ArrayList<RDN> rdnList = new ArrayList<>();
    rdnList.add(RDN.valueOf("dc=foo"));
    rdnList.add(RDN.valueOf("dc=opends"));
    rdnList.add(RDN.valueOf("dc=org"));
    DN dn = new DN(rdnList);
    assertEquals(dn, DN.valueOf("dc=foo,dc=opends,dc=org"));
  }
  /**
   * Tests the <CODE>valueOf</CODE> method which takes a String
   * argument.
@@ -283,12 +260,8 @@
   *           If the test failed unexpectedly.
   */
  @Test
  public void testToNormalizedString() throws Exception {
  public void testToNormalizedUrlSafeString() throws Exception {
    DN dn = DN.valueOf("dc=example,dc=com");
    assertEquals(dn.toNormalizedByteString(),
        new ByteStringBuilder().appendUtf8("dc=com").appendByte(DnKeyFormat.NORMALIZED_RDN_SEPARATOR)
                               .appendUtf8("dc=example").toByteString());
    assertEquals(dn.toNormalizedUrlSafeString(), "dc=com,dc=example");
  }
@@ -900,7 +873,7 @@
      AssertionError.class })
  public void testIsAncestorOfException() throws Exception {
    DN dn = DN.valueOf("dc=com");
    dn.isSuperiorOrEqualTo(null);
    dn.isSuperiorOrEqualTo((DN) null);
  }
@@ -970,7 +943,7 @@
      AssertionError.class })
  public void testIsDescendantOfException() throws Exception {
    DN dn = DN.valueOf("dc=com");
    dn.isSubordinateOrEqualTo(null);
    dn.isSubordinateOrEqualTo((DN) null);
  }
opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
@@ -102,7 +102,7 @@
   */
  @Test
  public void testConstructorWithName() throws Exception {
    RDN rdn = new RDN(AT_DC, "domainComponent", AV_DC_ORG);
    RDN rdn = new RDN(new AVA(AT_DC, "domainComponent", AV_DC_ORG));
    assertEquals(rdn.size(), 1);
    AVA ava = rdn.getFirstAVA();
@@ -221,28 +221,6 @@
        { "O=\"Sue, Grabbit and Runn\"", "o=sue%2C%20grabbit%20and%20runn", "O=Sue\\, Grabbit and Runn" }, };
  }
  /**
   * Test RDN string decoder.
   *
   * @param rawRDN
   *          Raw RDN string representation.
   * @param normRDN
   *          Normalized RDN string representation.
   * @param stringRDN
   *          String representation.
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test(dataProvider = "testRDNs")
  public void testNormalizationToSafeUrlString(String rawRDN, String normRDN, String stringRDN) throws Exception {
    RDN rdn = RDN.valueOf(rawRDN);
    assertEquals(rdn.toNormalizedUrlSafeString(), normRDN);
  }
  /**
   * Illegal RDN test data provider.
   *
@@ -251,8 +229,8 @@
  @DataProvider(name = "illegalRDNs")
  public Object[][] createIllegalData() {
    return new Object[][] { { null }, { "" }, { " " }, { "=" }, { "manager" },
        { "manager " }, { "cn+"}, { "cn+Jim" }, { "cn=Jim+" }, { "cn=Jim +" },
        { "cn=Jim+ " }, /* FIXME activate { "cn=Jim+cn=John" }, */ { "cn=Jim+sn" }, { "cn=Jim+sn " },
        { "manager " }, { "cn+"}, { "cn+Jim" }, { "cn="}, { "cn=Jim+" }, { "cn=Jim +" },
        { "cn=Jim+ " }, { "cn=Jim+cn=John" }, { "cn=Jim+sn" }, { "cn=Jim+sn " },
        { "cn=Jim+sn equals" }, { "cn=Jim," }, { "cn=Jim;" }, { "cn=Jim,  " },
        { "cn=Jim+sn=a," }, { "cn=Jim, sn=Jam " }, { "cn+uid=Jim" },
        { "-cn=Jim" }, { "/tmp=a" }, { "\\tmp=a" }, { "cn;lang-en=Jim" },
@@ -356,8 +334,8 @@
    RDN rdn = new RDN(AT_DC, AV_DC_ORG);
    assertEquals(rdn.size(), 1);
    rdn.addValue(AT_CN, AT_CN.getNameOrOID(), AV_CN);
    assertEquals(rdn.size(), 2);
    RDN rdn2 = new RDN(new AVA(AT_DC, AV_DC_ORG), new AVA(AT_CN, AV_CN));
    assertEquals(rdn2.size(), 2);
  }
  /**
@@ -369,28 +347,13 @@
  @Test
  public void testIsMultiValued() throws Exception {
    RDN rdn = new RDN(AT_DC, AV_DC_ORG);
    assertEquals(rdn.size(), 1);
    assertFalse(rdn.isMultiValued());
    rdn.addValue(AT_CN, AT_CN.getNameOrOID(), AV_CN);
    assertTrue(rdn.isMultiValued());
    RDN rdn2 = new RDN(new AVA(AT_DC, AV_DC_ORG), new AVA(AT_CN, AV_CN));
    assertTrue(rdn2.isMultiValued());
  }
  /**
   * Tests addValue with a duplicate value.
   *
   * @throws Exception
   *           If the test failed unexpectedly.
   */
  @Test
  public void testAddDuplicateValue() throws Exception {
    RDN rdn = new RDN(AT_DC, AV_DC_ORG);
    assertFalse(rdn.addValue(AT_DC, AT_DC.getNameOrOID(), AV_DC_ORG));
  }
  /**
   * Test RDN string decoder.
   *
   * @param rawRDN