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

matthew_swift
19.55.2007 07c6ebc55b1032a7107e2426ecc3db167b6c638f
opendj-sdk/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
@@ -633,6 +633,25 @@
  /**
   * Deregister a relation definition from the managed object
   * definition.
   * <p>
   * This method <b>must not</b> be called by applications and is
   * only intended for internal testing.
   *
   * @param d
   *          The relation definition to be deregistered.
   */
  protected final void deregisterRelationDefinition(RelationDefinition d) {
    String name = d.getName();
    relationDefinitions.remove(name);
    allRelationDefinitions.remove(name);
  }
  /**
   * Register a property definition with the managed object definition,
   * overriding any existing property definition with the same name.
   * <p>
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/MockLDAPProfile.java
@@ -96,7 +96,7 @@
  @Override
  public String getInstantiableRelationChildRDNType(
      InstantiableRelationDefinition<?, ?> r) {
    if (r == TestCfg.RD_TEST_ONE_TO_MANY_PARENT
    if (r == TestCfg.getTestOneToManyParentRelationDefinition()
        || r == TestParentCfgDefn.getInstance()
            .getTestChildrenRelationDefinition()) {
      return "cn";
@@ -129,9 +129,9 @@
   */
  @Override
  public String getRelationRDNSequence(RelationDefinition<?, ?> r) {
    if (r == TestCfg.RD_TEST_ONE_TO_MANY_PARENT) {
    if (r == TestCfg.getTestOneToManyParentRelationDefinition()) {
      return "cn=test parents,cn=config";
    } else if (r == TestCfg.RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT) {
    } else if (r == TestCfg.getTestOneToZeroOrOneParentRelationDefinition()) {
      return "cn=optional test parent,cn=config";
    } else if (r == TestParentCfgDefn.getInstance()
        .getTestChildrenRelationDefinition()) {
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestCfg.java
@@ -37,30 +37,23 @@
 */
public final class TestCfg {
  // Prevent instantiation.
  private TestCfg() {
    // No implementation required.
  }
  /**
   * A one-to-many relation between the root and test-parent
   * components.
   */
  public static final InstantiableRelationDefinition<TestParentCfgClient, TestParentCfg> RD_TEST_ONE_TO_MANY_PARENT;
  private static final InstantiableRelationDefinition<TestParentCfgClient, TestParentCfg> RD_TEST_ONE_TO_MANY_PARENT;
  /**
   * A one-to-zero-or-one relation between the root and a test-parent
   * component.
   */
  public static final OptionalRelationDefinition<TestParentCfgClient, TestParentCfg> RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT;
  private static final OptionalRelationDefinition<TestParentCfgClient, TestParentCfg> RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT;
  // Create a one-to-many relation for test-parent components.
  static {
    RD_TEST_ONE_TO_MANY_PARENT = new InstantiableRelationDefinition<TestParentCfgClient, TestParentCfg>(
        RootCfgDefn.getInstance(), "test-one-to-many-parent",
        "test-one-to-many-parents", TestParentCfgDefn.getInstance());
    RootCfgDefn.getInstance().registerRelationDefinition(
        RD_TEST_ONE_TO_MANY_PARENT);
  }
  // Create a one-to-many relation for test-parent components.
@@ -68,8 +61,65 @@
    RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT = new OptionalRelationDefinition<TestParentCfgClient, TestParentCfg>(
        RootCfgDefn.getInstance(), "test-one-to-zero-or-one-parent",
        TestParentCfgDefn.getInstance());
  }
  /**
   * Deregisters the test configurations from the administration
   * framework.
   */
  public static void cleanup() {
    RootCfgDefn.getInstance().deregisterRelationDefinition(
        RD_TEST_ONE_TO_MANY_PARENT);
    RootCfgDefn.getInstance().deregisterRelationDefinition(
        RD_TEST_ONE_TO_MANY_PARENT);
  }
  /**
   * Gets the one-to-many relation between the root and test-parent
   * components.
   * <p>
   * Unit tests which call this method <b>must</b> call
   * {@link #cleanup()} on completion.
   *
   * @return Returns the one-to-many relation between the root and
   *         test-parent components.
   */
  public static InstantiableRelationDefinition<TestParentCfgClient, TestParentCfg> getTestOneToManyParentRelationDefinition() {
    // Ensure that the relation is registered.
    RootCfgDefn.getInstance().registerRelationDefinition(
        RD_TEST_ONE_TO_MANY_PARENT);
    return RD_TEST_ONE_TO_MANY_PARENT;
  }
  /**
   * Gets the one-to-zero-or-one relation between the root and a
   * test-parent component.
   * <p>
   * Unit tests which call this method <b>must</b> call
   * {@link #cleanup()} on completion.
   *
   * @return Returns the one-to-zero-or-one relation between the root
   *         and a test-parent component.
   */
  public static OptionalRelationDefinition<TestParentCfgClient, TestParentCfg> getTestOneToZeroOrOneParentRelationDefinition() {
    // Ensure that the relation is registered.
    RootCfgDefn.getInstance().registerRelationDefinition(
        RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT);
    return RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT;
  }
  // Prevent instantiation.
  private TestCfg() {
    // No implementation required.
  }
}
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/ldap/LDAPClientTest.java
@@ -45,6 +45,7 @@
import org.opends.server.admin.ManagedObjectAlreadyExistsException;
import org.opends.server.admin.ManagedObjectNotFoundException;
import org.opends.server.admin.MockLDAPProfile;
import org.opends.server.admin.TestCfg;
import org.opends.server.admin.TestChildCfgClient;
import org.opends.server.admin.TestChildCfgDefn;
import org.opends.server.admin.TestParentCfgClient;
@@ -280,6 +281,7 @@
  @AfterClass
  public void tearDown() {
    LDAPProfile.getInstance().popWrapper();
    TestCfg.cleanup();
  }
@@ -814,8 +816,7 @@
      CommunicationException {
    ManagedObject<RootCfgClient> root = context
        .getRootConfigurationManagedObject();
    return root.createChild(
        org.opends.server.admin.TestCfg.RD_TEST_ONE_TO_MANY_PARENT,
    return root.createChild(TestCfg.getTestOneToManyParentRelationDefinition(),
        TestParentCfgDefn.getInstance(), name, null).getConfiguration();
  }
@@ -829,9 +830,8 @@
      CommunicationException {
    ManagedObject<RootCfgClient> root = context
        .getRootConfigurationManagedObject();
    return root.getChild(
        org.opends.server.admin.TestCfg.RD_TEST_ONE_TO_MANY_PARENT, name)
        .getConfiguration();
    return root.getChild(TestCfg.getTestOneToManyParentRelationDefinition(),
        name).getConfiguration();
  }
@@ -842,8 +842,7 @@
      CommunicationException {
    ManagedObject<RootCfgClient> root = context
        .getRootConfigurationManagedObject();
    return root
        .listChildren(org.opends.server.admin.TestCfg.RD_TEST_ONE_TO_MANY_PARENT);
    return root.listChildren(TestCfg.getTestOneToManyParentRelationDefinition());
  }
@@ -855,7 +854,6 @@
      CommunicationException {
    ManagedObject<RootCfgClient> root = context
        .getRootConfigurationManagedObject();
    root.removeChild(
        org.opends.server.admin.TestCfg.RD_TEST_ONE_TO_MANY_PARENT, name);
    root.removeChild(TestCfg.getTestOneToManyParentRelationDefinition(), name);
  }
}
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/server/DNBuilderTest.java
@@ -78,6 +78,7 @@
  @AfterClass
  public void tearDown() {
    LDAPProfile.getInstance().popWrapper();
    TestCfg.cleanup();
  }
@@ -95,7 +96,7 @@
    ManagedObjectPath<? extends ConfigurationClient, ? extends Configuration> path = ManagedObjectPath
        .emptyPath();
    path = path.child(TestCfg.RD_TEST_ONE_TO_MANY_PARENT, "test-parent-1");
    path = path.child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1");
    path = path.child(TestParentCfgDefn.getInstance()
        .getTestChildrenRelationDefinition(), "test-child-1");
@@ -143,7 +144,7 @@
    };
    path = path.child(TestCfg.RD_TEST_ONE_TO_MANY_PARENT, "test-parent-1");
    path = path.child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1");
    path = path.child(r2);
    // Now serialize it.
@@ -176,7 +177,7 @@
    ManagedObjectPath<? extends ConfigurationClient, ? extends Configuration> path = ManagedObjectPath
        .emptyPath();
    path = path.child(TestCfg.RD_TEST_ONE_TO_MANY_PARENT, "test-parent-1");
    path = path.child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1");
    path = path.child(TestParentCfgDefn.getInstance()
        .getOptionalTestChildRelationDefinition());
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/server/DefaultBehaviorTest.java
@@ -308,6 +308,7 @@
  @AfterClass
  public void tearDown() throws Exception {
    LDAPProfile.getInstance().popWrapper();
    TestCfg.cleanup();
    // Remove test entries.
    deleteSubtree("cn=test parents,cn=config");
@@ -849,7 +850,7 @@
      ConfigException {
    ServerManagementContext ctx = ServerManagementContext.getInstance();
    ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
    TestParentCfg parent = root.getChild(TestCfg.RD_TEST_ONE_TO_MANY_PARENT,
    TestParentCfg parent = root.getChild(TestCfg.getTestOneToManyParentRelationDefinition(),
        name).getConfiguration();
    return parent;
  }
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/server/ListenerTest.java
@@ -135,6 +135,7 @@
  @AfterClass
  public void tearDown() {
    LDAPProfile.getInstance().popWrapper();
    TestCfg.cleanup();
  }
@@ -152,7 +153,7 @@
    ServerManagementContext ctx = ServerManagementContext.getInstance();
    ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
    ConfigurationAddListener<TestParentCfg> listener = new TestParentAddListener();
    root.registerAddListener(TestCfg.RD_TEST_ONE_TO_MANY_PARENT, listener);
    root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(), listener);
    // Make sure that the relation entry does not exist.
    DN relationDN = DN.decode("cn=test parents,cn=config");
@@ -257,7 +258,7 @@
    ServerManagementContext ctx = ServerManagementContext.getInstance();
    ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
    ConfigurationAddListener<TestParentCfg> listener = new TestParentAddListener();
    root.registerAddListener(TestCfg.RD_TEST_ONE_TO_MANY_PARENT, listener);
    root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(), listener);
    // Add the relation entry.
    String[] entry = new String[] {
@@ -313,7 +314,7 @@
    ServerManagementContext ctx = ServerManagementContext.getInstance();
    ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
    ConfigurationAddListener<TestParentCfg> listener = new TestParentAddListener();
    root.registerAddListener(TestCfg.RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT,
    root.registerAddListener(TestCfg.getTestOneToZeroOrOneParentRelationDefinition(),
        listener);
    // Make sure that the relation entry exists.
@@ -356,7 +357,7 @@
    ServerManagementContext ctx = ServerManagementContext.getInstance();
    ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
    ConfigurationDeleteListener<TestParentCfg> listener = new TestParentDeleteListener();
    root.registerDeleteListener(TestCfg.RD_TEST_ONE_TO_MANY_PARENT, listener);
    root.registerDeleteListener(TestCfg.getTestOneToManyParentRelationDefinition(), listener);
    // Make sure that the relation entry does not exist.
    DN relationDN = DN.decode("cn=test parents,cn=config");
@@ -461,7 +462,7 @@
    ServerManagementContext ctx = ServerManagementContext.getInstance();
    ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
    ConfigurationDeleteListener<TestParentCfg> listener = new TestParentDeleteListener();
    root.registerDeleteListener(TestCfg.RD_TEST_ONE_TO_MANY_PARENT, listener);
    root.registerDeleteListener(TestCfg.getTestOneToManyParentRelationDefinition(), listener);
    // Add the relation entry.
    String[] entry = new String[] {
@@ -517,7 +518,7 @@
    ServerManagementContext ctx = ServerManagementContext.getInstance();
    ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
    ConfigurationDeleteListener<TestParentCfg> listener = new TestParentDeleteListener();
    root.registerDeleteListener(TestCfg.RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT,
    root.registerDeleteListener(TestCfg.getTestOneToZeroOrOneParentRelationDefinition(),
        listener);
    // Make sure that the relation entry exists.