DNPropertyDefinitionTest.java revision d70586b00b9530ab99ab4b8f003e9a54793e419f
/*
* 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
* 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 2008 Sun Microsystems, Inc.
*/
@SuppressWarnings("javadoc")
public class DNPropertyDefinitionTest extends ConfigTestCase {
public Object[][] createBuilderSetBaseDN() {
return new Object[][] {
{ null },
{ "cn=key manager providers, cn=config" } };
}
DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition.createBuilder(RootCfgDefn.getInstance(),
"test-property");
}
public Object[][] createLegalValues() {
return new Object[][] {
// base DN, value to validate
{ null, "cn=config" },
{ null, "dc=example,dc=com" },
{ "", "cn=config" },
{ "cn=config", "cn=key manager providers, cn=config" },
{ "cn=key manager providers, cn=config", "cn=my provider, cn=key manager providers, cn=config" },
};
}
public Object[][] createIllegalValues() {
return new Object[][] {
// Above base DN.
{ "cn=config", "" },
// Same as base DN.
{ "cn=config", "cn=config" },
// Same as base DN.
{ "cn=key manager providers, cn=config", "cn=key manager providers, cn=config" },
// Too far beneath base DN.
{ "cn=config", "cn=my provider, cn=key manager providers, cn=config" },
// Unrelated to base DN.
{ "cn=config", "dc=example, dc=com" }, };
}
public void testValidateLegalValues(String baseDN, String valueToValidate) throws DirectoryException {
DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition.createBuilder(RootCfgDefn.getInstance(),
"test-property");
propertyDef.validateValue(DN.valueOf(valueToValidate), PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
public void testValidateIllegalValues(String baseDN, String valueToValidate) throws DirectoryException {
DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition.createBuilder(RootCfgDefn.getInstance(),
"test-property");
propertyDef.validateValue(DN.valueOf(valueToValidate), PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
}
DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition.createBuilder(RootCfgDefn.getInstance(),
"test-property");
}
@Test(dataProvider = "illegalValues", expectedExceptions = IllegalPropertyValueStringException.class)
DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition.createBuilder(RootCfgDefn.getInstance(),
"test-property");
}
}