From d7258adb1d9a236f824c6cefe9b277db4e5f03e1 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 20 Oct 2015 13:07:36 +0000
Subject: [PATCH] Fixed random test in SchemaBackendTestCase: testRemoveAttributeTypeReferencedByNameForm() always failed when run after testRemoveObjectClassReferencedByNameForm() which does not properly cleanup schema changes.
---
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java | 1059 +++++++++++++++++++++-------------------------------------
1 files changed, 387 insertions(+), 672 deletions(-)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
index a69915c..11d7bca 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -32,7 +32,11 @@
import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
+import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.List;
import java.util.Map;
import org.forgerock.opendj.config.server.ConfigException;
@@ -42,31 +46,32 @@
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.util.Utils;
import org.opends.server.TestCaseUtils;
-import org.opends.server.core.*;
+import org.opends.server.core.AddOperation;
+import org.opends.server.core.DeleteOperationBasis;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ModifyDNOperationBasis;
+import org.opends.server.core.SchemaConfigManager;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.*;
+import org.opends.server.util.CollectionUtils;
+import org.opends.server.util.ServerConstants;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-/**
- * A set of test cases for the schema backend.
- */
+/** A set of test cases for the schema backend. */
@SuppressWarnings("javadoc")
public class SchemaBackendTestCase extends BackendTestCase
{
/** A reference to the schema backend. */
private SchemaBackend schemaBackend;
-
- /**
- * Ensures that the Directory Server is running and gets a reference to the
- * schema backend.
- */
+ /** Ensures that the Directory Server is running and gets a reference to the schema backend. */
@BeforeClass
public void startServer() throws Exception
{
@@ -76,8 +81,6 @@
assertNotNull(schemaBackend);
}
-
-
/**
* Tests the {@code initializeBackend} method by providing a null
* configuration entry.
@@ -93,8 +96,6 @@
schemaBackend.configureBackend(null, null);
}
-
-
/**
* Tests the {@code getEntry} method to ensure that it is able to retrieve
* the schema entry if it is given a valid entry DN.
@@ -123,8 +124,6 @@
assertTrue(schemaEntry.hasAttribute(t));
}
-
-
/**
* Tests the {@code getEntry} method to ensure that it is not able to retrieve
* anything when given an inappropriate DN.
@@ -144,8 +143,6 @@
assertNull(schemaEntry);
}
-
-
/**
* Tests the {@code getSchemaEntry} method to ensure that it is able to
* retrieve the appropriate information with different DNs.
@@ -173,7 +170,6 @@
t = DirectoryServer.getAttributeTypeOrNull("matchingrules");
assertTrue(schemaEntry.hasAttribute(t));
-
schemaDN = DN.valueOf("cn=subschema");
schemaEntry = schemaBackend.getSchemaEntry(schemaDN, false);
assertNotNull(schemaEntry);
@@ -192,8 +188,6 @@
assertTrue(schemaEntry.hasAttribute(t));
}
-
-
/**
* Tests the {@code entryExists} method with a valid schema DN.
*
@@ -207,8 +201,6 @@
assertTrue(schemaBackend.entryExists(schemaDN));
}
-
-
/**
* Tests the {@code entryExists} method with an invalid schema DN.
*
@@ -222,13 +214,8 @@
assertFalse(schemaBackend.entryExists(schemaDN));
}
-
-
- /**
- * Tests to ensure that the {@code addEntry} method always throws an
- * exception.
- */
- @Test(expectedExceptions = { DirectoryException.class })
+ /** Tests to ensure that the {@code addEntry} method always throws an exception. */
+ @Test(expectedExceptions = DirectoryException.class)
public void testAddEntry() throws Exception
{
Entry entry = createEntry(DN.valueOf("cn=schema"));
@@ -236,13 +223,8 @@
schemaBackend.addEntry(entry, addOperation);
}
-
-
- /**
- * Tests to ensure that the {@code deleteEntry} method always throws an
- * exception.
- */
- @Test(expectedExceptions = { DirectoryException.class })
+ /** Tests to ensure that the {@code deleteEntry} method always throws an exception. */
+ @Test(expectedExceptions = DirectoryException.class)
public void testDeleteEntry()
throws Exception
{
@@ -256,13 +238,8 @@
schemaBackend.deleteEntry(schemaDN, deleteOperation);
}
-
-
- /**
- * Tests to ensure that the {@code renameEntry} method always throws an
- * exception.
- */
- @Test(expectedExceptions = { DirectoryException.class })
+ /** Tests to ensure that the {@code renameEntry} method always throws an exception. */
+ @Test(expectedExceptions = DirectoryException.class)
public void testRenameEntry()
throws Exception
{
@@ -281,8 +258,6 @@
modifyDNOperation);
}
-
-
/**
* Performs a simple base-level search to verify that the schema entry is
* returned.
@@ -302,8 +277,6 @@
assertFalse(searchOperation.getSearchEntries().isEmpty());
}
-
-
/**
* Performs a simple single-level search to verify that nothing is returned.
*
@@ -321,8 +294,6 @@
assertTrue(searchOperation.getSearchEntries().isEmpty());
}
-
-
/**
* Performs a simple subtree search to verify that the schema entry is
* returned.
@@ -342,8 +313,6 @@
assertFalse(searchOperation.getSearchEntries().isEmpty());
}
-
-
/**
* Performs a simple subordinate subtree search to verify that nothing is
* returned.
@@ -363,8 +332,6 @@
assertTrue(searchOperation.getSearchEntries().isEmpty());
}
-
-
/**
* Performs a set of searches in the schema backend to ensure that they
* correctly set the matched DN in the response.
@@ -387,8 +354,6 @@
}
}
-
-
/**
* Tests the behavior of the schema backend with regard to the
* ds-cfg-show-all-attributes configuration.
@@ -429,8 +394,6 @@
assertTrue(schemaEntry.hasOperationalAttribute(s));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type that is not allowed to be altered.
@@ -441,17 +404,15 @@
public void testAddUnsupportedAttr()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClass",
"objectClass: extensibleObject");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type that is not allowed to be altered.
@@ -462,7 +423,7 @@
public void testRemoveUnsupportedAttr()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"delete: objectClass",
@@ -471,11 +432,9 @@
"add: objectClass",
"objectClass: extensibleObject");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove all
* attribute type definitions.
@@ -486,16 +445,14 @@
public void testRemoveAllAttributeTypes()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"delete: attributeTypes");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to replace all
* attribute types.
@@ -506,16 +463,14 @@
public void testReplaceAllAttributeTypes()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"replace: attributeTypes");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with a valid syntax and that isn't already defined.
@@ -526,7 +481,7 @@
public void testAddAttributeTypeSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -538,12 +493,10 @@
String attrName = "testaddattributetypesuccessful";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with a valid syntax (but using a textual OID rather than
@@ -555,7 +508,7 @@
public void testAddAttributeTypeSuccessfulNoOID()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -567,12 +520,10 @@
String attrName = "testaddattributetypesuccessfulnooid";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with a valid syntax (but using a textual OID rather than
@@ -584,7 +535,7 @@
public void testAddAttributeType()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -596,12 +547,10 @@
String attrName = "testaddattributetypenospacebeforeparenthesis";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type to a specific schema file.
@@ -612,7 +561,7 @@
public void testAddAttributeTypeToAltSchemaFile()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -629,13 +578,11 @@
"98-schema-test-attrtype.ldif");
assertFalse(schemaFile.exists());
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
assertTrue(schemaFile.exists());
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type in a manner that replaces an existing definition.
@@ -646,7 +593,7 @@
public void testAddAttributeTypeSuccessfulReplace()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -666,22 +613,10 @@
String attrName = "testaddattributetypesuccessfulreplace";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-J", "1.2.840.113556.1.4.1413",
- "-f", path
- };
-
- assertEquals(runModifyWithSystemErr(args), 0);
+ assertEquals(runModify(argsPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to replace an
* attribute type definition in a custom schema file.
@@ -692,7 +627,7 @@
public void testReplaceAttributeTypeInAltSchemaFile()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -717,23 +652,11 @@
"98-schema-test-replaceattrtype.ldif");
assertFalse(schemaFile.exists());
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-J", "1.2.840.113556.1.4.1413",
- "-f", path
- };
-
- assertEquals(runModifyWithSystemErr(args), 0);
+ assertEquals(runModify(argsPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
assertTrue(schemaFile.exists());
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type definition that can't be parsed.
@@ -744,17 +667,15 @@
public void testAddAttributeTypeInvalidSyntax()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
"attributeTypes: invalidsyntax");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with an undefined syntax.
@@ -765,7 +686,7 @@
public void testAddAttributeTypeUndefinedSyntax()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -774,11 +695,9 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.99999 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with an undefined equality matching rule.
@@ -789,7 +708,7 @@
public void testAddAttributeTypeUndefinedEMR()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -798,11 +717,9 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with an undefined ordering matching rule.
@@ -813,7 +730,7 @@
public void testAddAttributeTypeUndefinedOMR()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -822,11 +739,9 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with an undefined substring matching rule.
@@ -837,7 +752,7 @@
public void testAddAttributeTypeUndefinedSMR()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -846,11 +761,9 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with an undefined approximate matching rule.
@@ -861,7 +774,7 @@
public void testAddAttributeTypeUndefinedAMR()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -870,11 +783,9 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-APPROX 'xxxundefinedxxx' X-ORGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type with an invalid usage.
@@ -885,7 +796,7 @@
public void testAddAttributeTypeInvalidUsage()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -894,11 +805,9 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"USAGE xxxinvalidxxx X-ORGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type whose superior type is marked OBSOLETE in the server schema.
@@ -909,7 +818,7 @@
public void testAddAttributeTypeObsoleteSuperior()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -923,11 +832,9 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type whose equality matching rule is marked OBSOLETE in the
@@ -942,8 +849,7 @@
MatchingRule matchingRule = getMatchingRule("testAddATObsoleteEMRMatch", "1.3.6.1.4.1.26027.1.999.20", true);
DirectoryServer.registerMatchingRule(matchingRule, false);
-
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -953,11 +859,9 @@
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
"X-ORGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type that conflicts with multiple existing types.
@@ -968,7 +872,7 @@
public void testAddAttributeTypeMultipleConflicts()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -977,11 +881,9 @@
"1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " +
"'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* attribute type that references an undefined superior attribute type.
@@ -992,7 +894,7 @@
public void testAddAttributeTypeUndefinedSuperior()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -1001,12 +903,9 @@
"1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " +
"'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type that is defined in the server schema and does not have any
@@ -1018,7 +917,7 @@
public void testRemoveAttributeTypeSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -1038,12 +937,10 @@
String attrName = "testremoveattributetypesuccessful";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type and add it back in the same modification.
@@ -1054,7 +951,7 @@
public void testRemoveThenAddAttributeTypeSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -1080,12 +977,10 @@
String attrName = "testremoveattributetypesuccessful";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type that is not defined in the server schema.
@@ -1096,7 +991,7 @@
public void testRemoveAttributeTypeUndefined()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"delete: attributeTypes",
@@ -1108,11 +1003,9 @@
String attrName = "testremoveattributetypeundefined";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type that is referenced as the superior type for another
@@ -1124,7 +1017,7 @@
public void testRemoveSuperiorAttributeType()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"delete: attributeTypes",
@@ -1136,12 +1029,10 @@
String attrName = "name";
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type that is referenced by an existing objectclass.
@@ -1152,7 +1043,7 @@
public void testRemoveAttributeTypeReferencedByObjectClass()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"delete: attributeTypes",
@@ -1164,12 +1055,10 @@
String attrName = "uid";
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type that is referenced by an existing name form.
@@ -1180,44 +1069,64 @@
public void testRemoveAttributeTypeReferencedByNameForm()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String attrName = "testremoveattributetypereferencedbynf";
+ String modifyAttributeTypes = "attributeTypes: ( " + attrName + "-oid " +
+ "NAME '" + attrName + "' " +
+ "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
+ "X-ORIGIN 'SchemaBackendTestCase' )";
+ String modifyObjectClasses = "objectClasses: ( " + attrName + "oc-oid " +
+ "NAME '" + attrName + "OC' SUP top " +
+ "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')";
+ String modifyNameForms = "nameForms: ( " + attrName + "nf-oid " +
+ "NAME '" + attrName + "NF' " +
+ "OC " + attrName + "OC " +
+ "MUST " + attrName + " " +
+ "X-ORIGIN 'SchemaBackendTestCase' )";
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
- "attributeTypes: ( testremoveattributetypereferencedbynf-oid " +
- "NAME 'testRemoveAttributeTypeReferencedByNF' " +
- "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
- "X-ORIGIN 'SchemaBackendTestCase' )",
+ modifyAttributeTypes,
"-",
"add: objectClasses",
- "objectClasses: ( testremoveattributetypereferencedbynfoc-oid " +
- "NAME 'testRemoveAttributeTypeReferencedByNFOC' SUP top " +
- "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
+ modifyObjectClasses,
"-",
"add: nameForms",
- "nameForms: ( testremoveattributetypereferencedbynfnf-oid " +
- "NAME 'testRemoveAttributeTypeReferencedByNFNF' " +
- "OC testRemoveAttributeTypeReferencedByNFOC " +
- "MUST testRemoveAttributeTypeReferencedByNF " +
- "X-ORIGIN 'SchemaBackendTestCase' )",
- "",
+ modifyNameForms);
+
+ String ldif1 = toLdif(
"dn: cn=schema",
"changetype: modify",
"delete: attributeTypes",
- "attributeTypes: ( testremoveattributetypereferencedbynf-oid " +
- "NAME 'testRemoveAttributeTypeReferencedByNF' " +
- "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
- "X-ORIGIN 'SchemaBackendTestCase' )");
+ modifyAttributeTypes);
- String attrName = "testremoveattributetypereferencedbynf";
- assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
+ String ldif2 = toLdif(
+ "dn: cn=schema",
+ "changetype: modify",
+ "delete: nameForms",
+ modifyNameForms,
+ "-",
+ "delete: objectClasses",
+ modifyObjectClasses,
+ "-",
+ "delete: attributeTypes",
+ modifyAttributeTypes);
- assertNotEquals(runModify(standardArgs(path)), 0);
- assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
+ try
+ {
+ assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
+ assertEquals(runModify(argsNotPermissive(), ldif), 0);
+
+ assertNotEquals(runModify(argsNotPermissive(), ldif1), 0);
+ assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
+ }
+ finally
+ {
+ assertEquals(runModify(argsNotPermissive(), ldif2), 0);
+ assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
+ }
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type that is referenced by an existing DIT content rule.
@@ -1228,7 +1137,7 @@
public void testRemoveAttributeTypeReferencedByDCR()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -1259,12 +1168,10 @@
String attrName = "testremoveattributetypereferencedbydcr";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* attribute type that is referenced by an existing matching rule use.
@@ -1278,8 +1185,7 @@
MatchingRule matchingRule = getMatchingRule("testRemoveATRefByMRUMatch", "1.3.6.1.4.1.26027.1.999.17", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
-
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -1304,7 +1210,7 @@
String attrName = "testremoveatrefbymruat";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -1314,8 +1220,6 @@
assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that doesn't already exist, that has a valid superior class,
@@ -1327,7 +1231,7 @@
public void testAddObjectClassSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1338,12 +1242,10 @@
String ocName = "testaddobjectclasssuccessful";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that doesn't already exist, that has a textual OID rather than
@@ -1356,7 +1258,7 @@
public void testAddObjectClassSuccessfulNoOID()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1367,12 +1269,10 @@
String ocName = "testaddobjectclasssuccessfulnooid";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass to a specific schema file.
@@ -1383,7 +1283,7 @@
public void testAddObjectClassToAltSchemaFile()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1399,13 +1299,11 @@
"98-schema-test-oc.ldif");
assertFalse(schemaFile.exists());
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
assertTrue(schemaFile.exists());
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that already exists (i.e., a replace)
@@ -1416,7 +1314,7 @@
public void testAddObjectClassSuccessfulReplace()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1434,22 +1332,10 @@
String ocName = "testaddobjectclasssuccessfulreplace";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-J", "1.2.840.113556.1.4.1413",
- "-f", path
- };
-
- assertEquals(runModifyWithSystemErr(args), 0);
+ assertEquals(runModify(argsPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that conflicts with multiple existing objectclasses.
@@ -1460,7 +1346,7 @@
public void testAddObjectClassMultipleConflicts()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1472,12 +1358,10 @@
String ocName = "testaddobjectclassmultipleconflicts";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* existing objectclass definition and then add it back in the same operation
@@ -1489,7 +1373,7 @@
public void testRemoveThenAddAddObjectClassSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1513,12 +1397,10 @@
String ocName = "testremovethenaddobjectclasssuccessful";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass definition that can't be parsed.
@@ -1529,17 +1411,15 @@
public void testAddObjectClassInvalidSyntax()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
"objectClasses: invalidsyntax");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that references an undefined superior class.
@@ -1550,7 +1430,7 @@
public void testAddObjectClassUndefinedSuperiorClass()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1558,11 +1438,9 @@
"'testAddOCUndefinedSuperior' SUP undefined STRUCTURAL " +
"MUST cn X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that references an obsolete superior class.
@@ -1573,7 +1451,7 @@
public void testAddObjectClassObsoleteSuperiorClass()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1585,11 +1463,9 @@
"SUP testAddOCObsoleteSuperiorSup STRUCTURAL MUST cn " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that references an obsolete required attribute type.
@@ -1600,7 +1476,7 @@
public void testAddObjectClassObsoleteRequiredAttribute()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -1615,11 +1491,9 @@
"STRUCTURAL MUST testAddOCObsoleteRequiredAttrAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that references an obsolete optional attribute type.
@@ -1630,7 +1504,7 @@
public void testAddObjectClassObsoleteOptionalAttribute()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -1645,11 +1519,9 @@
"STRUCTURAL MAY testAddOCObsoleteOptionalAttrAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that references an undefined required attribute.
@@ -1660,7 +1532,7 @@
public void testAddObjectClassUndefinedRequiredAttribute()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1668,11 +1540,9 @@
"'testAddOCUndefinedRequired' SUP top STRUCTURAL " +
"MUST undefined X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that references an undefined required attribute when multiple
@@ -1684,7 +1554,7 @@
public void testAddObjectClassMultipleUndefinedRequiredAttribute()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1693,11 +1563,9 @@
"MUST ( cn $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that references an undefined optional attribute.
@@ -1708,7 +1576,7 @@
public void testAddObjectClassUndefinedOptionalAttribute()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1716,11 +1584,9 @@
"'testAddOCUndefinedOptional' SUP top STRUCTURAL " +
"MAY undefined X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* objectclass that references an undefined optional attribute when multiple
@@ -1732,7 +1598,7 @@
public void testAddObjectClassMultipleUndefinedOptionalAttribute()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1741,11 +1607,9 @@
"MAY ( cn $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* abstract objectclass whose superior class is not abstract.
@@ -1756,7 +1620,7 @@
public void testAddAbstractObjectClassWithNonAbstractSuperior()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1764,11 +1628,9 @@
"'testAddAbstractOCWithNonAbstractSuperior' SUP person " +
"ABSTRACT MAY description X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* auxiliary objectclass whose superior class is structural.
@@ -1779,7 +1641,7 @@
public void testAddAuxiliaryObjectClassWithStructuralSuperior()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1787,11 +1649,9 @@
"'testAddAuxiliaryOCWithStructuralSuperior' SUP person " +
"AUXILIARY MAY description X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* structural objectclass whose superior class is auxiliary.
@@ -1802,7 +1662,7 @@
public void testAddStructuralObjectClassWithAuxiliarySuperior()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1810,11 +1670,9 @@
"'testAddStructuralOCWithAuxiliarySuperior' SUP posixAccount " +
"STRUCTURAL MAY description X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* objectclass that exists and for which there are no dependencies.
@@ -1825,7 +1683,7 @@
public void testRemoveObjectClassSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1843,12 +1701,10 @@
String ocName = "testremoveobjectclasssuccessful";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* objectclass that is the superior class for another objectclass.
@@ -1859,7 +1715,7 @@
public void testRemoveSuperiorObjectClass()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"delete: objectClasses",
@@ -1870,12 +1726,10 @@
String ocName = "person";
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* objectclass that is referenced by an existing name form.
@@ -1883,49 +1737,54 @@
* @throws Exception If an unexpected problem occurs.
*/
@Test
- public void testRemoveObjectClassReferencedByNameForm()
- throws Exception
+ public void testRemoveObjectClassReferencedByNameForm() throws Exception
{
- String path = TestCaseUtils.createTempFile(
- "dn: cn=schema",
- "changetype: modify",
- "add: objectClasses",
- "objectClasses: ( testremoveobjectclassreferencedbynf-oid " +
- "NAME 'testRemoveObjectClassReferencedByNF' SUP top " +
- "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
- "-",
- "add: nameForms",
- "nameForms: ( testremoveattributetypereferencedbynfnf-oid " +
- "NAME 'testRemoveObjectClassReferencedByNFNF' " +
- "OC testRemoveObjectClassReferencedByNF MUST cn " +
- "X-ORIGIN 'SchemaBackendTestCase' )",
- "",
- "dn: cn=schema",
- "changetype: modify",
- "delete: objectClasses",
- "objectClasses: ( testremoveobjectclassreferencedbynf-oid " +
- "NAME 'testRemoveObjectClassReferencedByNF' SUP top " +
- "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')");
-
String ocName = "testremoveobjectclassreferencedbynf";
- assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
+ String modifyObjectClasses = "objectClasses: ( " + ocName + "-oid " +
+ "NAME '" + ocName + "' SUP top " +
+ "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')";
+ String modifyNameForms = "nameForms: ( testremoveattributetypereferencedbynfnf-oid " +
+ "NAME '" + ocName + "NF' " +
+ "OC " + ocName + " MUST cn " +
+ "X-ORIGIN 'SchemaBackendTestCase' )";
- String[] args =
+ String addOCThenNF = toLdif(
+ "dn: cn=schema",
+ "changetype: modify",
+ "add: objectClasses",
+ modifyObjectClasses,
+ "-",
+ "add: nameForms",
+ modifyNameForms);
+ String deleteOC = toLdif(
+ "dn: cn=schema",
+ "changetype: modify",
+ "delete: objectClasses",
+ modifyObjectClasses);
+ String deleteNFThenOC = toLdif(
+ "dn: cn=schema",
+ "changetype: modify",
+ "delete: nameForms",
+ modifyNameForms,
+ "-",
+ "delete: objectClasses",
+ modifyObjectClasses);
+
+ try
{
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-J", "1.2.840.113556.1.4.1413",
- "-f", path
- };
+ assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
+ assertEquals(runModify(argsPermissive(), addOCThenNF), 0);
- assertNotEquals(runModify(args), 0);
- assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
+ assertNotEquals(runModify(argsPermissive(), deleteOC), 0);
+ assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
+ }
+ finally
+ {
+ assertEquals(runModify(argsPermissive(), deleteNFThenOC), 0);
+ assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
+ }
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* objectclass that is referenced by an existing DIT content rule.
@@ -1936,7 +1795,7 @@
public void testRemoveObjectClassReferencedByDCR()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -1959,19 +1818,34 @@
String ocName = "testremoveobjectclassreferencedbydcr";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
}
- private String[] standardArgs(String path)
+ private String[] argsNotPermissive()
{
- return new String[] {
+ return args(false);
+ }
+
+ private String[] argsPermissive()
+ {
+ return args(true);
+ }
+
+ private String[] args(boolean usePermissiveModifyControl)
+ {
+ final List<String> args = CollectionUtils.newArrayList(
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-D", "cn=Directory Manager",
- "-w", "password",
- "-f", path
- };
+ "-w", "password"
+ );
+ if (usePermissiveModifyControl)
+ {
+ args.add("-J");
+ args.add(ServerConstants.OID_PERMISSIVE_MODIFY_CONTROL);
+ }
+ return args.toArray(new String[0]);
}
/**
@@ -1984,7 +1858,7 @@
public void testAddNameFormSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2001,12 +1875,10 @@
String nameFormName = "testaddnameformsuccessful";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form that doesn't already exist to an alternate schema file.
@@ -2017,7 +1889,7 @@
public void testAddNameFormToAltSchemaFile()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2039,13 +1911,11 @@
"98-schema-test-nameform.ldif");
assertFalse(schemaFile.exists());
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
assertTrue(schemaFile.exists());
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form that references a required attribute type not defined in the server
@@ -2057,7 +1927,7 @@
public void testAddNameFormWithUndefinedReqAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2074,12 +1944,10 @@
String nameFormName = "testaddnameformwithundefinedreqat";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form that references a required attribute type not defined in the server
@@ -2091,7 +1959,7 @@
public void testAddNameFormWithMultipleUndefinedReqAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2109,12 +1977,10 @@
String nameFormName = "testaddnameformwithmultipleundefinedreqat";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form that references an optional attribute type not defined in the server
@@ -2126,7 +1992,7 @@
public void testAddNameFormWithUndefinedOptAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2143,12 +2009,10 @@
String nameFormName = "testaddnameformwithundefinedoptat";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form that references an optional attribute type not defined in the server
@@ -2160,7 +2024,7 @@
public void testAddNameFormWithMultipleUndefinedOptAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2178,12 +2042,10 @@
String nameFormName = "testaddnameformwithmultipleundefinedoptat";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form whose structural objectclass is not defined in the server schema.
@@ -2194,7 +2056,7 @@
public void testAddNameFormWithUndefinedOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: nameForms",
@@ -2205,12 +2067,10 @@
String nameFormName = "testaddnameformwithundefinedoc";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form whose objectclass auxiliary rather than structural.
@@ -2221,7 +2081,7 @@
public void testAddNameFormWithAuxiliaryOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2238,12 +2098,10 @@
String nameFormName = "testaddnameformwithauxiliaryoc";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form whose structural objectclass is OBSOLETE rather than structural.
@@ -2254,7 +2112,7 @@
public void testAddNameFormWithObsoleteOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2271,12 +2129,10 @@
String nameFormName = "testaddnameformwithobsoleteoc";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form with a required attribute type that is declared OBSOLETE.
@@ -2287,7 +2143,7 @@
public void testAddNameFormWithObsoleteReqAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -2307,11 +2163,9 @@
"MUST testAddNFWithObsoleteReqATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form with an optional attribute type that is declared OBSOLETE.
@@ -2322,7 +2176,7 @@
public void testAddNameFormWithObsoleteOptAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -2342,11 +2196,9 @@
"MUST cn MAY testAddNFWithObsoleteOptATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new name
* form that references a structural objectclass already referenced by another
@@ -2358,7 +2210,7 @@
public void testAddNameFormOCConflict()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2383,12 +2235,10 @@
String nameFormName = "testaddnameformocconflict2";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertEquals(runModify(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* existing name form.
@@ -2399,7 +2249,7 @@
public void testRemoveNameFormSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2424,12 +2274,10 @@
String nameFormName = "testremovenameformsuccessful";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* existing name form and then add it back in the same operation.
@@ -2440,7 +2288,7 @@
public void testRemoveThenAddNameFormSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2471,12 +2319,10 @@
String nameFormName = "testremovethenaddnameformsuccessful";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove a name
* form that is referenced by a DIT structure rule.
@@ -2487,7 +2333,7 @@
public void testRemoveNameFormReferencedByDSR()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2518,12 +2364,10 @@
String nameFormName = "testremovenameformreferencedbydsrnf";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that doesn't already exist.
@@ -2534,7 +2378,7 @@
public void testAddDITContentRuleSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2550,7 +2394,7 @@
String ocName = "testaddditcontentrulesuccessfuloc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -2560,8 +2404,6 @@
assertTrue(dcr.hasName("testaddditcontentrulesuccessful"));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to replace an
* existing DIT content rule.
@@ -2572,7 +2414,7 @@
public void testReplaceDITContentRuleSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2592,20 +2434,10 @@
"NAME 'testReplaceDITContentRuleSuccessful' MAY sn " +
"NOT description X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-J", "1.2.840.113556.1.4.1413",
- "-f", path
- };
-
String ocName = "testreplaceditcontentrulesuccessfuloc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(runModifyWithSystemErr(args), 0);
+ assertEquals(runModify(argsPermissive(), ldif, System.err), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -2615,8 +2447,6 @@
assertTrue(dcr.hasName("testreplaceditcontentrulesuccessful"));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule to an alternate schema file.
@@ -2627,7 +2457,7 @@
public void testAddDITContentRuleToAltSchemaFile()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2649,7 +2479,7 @@
"98-schema-test-dcr.ldif");
assertFalse(schemaFile.exists());
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -2661,8 +2491,6 @@
assertTrue(schemaFile.exists());
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* existing DIT content rule and add it back in the same operation.
@@ -2673,7 +2501,7 @@
public void testRemoveThenAddDITContentRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2701,7 +2529,7 @@
String ocName = "testremovethenaddditcontentruleoc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -2711,8 +2539,6 @@
assertTrue(dcr.hasName("testremovethenaddditcontentrule"));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule whose structural objectclass is not defined in the schema.
@@ -2723,7 +2549,7 @@
public void testAddDITContentRuleUndefinedOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: ditContentRules",
@@ -2731,11 +2557,9 @@
"NAME 'testAddDITContentRuleUndefinedOC' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule whose structural objectclass is not actually structural.
@@ -2746,7 +2570,7 @@
public void testAddDITContentRuleAuxiliaryOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2759,11 +2583,9 @@
"NAME 'testAddDITContentRuleAuxiliaryOC' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule whose structural objectclass is OBSOLETE.
@@ -2774,7 +2596,7 @@
public void testAddDITContentRuleObsoleteOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2787,11 +2609,9 @@
"NAME 'testAddDITContentRuleObsoleteOC' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule whose structural objectclass is already referenced by an
@@ -2803,7 +2623,7 @@
public void testAddDITContentRuleConflictingOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2823,11 +2643,9 @@
"NAME 'testAddDITContentRuleConflictingOC2' NOT description " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule with an undefined auxiliary objectclass.
@@ -2838,7 +2656,7 @@
public void testAddDITContentRuleUndefinedAuxOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2851,11 +2669,9 @@
"NAME 'testAddDITContentRuleUndefinedAuxOC' " +
"AUX xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule with an undefined auxiliary objectclass when multiple
@@ -2867,7 +2683,7 @@
public void testAddDITContentRuleMultipleUndefinedAuxOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2881,11 +2697,9 @@
"AUX ( posixAccount $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule with an auxiliary objectclass that is not auxiliary.
@@ -2896,7 +2710,7 @@
public void testAddDITContentRuleAuxOCNotAux()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2909,11 +2723,9 @@
"NAME 'testAddDITContentRuleAuxOCNotAuxOC' " +
"AUX person X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule with an auxiliary objectclass that is not auxiliary when
@@ -2925,7 +2737,7 @@
public void testAddDITContentRuleMultipleAuxOCNotAux()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2939,11 +2751,9 @@
"AUX ( posixAccount $ person ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule with an auxiliary objectclass that is OBSOLETE.
@@ -2954,7 +2764,7 @@
public void testAddDITContentRuleObsoleteAuxOC()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2971,11 +2781,9 @@
"AUX testAddDITContentRuleObsoleteAuxOCAuxiliary " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that references an undefined required attribute type.
@@ -2986,7 +2794,7 @@
public void testAddDITContentRuleUndefinedReqAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -2999,11 +2807,9 @@
"NAME 'testAddDITContentRuleUndefinedReqAT' " +
"MUST xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that references an undefined required attribute type when
@@ -3015,7 +2821,7 @@
public void testAddDITContentRuleMultipleUndefinedReqAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3029,11 +2835,9 @@
"MUST ( cn $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that references an undefined optional attribute type.
@@ -3044,7 +2848,7 @@
public void testAddDITContentRuleUndefinedOptAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3057,11 +2861,9 @@
"NAME 'testAddDITContentRuleUndefinedOptAT' " +
"MAY xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that references an undefined optional attribute type when
@@ -3073,7 +2875,7 @@
public void testAddDITContentRuleMultipleUndefinedOptAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3087,11 +2889,9 @@
"MAY ( cn $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that references an undefined prohibited attribute type.
@@ -3102,7 +2902,7 @@
public void testAddDITContentRuleUndefinedNotAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3115,11 +2915,9 @@
"NAME 'testAddDITContentRuleUndefinedNotAT' " +
"NOT xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that references an undefined prohibited attribute type when
@@ -3131,7 +2929,7 @@
public void testAddDITContentRuleMultipleUndefinedNotAT()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3145,11 +2943,9 @@
"NOT ( description $ xxxundefinedxxx ) " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that prohibits an attribute type that is required by the
@@ -3161,7 +2957,7 @@
public void testAddDITContentRuleProhibitRequiredStructuralAttribute()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3174,11 +2970,9 @@
"NAME 'testAddDCRProhibitReqStructuralAT' " +
"NOT cn X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule that prohibits an attribute type that is required by an
@@ -3190,7 +2984,7 @@
public void testAddDITContentRuleProhibitRequiredAuxiliaryAttribute()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3203,11 +2997,9 @@
"NAME 'testAddDCRProhibitReqAuxiliaryAT' AUX posixAccount " +
"NOT uid X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule with an OBSOLETE required attribute type.
@@ -3218,7 +3010,7 @@
public void testAddDITContentRuleObsoleteRequiredAttributeType()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -3237,11 +3029,9 @@
"MUST testAddDCRObsoleteReqATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule with an OBSOLETE optional attribute type.
@@ -3252,7 +3042,7 @@
public void testAddDITContentRuleObsoleteOptionalAttributeType()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -3271,11 +3061,9 @@
"MAY testAddDCRObsoleteOptATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new DIT
* content rule with an OBSOLETE prohibited attribute type.
@@ -3286,7 +3074,7 @@
public void testAddDITContentRuleObsoleteProhibitedAttributeType()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -3305,11 +3093,9 @@
"NOT testAddDCRObsoleteNotATAT " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* existing DIT content rule.
@@ -3320,7 +3106,7 @@
public void testRemoveDITContentRuleSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3343,7 +3129,7 @@
String ocName = "testremoveditcontentrulesuccessfuloc";
assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
assertNotNull(oc);
@@ -3352,8 +3138,6 @@
assertNull(dcr);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* DIT structure rule.
@@ -3364,7 +3148,7 @@
public void testAddDITStructureRuleSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3387,12 +3171,10 @@
int ruleID = 999001;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to replace an
* existing DIT structure rule definition.
@@ -3403,7 +3185,7 @@
public void testReplaceDITStructureRuleSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3432,25 +3214,13 @@
"FORM testReplaceDITStructureRuleSuccessfulNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-J", "1.2.840.113556.1.4.1413",
- "-f", path
- };
-
int ruleID = 999002;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertEquals(runModifyWithSystemErr(args), 0);
+ assertEquals(runModify(argsPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* DIT structure rule to an alternate schema file.
@@ -3461,7 +3231,7 @@
public void testAddDITStructureRuleToAltSchemaFile()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3491,14 +3261,12 @@
"98-schema-test-dsr.ldif");
assertFalse(schemaFile.exists());
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
assertTrue(schemaFile.exists());
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* existing DIT structure rule definition and add it back in the same
@@ -3510,7 +3278,7 @@
public void testRemoveAndAddDITStructureRuleSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3548,12 +3316,10 @@
int ruleID = 999003;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* DIT structure rule with an undefined name form.
@@ -3564,7 +3330,7 @@
public void testAddDITStructureRuleUndefinedNameForm()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: ditStructureRules",
@@ -3576,12 +3342,10 @@
int ruleID = 999004;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* DIT structure rule that references an undefined superior rule.
@@ -3592,7 +3356,7 @@
public void testAddDITStructureRuleUndefinedSuperior()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3615,12 +3379,10 @@
int ruleID = 999005;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* DIT structure rule that references a name form which is OBSOLETE.
@@ -3631,7 +3393,7 @@
public void testAddDITStructureRuleObsoleteNameForm()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3651,11 +3413,9 @@
"FORM testAddDITStructureRuleObsoleteNameFormNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* DIT structure rule that references a superior rule which is OBSOLETE.
@@ -3666,7 +3426,7 @@
public void testAddDITStructureRuleObsoleteSuperiorRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3697,11 +3457,9 @@
"FORM testAddDITStructureRuleObsoleteSuperiorNF2 SUP 999012 " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* existing DIT structure rule definition.
@@ -3712,7 +3470,7 @@
public void testRemoveDITStructureRuleSuccessful()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3743,12 +3501,10 @@
int ruleID = 999006;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove an
* existing DIT structure rule definition which is the superior rule for
@@ -3760,7 +3516,7 @@
public void testRemoveSuperiorDITStructureRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -3802,11 +3558,10 @@
int ruleID = 999007;
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
-
- path = TestCaseUtils.createTempFile(
+ ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"delete: ditStructureRules",
@@ -3819,7 +3574,7 @@
"FORM testRemoveSuperiorDITStructureRuleNF " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
}
@@ -3849,7 +3604,7 @@
MatchingRule matchingRule = getMatchingRule("testAddMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.10", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -3859,7 +3614,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -3867,8 +3622,6 @@
assertTrue(mru.hasName("testaddmrusuccessful"));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* matching rule to an alternate schema file.
@@ -3882,8 +3635,7 @@
MatchingRule matchingRule = getMatchingRule("testAddMRUToAltSchemaFileMatch", "1.3.6.1.4.1.26027.1.999.18", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
-
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -3898,7 +3650,7 @@
"98-schema-test-mru.ldif");
assertFalse(schemaFile.exists());
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -3908,8 +3660,6 @@
assertTrue(schemaFile.exists());
}
-
-
/**
* Tests the behavior of the schema backend when attempting to replace an
* existing matching rule use.
@@ -3923,7 +3673,7 @@
MatchingRule matchingRule = getMatchingRule("testReplaceMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.11", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -3940,26 +3690,13 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- String[] args =
- {
- "-h", "127.0.0.1",
- "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
- "-D", "cn=Directory Manager",
- "-w", "password",
- "-J", "1.2.840.113556.1.4.1413",
- "-f", path
- };
+ assertEquals(runModify(argsPermissive(), ldif, System.err), 0);
- assertEquals(runModifyWithSystemErr(args), 0);
-
- MatchingRuleUse mru =
- DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
+ MatchingRuleUse mru = DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
assertNotNull(mru);
assertTrue(mru.hasName("testreplacemrusuccessful"));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to remove and
* re-add an existing matching rule use in the same operation.
@@ -3973,8 +3710,7 @@
MatchingRule matchingRule = getMatchingRule("testRemoveAndAddMRUMatch", "1.3.6.1.4.1.26027.1.999.12", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
-
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -3996,7 +3732,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -4018,7 +3754,7 @@
MatchingRule matchingRule = getMatchingRule("testAddMRUMRConflictMatch", "1.3.6.1.4.1.26027.1.999.14", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -4035,7 +3771,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
@@ -4043,8 +3779,6 @@
assertTrue(mru.hasName("testaddmrumrconflict"));
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* matching rule use that references an undefined matching rule.
@@ -4055,7 +3789,7 @@
public void testAddMatchingRuleUseMRUndefined()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -4063,7 +3797,7 @@
"NAME 'testAddMRUMRUndefined' APPLIES cn " +
"X-ORIGIN 'SchemaBackendTestCase' )");
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
/**
@@ -4079,8 +3813,7 @@
MatchingRule matchingRule = getMatchingRule("testAddMRUATUndefinedMatch", "1.3.6.1.4.1.26027.1.999.16", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
-
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -4091,11 +3824,9 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* matching rule use that references an undefined attribute type.
@@ -4110,7 +3841,7 @@
getMatchingRule("testAddMRUATMultipleUndefinedMatch", "1.3.6.1.4.1.26027.1.999.19", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -4121,7 +3852,7 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
/**
@@ -4137,7 +3868,7 @@
MatchingRule matchingRule = getMatchingRule("testAddMRUObsoleteMRMatch", "1.3.6.1.4.1.26027.1.999.21", true);
DirectoryServer.registerMatchingRule(matchingRule, false);
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -4147,11 +3878,9 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add a new
* matching rule with an associated attribute type that is marked OBSOLETE.
@@ -4165,7 +3894,7 @@
MatchingRule matchingRule = getMatchingRule("testAddMRUObsoleteATMatch", "1.3.6.1.4.1.26027.1.999.22", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -4180,12 +3909,31 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- assertNotEquals(runModify(standardArgs(path)), 0);
+ assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
}
- private int runModify(String[] args)
+ private int runModify(String[] args, String ldifContent)
{
- return LDAPModify.mainModify(args, false, null, null);
+ return runModify(args, ldifContent, null);
+ }
+
+ private int runModify(String[] args, String ldifContent, PrintStream stderr)
+ {
+ final InputStream stdin = System.in;
+ try
+ {
+ System.setIn(new ByteArrayInputStream(ldifContent.getBytes()));
+ return LDAPModify.mainModify(args, false, null, stderr);
+ }
+ finally
+ {
+ System.setIn(stdin);
+ }
+ }
+
+ private String toLdif(Object... ldifLines)
+ {
+ return Utils.joinAsString("\n", ldifLines);
}
/**
@@ -4201,7 +3949,7 @@
MatchingRule matchingRule = getMatchingRule("testRemoveMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.13", false);
DirectoryServer.registerMatchingRule(matchingRule, false);
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: matchingRuleUse",
@@ -4218,15 +3966,13 @@
assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
MatchingRuleUse mru =
DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
assertNull(mru);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add another
* value to attributeTypes that matches an existing one using the correct
@@ -4238,7 +3984,7 @@
public void testAttributeTypesMatchingRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -4258,11 +4004,9 @@
String attrName = "testattributetypesmatchingrule";
assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add another
* value to objectClasses that matches an existing one using the correct
@@ -4274,7 +4018,7 @@
public void testObjectClassesMatchingRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -4294,11 +4038,9 @@
String objectClassName = "testobjectclassesmatchingrule";
assertFalse(DirectoryServer.getSchema().hasObjectClass(objectClassName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add another
* value to nameForms that matches an existing one using the correct
@@ -4310,7 +4052,7 @@
public void testNameFormsMatchingRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -4338,11 +4080,9 @@
String nameFormName = "testnameformsmatchingrule";
assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add another
* value to dITContentRules that matches an existing one using the correct
@@ -4354,7 +4094,7 @@
public void testDitContentRulesMatchingRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -4382,11 +4122,9 @@
String objectClassName = "testditcontentrulesmatchingruleoc";
assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add another
* value to dITStructureRules that matches an existing one using the correct
@@ -4398,7 +4136,7 @@
public void testDitStructureRulesMatchingRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -4450,11 +4188,9 @@
String objectClassName = "testditcontentrulesmatchingruleoc1";
assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20);
}
-
-
/**
* Tests the behavior of the schema backend when attempting to add another
* value to matchingRuleUse that matches an existing one using the correct
@@ -4466,7 +4202,7 @@
public void testMatchingRuleUseMatchingRule()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -4502,11 +4238,9 @@
String attrName = "testmatchingruleusematchingruleat1";
assertNull(DirectoryServer.getSchema().getAttributeType(attrName));
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 20);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20);
}
-
-
/**
* This test case covers the problem identified in issue #1318. In that
* issue, a problem arose if the following elements occurred in the following
@@ -4534,7 +4268,7 @@
public void testRemoveAndAddObjectClassIssue1318()
throws Exception
{
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: objectClasses",
@@ -4552,7 +4286,7 @@
"objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " +
"MUST testIssue1381AT )");
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
}
/**
@@ -4582,7 +4316,7 @@
ByteString oldMTValue =
schemaEntry.getAttribute(mtType).get(0).iterator().next();
- String path = TestCaseUtils.createTempFile(
+ String ldif = toLdif(
"dn: cn=schema",
"changetype: modify",
"add: attributeTypes",
@@ -4594,7 +4328,7 @@
// Sleep longer than the TimeThread delay to ensure the modifytimestamp
// will be different.
Thread.sleep(6000);
- assertEquals(runModifyWithSystemErr(standardArgs(path)), 0);
+ assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
schemaEntry = DirectoryServer.getEntry(DN.valueOf("cn=schema"));
assertNotNull(schemaEntry);
@@ -4608,11 +4342,6 @@
assertNotEquals(oldMTValue, newMTValue);
}
- private int runModifyWithSystemErr(String[] args)
- {
- return LDAPModify.mainModify(args, false, null, System.err);
- }
-
/**
* Tests the ability to properly handle adding and removing a schema
* definition in which the definition has extra spaces. This was added as a
@@ -4653,8 +4382,6 @@
"testaddanddeletedefinitionwithextraspaces-oid"));
}
-
-
/**
* Tests the {@code exportLDIF} method with a valid configuration.
*
@@ -4676,8 +4403,6 @@
assertTrue(tempFile.length() > 0);
}
-
-
/**
* Tests the {@code importLDIF} method to ensure that it throws an exception.
*
@@ -4699,8 +4424,6 @@
schemaBackend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
}
-
-
/**
* Tests the {@code getComponentEntryDN} method.
*
@@ -4714,22 +4437,14 @@
assertEquals(schemaBackend.getComponentEntryDN(), configEntryDN);
}
-
-
- /**
- * Tests the {@code getClassName} method.
- */
+ /** Tests the {@code getClassName} method. */
@Test
public void testGetClassName()
{
assertEquals(schemaBackend.getClassName(), SchemaBackend.class.getName());
}
-
-
- /**
- * Tests the {@code getAlerts} method.
- */
+ /** Tests the {@code getAlerts} method. */
@Test
public void testGetAlerts()
{
--
Gitblit v1.10.0