| | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.AdminTestCase; |
| | | import org.opends.server.admin.LDAPProfile; |
| | | import org.opends.server.admin.MockLDAPProfile; |
| | | import org.opends.server.admin.TestCfg; |
| | | import org.opends.server.admin.TestChildCfg; |
| | | import org.opends.server.admin.TestChildCfgDefn; |
| | | import org.opends.server.admin.TestParentCfg; |
| | | import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | |
| | | private static final String[] TEST_CHILD_1 = new String[] { |
| | | "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-child-dummy", |
| | | "cn: test child 1", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | |
| | | // optional-multi-valued-dn-property. |
| | | "dn: cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | | "objectclass: ds-cfg-virtual-attribute", |
| | | "objectclass: ds-cfg-test-parent-dummy", |
| | | "cn: test parent 1", |
| | | "ds-cfg-virtual-attribute-enabled: true", |
| | | "ds-cfg-virtual-attribute-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider", |
| | |
| | | // This test suite depends on having the schema available, so |
| | | // we'll start the server. |
| | | TestCaseUtils.startServer(); |
| | | LDAPProfile.getInstance().pushWrapper(new MockLDAPProfile()); |
| | | TestCfg.setUp(); |
| | | |
| | | // Add test managed objects. |
| | | TestCaseUtils.addEntries(TEST_LDIF); |
| | |
| | | */ |
| | | @AfterClass |
| | | public void tearDown() throws Exception { |
| | | LDAPProfile.getInstance().popWrapper(); |
| | | TestCfg.cleanup(); |
| | | |
| | | // Remove test entries. |
| | |
| | | parent.addTestChildAddListener(listener); |
| | | |
| | | MockConstraint constraint = new MockConstraint(true, false, false); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | try { |
| | |
| | | } |
| | | } |
| | | } finally { |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | parent.removeTestChildAddListener(listener); |
| | | } |
| | | } |
| | |
| | | parent.addTestChildAddListener(listener); |
| | | |
| | | MockConstraint constraint = new MockConstraint(false, true, true); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | try { |
| | |
| | | } |
| | | } |
| | | } finally { |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | parent.removeTestChildAddListener(listener); |
| | | } |
| | | } |
| | |
| | | parent.addTestChildDeleteListener(listener); |
| | | |
| | | MockConstraint constraint = new MockConstraint(false, false, true); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | // Add the entry. |
| | |
| | | // Now delete it - this should trigger the constraint. |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } finally { |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | parent.removeTestChildDeleteListener(listener); |
| | | |
| | | try { |
| | |
| | | parent.addTestChildDeleteListener(listener); |
| | | |
| | | MockConstraint constraint = new MockConstraint(true, true, false); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | // Add the entry. |
| | |
| | | // Ignore - this is the expected exception. |
| | | } |
| | | } finally { |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | parent.removeTestChildDeleteListener(listener); |
| | | |
| | | try { |
| | |
| | | TestParentCfg parent = getParent("test parent 1"); |
| | | |
| | | MockConstraint constraint = new MockConstraint(false, true, false); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | // Add the entry. |
| | |
| | | int result = TestCaseUtils.applyModifications(changes); |
| | | Assert.assertEquals(result, ResultCode.SUCCESS.getIntValue()); |
| | | } finally { |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | try { |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |
| | |
| | | TestParentCfg parent = getParent("test parent 1"); |
| | | |
| | | MockConstraint constraint = new MockConstraint(true, false, true); |
| | | TestChildCfgDefn.getInstance().addConstraint(constraint); |
| | | TestCfg.addConstraint(constraint); |
| | | |
| | | try { |
| | | // Add the entry. |
| | |
| | | Assert |
| | | .assertEquals(result, ResultCode.UNWILLING_TO_PERFORM.getIntValue()); |
| | | } finally { |
| | | TestChildCfgDefn.getInstance().removeConstraint(constraint); |
| | | TestCfg.removeConstraint(constraint); |
| | | try { |
| | | deleteSubtree(TEST_CHILD_1_DN); |
| | | } catch (Exception e) { |