From 6fa0b021682d98ef9f908dfa248985a8507c6fa0 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 17 Sep 2007 15:43:08 +0000
Subject: [PATCH] Implement a new configuration definition called "TopCfgDefn" which acts as the parent of all other configuration definitions. This is analogous to the the "top" object class in LDAP.
---
opends/resource/admin/metaMO.xsl | 5
opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java | 2
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/spi/PropertySetTest.java | 43 +++-
opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java | 83 ++++++++-
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestParentCfgDefn.java | 2
opends/src/server/org/opends/server/admin/LDAPProfile.java | 9
opends/src/server/org/opends/server/admin/TopCfgDefn.java | 74 +++++++++
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestChildCfgDefn.java | 2
opends/src/server/org/opends/server/admin/ManagedObjectDefinitionResource.java | 18 +
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestTopCfgDefnTest.java | 190 +++++++++++++++++++++++
opends/src/server/org/opends/server/admin/ManagedObjectDefinitionI18NResource.java | 35 +++
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java | 2
12 files changed, 418 insertions(+), 47 deletions(-)
diff --git a/opends/resource/admin/metaMO.xsl b/opends/resource/admin/metaMO.xsl
index cc8d47f..8266696 100644
--- a/opends/resource/admin/metaMO.xsl
+++ b/opends/resource/admin/metaMO.xsl
@@ -222,7 +222,7 @@
<xsl:value-of
select="concat(' super("',
$this/@name,
- '", null);
')" />
+ '", TopCfgDefn.getInstance());
')" />
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="' }
'" />
@@ -1628,6 +1628,9 @@
<xsl:text>
</xsl:text>
<xsl:call-template name="generate-import-statements">
<xsl:with-param name="imports">
+ <xsl:if test="not(boolean($this/@extends))">
+ <import>org.opends.server.admin.TopCfgDefn</import>
+ </xsl:if>
<xsl:if
test="$this-local-properties[@multi-valued='true' or
@read-only='true' or
diff --git a/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java b/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
index 67e8249..960ff99 100644
--- a/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
+++ b/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
@@ -43,6 +43,7 @@
import org.opends.messages.Message;
import org.opends.server.admin.DefinitionDecodingException.Reason;
+import org.opends.server.util.Validator;
@@ -108,11 +109,24 @@
* @param name
* The name of the definition.
* @param parent
- * The parent definition, or <code>null</code> if there is no
- * parent.
+ * The parent definition, or <code>null</code> if there
+ * is no parent (only the {@link TopCfgDefn} should have a
+ * <code>null</code> parent}.
*/
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>();
@@ -309,8 +323,11 @@
* @return Returns the description of this managed object definition
* in the default locale, or <code>null</code> if there is
* no description.
+ * @throws UnsupportedOperationException
+ * If this managed object definition is the
+ * {@link TopCfgDefn}.
*/
- public final Message getDescription() {
+ public final Message getDescription() throws UnsupportedOperationException {
return getDescription(Locale.getDefault());
}
@@ -325,11 +342,15 @@
* @return Returns the description of this managed object definition
* in the specified locale, or <code>null</code> if there
* is no description.
+ * @throws UnsupportedOperationException
+ * If this managed object definition is the
+ * {@link TopCfgDefn}.
*/
- public final Message getDescription(Locale locale) {
+ public final Message getDescription(Locale locale)
+ throws UnsupportedOperationException {
try {
return ManagedObjectDefinitionI18NResource.getInstance()
- .getMessage(this, "description", locale);
+ .getMessage(this, "description", locale);
} catch (MissingResourceException e) {
return null;
}
@@ -352,8 +373,8 @@
* Get the parent managed object definition, if applicable.
*
* @return Returns the parent of this managed object definition, or
- * <code>null</code> if this definition does not have a
- * parent.
+ * <code>null</code> if this definition is the
+ * {@link TopCfgDefn}.
*/
public final AbstractManagedObjectDefinition<? super C,
? super S> getParent() {
@@ -459,8 +480,11 @@
*
* @return Returns the synopsis of this managed object definition in
* the default locale.
+ * @throws UnsupportedOperationException
+ * If this managed object definition is the
+ * {@link TopCfgDefn}.
*/
- public final Message getSynopsis() {
+ public final Message getSynopsis() throws UnsupportedOperationException {
return getSynopsis(Locale.getDefault());
}
@@ -474,8 +498,12 @@
* The locale.
* @return Returns the synopsis of this managed object definition in
* the specified locale.
+ * @throws UnsupportedOperationException
+ * If this managed object definition is the
+ * {@link TopCfgDefn}.
*/
- public final Message getSynopsis(Locale locale) {
+ public final Message getSynopsis(Locale locale)
+ throws UnsupportedOperationException {
return ManagedObjectDefinitionI18NResource.getInstance()
.getMessage(this, "synopsis", locale);
}
@@ -488,8 +516,12 @@
*
* @return Returns the user friendly name of this managed object
* definition in the default locale.
+ * @throws UnsupportedOperationException
+ * If this managed object definition is the
+ * {@link TopCfgDefn}.
*/
- public final Message getUserFriendlyName() {
+ public final Message getUserFriendlyName()
+ throws UnsupportedOperationException {
return getUserFriendlyName(Locale.getDefault());
}
@@ -503,8 +535,12 @@
* The locale.
* @return Returns the user friendly name of this managed object
* definition in the specified locale.
+ * @throws UnsupportedOperationException
+ * If this managed object definition is the
+ * {@link TopCfgDefn}.
*/
- public final Message getUserFriendlyName(Locale locale) {
+ public final Message getUserFriendlyName(Locale locale)
+ throws UnsupportedOperationException {
// TODO: have admin framework getMessage return a Message
return Message.raw(ManagedObjectDefinitionI18NResource.getInstance()
.getMessage(this, "user-friendly-name", locale));
@@ -518,8 +554,12 @@
*
* @return Returns the user friendly plural name of this managed
* object definition in the default locale.
+ * @throws UnsupportedOperationException
+ * If this managed object definition is the
+ * {@link TopCfgDefn}.
*/
- public final Message getUserFriendlyPluralName() {
+ public final Message getUserFriendlyPluralName()
+ throws UnsupportedOperationException {
return getUserFriendlyPluralName(Locale.getDefault());
}
@@ -533,8 +573,12 @@
* The locale.
* @return Returns the user friendly plural name of this managed
* object definition in the specified locale.
+ * @throws UnsupportedOperationException
+ * If this managed object definition is the
+ * {@link TopCfgDefn}.
*/
- public final Message getUserFriendlyPluralName(Locale locale) {
+ public final Message getUserFriendlyPluralName(Locale locale)
+ throws UnsupportedOperationException {
return ManagedObjectDefinitionI18NResource.getInstance()
.getMessage(this, "user-friendly-plural-name", locale);
}
@@ -616,6 +660,19 @@
/**
+ * Determines whether or not this managed object definition is the
+ * {@link TopCfgDefn}.
+ *
+ * @return Returns <code>true</code> if this managed object
+ * definition is the {@link TopCfgDefn}.
+ */
+ public final boolean isTop() {
+ return (this == TopCfgDefn.getInstance());
+ }
+
+
+
+ /**
* Finds a sub-type of this managed object definition which most closely
* corresponds to the matching criteria of the provided definition resolver.
*
diff --git a/opends/src/server/org/opends/server/admin/LDAPProfile.java b/opends/src/server/org/opends/server/admin/LDAPProfile.java
index 3e2505d..c4835e9 100644
--- a/opends/src/server/org/opends/server/admin/LDAPProfile.java
+++ b/opends/src/server/org/opends/server/admin/LDAPProfile.java
@@ -268,6 +268,10 @@
*/
public String getObjectClass(AbstractManagedObjectDefinition<?, ?> d)
throws MissingResourceException {
+ if (d.isTop()) {
+ return "top";
+ }
+
for (Wrapper profile : profiles) {
String objectClass = profile.getObjectClass(d);
if (objectClass != null) {
@@ -309,11 +313,6 @@
d = d.getParent();
}
- // Make sure that we have top.
- if (!s.contains("top")) {
- objectClasses.addFirst("top");
- }
-
return objectClasses;
}
diff --git a/opends/src/server/org/opends/server/admin/ManagedObjectDefinitionI18NResource.java b/opends/src/server/org/opends/server/admin/ManagedObjectDefinitionI18NResource.java
index 2280700..5853764 100644
--- a/opends/src/server/org/opends/server/admin/ManagedObjectDefinitionI18NResource.java
+++ b/opends/src/server/org/opends/server/admin/ManagedObjectDefinitionI18NResource.java
@@ -42,6 +42,9 @@
/**
* A class for retrieving internationalized resource properties
* associated with a managed object definition.
+ * <p>
+ * I18N resource properties are not available for the
+ * {@link TopCfgDefn}.
*/
public final class ManagedObjectDefinitionI18NResource {
@@ -127,9 +130,12 @@
* specified key in the default locale.
* @throws MissingResourceException
* If the key was not found.
+ * @throws UnsupportedOperationException
+ * If the provided managed object definition was the
+ * {@link TopCfgDefn}.
*/
- public Message getMessage(AbstractManagedObjectDefinition<?, ?> d,
- String key) throws MissingResourceException {
+ public Message getMessage(AbstractManagedObjectDefinition<?, ?> d, String key)
+ throws MissingResourceException, UnsupportedOperationException {
return getMessage(d, key, Locale.getDefault(), (String[]) null);
}
@@ -149,9 +155,13 @@
* specified key and locale.
* @throws MissingResourceException
* If the key was not found.
+ * @throws UnsupportedOperationException
+ * If the provided managed object definition was the
+ * {@link TopCfgDefn}.
*/
public Message getMessage(AbstractManagedObjectDefinition<?, ?> d,
- String key, Locale locale) throws MissingResourceException {
+ String key, Locale locale) throws MissingResourceException,
+ UnsupportedOperationException {
return getMessage(d, key, locale, (String[]) null);
}
@@ -174,10 +184,13 @@
* specified key and locale.
* @throws MissingResourceException
* If the key was not found.
+ * @throws UnsupportedOperationException
+ * If the provided managed object definition was the
+ * {@link TopCfgDefn}.
*/
public Message getMessage(AbstractManagedObjectDefinition<?, ?> d,
String key, Locale locale, String... args)
- throws MissingResourceException {
+ throws MissingResourceException, UnsupportedOperationException {
ResourceBundle resource = getResourceBundle(d, locale);
// TODO: use message framework directly
@@ -206,9 +219,13 @@
* specified key in the default locale.
* @throws MissingResourceException
* If the key was not found.
+ * @throws UnsupportedOperationException
+ * If the provided managed object definition was the
+ * {@link TopCfgDefn}.
*/
public Message getMessage(AbstractManagedObjectDefinition<?, ?> d,
- String key, String... args) throws MissingResourceException {
+ String key, String... args) throws MissingResourceException,
+ UnsupportedOperationException {
return getMessage(d, key, Locale.getDefault(), args);
}
@@ -303,7 +320,13 @@
// locale, lazily loading it if necessary.
private synchronized ResourceBundle getResourceBundle(
AbstractManagedObjectDefinition<?, ?> d, Locale locale)
- throws MissingResourceException {
+ throws MissingResourceException, UnsupportedOperationException {
+ if (d.isTop()) {
+ throw new UnsupportedOperationException(
+ "I18n resources are not available for the "
+ + "Top configuration definition");
+ }
+
// First get the locale-resource mapping, creating it if
// necessary.
Map<Locale, ResourceBundle> map = resources.get(d);
diff --git a/opends/src/server/org/opends/server/admin/ManagedObjectDefinitionResource.java b/opends/src/server/org/opends/server/admin/ManagedObjectDefinitionResource.java
index c3e4a20..6974cd3 100644
--- a/opends/src/server/org/opends/server/admin/ManagedObjectDefinitionResource.java
+++ b/opends/src/server/org/opends/server/admin/ManagedObjectDefinitionResource.java
@@ -42,6 +42,8 @@
/**
* A class for retrieving non-internationalized resource properties
* associated with a managed object definition.
+ * <p>
+ * Resource properties are not available for the {@link TopCfgDefn}.
*/
public final class ManagedObjectDefinitionResource {
@@ -89,9 +91,18 @@
* key.
* @throws MissingResourceException
* If the key was not found.
+ * @throws UnsupportedOperationException
+ * If the provided managed object definition was the
+ * {@link TopCfgDefn}.
*/
- public String getString(AbstractManagedObjectDefinition<?, ?> d,
- String key) throws MissingResourceException {
+ public String getString(AbstractManagedObjectDefinition<?, ?> d, String key)
+ throws MissingResourceException, UnsupportedOperationException {
+ if (d.isTop()) {
+ throw new UnsupportedOperationException(
+ "Profile resources are not available for the "
+ + "Top configuration definition");
+ }
+
Properties p = getProperties(d);
String result = p.getProperty(key);
@@ -109,8 +120,7 @@
// Retrieve the properties table associated with a managed object,
- // lazily
- // loading it if necessary.
+ // lazily loading it if necessary.
private synchronized Properties getProperties(
AbstractManagedObjectDefinition<?, ?> d)
throws MissingResourceException {
diff --git a/opends/src/server/org/opends/server/admin/TopCfgDefn.java b/opends/src/server/org/opends/server/admin/TopCfgDefn.java
new file mode 100644
index 0000000..68e1347
--- /dev/null
+++ b/opends/src/server/org/opends/server/admin/TopCfgDefn.java
@@ -0,0 +1,74 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+package org.opends.server.admin;
+
+
+
+/**
+ * Configuration definition <code>TopCfgDefn</code> is the root of
+ * the configuration definition hierarchy. Every configuration has
+ * <code>TopCfgDefn</code> as a superclass.
+ * <p>
+ * The <code>TopCfgDefn</code> has no properties or relations.
+ * However, it can be used to determine all the configuration
+ * definitions currently available to the administration framework
+ * using the {@link #getAllChildren()}.
+ * <p>
+ * <b>NOTE:</b> it is not possible to retrieve I18N related
+ * information or profile information for this managed object
+ * definition. In particular, calls to the methods
+ * {@link #getSynopsis()}, {@link #getDescription()},
+ * {@link #getUserFriendlyName()}, and
+ * {@link #getUserFriendlyPluralName()} will not work.
+ */
+public final class TopCfgDefn extends
+ AbstractManagedObjectDefinition<ConfigurationClient, Configuration> {
+
+ // The singleton configuration definition instance.
+ private static final TopCfgDefn INSTANCE = new TopCfgDefn();
+
+
+
+ /**
+ * Get the Top configuration definition singleton.
+ *
+ * @return Returns the Top configuration definition singleton.
+ */
+ public static TopCfgDefn getInstance() {
+ return INSTANCE;
+ }
+
+
+
+ /**
+ * Private constructor.
+ */
+ private TopCfgDefn() {
+ super("top", null);
+ }
+
+}
diff --git a/opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java b/opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
index 8450e4b..88b5e82 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
@@ -757,7 +757,7 @@
AbstractManagedObjectDefinition<?, ?> d) {
// Determine the definition's base name.
AbstractManagedObjectDefinition<?, ?> parent = d;
- while (parent.getParent() != null) {
+ while (!parent.getParent().isTop()) {
parent = parent.getParent();
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java
index a7f1874..fd13f9f 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java
@@ -71,7 +71,7 @@
}
// Test definitions.
- private TestDefinition top = new TestDefinition("top", null);
+ private TestDefinition top = new TestDefinition("topmost", TopCfgDefn.getInstance());
private TestDefinition middle1 = new TestDefinition("middle1", top);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestChildCfgDefn.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestChildCfgDefn.java
index 77af453..3e1f1ea 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestChildCfgDefn.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestChildCfgDefn.java
@@ -202,7 +202,7 @@
* Private constructor.
*/
private TestChildCfgDefn() {
- super("test-child", null);
+ super("test-child", TopCfgDefn.getInstance());
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestParentCfgDefn.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestParentCfgDefn.java
index c0e9042..8c58e60 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestParentCfgDefn.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestParentCfgDefn.java
@@ -201,7 +201,7 @@
* Private constructor.
*/
private TestParentCfgDefn() {
- super("test-parent", null);
+ super("test-parent", TopCfgDefn.getInstance());
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestTopCfgDefnTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestTopCfgDefnTest.java
new file mode 100644
index 0000000..534290f
--- /dev/null
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestTopCfgDefnTest.java
@@ -0,0 +1,190 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+
+package org.opends.server.admin;
+
+
+
+import static org.testng.Assert.*;
+
+import org.opends.server.DirectoryServerTestCase;
+import org.opends.server.TestCaseUtils;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+
+/**
+ * TopCfgDefn test cases.
+ */
+@Test(sequential = true)
+public class TestTopCfgDefnTest extends DirectoryServerTestCase {
+
+ /**
+ * Sets up tests
+ *
+ * @throws Exception
+ * If the server could not be initialized.
+ */
+ @BeforeClass
+ public void setUp() throws Exception {
+ // This test suite depends on having the admin framework
+ // initialized.
+ TestCaseUtils.startServer();
+ }
+
+
+
+ /**
+ * Tests getInstance() does not return null.
+ */
+ @Test
+ public void testGetInstance() {
+ assertNotNull(TopCfgDefn.getInstance());
+ }
+
+
+
+ /**
+ * Tests getName() returns "top".
+ */
+ @Test
+ public void testGetName() {
+ assertEquals(TopCfgDefn.getInstance().getName(), "top");
+ }
+
+
+
+ /**
+ * Tests that there are no property definitions.
+ */
+ @Test
+ public void testGetAllPropertyDefinitions() {
+ assertTrue(TopCfgDefn.getInstance().getAllPropertyDefinitions().isEmpty());
+ }
+
+
+
+ /**
+ * Tests that there are no relation definitions.
+ */
+ @Test
+ public void testGetAllRelationDefinitions() {
+ assertTrue(TopCfgDefn.getInstance().getAllRelationDefinitions().isEmpty());
+ }
+
+
+
+ /**
+ * Tests that there are no constraints.
+ */
+ @Test
+ public void testGetAllConstraints() {
+ assertTrue(TopCfgDefn.getInstance().getAllConstraints().isEmpty());
+ }
+
+
+
+ /**
+ * Tests that there are no tags.
+ */
+ @Test
+ public void testGetAllTags() {
+ assertTrue(TopCfgDefn.getInstance().getAllTags().isEmpty());
+ }
+
+
+
+ /**
+ * Tests that there is no parent.
+ */
+ @Test
+ public void testGetParent() {
+ assertNull(TopCfgDefn.getInstance().getParent());
+ }
+
+
+
+ /**
+ * Tests that isTop returns true.
+ */
+ @Test
+ public void testIsTop() {
+ assertTrue(TopCfgDefn.getInstance().isTop());
+ }
+
+
+
+ /**
+ * Tests that getSynopsis throws an exception.
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void testGetSynopsis() {
+ assertNotNull(TopCfgDefn.getInstance().getSynopsis());
+ }
+
+
+
+ /**
+ * Tests that getDescription throws an exception.
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void testGetDescription() {
+ assertNotNull(TopCfgDefn.getInstance().getDescription());
+ }
+
+
+
+ /**
+ * Tests that getUserFriendlyName throws an exception.
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void testGetUserFriendlyName() {
+ assertNotNull(TopCfgDefn.getInstance().getUserFriendlyName());
+ }
+
+
+
+ /**
+ * Tests that getUserFriendlyPluralName throws an exception.
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void testGetUserFriendlyPluralName() {
+ assertNotNull(TopCfgDefn.getInstance().getUserFriendlyPluralName());
+ }
+
+
+
+ /**
+ * Tests that there are children.
+ */
+ @Test
+ public void testGetAllChildren() {
+ assertTrue(TopCfgDefn.getInstance().getAllChildren().size() > 0);
+ }
+
+}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/spi/PropertySetTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/spi/PropertySetTest.java
index 60973e8..31fc2aa 100755
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/spi/PropertySetTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/client/spi/PropertySetTest.java
@@ -28,17 +28,32 @@
package org.opends.server.admin.client.spi;
import static org.testng.Assert.*;
-import org.testng.annotations.*;
-import org.opends.server.admin.*;
-import org.opends.server.admin.Configuration;
-import org.opends.server.admin.client.ManagedObject;
-import org.opends.server.admin.client.spi.Property;
-import org.opends.server.admin.client.spi.PropertySet;
-import org.opends.server.admin.server.ServerManagedObject;
-import org.opends.server.admin.std.meta.RootCfgDefn;
-import org.opends.server.DirectoryServerTestCase;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.SortedSet;
+
+import org.opends.server.admin.AbstractManagedObjectDefinition;
+import org.opends.server.admin.AdminTestCase;
+import org.opends.server.admin.BooleanPropertyDefinition;
+import org.opends.server.admin.Configuration;
+import org.opends.server.admin.ConfigurationClient;
+import org.opends.server.admin.DefaultBehaviorProvider;
+import org.opends.server.admin.DefinedDefaultBehaviorProvider;
+import org.opends.server.admin.ManagedObjectDefinition;
+import org.opends.server.admin.PropertyDefinition;
+import org.opends.server.admin.PropertyOption;
+import org.opends.server.admin.PropertyProvider;
+import org.opends.server.admin.StringPropertyDefinition;
+import org.opends.server.admin.TopCfgDefn;
+import org.opends.server.admin.client.ManagedObject;
+import org.opends.server.admin.server.ServerManagedObject;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
/**
* PropertySet Tester.
@@ -73,21 +88,21 @@
@BeforeClass
public void setUp() {
BooleanPropertyDefinition.Builder builder =
- BooleanPropertyDefinition.createBuilder(RootCfgDefn.getInstance(), "test-bool-prop");
+ BooleanPropertyDefinition.createBuilder(TopCfgDefn.getInstance(), "test-bool-prop");
DefinedDefaultBehaviorProvider<Boolean> dbp =
new DefinedDefaultBehaviorProvider<Boolean>(BOOL_DEFAULT.toString());
builder.setDefaultBehaviorProvider(dbp);
testBoolPropertyDefinition = builder.getInstance();
StringPropertyDefinition.Builder builder2 =
- StringPropertyDefinition.createBuilder(RootCfgDefn.getInstance(), "test-sv-str-prop");
+ StringPropertyDefinition.createBuilder(TopCfgDefn.getInstance(), "test-sv-str-prop");
DefinedDefaultBehaviorProvider<String> dbp2 =
new DefinedDefaultBehaviorProvider<String>(STR_DEFAULT);
builder2.setDefaultBehaviorProvider(dbp2);
testSvStringPropertyDefinition = builder2.getInstance();
StringPropertyDefinition.Builder builder3 =
- StringPropertyDefinition.createBuilder(RootCfgDefn.getInstance(), "test-mv-str-prop");
+ StringPropertyDefinition.createBuilder(TopCfgDefn.getInstance(), "test-mv-str-prop");
DefinedDefaultBehaviorProvider<String> dbp3 =
new DefinedDefaultBehaviorProvider<String>(STR_DEFAULT);
builder3.setDefaultBehaviorProvider(dbp3);
@@ -385,7 +400,7 @@
}
private PropertySet createTestPropertySet(PropertyProvider pp) {
- ManagedObjectDefinition<?, ?> d = new TestManagedObjectDefinition<ConfigurationClient, Configuration>("test-mod", null);
+ ManagedObjectDefinition<?, ?> d = new TestManagedObjectDefinition<ConfigurationClient, Configuration>("test-mod", TopCfgDefn.getInstance());
PropertySet ps = new PropertySet();
for (PropertyDefinition<?> pd : d.getPropertyDefinitions()) {
addProperty(ps, pd, pp);
--
Gitblit v1.10.0