From 79cb3d38939c48e71eb1d83592f61765d3983cf0 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Thu, 12 Jul 2007 22:46:42 +0000
Subject: [PATCH] Fix issues 1558 and 1919.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/admin/TestChildCfgDefn.java | 342 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 254 insertions(+), 88 deletions(-)
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 84c16f0..781ed0f 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
@@ -28,80 +28,145 @@
+import java.util.Collection;
+import java.util.SortedSet;
+import org.opends.server.admin.AdministratorAction;
+import org.opends.server.admin.AttributeTypePropertyDefinition;
+import org.opends.server.admin.BooleanPropertyDefinition;
+import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.client.AuthorizationException;
import org.opends.server.admin.client.CommunicationException;
import org.opends.server.admin.client.ConcurrentModificationException;
import org.opends.server.admin.client.ManagedObject;
import org.opends.server.admin.client.MissingMandatoryPropertiesException;
import org.opends.server.admin.client.OperationRejectedException;
+import org.opends.server.admin.DefaultBehaviorProvider;
+import org.opends.server.admin.DefinedDefaultBehaviorProvider;
+import org.opends.server.admin.DNPropertyDefinition;
+import org.opends.server.admin.ManagedObjectAlreadyExistsException;
+import org.opends.server.admin.ManagedObjectDefinition;
+import org.opends.server.admin.PropertyIsReadOnlyException;
+import org.opends.server.admin.PropertyOption;
+import org.opends.server.admin.PropertyProvider;
+import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider;
+import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ServerManagedObject;
+import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
+import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
/**
- * A sample configuration definition class for testing.
+ * An interface for querying the Test Child managed object definition
+ * meta information.
+ * <p>
+ * A configuration for testing components that are subordinate to a
+ * parent component. It re-uses the virtual-attribute configuration
+ * LDAP profile.
*/
-public final class TestChildCfgDefn extends
- ManagedObjectDefinition<TestChildCfgClient, TestChildCfg> {
+public final class TestChildCfgDefn extends ManagedObjectDefinition<TestChildCfgClient, TestChildCfg> {
// The singleton configuration definition instance.
private static final TestChildCfgDefn INSTANCE = new TestChildCfgDefn();
- // The "maximum-length" property definition.
- private static final IntegerPropertyDefinition PD_MAXIMUM_LENGTH;
- // The "minimum-length" property definition.
- private static final IntegerPropertyDefinition PD_MINIMUM_LENGTH;
- // The "heartbeat-interval" property definition.
- private static final DurationPropertyDefinition PD_HEARTBEAT_INTERVAL;
+ // The "mandatory-boolean-property" property definition.
+ private static final BooleanPropertyDefinition PD_MANDATORY_BOOLEAN_PROPERTY;
- // Build the "maximum-length" property definition.
+
+
+ // The "mandatory-class-property" property definition.
+ private static final ClassPropertyDefinition PD_MANDATORY_CLASS_PROPERTY;
+
+
+
+ // The "mandatory-read-only-attribute-type-property" property definition.
+ private static final AttributeTypePropertyDefinition PD_MANDATORY_READ_ONLY_ATTRIBUTE_TYPE_PROPERTY;
+
+
+
+ // The "optional-multi-valued-dn-property1" property definition.
+ private static final DNPropertyDefinition PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY1;
+
+
+
+ // The "optional-multi-valued-dn-property2" property definition.
+ private static final DNPropertyDefinition PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY2;
+
+
+
+ // Build the "mandatory-boolean-property" property definition.
static {
- IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition
- .createBuilder(INSTANCE, "maximum-length");
- DefaultBehaviorProvider<Integer> provider = new RelativeInheritedDefaultBehaviorProvider<Integer>(
- TestParentCfgDefn.getInstance(), "maximum-length", 1);
- builder.setDefaultBehaviorProvider(provider);
- builder.setLowerLimit(0);
- PD_MAXIMUM_LENGTH = builder.getInstance();
- INSTANCE.registerPropertyDefinition(PD_MAXIMUM_LENGTH);
+ BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "mandatory-boolean-property");
+ builder.setOption(PropertyOption.MANDATORY);
+ builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "mandatory-boolean-property"));
+ builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>());
+ PD_MANDATORY_BOOLEAN_PROPERTY = builder.getInstance();
+ INSTANCE.registerPropertyDefinition(PD_MANDATORY_BOOLEAN_PROPERTY);
}
- // Build the "minimum-length" property definition.
+
+
+ // Build the "mandatory-class-property" property definition.
static {
- IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition
- .createBuilder(INSTANCE, "minimum-length");
- DefaultBehaviorProvider<Integer> provider = new AbsoluteInheritedDefaultBehaviorProvider<Integer>(
- ManagedObjectPath.valueOf("/relation=test-parent+name=test parent 2"),
- "minimum-length");
- builder.setDefaultBehaviorProvider(provider);
- builder.setLowerLimit(0);
- PD_MINIMUM_LENGTH = builder.getInstance();
- INSTANCE.registerPropertyDefinition(PD_MINIMUM_LENGTH);
+ ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "mandatory-class-property");
+ builder.setOption(PropertyOption.MANDATORY);
+ builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "mandatory-class-property"));
+ DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ builder.setDefaultBehaviorProvider(provider);
+ builder.addInstanceOf("org.opends.server.api.VirtualAttributeProvider");
+ PD_MANDATORY_CLASS_PROPERTY = builder.getInstance();
+ INSTANCE.registerPropertyDefinition(PD_MANDATORY_CLASS_PROPERTY);
}
- // Build the "heartbeat-interval" property definition.
+
+
+ // Build the "mandatory-read-only-attribute-type-property" property definition.
static {
- DurationPropertyDefinition.Builder builder = DurationPropertyDefinition
- .createBuilder(INSTANCE, "heartbeat-interval");
- DefaultBehaviorProvider<Long> provider = new DefinedDefaultBehaviorProvider<Long>(
- "1000ms");
- builder.setDefaultBehaviorProvider(provider);
- builder.setAllowUnlimited(false);
- builder.setBaseUnit("ms");
- builder.setLowerLimit("100");
- PD_HEARTBEAT_INTERVAL = builder.getInstance();
- INSTANCE.registerPropertyDefinition(PD_HEARTBEAT_INTERVAL);
+ AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, "mandatory-read-only-attribute-type-property");
+ builder.setOption(PropertyOption.READ_ONLY);
+ builder.setOption(PropertyOption.MANDATORY);
+ builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "mandatory-read-only-attribute-type-property"));
+ builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<AttributeType>());
+ PD_MANDATORY_READ_ONLY_ATTRIBUTE_TYPE_PROPERTY = builder.getInstance();
+ INSTANCE.registerPropertyDefinition(PD_MANDATORY_READ_ONLY_ATTRIBUTE_TYPE_PROPERTY);
+ }
+
+
+
+ // Build the "optional-multi-valued-dn-property1" property definition.
+ static {
+ DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "optional-multi-valued-dn-property1");
+ builder.setOption(PropertyOption.MULTI_VALUED);
+ builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "optional-multi-valued-dn-property1"));
+ DefaultBehaviorProvider<DN> provider = new RelativeInheritedDefaultBehaviorProvider<DN>(TestParentCfgDefn.getInstance(), "optional-multi-valued-dn-property", 1);
+ builder.setDefaultBehaviorProvider(provider);
+ PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY1 = builder.getInstance();
+ INSTANCE.registerPropertyDefinition(PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY1);
+ }
+
+
+
+ // Build the "optional-multi-valued-dn-property2" property definition.
+ static {
+ DNPropertyDefinition.Builder builder = DNPropertyDefinition.createBuilder(INSTANCE, "optional-multi-valued-dn-property2");
+ builder.setOption(PropertyOption.MULTI_VALUED);
+ builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "optional-multi-valued-dn-property2"));
+ DefaultBehaviorProvider<DN> provider = new RelativeInheritedDefaultBehaviorProvider<DN>(TestChildCfgDefn.getInstance(), "optional-multi-valued-dn-property1", 0);
+ builder.setDefaultBehaviorProvider(provider);
+ PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY2 = builder.getInstance();
+ INSTANCE.registerPropertyDefinition(PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY2);
}
/**
- * Get the definition singleton.
+ * Get the Test Child configuration definition singleton.
*
- * @return Returns the definition singleton.
+ * @return Returns the Test Child configuration definition
+ * singleton.
*/
public static TestChildCfgDefn getInstance() {
return INSTANCE;
@@ -148,34 +213,68 @@
/**
- * Get the "heartbeat-interval" property definition.
+ * Get the "mandatory-boolean-property" property definition.
+ * <p>
+ * A mandatory boolean property.
*
- * @return Returns the "heartbeat-interval" property definition.
+ * @return Returns the "mandatory-boolean-property" property definition.
*/
- public DurationPropertyDefinition getHeartbeatIntervalPropertyDefinition() {
- return PD_HEARTBEAT_INTERVAL;
+ public BooleanPropertyDefinition getMandatoryBooleanPropertyPropertyDefinition() {
+ return PD_MANDATORY_BOOLEAN_PROPERTY;
}
/**
- * Get the "maximum-length" property definition.
+ * Get the "mandatory-class-property" property definition.
+ * <p>
+ * A mandatory Java-class property requiring a component restart.
*
- * @return Returns the "maximum-length" property definition.
+ * @return Returns the "mandatory-class-property" property definition.
*/
- public IntegerPropertyDefinition getMaximumLengthPropertyDefinition() {
- return PD_MAXIMUM_LENGTH;
+ public ClassPropertyDefinition getMandatoryClassPropertyPropertyDefinition() {
+ return PD_MANDATORY_CLASS_PROPERTY;
}
/**
- * Get the "minimum-length" property definition.
+ * Get the "mandatory-read-only-attribute-type-property" property definition.
+ * <p>
+ * A mandatory read-only attribute type property.
*
- * @return Returns the "minimum-length" property definition.
+ * @return Returns the "mandatory-read-only-attribute-type-property" property definition.
*/
- public IntegerPropertyDefinition getMinimumLengthPropertyDefinition() {
- return PD_MINIMUM_LENGTH;
+ public AttributeTypePropertyDefinition getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition() {
+ return PD_MANDATORY_READ_ONLY_ATTRIBUTE_TYPE_PROPERTY;
+ }
+
+
+
+ /**
+ * Get the "optional-multi-valued-dn-property1" property definition.
+ * <p>
+ * An optional multi-valued DN property which inherits its values
+ * from optional-multi-valued-dn-property in the parent.
+ *
+ * @return Returns the "optional-multi-valued-dn-property1" property definition.
+ */
+ public DNPropertyDefinition getOptionalMultiValuedDNProperty1PropertyDefinition() {
+ return PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY1;
+ }
+
+
+
+ /**
+ * Get the "optional-multi-valued-dn-property2" property definition.
+ * <p>
+ * An optional multi-valued DN property which inherits its values
+ * from optional-multi-valued-dn-property1.
+ *
+ * @return Returns the "optional-multi-valued-dn-property2" property definition.
+ */
+ public DNPropertyDefinition getOptionalMultiValuedDNProperty2PropertyDefinition() {
+ return PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY2;
}
@@ -183,7 +282,8 @@
/**
* Managed object client implementation.
*/
- private static class TestChildCfgClientImpl implements TestChildCfgClient {
+ private static class TestChildCfgClientImpl implements
+ TestChildCfgClient {
// Private implementation.
private ManagedObject<? extends TestChildCfgClient> impl;
@@ -201,9 +301,8 @@
/**
* {@inheritDoc}
*/
- public long getHeartbeatInterval() {
- return impl.getPropertyValue(INSTANCE
- .getHeartbeatIntervalPropertyDefinition());
+ public Boolean isMandatoryBooleanProperty() {
+ return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition());
}
@@ -211,9 +310,8 @@
/**
* {@inheritDoc}
*/
- public void setHeartbeatInterval(Long value) {
- impl.setPropertyValue(INSTANCE.getHeartbeatIntervalPropertyDefinition(),
- value);
+ public void setMandatoryBooleanProperty(boolean value) {
+ impl.setPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition(), value);
}
@@ -221,9 +319,8 @@
/**
* {@inheritDoc}
*/
- public int getMaximumLength() {
- return impl.getPropertyValue(INSTANCE
- .getMaximumLengthPropertyDefinition());
+ public String getMandatoryClassProperty() {
+ return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition());
}
@@ -231,9 +328,8 @@
/**
* {@inheritDoc}
*/
- public void setMaximumLength(Integer value) {
- impl.setPropertyValue(INSTANCE.getMaximumLengthPropertyDefinition(),
- value);
+ public void setMandatoryClassProperty(String value) {
+ impl.setPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition(), value);
}
@@ -241,9 +337,8 @@
/**
* {@inheritDoc}
*/
- public int getMinimumLength() {
- return impl.getPropertyValue(INSTANCE
- .getMinimumLengthPropertyDefinition());
+ public AttributeType getMandatoryReadOnlyAttributeTypeProperty() {
+ return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition());
}
@@ -251,9 +346,44 @@
/**
* {@inheritDoc}
*/
- public void setMinimumLength(Integer value) {
- impl.setPropertyValue(INSTANCE.getMinimumLengthPropertyDefinition(),
- value);
+ public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyIsReadOnlyException {
+ impl.setPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition(), value);
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SortedSet<DN> getOptionalMultiValuedDNProperty1() {
+ return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition());
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setOptionalMultiValuedDNProperty1(Collection<DN> values) {
+ impl.setPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition(), values);
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SortedSet<DN> getOptionalMultiValuedDNProperty2() {
+ return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition());
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setOptionalMultiValuedDNProperty2(Collection<DN> values) {
+ impl.setPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition(), values);
}
@@ -279,12 +409,13 @@
/**
* {@inheritDoc}
*/
- public void commit() throws ConcurrentModificationException,
+ public void commit() throws ManagedObjectAlreadyExistsException,
+ MissingMandatoryPropertiesException, ConcurrentModificationException,
OperationRejectedException, AuthorizationException,
- CommunicationException, ManagedObjectAlreadyExistsException,
- MissingMandatoryPropertiesException {
+ CommunicationException {
impl.commit();
}
+
}
@@ -292,7 +423,8 @@
/**
* Managed object server implementation.
*/
- private static class TestChildCfgServerImpl implements TestChildCfg {
+ private static class TestChildCfgServerImpl implements
+ TestChildCfg {
// Private implementation.
private ServerManagedObject<? extends TestChildCfg> impl;
@@ -300,8 +432,7 @@
// Private constructor.
- private TestChildCfgServerImpl(
- ServerManagedObject<? extends TestChildCfg> impl) {
+ private TestChildCfgServerImpl(ServerManagedObject<? extends TestChildCfg> impl) {
this.impl = impl;
}
@@ -310,9 +441,9 @@
/**
* {@inheritDoc}
*/
- public long getHeartbeatInterval() {
- return impl.getPropertyValue(INSTANCE
- .getHeartbeatIntervalPropertyDefinition());
+ public void addChangeListener(
+ ConfigurationChangeListener<TestChildCfg> listener) {
+ impl.registerChangeListener(listener);
}
@@ -320,9 +451,9 @@
/**
* {@inheritDoc}
*/
- public int getMaximumLength() {
- return impl.getPropertyValue(INSTANCE
- .getMaximumLengthPropertyDefinition());
+ public void removeChangeListener(
+ ConfigurationChangeListener<TestChildCfg> listener) {
+ impl.deregisterChangeListener(listener);
}
@@ -330,9 +461,44 @@
/**
* {@inheritDoc}
*/
- public int getMinimumLength() {
- return impl.getPropertyValue(INSTANCE
- .getMinimumLengthPropertyDefinition());
+ public boolean isMandatoryBooleanProperty() {
+ return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition());
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getMandatoryClassProperty() {
+ return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition());
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public AttributeType getMandatoryReadOnlyAttributeTypeProperty() {
+ return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition());
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SortedSet<DN> getOptionalMultiValuedDNProperty1() {
+ return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition());
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SortedSet<DN> getOptionalMultiValuedDNProperty2() {
+ return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition());
}
@@ -361,6 +527,6 @@
public DN dn() {
return impl.getDN();
}
- }
+ }
}
--
Gitblit v1.10.0