0N/A/*
2362N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License, Version 1.0 only
0N/A * (the "License"). You may not use this file except in compliance
2362N/A * with the License.
0N/A *
2362N/A * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
0N/A * or http://forgerock.org/license/CDDLv1.0.html.
0N/A * See the License for the specific language governing permissions
0N/A * and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
0N/A * file and include the License file at legal-notices/CDDLv1_0.txt.
0N/A * If applicable, add the following below this CDDL HEADER, with the
0N/A * fields enclosed by brackets "[]" replaced with your own identifying
0N/A * information:
0N/A * Portions Copyright [yyyy] [name of copyright owner]
0N/A *
2362N/A * CDDL HEADER END
2362N/A *
2362N/A *
0N/A * Copyright 2009 Sun Microsystems, Inc.
0N/A */
0N/Apackage org.opends.server.types;
0N/A
0N/A
1933N/A
0N/Aimport static org.testng.Assert.*;
0N/A
0N/Aimport org.opends.server.TestCaseUtils;
0N/Aimport org.opends.server.tools.LDAPModify;
406N/Aimport org.testng.annotations.BeforeClass;
0N/Aimport org.testng.annotations.Test;
0N/A
1933N/A
0N/A
1933N/A/**
1933N/A * This class provides a set of test cases for virtual attributes.
1933N/A */
0N/Apublic class DITContentRuleTestCase
1933N/A extends TypesTestCase
0N/A{
0N/A
0N/A
0N/A
0N/A /**
0N/A * Ensures that the Directory Server is running.
0N/A *
0N/A * @throws Exception If an unexpected problem occurs.
11N/A */
11N/A @BeforeClass()
11N/A public void startServer()
11N/A throws Exception
11N/A {
11N/A TestCaseUtils.startServer();
11N/A }
5698N/A
5698N/A
0N/A
0N/A /**
0N/A * Tests the addition of a new DITConentRule with a conflicting
0N/A * rule identifier.
0N/A *
0N/A * @throws Exception If an unexpected problem occurs.
0N/A */
0N/A @Test()
0N/A public void testInvalidDITContentRule()
1790N/A throws Exception
0N/A {
0N/A String filePath = TestCaseUtils.createTempFile(
0N/A "dn: cn=schema",
0N/A "changetype: modify",
0N/A "add: nameForms",
0N/A "nameForms: ( 1.3.6.1.1.10.15.100 NAME 'domainNameForm' OC domain MUST ( dc ) )",
0N/A "-",
0N/A "add: dITStructureRules",
0N/A "dITStructureRules: ( 1 NAME 'domainStructureRule' FORM domainNameForm )"
0N/A );
0N/A String[] args = new String []
0N/A {
0N/A "-h", "127.0.0.1",
0N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
0N/A "-D","cn=directory manager",
0N/A "-w","password",
0N/A "-a",
0N/A "-f", filePath
0N/A };
0N/A int err = LDAPModify.mainModify(args, false, null,null);
0N/A //Shouldn't perform this operation.
0N/A assertEquals(err,53);
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Tests the addition of new DITContentRules with unique rule ids.
0N/A *
0N/A * @throws Exception If an unexpected problem occurs.
0N/A */
0N/A @Test(dependsOnMethods = {"org.opends.server.types."+
0N/A "DITContentRuleTestCase.testInvalidDITContentRule"})
0N/A public void testValidDITRContentRules()
0N/A throws Exception
0N/A {
0N/A String filePath = TestCaseUtils.createTempFile(
0N/A "dn: cn=schema",
0N/A "changetype: modify",
686N/A "add: nameForms",
0N/A "nameForms: ( 1.3.6.1.1.10.15.11 NAME 'domainNameForm' OC domain MUST ( dc ) )",
0N/A "nameForms: ( 1.3.6.1.1.10.15.12 NAME 'organizationalUnitNameForm' OC organizationalUnit MUST ( ou ) )",
0N/A "nameForms: ( 1.3.6.1.1.10.15.13 NAME 'inetOrgPersonNameForm' OC inetOrgPerson MUST ( uid ) )",
0N/A "nameForms: ( 1.3.6.1.1.10.15.14 NAME 'groupOfNamesNameForm' OC groupOfNames MUST ( cn ) )",
0N/A "-",
0N/A "add: dITStructureRules",
0N/A "dITStructureRules: ( 11 NAME 'domainStructureRule' FORM domainNameForm )",
0N/A "dITStructureRules: ( 12 NAME 'organizationalUnitStructureRule' FORM organizationalUnitNameForm SUP 1 )",
0N/A "dITStructureRules: ( 13 NAME 'inetOrgPersonStructureRule' FORM inetOrgPersonNameForm SUP 2 )",
0N/A "dITStructureRules: ( 14 NAME 'groupOfNamesStructureRule' FORM groupOfNamesNameForm SUP 2 )"
0N/A );
0N/A String[] args = new String []
0N/A {
0N/A "-h", "127.0.0.1",
0N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
0N/A "-D","cn=directory manager",
0N/A "-w","password",
0N/A "-a",
686N/A "-f", filePath
0N/A };
0N/A int err = LDAPModify.mainModify(args, false, null,null);
0N/A //Should add the above entries.
0N/A assertEquals(err,0);
0N/A }
0N/A
0N/A
0N/A
686N/A /**
0N/A * Cleans up the DITContentRules.
0N/A *
0N/A * @throws Exception If an unexpected problem occurs.
0N/A */
0N/A @Test(dependsOnMethods = {"org.opends.server.types."+
406N/A "DITContentRuleTestCase.testValidDITRContentRules"})
406N/A public void cleanUpDITRContentRules()
0N/A throws Exception
0N/A {
0N/A String filePath = TestCaseUtils.createTempFile(
0N/A "dn: cn=schema",
0N/A "changetype: modify",
0N/A "delete: dITStructureRules",
0N/A "dITStructureRules: ( 11 NAME 'domainStructureRule' FORM domainNameForm )",
0N/A "dITStructureRules: ( 12 NAME 'organizationalUnitStructureRule' FORM organizationalUnitNameForm SUP 1 )",
0N/A "dITStructureRules: ( 13 NAME 'inetOrgPersonStructureRule' FORM inetOrgPersonNameForm SUP 2 )",
0N/A "dITStructureRules: ( 14 NAME 'groupOfNamesStructureRule' FORM groupOfNamesNameForm SUP 2 )",
0N/A "-",
0N/A "delete: nameForms",
0N/A "nameForms: ( 1.3.6.1.1.10.15.11 NAME 'domainNameForm' OC domain MUST ( dc ) )",
0N/A "nameForms: ( 1.3.6.1.1.10.15.12 NAME 'organizationalUnitNameForm' OC organizationalUnit MUST ( ou ) )",
0N/A "nameForms: ( 1.3.6.1.1.10.15.13 NAME 'inetOrgPersonNameForm' OC inetOrgPerson MUST ( uid ) )",
0N/A "nameForms: ( 1.3.6.1.1.10.15.14 NAME 'groupOfNamesNameForm' OC groupOfNames MUST ( cn ) )"
0N/A );
0N/A String[] args = new String []
0N/A {
0N/A "-h", "127.0.0.1",
0N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
0N/A "-D","cn=directory manager",
0N/A "-w","password",
0N/A "-a",
1790N/A "-f", filePath
1790N/A };
1790N/A int err = LDAPModify.mainModify(args, false, null,null);
0N/A //Should delete the above entries.
0N/A assertEquals(err,0);
0N/A }
353N/A}