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

matthew_swift
28.23.2007 d30d857423de7afd4c96919232af420739cede6f
Attempt to fix current JDK1.5 failures in ValidateCfgDefn tests: allow test configuration definitions to not register themselves with the TopCfgDefn. Previously, test definitions would register themselves with the TopCfgDefn and then deregister themselves during their tear down phase. However, this didn't seem to be working as expected on JDK1.5 for some reason, and was causing the ValidateCfgDefn tests to fail.
7 files modified
59 ■■■■ changed files
opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java 30 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/LDAPProfile.java 4 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java 15 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestCfg.java 4 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestChildCfgDefn.java 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestParentCfgDefn.java 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/spi/PropertySetTest.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
@@ -43,7 +43,6 @@
import org.opends.messages.Message;
import org.opends.server.admin.DefinitionDecodingException.Reason;
import org.opends.server.util.Validator;
@@ -107,22 +106,11 @@
   * @param parent
   *          The parent definition, or <code>null</code> if there
   *          is no parent (only the {@link TopCfgDefn} should have a
   *          <code>null</code> parent}.
   *          <code>null</code> parent, unless the definition is
   *          being used for testing).
   */
  protected AbstractManagedObjectDefinition(String name,
      AbstractManagedObjectDefinition<? super C, ? super S> parent) {
    // Perform sanity checks.
    if (this.getClass() == TopCfgDefn.class) {
      Validator.ensureTrue(name.equals("top"),
          "TopCfgDefn should have the name 'top'");
      Validator.ensureTrue(parent == null,
          "TopCfgDefn should not have a parent");
    } else {
      Validator.ensureTrue(!name.equals("top"),
          "Only the TopCfgDefn should have the name 'top'");
      Validator.ensureTrue(parent != null, "No parent defined");
    }
    this.name = name;
    this.parent = parent;
    this.constraints = new LinkedList<Constraint>();
@@ -842,20 +830,6 @@
  /**
   * Deregister this managed object definition from its parent.
   * <p>
   * This method <b>must not</b> be called by applications and is
   * only intended for internal testing.
   */
  final void deregisterFromParent() {
    if (parent != null) {
      parent.children.remove(name);
    }
  }
  /**
   * Deregister a relation definition from the managed object
   * definition.
   * <p>
opends/src/server/org/opends/server/admin/LDAPProfile.java
@@ -313,6 +313,10 @@
      d = d.getParent();
    }
    if (!s.contains("top")) {
      objectClasses.addFirst("top");
    }
    return objectClasses;
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java
@@ -34,12 +34,11 @@
import java.util.Collection;
import java.util.Collections;
import org.opends.server.TestCaseUtils;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.ConnectionHandlerCfgDefn;
import org.opends.server.admin.std.meta.JMXConnectionHandlerCfgDefn;
import org.opends.server.admin.std.meta.LDAPConnectionHandlerCfgDefn;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -72,7 +71,7 @@
  }
  // Test definitions.
  private TestDefinition top = new TestDefinition("topmost", TopCfgDefn.getInstance());
  private TestDefinition top = new TestDefinition("topmost", null);
  private TestDefinition middle1 = new TestDefinition("middle1", top);
@@ -102,16 +101,6 @@
  /**
   * Tears down test environment.
   */
  @AfterClass
  public void tearDown() {
    top.deregisterFromParent();
  }
  /**
   * @return data for testIsChildOf.
   */
  @DataProvider(name = "testIsChildOf")
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestCfg.java
@@ -127,7 +127,6 @@
      // Register the test parent resource bundle.
      TestParentCfgDefn d = TestParentCfgDefn.getInstance();
      d.registerInParent();
      d.initialize();
      String baseName = d.getClass().getName();
      ResourceBundle resourceBundle = ResourceBundle.getBundle(baseName);
@@ -141,7 +140,6 @@
      // Register the test child resource bundle.
      TestChildCfgDefn d = TestChildCfgDefn.getInstance();
      d.registerInParent();
      d.initialize();
      String baseName = d.getClass().getName();
      ResourceBundle resourceBundle = ResourceBundle.getBundle(baseName);
@@ -175,14 +173,12 @@
      DirectoryServer.deregisterObjectClass(TEST_PARENT_OCD);
      TestParentCfgDefn d = TestParentCfgDefn.getInstance();
      ManagedObjectDefinitionI18NResource.getInstance().removeResourceBundle(d);
      d.deregisterFromParent();
    }
    {
      DirectoryServer.deregisterObjectClass(TEST_CHILD_OCD);
      TestChildCfgDefn d = TestChildCfgDefn.getInstance();
      ManagedObjectDefinitionI18NResource.getInstance().removeResourceBundle(d);
      d.deregisterFromParent();
    }
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestChildCfgDefn.java
@@ -202,7 +202,7 @@
   * Private constructor.
   */
  private TestChildCfgDefn() {
    super("test-child", TopCfgDefn.getInstance());
    super("test-child", null);
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestParentCfgDefn.java
@@ -201,7 +201,7 @@
   * Private constructor.
   */
  private TestParentCfgDefn() {
    super("test-parent", TopCfgDefn.getInstance());
    super("test-parent", null);
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/spi/PropertySetTest.java
@@ -400,7 +400,7 @@
  }
  private PropertySet createTestPropertySet(PropertyProvider pp) {
    ManagedObjectDefinition<?, ?> d = new TestManagedObjectDefinition<ConfigurationClient, Configuration>("test-mod", TopCfgDefn.getInstance());
    ManagedObjectDefinition<?, ?> d = new TestManagedObjectDefinition<ConfigurationClient, Configuration>("test-mod", null);
    PropertySet ps = new PropertySet();
    for (PropertyDefinition<?> pd : d.getPropertyDefinitions()) {
      addProperty(ps, pd, pp);