From e114a899bbc0df59f5135f195d24797bf6c1b778 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Thu, 02 Jan 2014 09:33:43 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1235 : Migrate configuration framework
---
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AttributeTypePropertyDefinitionTest.java | 25
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/AggregationServerTest.java | 143 +++--
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/Reference.java | 3
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/EnumPropertyDefinition.java | 4
opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java | 14
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressMaskPropertyDefinition.java | 4
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/BooleanPropertyDefinitionTest.java | 9
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/StringPropertyDefinition.java | 6
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ClassPropertyDefinition.java | 61 --
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/EnumPropertyDefinitionTest.java | 7
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DefaultBehaviorTest.java | 113 ++--
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DNPropertyDefinition.java | 7
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AggregationPropertyDefinitionTest.java | 1
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DurationPropertyDefinitionTest.java | 21
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/server/ServerManagementContext.java | 40 +
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/StringPropertyDefinitionTest.java | 17
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/doc/ConfigGuideGeneration.java | 4
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/RelativeInheritedDefaultBehaviorProviderTest.java | 1
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinitionsOptions.java | 137 +++++
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DurationPropertyDefinition.java | 6
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DNPropertyDefinitionTest.java | 14
opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigTestCase.java | 10
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagedObject.java | 3
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java | 1
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AttributeTypePropertyDefinition.java | 37 -
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ACIPropertyDefinition.java | 4
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressPropertyDefinition.java | 4
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IntegerPropertyDefinition.java | 6
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java | 242 ++++++---
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/IllegalManagedObjectNameException.java | 16
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/IntegerPropertyDefinitionTest.java | 16
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/BooleanPropertyDefinition.java | 4
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DefaultManagedObject.java | 3
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/condition/ContainsCondition.java | 3
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ListenerTest.java | 95 ++-
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java | 6
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinition.java | 12
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPDriver.java | 39 +
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java | 6
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/Driver.java | 16
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectDefinitionI18NResourceTest.java | 1
opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java | 13
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/LDAPProfileTest.java | 6
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java | 16
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AggregationPropertyDefinition.java | 6
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/AbstractManagedObject.java | 19
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AdminTestCase.java | 4
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ClassPropertyDefinitionTest.java | 6
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DNBuilderTest.java | 1
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagementContext.java | 42 +
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java | 21
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ValidateConfigDefinitionsTest.java | 1
opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ConstraintTest.java | 95 ++-
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/PropertySet.java | 8
opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/SizePropertyDefinition.java | 6
55 files changed, 768 insertions(+), 637 deletions(-)
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ACIPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ACIPropertyDefinition.java
index afb40a5..d9e0b19 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ACIPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ACIPropertyDefinition.java
@@ -86,7 +86,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Aci value) {
+ public void validateValue(Aci value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// No additional validation required.
@@ -96,7 +96,7 @@
* {@inheritDoc}
*/
@Override
- public Aci decodeValue(String value) {
+ public Aci decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
try {
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AggregationPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AggregationPropertyDefinition.java
index 1c7aacc..bab2d5d 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AggregationPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AggregationPropertyDefinition.java
@@ -811,11 +811,11 @@
* {@inheritDoc}
*/
@Override
- public String decodeValue(String value) {
+ public String decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
try {
- validateValue(value);
+ validateValue(value, options);
return value;
} catch (IllegalPropertyValueException e) {
throw new IllegalPropertyValueStringException(this, value);
@@ -979,7 +979,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(String value) {
+ public void validateValue(String value, PropertyDefinitionsOptions options) {
try {
Reference.parseName(parentPath, relationDefinition, value);
} catch (IllegalArgumentException e) {
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AttributeTypePropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AttributeTypePropertyDefinition.java
index bfb17b0..d998a79 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AttributeTypePropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/AttributeTypePropertyDefinition.java
@@ -60,10 +60,6 @@
}
}
- // Flag indicating whether or not attribute type names should be
- // validated against the schema.
- private static boolean isCheckSchema = true;
-
/**
* Create a attribute type property definition builder.
*
@@ -78,31 +74,6 @@
return new Builder(d, propertyName);
}
- /**
- * Determines whether or not attribute type names should be validated
- * against the schema.
- *
- * @return Returns <code>true</code> if attribute type names should be
- * validated against the schema.
- */
- public static boolean isCheckSchema() {
- return isCheckSchema;
- }
-
- /**
- * Specify whether or not attribute type names should be validated against
- * the schema.
- * <p>
- * By default validation is switched on.
- *
- * @param value
- * <code>true</code> if attribute type names should be validated
- * against the schema.
- */
- public static void setCheckSchema(boolean value) {
- isCheckSchema = value;
- }
-
// Private constructor.
private AttributeTypePropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName,
EnumSet<PropertyOption> options, AdministratorAction adminAction,
@@ -138,17 +109,17 @@
* {@inheritDoc}
*/
@Override
- public AttributeType decodeValue(String value) {
+ public AttributeType decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
String name = value.trim().toLowerCase();
- AttributeType type = DirectoryServer.getAttributeType(name, !isCheckSchema);
+ AttributeType type = DirectoryServer.getAttributeType(name, !options.checkSchemaForAttributes());
if (type == null) {
throw new IllegalPropertyValueStringException(this, value);
} else {
try {
- validateValue(type);
+ validateValue(type, options);
return type;
} catch (IllegalPropertyValueException e) {
throw new IllegalPropertyValueStringException(this, value);
@@ -168,7 +139,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(AttributeType value) {
+ public void validateValue(AttributeType value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// No implementation required.
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/BooleanPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/BooleanPropertyDefinition.java
index 3d6c90d..5eef04d 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/BooleanPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/BooleanPropertyDefinition.java
@@ -97,7 +97,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Boolean value) {
+ public void validateValue(Boolean value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// No additional validation required.
@@ -107,7 +107,7 @@
* {@inheritDoc}
*/
@Override
- public Boolean decodeValue(String value) {
+ public Boolean decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
String nvalue = value.trim().toLowerCase();
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ClassPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ClassPropertyDefinition.java
index 766db83..ed0bcf2 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ClassPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/ClassPropertyDefinition.java
@@ -44,8 +44,8 @@
* Note that in a client/server environment, the client is probably not capable
* of validating the Java class (e.g. it will not be able to load it nor have
* access to the interfaces it is supposed to implement). For this reason, it is
- * possible to switch off validation in the client by calling the static method
- * {@link #setAllowClassValidation(boolean)}.
+ * possible to switch off validation in the client by using the appropriate
+ * {@link PropertyDefinitionsOptions}.
*/
public final class ClassPropertyDefinition extends PropertyDefinition<String> {
@@ -82,23 +82,6 @@
throw new IllegalArgumentException("\"" + value + "\" is not a valid Java class name");
}
- /*
- * If possible try and load the class in order to perform additional
- * validation.
- */
- if (isAllowClassValidation()) {
- /*
- * Check that the class can be loaded so that validation can be
- * performed.
- */
- try {
- loadClass(value, true);
- } catch (ClassNotFoundException e) {
- // TODO: can we do something better here?
- throw new RuntimeException(e);
- }
- }
-
instanceOfInterfaces.add(value);
}
@@ -118,11 +101,6 @@
// Regular expression for validating class names.
private static final String CLASS_RE = "^([A-Za-z][A-Za-z0-9_]*\\.)*[A-Za-z][A-Za-z0-9_]*(\\$[A-Za-z0-9_]+)*$";
- /*
- * Flag indicating whether class property values should be validated.
- */
- private static boolean allowClassValidation = true;
-
/**
* Create a class property definition builder.
*
@@ -137,33 +115,6 @@
return new Builder(d, propertyName);
}
- /**
- * Determine whether or not class property definitions should validate class
- * name property values. Validation involves checking that the class exists
- * and that it implements the required interfaces.
- *
- * @return Returns <code>true</code> if class property definitions should
- * validate class name property values.
- */
- public static boolean isAllowClassValidation() {
- return allowClassValidation;
- }
-
- /**
- * Specify whether or not class property definitions should validate class
- * name property values. Validation involves checking that the class exists
- * and that it implements the required interfaces.
- * <p>
- * By default validation is switched on.
- *
- * @param value
- * <code>true</code> if class property definitions should
- * validate class name property values.
- */
- public static void setAllowClassValidation(boolean value) {
- allowClassValidation = value;
- }
-
// Load a named class.
private static Class<?> loadClass(String className, boolean initialize) throws ClassNotFoundException {
return Class.forName(className, initialize, ClassLoaderProvider.getInstance().getClassLoader());
@@ -201,11 +152,11 @@
* {@inheritDoc}
*/
@Override
- public String decodeValue(String value) {
+ public String decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
try {
- validateValue(value);
+ validateValue(value, options);
} catch (IllegalPropertyValueException e) {
throw new IllegalPropertyValueStringException(this, value, e.getCause());
}
@@ -268,7 +219,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(String value) {
+ public void validateValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// Always make sure the name is a valid class name.
@@ -278,7 +229,7 @@
* If additional validation is enabled then attempt to load the class
* and check the interfaces that it implements/extends.
*/
- if (allowClassValidation) {
+ if (options.allowClassValidation()) {
validateClassInterfaces(value, false);
}
}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DNPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DNPropertyDefinition.java
index 377f403..ca65a04 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DNPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DNPropertyDefinition.java
@@ -134,7 +134,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(DN value) {
+ public void validateValue(DN value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
if (baseDN != null) {
@@ -154,13 +154,12 @@
* {@inheritDoc}
*/
@Override
- public DN decodeValue(String value) {
+ public DN decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
try {
- // TODO: is it correct to replace server DN.decode by SDK valueOf ?
DN dn = DN.valueOf(value);
- validateValue(dn);
+ validateValue(dn, options);
return dn;
} catch (IllegalPropertyValueException e) {
throw new IllegalPropertyValueStringException(this, value);
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DefaultManagedObject.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DefaultManagedObject.java
index 3cb97c0..09ad5c9 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DefaultManagedObject.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DefaultManagedObject.java
@@ -146,7 +146,8 @@
List<String> stringValues = propertyStringValues.get(pd.getName());
if (stringValues != null) {
for (String stringValue : stringValues) {
- values.add(pd.decodeValue(stringValue));
+ // TODO : is it correct to have no validation ?
+ values.add(pd.decodeValue(stringValue, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS));
}
}
return values;
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DurationPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DurationPropertyDefinition.java
index 2f0838a..5090b99 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DurationPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/DurationPropertyDefinition.java
@@ -392,7 +392,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Long value) {
+ public void validateValue(Long value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
long nvalue = baseUnit.toMilliSeconds(value);
@@ -436,7 +436,7 @@
* {@inheritDoc}
*/
@Override
- public Long decodeValue(String value) {
+ public Long decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// First check for the special "unlimited" value when necessary.
@@ -463,7 +463,7 @@
// Convert the value a long in the property's required unit.
Long i = (long) baseUnit.fromMilliSeconds(ms);
try {
- validateValue(i);
+ validateValue(i, options);
} catch (IllegalPropertyValueException e) {
throw new IllegalPropertyValueStringException(this, value);
}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/EnumPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/EnumPropertyDefinition.java
index 8006662..53812c9 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/EnumPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/EnumPropertyDefinition.java
@@ -150,7 +150,7 @@
* {@inheritDoc}
*/
@Override
- public E decodeValue(String value) {
+ public E decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
String nvalue = value.trim().toLowerCase();
@@ -219,7 +219,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(E value) {
+ public void validateValue(E value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// No additional validation required.
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressMaskPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressMaskPropertyDefinition.java
index d88ef94..03f7c03 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressMaskPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressMaskPropertyDefinition.java
@@ -86,7 +86,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(AddressMask value) {
+ public void validateValue(AddressMask value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// No additional validation required.
@@ -96,7 +96,7 @@
* {@inheritDoc}
*/
@Override
- public AddressMask decodeValue(String value) {
+ public AddressMask decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
try {
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressPropertyDefinition.java
index f7f4650..1a2cec2 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IPAddressPropertyDefinition.java
@@ -85,7 +85,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(InetAddress value) {
+ public void validateValue(InetAddress value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// No additional validation required.
@@ -95,7 +95,7 @@
* {@inheritDoc}
*/
@Override
- public InetAddress decodeValue(String value) {
+ public InetAddress decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
try {
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IntegerPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IntegerPropertyDefinition.java
index 3dfb37f..08104fb 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IntegerPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/IntegerPropertyDefinition.java
@@ -229,7 +229,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Integer value) {
+ public void validateValue(Integer value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
if (!allowUnlimited && value < lowerLimit) {
@@ -266,7 +266,7 @@
* {@inheritDoc}
*/
@Override
- public Integer decodeValue(String value) {
+ public Integer decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
if (allowUnlimited) {
@@ -283,7 +283,7 @@
}
try {
- validateValue(i);
+ validateValue(i, options);
} catch (IllegalPropertyValueException e) {
throw new IllegalPropertyValueStringException(this, value);
}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinition.java
index ebd89fb..e9bd5ba 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinition.java
@@ -244,7 +244,7 @@
* <p>
* This method only casts the object to the required type; it does not
* validate the value once it has been cast. Subsequent validation should be
- * performed using the method {@link #validateValue(Object)}.
+ * performed using the method {@link #validateValue(Object, PropertyDefinitionsOptions)}.
* <p>
* This method guarantees the following expression is always
* <code>true</code>:
@@ -318,11 +318,13 @@
*
* @param value
* The property string value (must not be <code>null</code>).
+ * @param options
+ * Options to use when decoding value.
* @return Returns the decoded property value.
* @throws IllegalPropertyValueStringException
* If the property value string is invalid.
*/
- public abstract T decodeValue(String value);
+ public abstract T decodeValue(String value, PropertyDefinitionsOptions options);
/**
* Encode the provided property value into its string representation.
@@ -508,7 +510,7 @@
* This method may throw an exception if the provided value is invalid.
* However, applications should not assume that implementations of this
* method will always validate a value. This task is the responsibility of
- * {@link #validateValue(Object)}.
+ * {@link #validateValue(Object, PropertyDefinitionsOptions)}.
* <p>
* This default implementation simply returns the string representation of
* the provided value. Sub-classes might want to override this method if
@@ -562,10 +564,12 @@
*
* @param value
* The property value (must not be <code>null</code>).
+ * @param options
+ * Options to use when decoding value.
* @throws IllegalPropertyValueException
* If the property value is invalid.
*/
- public abstract void validateValue(T value);
+ public abstract void validateValue(T value, PropertyDefinitionsOptions options);
/**
* Performs any run-time initialization required by this property
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinitionsOptions.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinitionsOptions.java
new file mode 100644
index 0000000..2b83adb
--- /dev/null
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/PropertyDefinitionsOptions.java
@@ -0,0 +1,137 @@
+/*
+ * 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 legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * 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 legal-notices/CDDLv1_0.txt.
+ * 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
+ *
+ *
+ * Copyright 2013 ForgeRock AS.
+ */
+package org.opends.server.admin;
+
+/**
+ * Provides options for {@code PropertyDefinition property definitions}.
+ * <p>
+ * These options are used by some {@code PropertyDefinition} methods to define
+ * strategy used when processing value(s) of a property definition.
+ */
+public final class PropertyDefinitionsOptions {
+
+ /** Immutable options with no validation of java classes or LDAP attributes. */
+ public static final PropertyDefinitionsOptions NO_VALIDATION_OPTIONS = new PropertyDefinitionsOptions().
+ setAllowClassValidation(false).
+ setCheckSchemaForAttributes(false).
+ freeze();
+
+ /** By default, class validation is enabled. */
+ private boolean allowClassValidation = true;
+
+ /** By default, attributes validation against the schema is enabled. */
+ private boolean checkSchemaForAttributes = true;
+
+ /**
+ * If true, then the instance is frozen so state can't be changed (object is
+ * immutable).
+ */
+ private boolean isFrozen = false;
+
+ /**
+ * Creates a new set of properties options with default settings. By
+ * default, class validation and attributes checking are enabled.
+ */
+ public PropertyDefinitionsOptions() {
+ // empty implementation
+ }
+
+ /**
+ * Determine whether or not class property definitions should validate class
+ * name property values. Validation involves checking that the class exists
+ * and that it implements the required interfaces.
+ *
+ * @return Returns <code>true</code> if class property definitions should
+ * validate class name property values.
+ */
+ public boolean allowClassValidation() {
+ return allowClassValidation;
+ }
+
+ /**
+ * Specify whether or not class property definitions should validate class
+ * name property values. Validation involves checking that the class exists
+ * and that it implements the required interfaces.
+ * <p>
+ * By default validation is switched on.
+ *
+ * @param value
+ * <code>true</code> if class property definitions should
+ * validate class name property values.
+ * @return A reference to this definitions options.
+ */
+ public PropertyDefinitionsOptions setAllowClassValidation(boolean value) {
+ if (isFrozen) {
+ throw new IllegalStateException("This object is frozen, it can't be changed");
+ }
+ allowClassValidation = value;
+ return this;
+ }
+
+ /**
+ * Determines whether or not attribute type names should be validated
+ * against the schema.
+ *
+ * @return Returns <code>true</code> if attribute type names should be
+ * validated against the schema.
+ */
+ public boolean checkSchemaForAttributes() {
+ return checkSchemaForAttributes;
+ }
+
+ /**
+ * Specify whether or not attribute type names should be validated against
+ * the schema.
+ * <p>
+ * By default validation is switched on.
+ *
+ * @param value
+ * <code>true</code> if attribute type names should be validated
+ * against the schema.
+ * @return A reference to this definitions options.
+ */
+ public PropertyDefinitionsOptions setCheckSchemaForAttributes(boolean value) {
+ if (isFrozen) {
+ throw new IllegalStateException("This object is frozen, it can't be changed");
+ }
+ checkSchemaForAttributes = value;
+ return this;
+ }
+
+ /**
+ * Freeze this object, making it effectively immutable.
+ * <p>
+ * Once this method is called, all {@code set} methods will throw
+ * an IllegalStateException if called.
+ *
+ * @return A reference to this definitions options.
+ */
+ public PropertyDefinitionsOptions freeze() {
+ isFrozen = true;
+ return this;
+ }
+
+}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/Reference.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/Reference.java
index d4c8f0d..b3aafa6 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/Reference.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/Reference.java
@@ -189,7 +189,8 @@
private <T> String normalizeName(PropertyDefinition<T> pd) {
if (pd != null) {
try {
- T tvalue = pd.decodeValue(name);
+ // TODO : is it correct to have no validation ?
+ T tvalue = pd.decodeValue(name, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
return pd.normalizeValue(tvalue);
} catch (IllegalPropertyValueStringException e) {
// Fall through to default normalization.
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/SizePropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/SizePropertyDefinition.java
index b5382c3..8cf9059 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/SizePropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/SizePropertyDefinition.java
@@ -230,7 +230,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Long value) {
+ public void validateValue(Long value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
if (!allowUnlimited && value < lowerLimit) {
@@ -276,7 +276,7 @@
* {@inheritDoc}
*/
@Override
- public Long decodeValue(String value) {
+ public Long decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
// First check for the special "unlimited" value when necessary.
@@ -295,7 +295,7 @@
}
try {
- validateValue(i);
+ validateValue(i, options);
} catch (IllegalPropertyValueException e) {
throw new IllegalPropertyValueStringException(this, value);
}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/StringPropertyDefinition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/StringPropertyDefinition.java
index 2e21341..74da070 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/StringPropertyDefinition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/StringPropertyDefinition.java
@@ -170,11 +170,11 @@
* {@inheritDoc}
*/
@Override
- public String decodeValue(String value) {
+ public String decodeValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
try {
- validateValue(value);
+ validateValue(value, options);
} catch (IllegalPropertyValueException e) {
throw new IllegalPropertyValueStringException(this, value);
}
@@ -269,7 +269,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(String value) {
+ public void validateValue(String value, PropertyDefinitionsOptions options) {
Reject.ifNull(value);
if (pattern != null) {
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/IllegalManagedObjectNameException.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/IllegalManagedObjectNameException.java
index cca8526..e9c56b6 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/IllegalManagedObjectNameException.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/IllegalManagedObjectNameException.java
@@ -32,6 +32,7 @@
import org.opends.server.admin.OperationsException;
import org.opends.server.admin.PropertyDefinition;
import org.opends.server.admin.PropertyDefinitionUsageBuilder;
+import org.opends.server.admin.PropertyDefinitionsOptions;
/**
* Thrown when an attempt is made to create a new managed object with an illegal
@@ -50,15 +51,15 @@
private static final long serialVersionUID = 7491748228684293291L;
/** Create the message. */
- // @Checkstyle:ignore
- private static LocalizableMessage createMessage(String illegalName, PropertyDefinition<?> namingPropertyDefinition) {
+ private static LocalizableMessage createMessage(String illegalName, PropertyDefinition<?> namingPropertyDefinition,
+ PropertyDefinitionsOptions options) {
if (illegalName.length() == 0) {
return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_EMPTY.get();
} else if (illegalName.trim().length() == 0) {
return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_BLANK.get();
} else if (namingPropertyDefinition != null) {
try {
- namingPropertyDefinition.decodeValue(illegalName);
+ namingPropertyDefinition.decodeValue(illegalName, options);
} catch (IllegalPropertyValueStringException e) {
PropertyDefinitionUsageBuilder builder = new PropertyDefinitionUsageBuilder(true);
return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_SYNTAX.get(illegalName,
@@ -82,7 +83,7 @@
* The illegal managed object name.
*/
public IllegalManagedObjectNameException(String illegalName) {
- this(illegalName, null);
+ this(illegalName, null, null);
}
/**
@@ -92,9 +93,12 @@
* The illegal managed object name.
* @param namingPropertyDefinition
* The naming property definition.
+ * @param options
+ * Options to decode property definition values.
*/
- public IllegalManagedObjectNameException(String illegalName, PropertyDefinition<?> namingPropertyDefinition) {
- super(createMessage(illegalName, namingPropertyDefinition));
+ public IllegalManagedObjectNameException(String illegalName, PropertyDefinition<?> namingPropertyDefinition,
+ PropertyDefinitionsOptions options) {
+ super(createMessage(illegalName, namingPropertyDefinition, options));
this.illegalName = illegalName;
this.namingPropertyDefinition = namingPropertyDefinition;
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPDriver.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPDriver.java
index 3814328..1a4e9e6 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPDriver.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPDriver.java
@@ -60,6 +60,7 @@
import org.opends.server.admin.ManagedObjectPath;
import org.opends.server.admin.PropertyDefinition;
import org.opends.server.admin.PropertyDefinitionVisitor;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.PropertyException;
import org.opends.server.admin.PropertyIsMandatoryException;
import org.opends.server.admin.PropertyIsSingleValuedException;
@@ -85,6 +86,8 @@
*/
private static final class ValueDecoder extends PropertyDefinitionVisitor<Object, String> {
+ private final PropertyDefinitionsOptions options;
+
/**
* Decodes the provided property LDAP value.
*
@@ -94,19 +97,21 @@
* The property definition.
* @param value
* The LDAP string representation.
+ * @param options
+ * Decoding options for property definitions.
* @return Returns the decoded LDAP value.
* @throws IllegalPropertyValueStringException
* If the property value could not be decoded because it was
* invalid.
*/
- public static <P> P decode(PropertyDefinition<P> pd, Object value) {
+ public static <P> P decode(PropertyDefinition<P> pd, Object value, PropertyDefinitionsOptions options) {
String s = String.valueOf(value);
- return pd.castValue(pd.accept(new ValueDecoder(), s));
+ return pd.castValue(pd.accept(new ValueDecoder(options), s));
}
// Prevent instantiation.
- private ValueDecoder() {
- // No implementation required.
+ private ValueDecoder(PropertyDefinitionsOptions options) {
+ this.options = options;
}
/**
@@ -131,15 +136,13 @@
@Override
public <T> Object visitUnknown(PropertyDefinition<T> d, String p) {
// By default the property definition's decoder will do.
- return d.decodeValue(p);
+ return d.decodeValue(p, options);
}
}
- // The LDAP connection.
- private final LDAPConnection connection;
+ private LDAPManagementContext context;
- // The LDAP management context.
- private final LDAPManagementContext context;
+ private final LDAPConnection connection;
// The LDAP profile which should be used to construct LDAP
// requests and decode LDAP responses.
@@ -149,19 +152,23 @@
* Creates a new LDAP driver using the specified LDAP connection and
* profile.
*
- * @param context
- * The LDAP management context.
* @param connection
* The LDAP connection.
* @param profile
* The LDAP profile.
+ * @param propertyDefOptions
+ * Options used to validate property definitions values
*/
- public LDAPDriver(LDAPManagementContext context, LDAPConnection connection, LDAPProfile profile) {
- this.context = context;
+ public LDAPDriver(LDAPConnection connection, LDAPProfile profile, PropertyDefinitionsOptions propertyDefOptions) {
+ super(propertyDefOptions);
this.connection = connection;
this.profile = profile;
}
+ void setManagementContext(LDAPManagementContext context) {
+ this.context = context;
+ }
+
/**
* {@inheritDoc}
*/
@@ -261,9 +268,10 @@
// Decode the values.
SortedSet<P> values = new TreeSet<P>(propertyDef);
+ PropertyDefinitionsOptions options = context.getPropertyDefOptions();
if (attribute != null) {
for (ByteString byteValue : attribute) {
- P value = ValueDecoder.decode(propertyDef, byteValue);
+ P value = ValueDecoder.decode(propertyDef, byteValue, options);
values.add(value);
}
}
@@ -485,9 +493,10 @@
// Get the property's active values.
SortedSet<P> activeValues = new TreeSet<P>(propertyDef);
+ PropertyDefinitionsOptions options = context.getPropertyDefOptions();
if (attribute != null) {
for (ByteString byteValue : attribute) {
- P value = ValueDecoder.decode(propertyDef, byteValue);
+ P value = ValueDecoder.decode(propertyDef, byteValue, options);
activeValues.add(value);
}
}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagedObject.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagedObject.java
index f785f2e..d58533d 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagedObject.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagedObject.java
@@ -126,7 +126,8 @@
LDAPManagedObject(LDAPDriver driver, ManagedObjectDefinition<T, ? extends Configuration> d,
ManagedObjectPath<T, ? extends Configuration> path, PropertySet properties, boolean existsOnServer,
PropertyDefinition<?> namingPropertyDefinition) {
- super(d, path, properties, existsOnServer, namingPropertyDefinition);
+ super(d, path, properties, existsOnServer, namingPropertyDefinition,
+ driver.getManagementContext().getPropertyDefOptions());
this.driver = driver;
}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagementContext.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagementContext.java
index 8ddeedd..348d7e9 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagementContext.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/ldap/LDAPManagementContext.java
@@ -27,9 +27,9 @@
package org.opends.server.admin.client.ldap;
import org.opends.server.admin.LDAPProfile;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.client.spi.Driver;
-
import org.forgerock.util.Reject;
/**
@@ -42,26 +42,46 @@
*
* @param connection
* The LDAP connection.
+ * @param profile
+ * The LDAP profile.
+ * @param options
+ * Options to decode values of property definitions.
* @return Returns the new management context.
*/
- public static ManagementContext createFromContext(LDAPConnection connection) {
- Reject.ifNull(connection);
- return new LDAPManagementContext(connection, LDAPProfile.getInstance());
+ public static ManagementContext createFromContext(LDAPConnection connection, LDAPProfile profile,
+ PropertyDefinitionsOptions options) {
+ Reject.ifNull(connection, profile, options);
+ LDAPDriver driver = new LDAPDriver(connection, profile, options);
+ LDAPManagementContext context = new LDAPManagementContext(driver, options);
+ driver.setManagementContext(context);
+ return context;
}
- // The LDAP management context driver.
+ /** The LDAP management context driver. */
private final LDAPDriver driver;
- // Private constructor.
- private LDAPManagementContext(LDAPConnection connection, LDAPProfile profile) {
- this.driver = new LDAPDriver(this, connection, profile);
+ /** Options to validate and decode values of property definitions. */
+ private final PropertyDefinitionsOptions options;
+
+ /** Private constructor. */
+ private LDAPManagementContext(LDAPDriver driver, PropertyDefinitionsOptions options) {
+ this.driver = driver;
+ this.options = options;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
protected Driver getDriver() {
return driver;
}
+
+ /**
+ * Returns the property definitions options.
+ *
+ * @return the options to validate and decode values of property
+ * definitions.
+ */
+ protected PropertyDefinitionsOptions getPropertyDefOptions() {
+ return options;
+ }
}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/AbstractManagedObject.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/AbstractManagedObject.java
index 03cac45..3adbbc0 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/AbstractManagedObject.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/AbstractManagedObject.java
@@ -50,6 +50,7 @@
import org.opends.server.admin.ManagedObjectPath;
import org.opends.server.admin.OptionalRelationDefinition;
import org.opends.server.admin.PropertyDefinition;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.PropertyIsMandatoryException;
import org.opends.server.admin.PropertyIsReadOnlyException;
import org.opends.server.admin.PropertyOption;
@@ -228,6 +229,9 @@
// The managed object's properties.
private final PropertySet properties;
+ /** Decoding options for property definitions values. */
+ private final PropertyDefinitionsOptions propertyDefOptions;
+
/**
* Creates a new abstract managed object.
*
@@ -243,15 +247,17 @@
* committed).
* @param namingPropertyDefinition
* Optional naming property definition.
+ * @param propertyDefOptions TODO
*/
protected AbstractManagedObject(ManagedObjectDefinition<T, ? extends Configuration> d,
ManagedObjectPath<T, ? extends Configuration> path, PropertySet properties, boolean existsOnServer,
- PropertyDefinition<?> namingPropertyDefinition) {
+ PropertyDefinition<?> namingPropertyDefinition, PropertyDefinitionsOptions propertyDefOptions) {
this.definition = d;
this.path = path;
this.properties = properties;
this.existsOnServer = existsOnServer;
this.namingPropertyDefinition = namingPropertyDefinition;
+ this.propertyDefOptions = propertyDefOptions;
}
/**
@@ -346,9 +352,9 @@
PropertyDefinition<?> pd = r.getNamingPropertyDefinition();
if (pd != null) {
try {
- pd.decodeValue(name);
+ pd.decodeValue(name, propertyDefOptions);
} catch (IllegalPropertyValueStringException e) {
- throw new IllegalManagedObjectNameException(name, pd);
+ throw new IllegalManagedObjectNameException(name, pd, propertyDefOptions);
}
}
@@ -664,7 +670,7 @@
throw new PropertyIsReadOnlyException(pd);
}
- properties.setPropertyValues(pd, values);
+ properties.setPropertyValues(pd, values, propertyDefOptions);
// If this is a naming property then update the name.
if (pd.equals(namingPropertyDefinition)) {
@@ -809,8 +815,9 @@
// Set the naming property if there is one.
if (namingPropertyDefinition != null) {
- P value = namingPropertyDefinition.decodeValue(name);
- childProperties.setPropertyValues(namingPropertyDefinition, Collections.singleton(value));
+ P value = namingPropertyDefinition.decodeValue(name, propertyDefOptions);
+ childProperties.setPropertyValues(namingPropertyDefinition, Collections.singleton(value),
+ propertyDefOptions);
}
return newInstance(d, p, childProperties, false, namingPropertyDefinition);
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/Driver.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/Driver.java
index ecae3a8..40a4574 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/Driver.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/Driver.java
@@ -51,6 +51,7 @@
import org.opends.server.admin.ManagedObjectPath;
import org.opends.server.admin.OptionalRelationDefinition;
import org.opends.server.admin.PropertyDefinition;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.PropertyException;
import org.opends.server.admin.PropertyIsSingleValuedException;
import org.opends.server.admin.PropertyNotFoundException;
@@ -136,7 +137,7 @@
for (String stringValue : stringValues) {
try {
- values.add(nextProperty.decodeValue(stringValue));
+ values.add(nextProperty.decodeValue(stringValue, propertyDefOptions));
} catch (IllegalPropertyValueStringException e) {
exception = new DefaultBehaviorException(nextProperty, e);
break;
@@ -226,7 +227,7 @@
Collection<T> tmp = find(target, pd2);
Collection<T> values = new ArrayList<T>(tmp.size());
for (T value : tmp) {
- pd1.validateValue(value);
+ pd1.validateValue(value, propertyDefOptions);
values.add(value);
}
return values;
@@ -254,11 +255,16 @@
}
};
+ private final PropertyDefinitionsOptions propertyDefOptions;
+
/**
- * Creates a new abstract management context.
+ * Creates a new abstract driver.
+ *
+ * @param propertyDefOptions
+ * Decoding options for property definitions values.
*/
- protected Driver() {
- // No implementation required.
+ protected Driver(PropertyDefinitionsOptions propertyDefOptions) {
+ this.propertyDefOptions = propertyDefOptions;
}
/**
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/PropertySet.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/PropertySet.java
index 7795959..cc506eb 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/PropertySet.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/client/spi/PropertySet.java
@@ -35,6 +35,7 @@
import org.opends.server.admin.IllegalPropertyValueException;
import org.opends.server.admin.PropertyDefinition;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.PropertyIsMandatoryException;
import org.opends.server.admin.PropertyIsSingleValuedException;
import org.opends.server.admin.PropertyOption;
@@ -282,6 +283,8 @@
* property (an empty set indicates that the property should be
* reset to its default behavior). The set will not be referenced
* by this managed object.
+ * @param options
+ * Options to validate property definitions values.
* @throws IllegalPropertyValueException
* If a new pending value is deemed to be invalid according to
* the property definition.
@@ -294,7 +297,8 @@
* If the specified property definition is not associated with
* this managed object.
*/
- <T> void setPropertyValues(PropertyDefinition<T> d, Collection<T> values) {
+ <T> void setPropertyValues(PropertyDefinition<T> d, Collection<T> values,
+ PropertyDefinitionsOptions options) {
MyProperty<T> property = (MyProperty<T>) getProperty(d);
if (values.size() > 1 && !d.hasOption(PropertyOption.MULTI_VALUED)) {
@@ -314,7 +318,7 @@
throw new NullPointerException();
}
- d.validateValue(e);
+ d.validateValue(e, options);
}
// Update the property.
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/condition/ContainsCondition.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/condition/ContainsCondition.java
index cef06e9..d5d0b18 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/condition/ContainsCondition.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/condition/ContainsCondition.java
@@ -31,6 +31,7 @@
import org.forgerock.util.Reject;
import org.opends.server.admin.AbstractManagedObjectDefinition;
import org.opends.server.admin.PropertyDefinition;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.client.ManagedObject;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.server.ServerManagedObject;
@@ -150,7 +151,7 @@
// Creates the new private implementation.
private <T> void buildImpl(PropertyDefinition<T> pd) {
- T value = pd.decodeValue(propertyStringValue);
+ T value = pd.decodeValue(propertyStringValue, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
this.impl = new Impl<T>(pd, value);
}
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/doc/ConfigGuideGeneration.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/doc/ConfigGuideGeneration.java
index 7a27ad2..14f368b 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/doc/ConfigGuideGeneration.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/doc/ConfigGuideGeneration.java
@@ -203,10 +203,6 @@
e.printStackTrace();
System.exit(1);
}
- // Switch off class name validation in client.
- ClassPropertyDefinition.setAllowClassValidation(false);
- // Switch off attribute type name validation in client.
- AttributeTypePropertyDefinition.setCheckSchema(false);
// Build a sorted list of top managed objects
TopCfgDefn topCfg = TopCfgDefn.getInstance();
diff --git a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/server/ServerManagementContext.java b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/server/ServerManagementContext.java
index 29e4164..010371b 100644
--- a/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/server/ServerManagementContext.java
+++ b/opendj-sdk/opendj-admin/src/main/java/org/opends/server/admin/server/ServerManagementContext.java
@@ -59,6 +59,7 @@
import org.opends.server.admin.ManagedObjectPath;
import org.opends.server.admin.PropertyDefinition;
import org.opends.server.admin.PropertyDefinitionVisitor;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.PropertyException;
import org.opends.server.admin.PropertyIsMandatoryException;
import org.opends.server.admin.PropertyIsSingleValuedException;
@@ -146,7 +147,7 @@
for (String stringValue : stringValues) {
try {
- values.add(nextProperty.decodeValue(stringValue));
+ values.add(nextProperty.decodeValue(stringValue, propertyDefOptions));
} catch (IllegalPropertyValueStringException e) {
exception = new DefaultBehaviorException(nextProperty, e);
break;
@@ -237,7 +238,7 @@
if (attributeValues.size() > 0) {
Collection<T> pvalues = new ArrayList<T>();
for (String value : attributeValues) {
- pvalues.add(ValueDecoder.decode(propDef1, value));
+ pvalues.add(ValueDecoder.decode(propDef1, value, propertyDefOptions));
}
return pvalues;
} else {
@@ -245,7 +246,7 @@
Collection<T> tmp = find(target, propDef2);
Collection<T> pvalues = new ArrayList<T>(tmp.size());
for (T value : tmp) {
- propDef1.validateValue(value);
+ propDef1.validateValue(value, propertyDefOptions);
pvalues.add(value);
}
return pvalues;
@@ -300,6 +301,8 @@
*/
private static final class ValueDecoder extends PropertyDefinitionVisitor<Object, String> {
+ private final PropertyDefinitionsOptions options;
+
/**
* Decodes the provided property LDAP value.
*
@@ -309,18 +312,21 @@
* The property definition.
* @param value
* The LDAP string representation.
+ * @param options
+ * Options to decode property definitions values.
* @return Returns the decoded LDAP value.
* @throws IllegalPropertyValueStringException
* If the property value could not be decoded because it was
* invalid.
*/
- public static <P> P decode(PropertyDefinition<P> propertyDef, String value) {
- return propertyDef.castValue(propertyDef.accept(new ValueDecoder(), value));
+ public static <P> P decode(PropertyDefinition<P> propertyDef, String value,
+ PropertyDefinitionsOptions options) {
+ return propertyDef.castValue(propertyDef.accept(new ValueDecoder(options), value));
}
// Prevent instantiation.
- private ValueDecoder() {
- // No implementation required.
+ private ValueDecoder(PropertyDefinitionsOptions options) {
+ this.options = options;
}
/**
@@ -345,7 +351,7 @@
@Override
public <T> Object visitUnknown(PropertyDefinition<T> d, String p) {
// By default the property definition's decoder will do.
- return d.decodeValue(p);
+ return d.decodeValue(p, options);
}
}
@@ -360,13 +366,23 @@
private final ConfigurationRepository configRepository;
/**
+ * Options to use when decoding and validating values of property
+ * definitions.
+ */
+ private final PropertyDefinitionsOptions propertyDefOptions;
+
+ /**
* Creates a context from the provided configuration repository.
*
* @param repository
* The repository of configuration entries.
+ * @param propertyDefOptions
+ * Options to use when decoding and validating values
+ * of property definitions.
*/
- ServerManagementContext(ConfigurationRepository repository) {
+ ServerManagementContext(ConfigurationRepository repository, PropertyDefinitionsOptions propertyDefOptions) {
configRepository = repository;
+ this.propertyDefOptions = propertyDefOptions;
}
/**
@@ -530,8 +546,8 @@
* @return the root configuration server managed object
*/
public ServerManagedObject<RootCfg> getRootConfigurationManagedObject() {
- // Use lazy initialisation because it needs a reference to this server
- // context.
+ // Use lazy initialisation
+ // because it needs a reference to this server context.
ServerManagedObject<RootCfg> rootObject = root;
if (rootObject == null) {
synchronized (this) {
@@ -711,7 +727,7 @@
// The property has values defined for it.
for (String value : attributeValues) {
try {
- pvalues.add(ValueDecoder.decode(propertyDef, value));
+ pvalues.add(ValueDecoder.decode(propertyDef, value, propertyDefOptions));
} catch (IllegalPropertyValueStringException e) {
exception = e;
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigTestCase.java b/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigTestCase.java
index 92a32e4..d8a4837 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigTestCase.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigTestCase.java
@@ -26,7 +26,6 @@
package org.forgerock.opendj.config;
import org.forgerock.opendj.ldap.SdkTestCase;
-import org.opends.server.admin.ClassPropertyDefinition;
import org.testng.annotations.Test;
/**
@@ -34,12 +33,5 @@
*/
@Test(groups = { "precommit", "config" })
public abstract class ConfigTestCase extends SdkTestCase {
-
- protected void disableClassValidationForProperties() {
- ClassPropertyDefinition.setAllowClassValidation(false);
- }
-
- protected void enableClassValidationForProperties() {
- ClassPropertyDefinition.setAllowClassValidation(true);
- }
+ // no implementation
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java b/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java
index a2785ed..becb591 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java
@@ -42,6 +42,7 @@
import org.opends.server.admin.DefinedDefaultBehaviorProvider;
import org.opends.server.admin.ManagedObjectDefinition;
import org.opends.server.admin.PropertyDefinition;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.PropertyOption;
import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider;
import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
@@ -56,11 +57,8 @@
* Example:
*
* <pre>
- * {
- * @code
- * LDAPConnectionHandlerCfg mockCfg = mockCfg(LDAPConnectionHandlerCfg.class);
- * assertThat(mockCfg.getMaxRequestSize()).isEqualTo(5 * 1000 * 1000);
- * }
+ * LDAPConnectionHandlerCfg mockCfg = mockCfg(LDAPConnectionHandlerCfg.class);
+ * assertThat(mockCfg.getMaxRequestSize()).isEqualTo(5 * 1000 * 1000);
* </pre>
*/
public final class ConfigurationMock {
@@ -146,7 +144,8 @@
*/
@SuppressWarnings("unchecked")
private <T> Object getDefaultValue(ManagedObjectDefinition<?, ?> definition,
- Method getPropertyDefMethod, Class<T> propertyReturnClass) throws Exception {
+ Method getPropertyDefMethod, @SuppressWarnings("unused") Class<T> propertyReturnClass)
+ throws Exception {
PropertyDefinition<T> propertyDefinition = (PropertyDefinition<T>) getPropertyDefMethod.invoke(definition);
DefaultBehaviorProvider<T> defaultBehaviorProvider = (DefaultBehaviorProvider<T>) propertyDefinition
.getClass().getMethod("getDefaultBehaviorProvider").invoke(propertyDefinition);
@@ -194,7 +193,7 @@
public Collection<T> visitDefined(DefinedDefaultBehaviorProvider<T> provider, Void p) {
SortedSet<T> values = new TreeSet<T>();
for (String stringValue : provider.getDefaultValues()) {
- values.add(propertyDef.decodeValue(stringValue));
+ values.add(propertyDef.decodeValue(stringValue, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS));
}
return values;
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java b/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java
index c239b53..a6f1983 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/forgerock/opendj/config/ConfigurationMockTest.java
@@ -34,9 +34,6 @@
import org.forgerock.opendj.admin.server.GoverningStructureRuleVirtualAttributeCfg;
import org.forgerock.opendj.admin.server.LDAPConnectionHandlerCfg;
import org.forgerock.opendj.ldap.schema.Schema;
-import org.opends.server.admin.AttributeTypePropertyDefinition;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
@@ -45,16 +42,6 @@
@SuppressWarnings("javadoc")
public class ConfigurationMockTest extends ConfigTestCase {
- @BeforeClass
- void setup() {
- disableClassValidationForProperties();
- }
-
- @AfterClass
- void cleanup() {
- enableClassValidationForProperties();
- }
-
@Test
public void testPropertyWithStringReturnValue() {
GoverningStructureRuleVirtualAttributeCfg mock = mockCfg(GoverningStructureRuleVirtualAttributeCfg.class);
@@ -76,7 +63,6 @@
@Test
public void testPropertyWithAttributeTypeReturnValue() throws Exception {
- AttributeTypePropertyDefinition.setCheckSchema(false); // attribute type is not in default schema
CollectiveAttributeSubentriesVirtualAttributeCfg mock =
mockCfg(CollectiveAttributeSubentriesVirtualAttributeCfg.class);
assertThat(mock.getAttributeType()).isEqualTo(
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java
index 322bd30..27c136d2 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AbstractManagedObjectDefinitionTest.java
@@ -64,7 +64,6 @@
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AdminTestCase.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AdminTestCase.java
index 22e8b91..3a138a0 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AdminTestCase.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AdminTestCase.java
@@ -54,12 +54,12 @@
return configRepository;
}
- /** Returns the name used for this entry (the value of the cn attribute) */
+ /** Returns the name used for the provided entry (the value of the cn attribute) */
protected final String entryName(final Entry entry) {
return entry.getName().rdn().getFirstAVA().getAttributeValue().toString();
}
- /** Gets the named parent configuration corresponding to the entry */
+ /** Gets the named parent configuration corresponding to the provided entry */
protected final TestParentCfg getParentCfg(final Entry entry, final ServerManagementContext serverContext)
throws Exception {
return getParentCfg(entryName(entry), serverContext);
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AggregationPropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AggregationPropertyDefinitionTest.java
index c8237a5..606831d 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AggregationPropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AggregationPropertyDefinitionTest.java
@@ -39,7 +39,6 @@
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AttributeTypePropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AttributeTypePropertyDefinitionTest.java
index c058566..ba5bd10 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AttributeTypePropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/AttributeTypePropertyDefinitionTest.java
@@ -31,23 +31,16 @@
import org.forgerock.opendj.config.ConfigTestCase;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.Schema;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class AttributeTypePropertyDefinitionTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() throws Exception {
- disableClassValidationForProperties();
- }
-
@Test
public void testValidateValue() {
- AttributeTypePropertyDefinition.setCheckSchema(true);
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
- propertyDef.validateValue(Schema.getDefaultSchema().getAttributeType("cn"));
+ propertyDef.validateValue(Schema.getDefaultSchema().getAttributeType("cn"), new PropertyDefinitionsOptions());
}
@DataProvider(name = "valueLegalData")
@@ -57,17 +50,15 @@
@Test(dataProvider = "valueLegalData")
public void testDecodeValue(String value) {
- AttributeTypePropertyDefinition.setCheckSchema(true);
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
AttributeType expected = Schema.getDefaultSchema().getAttributeType(value);
- assertEquals(propertyDef.decodeValue(value), expected);
+ assertEquals(propertyDef.decodeValue(value, new PropertyDefinitionsOptions()), expected);
}
@Test(dataProvider = "valueLegalData")
public void testEncodeValue(String value) {
- AttributeTypePropertyDefinition.setCheckSchema(true);
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
- assertEquals(propertyDef.encodeValue(propertyDef.decodeValue(value)), value);
+ assertEquals(propertyDef.encodeValue(propertyDef.decodeValue(value, new PropertyDefinitionsOptions())), value);
}
@DataProvider(name = "valueIllegalData")
@@ -77,21 +68,15 @@
@Test(dataProvider = "valueIllegalData", expectedExceptions = { IllegalPropertyValueStringException.class })
public void testDecodeValueIllegal(String value) {
- AttributeTypePropertyDefinition.setCheckSchema(true);
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
- propertyDef.decodeValue(value);
+ propertyDef.decodeValue(value, new PropertyDefinitionsOptions());
}
@Test(dataProvider = "valueIllegalData")
public void testDecodeValueIllegalNoSchemaCheck(String value) {
- AttributeTypePropertyDefinition.setCheckSchema(false);
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
- AttributeType type = propertyDef.decodeValue(value);
+ AttributeType type = propertyDef.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
assertEquals(type.getNameOrOID(), value);
-
- // Make sure to turn schema checking back on
- // so that other tests which depend on it don't fail.
- AttributeTypePropertyDefinition.setCheckSchema(true);
}
// Create a new definition.
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/BooleanPropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/BooleanPropertyDefinitionTest.java
index 7ad081b..30cf14c 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/BooleanPropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/BooleanPropertyDefinitionTest.java
@@ -40,20 +40,19 @@
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
builder = BooleanPropertyDefinition.createBuilder(RootCfgDefn.getInstance(), "test-property");
}
@Test
public void testValidateValue() {
BooleanPropertyDefinition def = createPropertyDefinition();
- def.validateValue(Boolean.TRUE);
+ def.validateValue(Boolean.TRUE, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(expectedExceptions = NullPointerException.class)
public void testValidateValueIllegal() {
BooleanPropertyDefinition def = createPropertyDefinition();
- def.validateValue(null);
+ def.validateValue(null, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "decodeValueData")
@@ -64,7 +63,7 @@
@Test(dataProvider = "decodeValueData")
public void testDecodeValue(String value, Boolean expected) {
BooleanPropertyDefinition def = createPropertyDefinition();
- assertEquals(def.decodeValue(value), expected);
+ assertEquals(def.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS), expected);
}
@DataProvider(name = "decodeValueDataIllegal")
@@ -76,7 +75,7 @@
IllegalPropertyValueStringException.class })
public void testDecodeValueIllegal(String value) {
BooleanPropertyDefinition def = createPropertyDefinition();
- def.decodeValue(value);
+ def.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
private BooleanPropertyDefinition createPropertyDefinition() {
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ClassPropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ClassPropertyDefinitionTest.java
index 68e1958..e9fab8c 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ClassPropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ClassPropertyDefinitionTest.java
@@ -34,18 +34,12 @@
import org.forgerock.opendj.admin.meta.RootCfgDefn;
import org.forgerock.opendj.config.ConfigTestCase;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class ClassPropertyDefinitionTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() throws Exception {
- disableClassValidationForProperties();
- }
-
// Dummy class used in tests.
public static final class Dummy {
public class X {
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DNPropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DNPropertyDefinitionTest.java
index e392edb..2a23773 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DNPropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DNPropertyDefinitionTest.java
@@ -32,18 +32,12 @@
import org.forgerock.opendj.config.ConfigTestCase;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.DirectoryException;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class DNPropertyDefinitionTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() throws Exception {
- disableClassValidationForProperties();
- }
-
@DataProvider(name = "baseDN")
public Object[][] createBuilderSetBaseDN() {
return new Object[][] {
@@ -102,7 +96,7 @@
"test-property");
localBuilder.setBaseDN(baseDN);
DNPropertyDefinition propertyDef = localBuilder.getInstance();
- propertyDef.validateValue(DN.valueOf(valueToValidate));
+ propertyDef.validateValue(DN.valueOf(valueToValidate), PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(dataProvider = "illegalValues", expectedExceptions = IllegalPropertyValueException.class)
@@ -111,7 +105,7 @@
"test-property");
localBuilder.setBaseDN(baseDN);
DNPropertyDefinition propertyDef = localBuilder.getInstance();
- propertyDef.validateValue(DN.valueOf(valueToValidate));
+ propertyDef.validateValue(DN.valueOf(valueToValidate), PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(dataProvider = "legalValues")
@@ -120,7 +114,7 @@
"test-property");
localBuilder.setBaseDN(baseDN);
DNPropertyDefinition propertyDef = localBuilder.getInstance();
- propertyDef.decodeValue(valueToValidate);
+ propertyDef.decodeValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(dataProvider = "illegalValues", expectedExceptions = IllegalPropertyValueStringException.class)
@@ -129,6 +123,6 @@
"test-property");
localBuilder.setBaseDN(baseDN);
DNPropertyDefinition propertyDef = localBuilder.getInstance();
- propertyDef.decodeValue(valueToValidate);
+ propertyDef.decodeValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DurationPropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DurationPropertyDefinitionTest.java
index 1196100..398b597 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DurationPropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/DurationPropertyDefinitionTest.java
@@ -31,18 +31,12 @@
import org.forgerock.opendj.admin.meta.RootCfgDefn;
import org.forgerock.opendj.config.ConfigTestCase;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class DurationPropertyDefinitionTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() throws Exception {
- disableClassValidationForProperties();
- }
-
@Test
public void testCreateBuilder() {
DurationPropertyDefinition.Builder builder = createTestBuilder();
@@ -130,7 +124,7 @@
DurationPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(true);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.decodeValue("unlimited");
+ def.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(expectedExceptions = IllegalPropertyValueStringException.class)
@@ -138,7 +132,7 @@
DurationPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.decodeValue("unlimited");
+ def.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(expectedExceptions = IllegalPropertyValueException.class)
@@ -146,7 +140,7 @@
DurationPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.validateValue(-1L);
+ def.validateValue(-1L, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "validateValueData")
@@ -169,7 +163,7 @@
builder.setUpperLimit(higherLimitInMillis);
builder.setAllowUnlimited(isAllowUnlimited);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.validateValue(valueInSeconds);
+ def.validateValue(valueInSeconds, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "illegalValidateValueData")
@@ -191,7 +185,7 @@
builder.setUpperLimit(highLimitInMillis);
builder.setAllowUnlimited(isAllowUnlimited);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.validateValue(valueInSeconds);
+ def.validateValue(valueInSeconds, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "encodeValueData")
@@ -310,7 +304,8 @@
builder.setMaximumUnit(DurationUnit.DAYS);
DurationPropertyDefinition def = buildTestDefinition(builder);
- assertThat(def.decodeValue(valueToDecode)).isEqualTo(expectedValue);
+ assertThat(def.decodeValue(valueToDecode, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS)).
+ isEqualTo(expectedValue);
}
@DataProvider(name = "decodeValueDataIllegal")
@@ -343,7 +338,7 @@
builder.setLowerLimit(5L);
builder.setUpperLimit(10L);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.decodeValue(valueToDecode);
+ def.decodeValue(valueToDecode, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
private DurationPropertyDefinition.Builder createTestBuilder() {
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/EnumPropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/EnumPropertyDefinitionTest.java
index 11c433d..e96bff9 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/EnumPropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/EnumPropertyDefinitionTest.java
@@ -45,7 +45,6 @@
@BeforeClass
public void setUp() {
- disableClassValidationForProperties();
builder = EnumPropertyDefinition.createBuilder(RootCfgDefn.getInstance(), "test-property");
builder.setEnumClass(TestEnum.class);
}
@@ -95,7 +94,7 @@
@Test(dataProvider = "decodeValueData")
public void testDecodeValue(String value, TestEnum expectedValue) {
EnumPropertyDefinition<?> def = builder.getInstance();
- assertEquals(def.decodeValue(value), expectedValue);
+ assertEquals(def.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS), expectedValue);
}
/**
@@ -118,7 +117,7 @@
IllegalPropertyValueStringException.class })
public void testDecodeValueIllegalData(String value) {
EnumPropertyDefinition<?> def = builder.getInstance();
- def.decodeValue(value);
+ def.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
/**
@@ -136,7 +135,7 @@
@Test
public void testValidateValue() {
EnumPropertyDefinition<TestEnum> def = builder.getInstance();
- def.validateValue(TestEnum.ONE);
+ def.validateValue(TestEnum.ONE, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/IntegerPropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/IntegerPropertyDefinitionTest.java
index 09de9a5..49ba994 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/IntegerPropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/IntegerPropertyDefinitionTest.java
@@ -29,18 +29,12 @@
import org.forgerock.opendj.admin.meta.RootCfgDefn;
import org.forgerock.opendj.config.ConfigTestCase;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class IntegerPropertyDefinitionTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() {
- disableClassValidationForProperties();
- }
-
@Test
public void testCreateBuilder() {
IntegerPropertyDefinition.Builder builder = createTestBuilder();
@@ -98,7 +92,7 @@
IntegerPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(true);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.decodeValue("unlimited");
+ propertyDef.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(expectedExceptions = IllegalPropertyValueStringException.class)
@@ -106,7 +100,7 @@
IntegerPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.decodeValue("unlimited");
+ propertyDef.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(expectedExceptions = IllegalPropertyValueException.class)
@@ -114,7 +108,7 @@
IntegerPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(-1);
+ propertyDef.validateValue(-1, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "validateValueData")
@@ -134,7 +128,7 @@
builder.setUpperLimit(high);
builder.setAllowUnlimited(allowUnlimited);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(valueToValidate);
+ propertyDef.validateValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "illegalValidateValueData")
@@ -158,7 +152,7 @@
builder.setUpperLimit(high);
builder.setAllowUnlimited(allowUnlimited);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(value);
+ propertyDef.validateValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "encodeValueData")
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/LDAPProfileTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/LDAPProfileTest.java
index 5d2e64c..204bbbb 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/LDAPProfileTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/LDAPProfileTest.java
@@ -31,17 +31,11 @@
import org.forgerock.opendj.admin.meta.GlobalCfgDefn;
import org.forgerock.opendj.config.ConfigTestCase;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class LDAPProfileTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() {
- disableClassValidationForProperties();
- }
-
/** Makes sure the returned list contains "top" */
@Test
public void testGetObjectClasses() {
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectDefinitionI18NResourceTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectDefinitionI18NResourceTest.java
index 66ee14e..15be2ca 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectDefinitionI18NResourceTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectDefinitionI18NResourceTest.java
@@ -41,7 +41,6 @@
@BeforeClass
public void setUp() {
- disableClassValidationForProperties();
definitionI18NResource = ManagedObjectDefinitionI18NResource.getInstanceForProfile("ldap");
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java
index 1efa6e9..86fa17b 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ManagedObjectPathTest.java
@@ -41,17 +41,11 @@
import org.forgerock.opendj.admin.server.LDAPConnectionHandlerCfg;
import org.forgerock.opendj.config.ConfigTestCase;
import org.forgerock.opendj.ldap.DN;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class ManagedObjectPathTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() throws Exception {
- disableClassValidationForProperties();
- }
-
@Test
public void testEmptyPathIsEmpty() {
ManagedObjectPath<?, ?> path = ManagedObjectPath.emptyPath();
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/RelativeInheritedDefaultBehaviorProviderTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/RelativeInheritedDefaultBehaviorProviderTest.java
index 1d82efd..3a1cb21 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/RelativeInheritedDefaultBehaviorProviderTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/RelativeInheritedDefaultBehaviorProviderTest.java
@@ -43,7 +43,6 @@
@BeforeClass
public void setUp() {
- disableClassValidationForProperties();
parentDefinition = TestParentCfgDefn.getInstance();
this.defaultBehaviorProvider = new RelativeInheritedDefaultBehaviorProvider<Boolean>(
parentDefinition,
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java
index 3ff985d..4813675 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/SizePropertyDefinitionTest.java
@@ -29,18 +29,12 @@
import org.forgerock.opendj.admin.meta.RootCfgDefn;
import org.forgerock.opendj.config.ConfigTestCase;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class SizePropertyDefinitionTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() throws Exception {
- disableClassValidationForProperties();
- }
-
@Test
public void testCreateBuilder() {
SizePropertyDefinition.Builder builder = createTestBuilder();
@@ -105,7 +99,7 @@
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(true);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.decodeValue("unlimited");
+ propertyDef.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(expectedExceptions = IllegalPropertyValueStringException.class)
@@ -113,7 +107,7 @@
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.decodeValue("unlimited");
+ propertyDef.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test(expectedExceptions = IllegalPropertyValueException.class)
@@ -121,7 +115,7 @@
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(-1L);
+ propertyDef.validateValue(-1L, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "validateValueData")
@@ -141,7 +135,7 @@
builder.setUpperLimit(high);
builder.setAllowUnlimited(isAllowUnlimited);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(valueToValidate);
+ propertyDef.validateValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "illegalValidateValueData")
@@ -165,7 +159,7 @@
builder.setUpperLimit(high);
builder.setAllowUnlimited(allowUnlimited);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(valueToValidate);
+ propertyDef.validateValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@DataProvider(name = "encodeValueData")
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/StringPropertyDefinitionTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/StringPropertyDefinitionTest.java
index 10105cb..7055ccf 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/StringPropertyDefinitionTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/StringPropertyDefinitionTest.java
@@ -29,47 +29,40 @@
import org.forgerock.opendj.admin.meta.RootCfgDefn;
import org.forgerock.opendj.config.ConfigTestCase;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
public class StringPropertyDefinitionTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() {
- disableClassValidationForProperties();
- }
-
- @Test
public void testValidateValueNoPattern() {
StringPropertyDefinition d = getDefinition(true, null);
- d.validateValue("abc");
+ d.validateValue("abc", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test
public void testValidateValuePatternMatches() {
StringPropertyDefinition d = getDefinition(true, "^[a-z]+$");
- d.validateValue("abc");
+ d.validateValue("abc", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
// TODO : I18N problem
@Test(enabled = false, expectedExceptions = IllegalPropertyValueException.class)
public void testValidateValuePatternDoesNotMatch() {
StringPropertyDefinition d = getDefinition(true, "^[a-z]+$");
- d.validateValue("abc123");
+ d.validateValue("abc123", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
@Test
public void testDecodeValuePatternMatches() {
StringPropertyDefinition d = getDefinition(true, "^[a-z]+$");
- assertEquals(d.decodeValue("abc"), "abc");
+ assertEquals(d.decodeValue("abc", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS), "abc");
}
// TODO : I18N problem
@Test(enabled = false, expectedExceptions = IllegalPropertyValueStringException.class)
public void testDecodeValuePatternDoesNotMatch() {
StringPropertyDefinition d = getDefinition(true, "^[a-z]+$");
- d.decodeValue("abc123");
+ d.decodeValue("abc123", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
// Create a string property definition.
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java
index d42dba3..aaafbfc 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java
@@ -31,7 +31,6 @@
import org.forgerock.opendj.admin.meta.RootCfgDefn;
import org.forgerock.opendj.config.ConfigTestCase;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -39,11 +38,6 @@
@Test(singleThreaded = true)
public class TestTopCfgDefnTest extends ConfigTestCase {
- @BeforeClass
- public void setUp() throws Exception {
- disableClassValidationForProperties();
- }
-
@Test
public void testGetInstance() {
assertNotNull(TopCfgDefn.getInstance());
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ValidateConfigDefinitionsTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ValidateConfigDefinitionsTest.java
index 9505db3..0592071 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ValidateConfigDefinitionsTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/ValidateConfigDefinitionsTest.java
@@ -51,7 +51,6 @@
@BeforeClass
public void setup() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java
index 4f5b61d..9a4d727 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java
@@ -34,6 +34,8 @@
import org.forgerock.opendj.admin.client.RootCfgClient;
import org.opends.server.admin.AdminTestCase;
import org.opends.server.admin.IllegalPropertyValueStringException;
+import org.opends.server.admin.LDAPProfile;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.PropertyException;
import org.opends.server.admin.TestCfg;
import org.opends.server.admin.TestChildCfgClient;
@@ -154,7 +156,6 @@
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
@@ -177,7 +178,8 @@
public void testAggregationEmpty() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 1");
assertSetEquals(child.getAggregationProperty(), new String[0]);
@@ -194,7 +196,8 @@
public void testAggregationSingle() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
@@ -215,7 +218,8 @@
public void testAggregationMultiple() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 3");
assertSetEquals(child.getAggregationProperty(), "LDAPS Connection Handler", "LDAP Connection Handler");
@@ -232,7 +236,8 @@
public void testAggregationBadBaseDN() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
try {
@@ -275,7 +280,8 @@
c.addExpectedAttribute("ds-cfg-rotation-policy",
"cn=LDAP Connection Handler,cn=connection handlers, cn=config");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
child.setMandatoryBooleanProperty(true);
@@ -301,7 +307,8 @@
c.addExpectedModification("ds-cfg-rotation-policy",
"cn=HTTP Connection Handler,cn=connection handlers, cn=config",
"cn=JMX Connection Handler,cn=connection handlers, cn=config");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
child.setAggregationProperty(Arrays.asList("JMX Connection Handler", "HTTP Connection Handler"));
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java
index 2bfddf0..8194638 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/client/ldap/LDAPClientTest.java
@@ -40,8 +40,10 @@
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.opends.server.admin.AdminTestCase;
import org.opends.server.admin.Constraint;
+import org.opends.server.admin.LDAPProfile;
import org.opends.server.admin.ManagedObjectAlreadyExistsException;
import org.opends.server.admin.ManagedObjectNotFoundException;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.TestCfg;
import org.opends.server.admin.TestChildCfgClient;
import org.opends.server.admin.TestChildCfgDefn;
@@ -61,7 +63,7 @@
@Test(singleThreaded = true)
public final class LDAPClientTest extends AdminTestCase {
- // Test LDIF.
+ // @Checkstyle:off
private static final String[] TEST_LDIF = new String[] {
// Base entries.
"dn: cn=config",
@@ -164,6 +166,7 @@
"objectclass: ds-cfg-test-child-dummy", "cn: test child 1", "ds-cfg-enabled: true",
"ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
"ds-cfg-attribute-type: description", "", };
+ // @Checkstyle:on
/**
* Provide valid naming exception to client API exception mappings.
@@ -173,14 +176,14 @@
@DataProvider(name = "createManagedObjectExceptions")
public Object[][] createManagedObjectExceptions() {
return new Object[][] {
- // result code corresponding to exception thrown, expected exception, expected code result
+ // result code corresponding to exception thrown, expected
+ // exception, expected code result
{ ResultCode.PROTOCOL_ERROR, ErrorResultException.class, ResultCode.PROTOCOL_ERROR },
- { ResultCode.UNAVAILABLE , ErrorResultException.class, ResultCode.UNAVAILABLE },
+ { ResultCode.UNAVAILABLE, ErrorResultException.class, ResultCode.UNAVAILABLE },
{ ResultCode.ENTRY_ALREADY_EXISTS, ManagedObjectAlreadyExistsException.class, null },
{ ResultCode.INSUFFICIENT_ACCESS_RIGHTS, ErrorResultException.class,
- ResultCode.INSUFFICIENT_ACCESS_RIGHTS },
- { ResultCode.UNWILLING_TO_PERFORM, OperationRejectedException.class, null }
- };
+ ResultCode.INSUFFICIENT_ACCESS_RIGHTS },
+ { ResultCode.UNWILLING_TO_PERFORM, OperationRejectedException.class, null } };
}
/**
@@ -191,24 +194,21 @@
@DataProvider(name = "getManagedObjectExceptions")
public Object[][] getManagedObjectExceptions() {
return new Object[][] {
- // result code corresponding to exception thrown, expected exception, expected code result
+ // result code corresponding to exception thrown, expected
+ // exception, expected code result
{ ResultCode.PROTOCOL_ERROR, ErrorResultException.class, ResultCode.PROTOCOL_ERROR },
{ ResultCode.UNAVAILABLE, ErrorResultException.class, ResultCode.UNAVAILABLE },
{ ResultCode.NO_SUCH_OBJECT, ManagedObjectNotFoundException.class, null },
{ ResultCode.INSUFFICIENT_ACCESS_RIGHTS, ErrorResultException.class,
- ResultCode.INSUFFICIENT_ACCESS_RIGHTS },
- { ResultCode.UNWILLING_TO_PERFORM, ErrorResultException.class,
- ResultCode.UNWILLING_TO_PERFORM }
- };
+ ResultCode.INSUFFICIENT_ACCESS_RIGHTS },
+ { ResultCode.UNWILLING_TO_PERFORM, ErrorResultException.class, ResultCode.UNWILLING_TO_PERFORM } };
}
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
-
@AfterClass
public void tearDown() {
TestCfg.cleanup();
@@ -222,17 +222,20 @@
*/
@Test
public void testCreateChildManagedObject() throws Exception {
- CreateEntryMockLDAPConnection c = new CreateEntryMockLDAPConnection(
+ CreateEntryMockLDAPConnection c =
+ new CreateEntryMockLDAPConnection(
"cn=test child new,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedAttribute("cn", "test child new");
c.addExpectedAttribute("objectClass", "top", "ds-cfg-test-child-dummy");
c.addExpectedAttribute("ds-cfg-enabled", "true");
c.addExpectedAttribute("ds-cfg-java-class",
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
child.setMandatoryBooleanProperty(true);
@@ -248,7 +251,7 @@
*/
@Test(dataProvider = "createManagedObjectExceptions")
public void testCreateManagedObjectException(final ResultCode resultCodeOfThrownException,
- Class<? extends Exception> expectedExceptionClass, ResultCode expectedCode) {
+ Class<? extends Exception> expectedExceptionClass, ResultCode expectedCode) {
MockLDAPConnection conn = new MockLDAPConnection() {
@Override
@@ -258,7 +261,9 @@
};
conn.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(conn);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
try {
TestParentCfgClient parent = createTestParent(ctx, "test parent new");
parent.setMandatoryBooleanProperty(true);
@@ -282,17 +287,18 @@
*/
@Test
public void testCreateTopLevelManagedObject() throws Exception {
- CreateEntryMockLDAPConnection c = new CreateEntryMockLDAPConnection(
- "cn=test parent new,cn=test parents,cn=config");
+ CreateEntryMockLDAPConnection c =
+ new CreateEntryMockLDAPConnection("cn=test parent new,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedAttribute("cn", "test parent new");
c.addExpectedAttribute("objectClass", "top", "ds-cfg-test-parent-dummy");
c.addExpectedAttribute("ds-cfg-enabled", "true");
- c.addExpectedAttribute("ds-cfg-java-class",
- "org.opends.server.extensions.SomeVirtualAttributeProvider");
+ c.addExpectedAttribute("ds-cfg-java-class", "org.opends.server.extensions.SomeVirtualAttributeProvider");
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = createTestParent(ctx, "test parent new");
parent.setMandatoryBooleanProperty(true);
parent.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
@@ -310,18 +316,20 @@
public void testGetChildManagedObject() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 3");
Assert.assertEquals(child.isMandatoryBooleanProperty(), Boolean.TRUE);
Assert.assertEquals(child.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
+ DirectoryServer.getAttributeType("description"));
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), "dc=default value c3v1,dc=com",
- "dc=default value c3v2,dc=com");
+ "dc=default value c3v2,dc=com");
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), "dc=default value c3v3,dc=com",
- "dc=default value c3v4,dc=com");
+ "dc=default value c3v4,dc=com");
}
/**
@@ -334,18 +342,20 @@
public void testGetChildManagedObjectDefault() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 1");
Assert.assertEquals(child.isMandatoryBooleanProperty(), Boolean.TRUE);
Assert.assertEquals(child.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
+ DirectoryServer.getAttributeType("description"));
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), "dc=domain1,dc=com", "dc=domain2,dc=com",
- "dc=domain3,dc=com");
+ "dc=domain3,dc=com");
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), "dc=domain1,dc=com", "dc=domain2,dc=com",
- "dc=domain3,dc=com");
+ "dc=domain3,dc=com");
Assert.assertEquals(child.isMandatoryBooleanProperty(), Boolean.TRUE);
}
@@ -360,7 +370,7 @@
*/
@Test(dataProvider = "getManagedObjectExceptions")
public void testGetManagedObjectException(final ResultCode resultCodeOfThrownException,
- final Class<? extends Exception> expectedExceptionClass, final ResultCode expectedCode) {
+ final Class<? extends Exception> expectedExceptionClass, final ResultCode expectedCode) {
MockLDAPConnection c = new MockLDAPConnection() {
@Override
@@ -370,7 +380,9 @@
};
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
try {
getTestParent(ctx, "test parent 2");
} catch (Exception e) {
@@ -393,15 +405,17 @@
public void testGetTopLevelManagedObject() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 2");
Assert.assertEquals(parent.isMandatoryBooleanProperty(), Boolean.TRUE);
Assert.assertEquals(parent.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(parent.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
+ DirectoryServer.getAttributeType("description"));
assertDNSetEquals(parent.getOptionalMultiValuedDNProperty(), "dc=default value p2v1,dc=com",
- "dc=default value p2v2,dc=com");
+ "dc=default value p2v2,dc=com");
}
/**
@@ -414,15 +428,17 @@
public void testGetTopLevelManagedObjectDefault() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
Assert.assertEquals(parent.isMandatoryBooleanProperty(), Boolean.TRUE);
Assert.assertEquals(parent.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(parent.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
+ DirectoryServer.getAttributeType("description"));
assertDNSetEquals(parent.getOptionalMultiValuedDNProperty(), "dc=domain1,dc=com", "dc=domain2,dc=com",
- "dc=domain3,dc=com");
+ "dc=domain3,dc=com");
}
/**
@@ -433,29 +449,32 @@
*/
@Test
public void testInheritedDefaultValues1() throws Exception {
- CreateEntryMockLDAPConnection c = new CreateEntryMockLDAPConnection(
+ CreateEntryMockLDAPConnection c =
+ new CreateEntryMockLDAPConnection(
"cn=test child new,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedAttribute("cn", "test child new");
c.addExpectedAttribute("objectClass", "top", "ds-cfg-test-child-dummy");
c.addExpectedAttribute("ds-cfg-enabled", "true");
c.addExpectedAttribute("ds-cfg-java-class",
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
// Check pre-commit values.
Assert.assertEquals(child.isMandatoryBooleanProperty(), null);
Assert.assertEquals(child.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(), null);
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), "dc=domain1,dc=com", "dc=domain2,dc=com",
- "dc=domain3,dc=com");
+ "dc=domain3,dc=com");
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), "dc=domain1,dc=com", "dc=domain2,dc=com",
- "dc=domain3,dc=com");
+ "dc=domain3,dc=com");
// Check that the default values are not committed.
child.setMandatoryBooleanProperty(true);
@@ -473,29 +492,32 @@
*/
@Test
public void testInheritedDefaultValues2() throws Exception {
- CreateEntryMockLDAPConnection c = new CreateEntryMockLDAPConnection(
+ CreateEntryMockLDAPConnection c =
+ new CreateEntryMockLDAPConnection(
"cn=test child new,cn=test children,cn=test parent 2,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedAttribute("cn", "test child new");
c.addExpectedAttribute("objectClass", "top", "ds-cfg-test-child-dummy");
c.addExpectedAttribute("ds-cfg-enabled", "true");
c.addExpectedAttribute("ds-cfg-java-class",
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 2");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
// Check pre-commit values.
Assert.assertEquals(child.isMandatoryBooleanProperty(), null);
Assert.assertEquals(child.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(), null);
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), "dc=default value p2v1,dc=com",
- "dc=default value p2v2,dc=com");
+ "dc=default value p2v2,dc=com");
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), "dc=default value p2v1,dc=com",
- "dc=default value p2v2,dc=com");
+ "dc=default value p2v2,dc=com");
// Check that the default values are not committed.
child.setMandatoryBooleanProperty(true);
@@ -515,7 +537,9 @@
public void testListChildManagedObjects() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
String[] actual = parent.listTestChildren();
String[] expected = new String[] { "test child 1", "test child 2", "test child 3" };
@@ -532,7 +556,9 @@
public void testListChildManagedObjectsEmpty() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 3");
String[] actual = parent.listTestChildren();
String[] expected = new String[] {};
@@ -549,7 +575,9 @@
public void testListTopLevelManagedObjects() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
String[] actual = listTestParents(ctx);
String[] expected = new String[] { "test parent 1", "test parent 2", "test parent 3" };
Assert.assertEqualsNoOrder(actual, expected);
@@ -564,7 +592,9 @@
@Test
public void testListTopLevelManagedObjectsEmpty() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
String[] actual = listTestParents(ctx);
String[] expected = new String[] {};
Assert.assertEqualsNoOrder(actual, expected);
@@ -578,11 +608,14 @@
*/
@Test
public void testModifyChildManagedObjectResetToDefault() throws Exception {
- ModifyEntryMockLDAPConnection c = new ModifyEntryMockLDAPConnection(
+ ModifyEntryMockLDAPConnection c =
+ new ModifyEntryMockLDAPConnection(
"cn=test child 2,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedModification("ds-cfg-base-dn");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet());
@@ -598,10 +631,12 @@
*/
@Test
public void testModifyTopLevelManagedObjectNoChanges() throws Exception {
- ModifyEntryMockLDAPConnection c = new ModifyEntryMockLDAPConnection(
- "cn=test parent 1,cn=test parents,cn=config");
+ ModifyEntryMockLDAPConnection c =
+ new ModifyEntryMockLDAPConnection("cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.commit();
Assert.assertFalse(c.isEntryModified());
@@ -615,16 +650,18 @@
*/
@Test
public void testModifyTopLevelManagedObjectWithChanges() throws Exception {
- ModifyEntryMockLDAPConnection c = new ModifyEntryMockLDAPConnection(
- "cn=test parent 1,cn=test parents,cn=config");
+ ModifyEntryMockLDAPConnection c =
+ new ModifyEntryMockLDAPConnection("cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedModification("ds-cfg-enabled", "false");
c.addExpectedModification("ds-cfg-base-dn", "dc=mod1,dc=com", "dc=mod2,dc=com");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.setMandatoryBooleanProperty(false);
parent.setOptionalMultiValuedDNProperty(Arrays.asList(DN.valueOf("dc=mod1,dc=com"),
- DN.valueOf("dc=mod2,dc=com")));
+ DN.valueOf("dc=mod2,dc=com")));
parent.commit();
Assert.assertTrue(c.isEntryModified());
}
@@ -637,10 +674,13 @@
*/
@Test
public void testRemoveChildManagedObject() throws Exception {
- DeleteSubtreeMockLDAPConnection c = new DeleteSubtreeMockLDAPConnection(
+ DeleteSubtreeMockLDAPConnection c =
+ new DeleteSubtreeMockLDAPConnection(
"cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.removeTestChild("test child 1");
c.assertSubtreeIsDeleted();
@@ -654,10 +694,12 @@
*/
@Test
public void testRemoveTopLevelManagedObject() throws Exception {
- DeleteSubtreeMockLDAPConnection c = new DeleteSubtreeMockLDAPConnection(
- "cn=test parent 1,cn=test parents,cn=config");
+ DeleteSubtreeMockLDAPConnection c =
+ new DeleteSubtreeMockLDAPConnection("cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
removeTestParent(ctx, "test parent 1");
c.assertSubtreeIsDeleted();
}
@@ -675,17 +717,20 @@
TestCfg.addConstraint(constraint);
try {
- CreateEntryMockLDAPConnection c = new CreateEntryMockLDAPConnection(
+ CreateEntryMockLDAPConnection c =
+ new CreateEntryMockLDAPConnection(
"cn=test child new,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedAttribute("cn", "test child new");
c.addExpectedAttribute("objectClass", "top", "ds-cfg-test-child-dummy");
c.addExpectedAttribute("ds-cfg-enabled", "true");
c.addExpectedAttribute("ds-cfg-java-class",
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
child.setMandatoryBooleanProperty(true);
@@ -712,17 +757,20 @@
TestCfg.addConstraint(constraint);
try {
- CreateEntryMockLDAPConnection conn = new CreateEntryMockLDAPConnection(
+ CreateEntryMockLDAPConnection conn =
+ new CreateEntryMockLDAPConnection(
"cn=test child new,cn=test children,cn=test parent 1,cn=test parents,cn=config");
conn.importLDIF(TEST_LDIF);
conn.addExpectedAttribute("cn", "test child new");
conn.addExpectedAttribute("objectClass", "top", "ds-cfg-test-child-dummy");
conn.addExpectedAttribute("ds-cfg-enabled", "true");
conn.addExpectedAttribute("ds-cfg-java-class",
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
conn.addExpectedAttribute("ds-cfg-attribute-type", "description");
- ManagementContext ctx = LDAPManagementContext.createFromContext(conn);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
child.setMandatoryBooleanProperty(true);
@@ -748,10 +796,13 @@
TestCfg.addConstraint(constraint);
try {
- DeleteSubtreeMockLDAPConnection c = new DeleteSubtreeMockLDAPConnection(
+ DeleteSubtreeMockLDAPConnection c =
+ new DeleteSubtreeMockLDAPConnection(
"cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.removeTestChild("test child 1");
c.assertSubtreeIsDeleted();
@@ -774,10 +825,13 @@
TestCfg.addConstraint(constraint);
try {
- DeleteSubtreeMockLDAPConnection c = new DeleteSubtreeMockLDAPConnection(
+ DeleteSubtreeMockLDAPConnection c =
+ new DeleteSubtreeMockLDAPConnection(
"cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.removeTestChild("test child 1");
Assert.fail("The remove constraint failed to prevent removal of the managed object");
@@ -800,11 +854,14 @@
TestCfg.addConstraint(constraint);
try {
- ModifyEntryMockLDAPConnection c = new ModifyEntryMockLDAPConnection(
+ ModifyEntryMockLDAPConnection c =
+ new ModifyEntryMockLDAPConnection(
"cn=test child 2,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedModification("ds-cfg-base-dn");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet());
@@ -829,11 +886,14 @@
TestCfg.addConstraint(constraint);
try {
- ModifyEntryMockLDAPConnection c = new ModifyEntryMockLDAPConnection(
+ ModifyEntryMockLDAPConnection c =
+ new ModifyEntryMockLDAPConnection(
"cn=test child 2,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
c.addExpectedModification("ds-cfg-base-dn");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c);
+ ManagementContext ctx =
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
+ PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet());
@@ -857,16 +917,14 @@
}
// Create the named test parent managed object.
- private TestParentCfgClient createTestParent(ManagementContext context, String name)
- throws Exception {
+ private TestParentCfgClient createTestParent(ManagementContext context, String name) throws Exception {
ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject();
return root.createChild(TestCfg.getTestOneToManyParentRelationDefinition(), TestParentCfgDefn.getInstance(),
- name, null).getConfiguration();
+ name, null).getConfiguration();
}
// Retrieve the named test parent managed object.
- private TestParentCfgClient getTestParent(ManagementContext context, String name)
- throws Exception {
+ private TestParentCfgClient getTestParent(ManagementContext context, String name) throws Exception {
ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject();
return root.getChild(TestCfg.getTestOneToManyParentRelationDefinition(), name).getConfiguration();
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/AggregationServerTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/AggregationServerTest.java
index 3fa1f92..d87ceb7 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/AggregationServerTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/AggregationServerTest.java
@@ -49,6 +49,7 @@
import org.opends.server.admin.AdministratorAction;
import org.opends.server.admin.AggregationPropertyDefinition;
import org.opends.server.admin.IllegalPropertyValueStringException;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.PropertyException;
import org.opends.server.admin.PropertyOption;
import org.opends.server.admin.TestCfg;
@@ -84,7 +85,7 @@
}
public boolean isConfigurationChangeAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
+ List<LocalizableMessage> unacceptableReasons) {
return true;
}
}
@@ -99,16 +100,18 @@
}
public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
+ List<LocalizableMessage> unacceptableReasons) {
return true;
}
}
+ // @Checkstyle:off
private static final Entry TEST_CHILD_1 = makeEntry(
"dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config",
"objectclass: top",
"objectclass: ds-cfg-test-child-dummy",
- "cn: test child 1", "ds-cfg-enabled: true",
+ "cn: test child 1",
+ "ds-cfg-enabled: true",
"ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
"ds-cfg-attribute-type: description",
"ds-cfg-conflict-behavior: virtual-overrides-real");
@@ -117,7 +120,8 @@
"dn: cn=test child 2,cn=test children,cn=test parent 1,cn=test parents,cn=config",
"objectclass: top",
"objectclass: ds-cfg-test-child-dummy",
- "cn: test child 2", "ds-cfg-enabled: true",
+ "cn: test child 2",
+ "ds-cfg-enabled: true",
"ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
"ds-cfg-attribute-type: description",
"ds-cfg-conflict-behavior: virtual-overrides-real",
@@ -151,7 +155,8 @@
"objectclass: ds-cfg-test-child-dummy",
"cn: test child 5", "ds-cfg-enabled: true",
"ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description", "ds-cfg-conflict-behavior: virtual-overrides-real",
+ "ds-cfg-attribute-type: description",
+ "ds-cfg-conflict-behavior: virtual-overrides-real",
"ds-cfg-rotation-policy: cn=BAD Connection Handler 1, cn=connection handlers, cn=config",
"ds-cfg-rotation-policy: cn=BAD Connection Handler 2, cn=connection handlers, cn=config",
"ds-cfg-rotation-policy: cn=LDAP Connection Handler, cn=connection handlers, cn=config");
@@ -162,7 +167,8 @@
"objectclass: ds-cfg-test-child-dummy",
"cn: test child 6", "ds-cfg-enabled: true",
"ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description", "ds-cfg-conflict-behavior: virtual-overrides-real",
+ "ds-cfg-attribute-type: description",
+ "ds-cfg-conflict-behavior: virtual-overrides-real",
"ds-cfg-rotation-policy: cn=Test Connection Handler, cn=connection handlers, cn=config");
private static final Entry TEST_CHILD_7 = makeEntry(
@@ -218,6 +224,7 @@
"ds-cfg-java-class: org.opends.server.protocols.ldap.LDAPConnectionHandler",
"ds-cfg-enabled: true",
"ds-cfg-listen-address: 0.0.0.0", "ds-cfg-listen-port: 389");
+ // @Checkstyle:on
// @Checkstyle:off
/**
@@ -240,13 +247,12 @@
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
// Save the aggregation property definition so that it can be
// replaced and restored later.
- aggregationPropertyDefinitionDefault = TestChildCfgDefn.getInstance()
- .getAggregationPropertyPropertyDefinition();
+ aggregationPropertyDefinitionDefault =
+ TestChildCfgDefn.getInstance().getAggregationPropertyPropertyDefinition();
// Create the two test aggregation properties.
AggregationPropertyDefinition.Builder<ConnectionHandlerCfgClient, ConnectionHandlerCfg> builder;
@@ -254,7 +260,7 @@
builder = AggregationPropertyDefinition.createBuilder(d, "aggregation-property");
builder.setOption(PropertyOption.MULTI_VALUED);
builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, d,
- "aggregation-property"));
+ "aggregation-property"));
builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
builder.setParentPath("/");
builder.setRelationDefinition("connection-handler");
@@ -265,7 +271,7 @@
builder = AggregationPropertyDefinition.createBuilder(d, "aggregation-property");
builder.setOption(PropertyOption.MULTI_VALUED);
builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, d,
- "aggregation-property"));
+ "aggregation-property"));
builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
builder.setParentPath("/");
builder.setRelationDefinition("connection-handler");
@@ -289,9 +295,10 @@
*/
@Test
public void testAggregationBadBaseDN() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_3,
- LDAP_CONN_HANDLER_ENTRY);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_3, LDAP_CONN_HANDLER_ENTRY);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
try {
parentCfg.getTestChild(entryName(TEST_CHILD_3));
@@ -304,7 +311,7 @@
assertThat(propertyException).isInstanceOf(IllegalPropertyValueStringException.class);
IllegalPropertyValueStringException pe = (IllegalPropertyValueStringException) propertyException;
assertEquals(pe.getPropertyDefinition(), TestChildCfgDefn.getInstance()
- .getAggregationPropertyPropertyDefinition());
+ .getAggregationPropertyPropertyDefinition());
assertEquals(pe.getIllegalValueString(), "cn=LDAP Connection Handler, cn=bad rdn, cn=config");
}
}
@@ -315,9 +322,10 @@
*/
@Test
public void testAggregationDanglingReference() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(
- TEST_PARENT_1, TEST_CHILD_5, LDAP_CONN_HANDLER_ENTRY);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_5, LDAP_CONN_HANDLER_ENTRY);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
try {
@@ -337,9 +345,10 @@
*/
@Test
public void testAggregationDisabledReference1() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(
- TEST_PARENT_1, TEST_CHILD_6, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_6, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
registerAggregationDefinitionWithTargetEnabled();
@@ -363,9 +372,10 @@
*/
@Test
public void testAggregationDisabledReference2() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(
- TEST_PARENT_1, TEST_CHILD_7, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_7, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
registerAggregationDefinitionWithTargetEnabled();
@@ -390,9 +400,10 @@
*/
@Test
public void testAggregationDisabledReference3() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(
- TEST_PARENT_1, TEST_CHILD_6, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_6, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
registerAggregationDefinitionWithTargetAndSourceEnabled();
@@ -416,9 +427,10 @@
*/
@Test
public void testAggregationDisabledReference4() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(
- TEST_PARENT_1, TEST_CHILD_7, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_7, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
registerAggregationDefinitionWithTargetAndSourceEnabled();
@@ -437,14 +449,15 @@
@Test
public void testAggregationEmpty() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_1);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg testChildCfg = parentCfg.getTestChild(entryName(TEST_CHILD_1));
assertEquals(testChildCfg.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
- assertEquals(testChildCfg.getMandatoryReadOnlyAttributeTypeProperty(),
- Schema.getDefaultSchema().getAttributeType("description"));
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ assertEquals(testChildCfg.getMandatoryReadOnlyAttributeTypeProperty(), Schema.getDefaultSchema()
+ .getAttributeType("description"));
assertSetEquals(testChildCfg.getAggregationProperty(), new String[0]);
}
@@ -454,18 +467,19 @@
*/
@Test
public void testAggregationMultipleValues() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_4,
- LDAP_CONN_HANDLER_ENTRY, LDAPS_CONN_HANDLER_ENTRY);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_4, LDAP_CONN_HANDLER_ENTRY,
+ LDAPS_CONN_HANDLER_ENTRY);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg testChildCfg = parentCfg.getTestChild(entryName(TEST_CHILD_4));
assertEquals(testChildCfg.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
- assertEquals(testChildCfg.getMandatoryReadOnlyAttributeTypeProperty(),
- Schema.getDefaultSchema().getAttributeType("description"));
- assertSetEquals(testChildCfg.getAggregationProperty(),
- "LDAPS Connection Handler", "LDAP Connection Handler");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ assertEquals(testChildCfg.getMandatoryReadOnlyAttributeTypeProperty(), Schema.getDefaultSchema()
+ .getAttributeType("description"));
+ assertSetEquals(testChildCfg.getAggregationProperty(), "LDAPS Connection Handler", "LDAP Connection Handler");
}
/**
@@ -474,16 +488,17 @@
*/
@Test
public void testAggregationSingle() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_2,
- LDAP_CONN_HANDLER_ENTRY);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_2, LDAP_CONN_HANDLER_ENTRY);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg testChildCfg = parentCfg.getTestChild(entryName(TEST_CHILD_2));
assertEquals(testChildCfg.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
- assertEquals(testChildCfg.getMandatoryReadOnlyAttributeTypeProperty(),
- Schema.getDefaultSchema().getAttributeType("description"));
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ assertEquals(testChildCfg.getMandatoryReadOnlyAttributeTypeProperty(), Schema.getDefaultSchema()
+ .getAttributeType("description"));
// Test normalization.
assertSetEquals(testChildCfg.getAggregationProperty(), "LDAP Connection Handler");
@@ -498,9 +513,11 @@
*/
@Test
public void testCannotDeleteReferencedComponent() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENTS, TEST_PARENT_1,
- TEST_BASE_CHILD, TEST_CHILD_7, CONN_HANDLER_ENTRY, TEST_CONNECTION_HANDLER_ENTRY_ENABLED);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENTS, TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_7,
+ CONN_HANDLER_ENTRY, TEST_CONNECTION_HANDLER_ENTRY_ENABLED);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
registerAggregationDefinitionWithTargetEnabled();
@@ -518,9 +535,9 @@
registeredListener.capture());
// Now simulate the delete ofthe referenced connection handler.
- assertThat(registeredListener.getValue().
- configDeleteIsAcceptable(TEST_CONNECTION_HANDLER_ENTRY_ENABLED, new LocalizableMessageBuilder())).
- isFalse();
+ assertThat(
+ registeredListener.getValue().configDeleteIsAcceptable(TEST_CONNECTION_HANDLER_ENTRY_ENABLED,
+ new LocalizableMessageBuilder())).isFalse();
} finally {
putBackDefaultAggregationDefinitionFromTargetEnabled();
@@ -534,9 +551,11 @@
*/
@Test
public void testCannotDisableReferencedComponent() throws Exception {
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENTS, TEST_PARENT_1,
- TEST_BASE_CHILD, TEST_CHILD_7, CONN_HANDLER_ENTRY, TEST_CONNECTION_HANDLER_ENTRY_ENABLED);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENTS, TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_7,
+ CONN_HANDLER_ENTRY, TEST_CONNECTION_HANDLER_ENTRY_ENABLED);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
registerAggregationDefinitionWithTargetEnabled();
@@ -554,9 +573,9 @@
verify(configRepository).registerChangeListener(eq(TEST_CHILD_7.getName()), registeredListener.capture());
// Now simulate the disabling ofthe referenced connection handler.
- assertThat(registeredListener.getValue().
- configChangeIsAcceptable(TEST_CONNECTION_HANDLER_ENTRY_DISABLED, new LocalizableMessageBuilder())).
- isFalse();
+ assertThat(
+ registeredListener.getValue().configChangeIsAcceptable(TEST_CONNECTION_HANDLER_ENTRY_DISABLED,
+ new LocalizableMessageBuilder())).isFalse();
} finally {
putBackDefaultAggregationDefinitionFromTargetEnabled();
@@ -606,8 +625,8 @@
/** Asserts that the actual set of DNs contains the expected values. */
private void assertSetEquals(SortedSet<String> actual, String... expected) {
- SortedSet<String> values = new TreeSet<String>(TestChildCfgDefn.getInstance()
- .getAggregationPropertyPropertyDefinition());
+ SortedSet<String> values =
+ new TreeSet<String>(TestChildCfgDefn.getInstance().getAggregationPropertyPropertyDefinition());
if (expected != null) {
for (String value : expected) {
values.add(value);
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ConstraintTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ConstraintTest.java
index 7656ba2..ae44610 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ConstraintTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ConstraintTest.java
@@ -39,6 +39,7 @@
import org.forgerock.opendj.ldif.LDIF;
import org.mockito.ArgumentCaptor;
import org.opends.server.admin.AdminTestCase;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.TestCfg;
import org.opends.server.admin.TestChildCfg;
import org.opends.server.admin.TestChildCfgDefn;
@@ -67,7 +68,7 @@
}
public boolean isConfigurationAddAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
+ List<LocalizableMessage> unacceptableReasons) {
return true;
}
}
@@ -79,7 +80,7 @@
}
public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
+ List<LocalizableMessage> unacceptableReasons) {
return true;
}
@@ -92,27 +93,22 @@
}
public boolean isConfigurationChangeAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
+ List<LocalizableMessage> unacceptableReasons) {
return true;
}
}
+ // @Checkstyle:off
private static final Entry TEST_CHILD_1 = LDIF.makeEntry(
- "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config", "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy", "cn: test child 1", "ds-cfg-enabled: true",
+ "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config",
+ "objectclass: top",
+ "objectclass: ds-cfg-test-child-dummy",
+ "cn: test child 1",
+ "ds-cfg-enabled: true",
"ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description", "ds-cfg-conflict-behavior: virtual-overrides-real");
-
- private static final Entry NEW_TEST_CHILD_1 = LDIF.makeEntry(
- "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config", "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy", "cn: test child 1", "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description", "ds-cfg-conflict-behavior: virtual-overrides-real",
- "ds-cfg-base-dn: dc=new value 1,dc=com",
- "ds-cfg-base-dn: dc=new value 2,dc=com",
- "ds-cfg-group-dn: dc=new value 3,dc=com",
- "ds-cfg-group-dn: dc=new value 4,dc=com");
+ "ds-cfg-attribute-type: description",
+ "ds-cfg-conflict-behavior: virtual-overrides-real");
private static final Entry TEST_BASE_CHILD = LDIF.makeEntry(
"dn:cn=test children,cn=test parent 1,cn=test parents,cn=config",
@@ -123,23 +119,19 @@
// Parent 1 - uses default values for
// optional-multi-valued-dn-property.
private static final Entry TEST_PARENT_1 = LDIF.makeEntry(
- "dn: cn=test parent 1,cn=test parents,cn=config", "objectclass: top",
- "objectclass: ds-cfg-test-parent-dummy", "cn: test parent 1", "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description", "ds-cfg-conflict-behavior: virtual-overrides-real");
-
- private static final String[] TEST_LDIF = new String[] {
- // Base entries.
- "dn: cn=test parents,cn=config",
+ "dn: cn=test parent 1,cn=test parents,cn=config",
"objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test parents",
- ""};
+ "objectclass: ds-cfg-test-parent-dummy",
+ "cn: test parent 1",
+ "ds-cfg-enabled: true",
+ "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
+ "ds-cfg-attribute-type: description",
+ "ds-cfg-conflict-behavior: virtual-overrides-real");
+ // @Checkstyle:on
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
@@ -152,9 +144,10 @@
@Test
public void testGetManagedObjectSuccess() throws Exception {
// arrange
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD,
- TEST_CHILD_1);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
MockConstraint constraint = new MockConstraint(true, false, configRepository);
try {
TestCfg.addConstraint(constraint);
@@ -170,9 +163,10 @@
@Test
public void testGetManagedObjectFail() throws Exception {
// arrange
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD,
- TEST_CHILD_1);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
MockConstraint constraint = new MockConstraint(false, true, configRepository);
try {
TestCfg.addConstraint(constraint);
@@ -206,9 +200,10 @@
@Test(dataProvider = "constraintValues")
public void testAddConstraint(boolean isUsableConstraint) throws Exception {
// arrange
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD,
- TEST_CHILD_1);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
parentCfg.addTestChildAddListener(new AddListener());
MockConstraint constraint = new MockConstraint(isUsableConstraint, false, configRepository);
@@ -228,9 +223,10 @@
@Test(dataProvider = "constraintValues")
public void testDeleteConstraint(boolean isDeleteAllowedConstraint) throws Exception {
// arrange
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD,
- TEST_CHILD_1);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
parentCfg.addTestChildDeleteListener(new DeleteListener());
MockConstraint constraint = new MockConstraint(false, isDeleteAllowedConstraint, configRepository);
@@ -250,9 +246,10 @@
@Test(dataProvider = "constraintValues")
public void testChangeConstraint(boolean isUsableConstraint) throws Exception {
// arrange
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD,
- TEST_CHILD_1);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
MockConstraint constraint = new MockConstraint(isUsableConstraint, false, configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg childCfg = parentCfg.getTestChild(entryName(TEST_CHILD_1));
@@ -274,7 +271,9 @@
}
/**
- * Simulate an entry add by triggering configAddIsAcceptable method of last registered add listener.
+ * Simulate an entry add by triggering configAddIsAcceptable method of last
+ * registered add listener.
+ *
* @return true if add is acceptable, false otherwise.
*/
private boolean simulateEntryAdd(Entry entry, ConfigurationRepository configRepository) throws IOException {
@@ -286,7 +285,9 @@
}
/**
- * Simulate an entry delete by triggering configDeleteIsAcceptable method of last registered add listener.
+ * Simulate an entry delete by triggering configDeleteIsAcceptable method of
+ * last registered add listener.
+ *
* @return true if delete is acceptable, false otherwise.
*/
private boolean simulateEntryDelete(Entry entry, ConfigurationRepository configRepository) throws IOException {
@@ -298,7 +299,9 @@
}
/**
- * Simulate an entry change by triggering configChangeIsAcceptable method on last registered change listener.
+ * Simulate an entry change by triggering configChangeIsAcceptable method on
+ * last registered change listener.
+ *
* @return true if change is acceptable, false otherwise.
*/
private boolean simulateEntryChange(Entry newEntry, ConfigurationRepository configRepository) {
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DNBuilderTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DNBuilderTest.java
index 6798427..48c7ac5 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DNBuilderTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DNBuilderTest.java
@@ -47,7 +47,6 @@
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DefaultBehaviorTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DefaultBehaviorTest.java
index 9b9bc2a..dade4fb 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DefaultBehaviorTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/DefaultBehaviorTest.java
@@ -44,6 +44,7 @@
import org.forgerock.opendj.ldap.schema.Schema;
import org.mockito.ArgumentCaptor;
import org.opends.server.admin.AdminTestCase;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.TestCfg;
import org.opends.server.admin.TestChildCfg;
import org.opends.server.admin.TestParentCfg;
@@ -79,7 +80,7 @@
}
public boolean isConfigurationAddAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
+ List<LocalizableMessage> unacceptableReasons) {
childCfg = configuration;
return true;
}
@@ -101,12 +102,13 @@
}
public boolean isConfigurationChangeAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
+ List<LocalizableMessage> unacceptableReasons) {
childCfg = configuration;
return true;
}
}
+ // @Checkstyle:off
static final Entry CONFIG = makeEntry(
"dn: cn=config",
"objectClass: top",
@@ -219,9 +221,10 @@
"ds-cfg-attribute-type: description",
"ds-cfg-conflict-behavior: virtual-overrides-real");
+ // @Checkstyle:on
+
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
@@ -237,33 +240,34 @@
// expected first dn property values,
// expected second dn property values
{ TEST_PARENT_1, TEST_CHILD_BASE_1, TEST_CHILD_1,
- Arrays.asList("dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com"),
- Arrays.asList("dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com") },
+ Arrays.asList("dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com"),
+ Arrays.asList("dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com") },
{ TEST_PARENT_1, TEST_CHILD_BASE_1, TEST_CHILD_2,
- Arrays.asList("dc=default value c2v1,dc=com", "dc=default value c2v2,dc=com"),
- Arrays.asList("dc=default value c2v1,dc=com", "dc=default value c2v2,dc=com") },
+ Arrays.asList("dc=default value c2v1,dc=com", "dc=default value c2v2,dc=com"),
+ Arrays.asList("dc=default value c2v1,dc=com", "dc=default value c2v2,dc=com") },
{ TEST_PARENT_1, TEST_CHILD_BASE_1, TEST_CHILD_3,
- Arrays.asList("dc=default value c3v1,dc=com", "dc=default value c3v2,dc=com"),
- Arrays.asList("dc=default value c3v3,dc=com", "dc=default value c3v4,dc=com") },
+ Arrays.asList("dc=default value c3v1,dc=com", "dc=default value c3v2,dc=com"),
+ Arrays.asList("dc=default value c3v3,dc=com", "dc=default value c3v4,dc=com") },
{ TEST_PARENT_2, TEST_CHILD_BASE_2, TEST_CHILD_4,
- Arrays.asList("dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com"),
- Arrays.asList("dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com") }
- };
+ Arrays.asList("dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com"),
+ Arrays.asList("dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com") } };
}
/**
- * Test that a child config have correct values when accessed from its parent config.
+ * Test that a child config have correct values when accessed from its
+ * parent config.
*/
@Test(dataProvider = "childConfigurationsValues")
public void testChildValues(Entry testParent, Entry testBaseChild, Entry testChild,
- List<String> valuesForOptionalDNProperty1, List<String> valuesForOptionalDNProperty2) throws Exception {
+ List<String> valuesForOptionalDNProperty1, List<String> valuesForOptionalDNProperty2) throws Exception {
// arrange
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(
- testParent, testBaseChild, testChild);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(testParent, testBaseChild, testChild);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(testParent, context);
// assert
@@ -272,15 +276,17 @@
}
/**
- * Test that a child config have correct values when accessed through an add listener.
+ * Test that a child config have correct values when accessed through an add
+ * listener.
*/
@Test(dataProvider = "childConfigurationsValues")
public void testAddListenerChildValues(Entry testParent, Entry testBaseChild, Entry testChild,
- List<String> valuesForOptionalDNProperty1, List<String> valuesForOptionalDNProperty2) throws Exception {
+ List<String> valuesForOptionalDNProperty1, List<String> valuesForOptionalDNProperty2) throws Exception {
// arrange
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(
- testParent, testBaseChild, testChild);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(testParent, testBaseChild, testChild);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(testParent, context);
TestConfigurationAddListener addListener = new TestConfigurationAddListener();
parentCfg.addTestChildAddListener(addListener);
@@ -296,36 +302,38 @@
@DataProvider
Object[][] childConfigurationsValuesForChangeListener() {
return new Object[][] {
- // new entry after change, expected first dn property values, expected second dn property values
+ // new entry after change, expected first dn property values,
+ // expected second dn property values
{ makeEntryFrom(LDIF_TEST_CHILD_1, NEW_ATTRS_1),
- Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com"),
- Arrays.asList("dc=new value 3,dc=com", "dc=new value 4,dc=com") },
+ Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com"),
+ Arrays.asList("dc=new value 3,dc=com", "dc=new value 4,dc=com") },
{ makeEntryFrom(LDIF_TEST_CHILD_1, NEW_ATTRS_2),
- Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com"),
- Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com") },
+ Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com"),
+ Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com") },
{ makeEntryFrom(LDIF_TEST_CHILD_1, NEW_ATTRS_3),
- Arrays.asList("dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com"),
- Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com") },
+ Arrays.asList("dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com"),
+ Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com") },
{ makeEntryFrom(LDIF_TEST_PARENT_1, NEW_ATTRS_2),
- Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com"),
- Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com") }
- };
+ Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com"),
+ Arrays.asList("dc=new value 1,dc=com", "dc=new value 2,dc=com") } };
}
/**
- * Tests that a child config have correct values when accessed through an change listener.
- * The defaulted properties are replaced with some real values.
+ * Tests that a child config have correct values when accessed through an
+ * change listener. The defaulted properties are replaced with some real
+ * values.
*/
@Test(dataProvider = "childConfigurationsValuesForChangeListener")
public void testChangeListenerChildValues(Entry newEntry, List<String> valuesForOptionalDNProperty1,
- List<String> valuesForOptionalDNProperty2) throws Exception {
+ List<String> valuesForOptionalDNProperty2) throws Exception {
// arrange
- ConfigurationRepository configRepository = createConfigRepositoryWithEntries(
- TEST_PARENT_1, TEST_CHILD_BASE_1, TEST_CHILD_1);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ConfigurationRepository configRepository =
+ createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_BASE_1, TEST_CHILD_1);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg childCfg = parentCfg.getTestChild(entryName(TEST_CHILD_1));
TestConfigurationChangeListener changeListener = new TestConfigurationChangeListener();
@@ -335,17 +343,17 @@
simulateEntryChange(newEntry, configRepository);
// assert
- assertChildHasCorrectValues(changeListener.getChildCfg(entryName(TEST_CHILD_1)), valuesForOptionalDNProperty1,
- valuesForOptionalDNProperty2);
+ assertChildHasCorrectValues(changeListener.getChildCfg(entryName(TEST_CHILD_1)),
+ valuesForOptionalDNProperty1, valuesForOptionalDNProperty2);
}
@DataProvider
Object[][] parentConfigurationsValues() {
return new Object[][] {
- // parent entry, expected first dn property values, expected second dn property values
+ // parent entry, expected first dn property values, expected second
+ // dn property values
{ TEST_PARENT_1, Arrays.asList("dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com") },
- { TEST_PARENT_2, Arrays.asList("dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com") }
- };
+ { TEST_PARENT_2, Arrays.asList("dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com") } };
}
/**
@@ -354,20 +362,20 @@
@Test(dataProvider = "parentConfigurationsValues")
public void testParentValues(Entry parentEntry, List<String> valuesForOptionalDNProperty) throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithEntries(parentEntry);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
TestParentCfg parent = getParentCfg(parentEntry, context);
assertThat(parent.getMandatoryClassProperty()).isEqualTo(
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
assertThat(parent.getMandatoryReadOnlyAttributeTypeProperty()).isEqualTo(
- Schema.getDefaultSchema().getAttributeType("description"));
+ Schema.getDefaultSchema().getAttributeType("description"));
assertDNSetEquals(parent.getOptionalMultiValuedDNProperty(), valuesForOptionalDNProperty);
}
-
-
/**
- * Simulate an entry add by triggering configAddIsAcceptable method of last registered add listener.
+ * Simulate an entry add by triggering configAddIsAcceptable method of last
+ * registered add listener.
*/
private void simulateEntryAdd(Entry entry, ConfigurationRepository configRepository) throws IOException {
// use argument capture to retrieve the actual listener
@@ -378,7 +386,8 @@
}
/**
- * Simulate an entry change by triggering configChangeIsAcceptable method on last registered change listener.
+ * Simulate an entry change by triggering configChangeIsAcceptable method on
+ * last registered change listener.
*/
private void simulateEntryChange(Entry newEntry, ConfigurationRepository configRepository) {
// use argument capture to retrieve the actual listener
@@ -390,9 +399,9 @@
private void assertChildHasCorrectValues(TestChildCfg child, List<String> dnProperty1, List<String> dnProperty2) {
assertThat(child.getMandatoryClassProperty()).isEqualTo(
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
+ "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
assertThat(child.getMandatoryReadOnlyAttributeTypeProperty()).isEqualTo(
- Schema.getDefaultSchema().getAttributeType("description"));
+ Schema.getDefaultSchema().getAttributeType("description"));
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), dnProperty1);
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), dnProperty2);
}
diff --git a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ListenerTest.java b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ListenerTest.java
index 9174888..dda5322 100644
--- a/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ListenerTest.java
+++ b/opendj-sdk/opendj-admin/src/test/java/org/opends/server/admin/server/ListenerTest.java
@@ -36,6 +36,7 @@
import org.forgerock.opendj.ldap.Entry;
import org.mockito.ArgumentCaptor;
import org.opends.server.admin.AdminTestCase;
+import org.opends.server.admin.PropertyDefinitionsOptions;
import org.opends.server.admin.TestCfg;
import org.opends.server.admin.TestParentCfg;
import org.opends.server.api.ConfigAddListener;
@@ -47,7 +48,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-
@SuppressWarnings({ "javadoc", "rawtypes", "unchecked" })
public class ListenerTest extends AdminTestCase {
@@ -56,7 +56,6 @@
@BeforeClass
public void setUp() throws Exception {
- disableClassValidationForProperties();
TestCfg.setUp();
}
@@ -66,17 +65,14 @@
}
private Entry getTestParentEntry() throws Exception {
- return makeEntry(
- "dn: cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
+ return makeEntry("dn: cn=test parents,cn=config", "objectclass: top", "objectclass: ds-cfg-branch",
"cn: test parents");
}
/**
* Create a mock of ConfigurationRepository with provided DNs registered.
*/
- private ConfigurationRepository createConfigRepositoryWithDNs(DN...dns) throws ConfigException {
+ private ConfigurationRepository createConfigRepositoryWithDNs(DN... dns) throws ConfigException {
ConfigurationRepository configRepository = mock(ConfigurationRepository.class);
for (DN dn : dns) {
when(configRepository.hasEntry(dn)).thenReturn(true);
@@ -84,10 +80,12 @@
return configRepository;
}
- /** Register a listener for test parent entry and return the actual registered listener */
+ /**
+ * Register a listener for test parent entry and return the actual
+ * registered listener
+ */
private ConfigAddListener registerAddListenerForTestParent(ConfigurationRepository configRepository,
- ServerManagedObject<RootCfg> root, ConfigurationAddListener<TestParentCfg> parentListener)
- throws Exception {
+ ServerManagedObject<RootCfg> root, ConfigurationAddListener<TestParentCfg> parentListener) throws Exception {
root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(), parentListener);
ArgumentCaptor<ConfigAddListener> registered = ArgumentCaptor.forClass(ConfigAddListener.class);
@@ -95,10 +93,13 @@
return registered.getValue();
}
- /** Register a listener for test parent entry in delayed scenario and return the actual registered listener */
- private DelayedConfigAddListener registerAddListenerForTestParentDelayed(ConfigurationRepository configRepository,
- ServerManagedObject<RootCfg> root, ConfigurationAddListener<TestParentCfg> parentListener)
- throws Exception {
+ /**
+ * Register a listener for test parent entry in delayed scenario and return
+ * the actual registered listener
+ */
+ private DelayedConfigAddListener registerAddListenerForTestParentDelayed(
+ ConfigurationRepository configRepository, ServerManagedObject<RootCfg> root,
+ ConfigurationAddListener<TestParentCfg> parentListener) throws Exception {
root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(), parentListener);
ArgumentCaptor<DelayedConfigAddListener> registered = ArgumentCaptor.forClass(DelayedConfigAddListener.class);
@@ -109,20 +110,21 @@
@Test
public void testRegisterAddListenerWithInstantiableRelationImmediate() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN, TEST_PARENTS_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(),
- mock(ConfigurationAddListener.class));
+ mock(ConfigurationAddListener.class));
- verify(configRepository).registerAddListener(eq(TEST_PARENTS_DN),
- isA(ConfigAddListener.class));
+ verify(configRepository).registerAddListener(eq(TEST_PARENTS_DN), isA(ConfigAddListener.class));
}
@Test
public void testRegisterAddListenerWithInstantiableRelationDelayed() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
ConfigurationAddListener<TestParentCfg> parentListener = mock(ConfigurationAddListener.class);
@@ -141,7 +143,8 @@
@Test
public void testRegisterAddListenerWithInstantiableRelationDelayedThenActualized() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
// register a listener to root
@@ -157,9 +160,10 @@
when(configRepository.hasEntry(DN.valueOf(parentDN))).thenReturn(true);
registered.getValue().applyConfigurationAdd(getTestParentEntry());
- // check that listener is added for target entry and deleted for its parent entry
+ // check that listener is added for target entry and deleted for its
+ // parent entry
ConfigAddListenerAdaptor listener =
- (ConfigAddListenerAdaptor<?>) registered.getValue().getDelayedAddListener();
+ (ConfigAddListenerAdaptor<?>) registered.getValue().getDelayedAddListener();
verify(configRepository).registerAddListener(DN.valueOf(parentDN), listener);
verify(configRepository).deregisterAddListener(ROOT_CONFIG_DN, registered.getValue());
}
@@ -167,33 +171,34 @@
@Test
public void testRegisterAddListenerWithOptionalRelation() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.registerAddListener(TestCfg.getTestOneToZeroOrOneParentRelationDefinition(),
mock(ConfigurationAddListener.class));
- verify(configRepository).registerAddListener(eq(ROOT_CONFIG_DN),
- isA(ConfigAddListener.class));
+ verify(configRepository).registerAddListener(eq(ROOT_CONFIG_DN), isA(ConfigAddListener.class));
}
@Test
public void testRegisterDeleteListenerWithInstantiableRelationImmediate() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN, TEST_PARENTS_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.registerDeleteListener(TestCfg.getTestOneToManyParentRelationDefinition(),
- mock(ConfigurationDeleteListener.class));
+ mock(ConfigurationDeleteListener.class));
- verify(configRepository).registerDeleteListener(eq(TEST_PARENTS_DN),
- isA(ConfigDeleteListener.class));
+ verify(configRepository).registerDeleteListener(eq(TEST_PARENTS_DN), isA(ConfigDeleteListener.class));
}
@Test
public void testRegisterDeleteListenerWithInstantiableRelationDelayed() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
ConfigurationDeleteListener<TestParentCfg> parentListener = mock(ConfigurationDeleteListener.class);
@@ -203,48 +208,49 @@
verify(configRepository).registerAddListener(eq(ROOT_CONFIG_DN), argument.capture());
// check that actual listener is the one provided to the root
ConfigurationDeleteListener actualListener =
- ((ServerManagedObjectDeleteListenerAdaptor)
- ((ConfigDeleteListenerAdaptor) argument.getValue().getDelayedDeleteListener()).
- getServerManagedObjectDeleteListener()).getConfigurationDeleteListener();
+ ((ServerManagedObjectDeleteListenerAdaptor)
+ ((ConfigDeleteListenerAdaptor) argument.getValue().getDelayedDeleteListener()).
+ getServerManagedObjectDeleteListener()).getConfigurationDeleteListener();
assertThat(actualListener).isEqualTo(parentListener);
}
@Test
public void testRegisterDeleteListenerWithOptionalRelation() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.registerDeleteListener(TestCfg.getTestOneToZeroOrOneParentRelationDefinition(),
- mock(ConfigurationDeleteListener.class));
+ mock(ConfigurationDeleteListener.class));
- verify(configRepository).registerDeleteListener(eq(ROOT_CONFIG_DN),
- isA(ConfigDeleteListener.class));
+ verify(configRepository).registerDeleteListener(eq(ROOT_CONFIG_DN), isA(ConfigDeleteListener.class));
}
@Test
public void testRegisterChangeListener() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.setConfigDN(ROOT_CONFIG_DN);
root.registerChangeListener(mock(ConfigurationChangeListener.class));
- verify(configRepository).registerChangeListener(eq(ROOT_CONFIG_DN),
- isA(ConfigChangeListener.class));
+ verify(configRepository).registerChangeListener(eq(ROOT_CONFIG_DN), isA(ConfigChangeListener.class));
}
@Test
public void testDeregisterAddListenerWithInstantiableRelationImmediate() throws Exception {
// arrange
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN, TEST_PARENTS_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
ConfigurationAddListener<TestParentCfg> parentListener = mock(ConfigurationAddListener.class);
ConfigAddListener registeredListener =
- registerAddListenerForTestParent(configRepository, root, parentListener);
+ registerAddListenerForTestParent(configRepository, root, parentListener);
when(configRepository.getAddListeners(TEST_PARENTS_DN)).thenReturn(Arrays.asList(registeredListener));
// act
@@ -258,12 +264,13 @@
public void testDeregisterAddListenerWithInstantiableRelationDelayed() throws Exception {
// arrange
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
- ServerManagementContext context = new ServerManagementContext(configRepository);
+ ServerManagementContext context =
+ new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
ConfigurationAddListener<TestParentCfg> parentListener = mock(ConfigurationAddListener.class);
ConfigAddListener registeredListener =
- registerAddListenerForTestParentDelayed(configRepository, root, parentListener);
+ registerAddListenerForTestParentDelayed(configRepository, root, parentListener);
when(configRepository.getAddListeners(ROOT_CONFIG_DN)).thenReturn(Arrays.asList(registeredListener));
// act
--
Gitblit v1.10.0