From 54b7ec929a3d3c311cc6e80e2d749170b10f02dc Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 30 May 2016 10:43:13 +0000
Subject: [PATCH] OPENDJ-2987 Remove server TestObjectClass and TestCommonSchemaElements Port all missing tests to SDK ObjectClassTestCase

---
 /dev/null                                                                           | 1610 --------------------------------------
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ObjectClassTestCase.java |  868 ++++++++++++++++++++
 2 files changed, 866 insertions(+), 1,612 deletions(-)

diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ObjectClassTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ObjectClassTestCase.java
index 06cf204..8c923a7 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ObjectClassTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ObjectClassTestCase.java
@@ -15,10 +15,15 @@
  */
 package org.forgerock.opendj.ldap.schema;
 
+import static org.forgerock.opendj.ldap.schema.SchemaConstants.EXTENSIBLE_OBJECT_OBJECTCLASS_OID;
+import static org.forgerock.opendj.ldap.schema.SchemaConstants.TOP_OBJECTCLASS_OID;
+import static org.forgerock.opendj.ldap.schema.Schema.getCoreSchema;
 import static org.fest.assertions.Assertions.*;
-import static org.forgerock.opendj.ldap.schema.Schema.*;
-import static org.forgerock.opendj.ldap.schema.SchemaConstants.*;
 
+import java.util.Set;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 @SuppressWarnings("javadoc")
@@ -47,4 +52,863 @@
         assertThat(extensibleObject.isOptional(cn)).isTrue();
         assertThat(extensibleObject.isRequiredOrOptional(cn)).isTrue();
     }
+
+    @Test
+    public void testNames() throws Exception {
+        ObjectClass oc = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType", "testNameAlias", "anotherNameAlias")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+
+        assertThat(oc.hasName("testType")).isTrue();
+        assertThat(oc.hasName("testNameAlias")).isTrue();
+        assertThat(oc.hasName("anotherNameAlias")).isTrue();
+        assertThat(oc.hasName("unknownAlias")).isFalse();
+        assertThat(oc.getNames()).containsOnly("testType", "testNameAlias", "anotherNameAlias");
+    }
+
+    @Test
+    public void testNameOrOIDReturnsOIDWhenNoName() throws Exception {
+        ObjectClass oc = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+
+        assertThat(oc.getNameOrOID()).isEqualTo("1.2.3");
+    }
+
+    @Test
+    public void testNameOrOIDReturnsPrimaryNameWhenOneOrMoreNames() throws Exception {
+        ObjectClass oc1 = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+        ObjectClass oc2 = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType", "testAlias")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+
+        assertThat(oc1.getNameOrOID()).isEqualTo("testType");
+        assertThat(oc2.getNameOrOID()).isEqualTo("testType");
+    }
+
+    @DataProvider
+    public final Object[][] equalsData() {
+        return new Object[][] {
+            // name1 and oid1 for first object class, name2 and oid2 for second object class, should be equal ?
+            { "testType", "1.2.3", "testType", "1.2.3", true },
+            { "testType", "1.2.3", "xxx", "1.2.3", true },
+            { "testType", "1.2.3", "testType", "1.2.4", false },
+            { "testType", "1.2.3", "xxx", "1.2.4", false } };
+    }
+
+    @Test(dataProvider = "equalsData")
+    public final void testEquals(String name1, String oid1, String name2, String oid2, boolean shouldBeEqual)
+            throws Exception {
+        ObjectClass oc1 = new SchemaBuilder(schema())
+            .buildObjectClass(oid1)
+            .names(name1)
+            .addToSchema().toSchema().getObjectClass(oid1);
+        ObjectClass oc2 = new SchemaBuilder(schema())
+            .buildObjectClass(oid2)
+            .names(name2)
+            .addToSchema().toSchema().getObjectClass(oid2);
+
+        if (shouldBeEqual) {
+            assertThat(oc1).isEqualTo(oc2);
+            assertThat(oc2).isEqualTo(oc1);
+        } else {
+            assertThat(oc1).isNotEqualTo(oc2);
+            assertThat(oc2).isNotEqualTo(oc1);
+        }
+    }
+
+    @Test
+    public void testGetOptionalAttributesNoSuperiorEmpty() throws Exception {
+        final ObjectClass.Builder ocBuilder = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType");
+        ObjectClass oc = ocBuilder.addToSchema().toSchema().getObjectClass("1.2.3");
+        assertThat(oc.getOptionalAttributes()).isEmpty();
+    }
+
+    @Test
+    public void testGetOptionalAttributesNoSuperior() throws Exception {
+        Schema schema = schema();
+        ObjectClass oc = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType")
+            .optionalAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+
+        Set<AttributeType> attributes = oc.getOptionalAttributes();
+        assertThat(attributes).containsOnly(attrs(schema, "at1", "at2", "at3"));
+    }
+
+    @Test
+    public void testGetOptionalAttributeOneSuperiorEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .optionalAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getOptionalAttributes();
+        assertThat(attributes).containsOnly(attrs(schema, "at1", "at2", "at3"));
+    }
+
+    @Test
+    public void testGetOptionalAttributeMultipleSuperiorsEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent1")
+            .optionalAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("parent2")
+            .optionalAttributes("at4", "at5", "at6")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.3")
+            .names("child")
+            .superiorObjectClasses("parent1", "parent2")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getOptionalAttributes();
+        assertThat(attributes).containsOnly(attrs(schema, "at1", "at2", "at3", "at4", "at5", "at6"));
+    }
+
+    @Test
+    public void testGetOptionalAttributeOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .optionalAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .optionalAttributes("at4", "at5", "at6")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getOptionalAttributes();
+        assertThat(attributes).containsOnly(attrs(schema, "at1", "at2", "at3", "at4", "at5", "at6"));
+    }
+
+    @Test
+    public void testGetOptionalAttributeMultipleSuperiors() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent1")
+            .optionalAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("parent2")
+            .optionalAttributes("at4", "at5", "at6")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.3")
+            .names("child")
+            .optionalAttributes("at7", "at8", "at9")
+            .superiorObjectClasses("parent1", "parent2")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getOptionalAttributes();
+        assertThat(attributes).containsOnly(
+                attrs(schema, "at1", "at2", "at3", "at4", "at5", "at6", "at7", "at8", "at9"));
+    }
+
+    @Test
+    public void testGetDeclaredOptionalAttributesNoSuperiorEmpty() throws Exception {
+        final ObjectClass.Builder ocBuilder = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType");
+        ObjectClass oc = ocBuilder.addToSchema().toSchema().getObjectClass("1.2.3");
+        assertThat(oc.getDeclaredOptionalAttributes()).isEmpty();
+    }
+
+    @Test
+    public void testGetDeclaredOptionalAttributesNoSuperior() throws Exception {
+        Schema schema = schema();
+        ObjectClass oc = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType")
+            .optionalAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+
+        Set<AttributeType> attributes = oc.getDeclaredOptionalAttributes();
+        assertThat(attributes).containsOnly((attrs(schema, "at1", "at2", "at3")));
+    }
+
+    @Test
+    public void testGetDeclaredOptionalAttributeOneSuperiorEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .optionalAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        assertThat(child.getDeclaredOptionalAttributes()).isEmpty();
+    }
+
+    @Test
+    public void testGetDeclaredOptionalAttributeOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .optionalAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .optionalAttributes("at4", "at5", "at6")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getDeclaredOptionalAttributes();
+        assertThat(attributes).containsOnly((attrs(schema, "at4", "at5", "at6")));
+    }
+
+    @Test
+    public void testGetRequiredAttributesNoSuperiorEmpty() throws Exception {
+        final ObjectClass.Builder ocBuilder = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType");
+        ObjectClass oc = ocBuilder.addToSchema().toSchema().getObjectClass("1.2.3");
+        assertThat(oc.getRequiredAttributes()).isEmpty();
+    }
+
+    @Test
+    public void testGetRequiredAttributesNoSuperior() throws Exception {
+        Schema schema = schema();
+        ObjectClass oc = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType")
+            .requiredAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+
+        Set<AttributeType> attributes = oc.getRequiredAttributes();
+        assertThat(attributes).containsOnly((attrs(schema, "at1", "at2", "at3")));
+    }
+
+    @Test
+    public void testGetRequiredAttributeOneSuperiorEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .requiredAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getRequiredAttributes();
+        assertThat(attributes).containsOnly((attrs(schema, "at1", "at2", "at3")));
+    }
+
+    @Test
+    public void testGetRequiredAttributeMultipleSuperiorsEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent1")
+            .requiredAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("parent2")
+            .requiredAttributes("at4", "at5", "at6")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.3")
+            .names("child")
+            .superiorObjectClasses("parent1", "parent2")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getRequiredAttributes();
+        assertThat(attributes).containsOnly((attrs(schema, "at1", "at2", "at3", "at4", "at5", "at6")));
+    }
+
+    @Test
+    public void testGetRequiredAttributeOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .requiredAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .requiredAttributes("at4", "at5", "at6")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getRequiredAttributes();
+        assertThat(attributes).containsOnly(attrs(schema, "at1", "at2", "at3", "at4", "at5", "at6"));
+    }
+
+    @Test
+    public void testGetRequiredAttributeMultipleSuperiors() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent1")
+            .requiredAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("parent2")
+            .requiredAttributes("at4", "at5", "at6")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.3")
+            .names("child")
+            .requiredAttributes("at7", "at8", "at9")
+            .superiorObjectClasses("parent1", "parent2")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getRequiredAttributes();
+        assertThat(attributes).containsOnly(
+                attrs(schema, "at1", "at2", "at3", "at4", "at5", "at6", "at7", "at8", "at9"));
+    }
+
+    @Test
+    public void testGetDeclaredRequiredAttributesNoSuperiorEmpty() throws Exception {
+        final ObjectClass.Builder ocBuilder = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType");
+        ObjectClass oc = ocBuilder.addToSchema().toSchema().getObjectClass("1.2.3");
+        assertThat(oc.getDeclaredRequiredAttributes()).isEmpty();
+    }
+
+    @Test
+    public void testGetDeclaredRequiredAttributesNoSuperior() throws Exception {
+        Schema schema = schema();
+        ObjectClass oc = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType")
+            .requiredAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+
+        Set<AttributeType> attributes = oc.getDeclaredRequiredAttributes();
+        assertThat(attributes).containsOnly(attrs(schema, "at1", "at2", "at3"));
+    }
+
+    @Test
+    public void testGetDeclaredRequiredAttributeOneSuperiorEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .requiredAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        assertThat(child.getDeclaredRequiredAttributes()).isEmpty();
+    }
+
+    @Test
+    public void testGetDeclaredRequiredAttributeOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .requiredAttributes("at1", "at2", "at3")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .requiredAttributes("at4", "at5", "at6")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Set<AttributeType> attributes = child.getDeclaredRequiredAttributes();
+        assertThat(attributes).containsOnly(attrs(schema, "at4", "at5", "at6"));
+    }
+
+    @Test
+    public void testGetSuperiorClassNoSuperiorDefined() throws Exception {
+        Schema schema = schema();
+        ObjectClass oc = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3")
+            .names("testType")
+            .addToSchema().toSchema().getObjectClass("1.2.3");
+
+        // top should be added to superior classes
+        assertThat(oc.getSuperiorClasses()).containsOnly(schema.getObjectClass(TOP_OBJECTCLASS_OID));
+        // toString() should return the initial definition, without top
+        assertThat(oc.toString()).isEqualTo("( 1.2.3 NAME 'testType' )");
+    }
+
+    @Test
+    public void testGetSuperiorClassWithSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        assertThat(child.getSuperiorClasses()).containsOnly(objectClasses(schema, "parent"));
+        assertThat(child.toString()).isEqualTo("( 1.2.3.2 NAME 'child' SUP parent )");
+    }
+
+    @Test
+    public void testGetSuperiorClassWithMultipleSuperiors() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent1")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("parent2")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.3")
+            .names("child")
+            .superiorObjectClasses("parent1", "parent2")
+            .addToSchema().toSchema();
+
+        ObjectClass child = schema.getObjectClass("child");
+        assertThat(child.getSuperiorClasses()).containsOnly(objectClasses(schema, "parent1", "parent2"));
+    }
+
+    @Test
+    public void testIsDescendantOfNoSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("testType1")
+            .addToSchema().toSchema();
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("testType2")
+            .addToSchema().toSchema();
+        ObjectClass testType1 = schema.getObjectClass("testType1");
+        ObjectClass testType2 = schema.getObjectClass("testType2");
+
+        assertThat(testType1.isDescendantOf(testType2)).isFalse();
+        assertThat(testType1.isDescendantOf(schema.getObjectClass(TOP_OBJECTCLASS_OID))).isTrue();
+    }
+
+    @Test
+    public void testIsDescendantOfWithSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("grandParent")
+            .addToSchema().toSchema();
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("parent")
+            .superiorObjectClasses("grandParent")
+            .addToSchema().toSchema();
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.3")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass grandParent = schema.getObjectClass("grandParent");
+        ObjectClass parent = schema.getObjectClass("parent");
+        ObjectClass child = schema.getObjectClass("child");
+
+        Assert.assertTrue(parent.isDescendantOf(grandParent));
+        Assert.assertTrue(child.isDescendantOf(parent));
+        Assert.assertTrue(child.isDescendantOf(grandParent));
+
+        Assert.assertFalse(child.isDescendantOf(child));
+        Assert.assertFalse(parent.isDescendantOf(child));
+        Assert.assertFalse(grandParent.isDescendantOf(child));
+    }
+
+    @Test
+    public void testIsDescendantOfWithMultipleSuperiors() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("grandParent")
+            .addToSchema().toSchema();
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("parent1")
+            .superiorObjectClasses("grandParent")
+            .addToSchema().toSchema();
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.3")
+            .names("parent2")
+            .addToSchema().toSchema();
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.4")
+            .names("child")
+            .superiorObjectClasses("parent1", "parent2")
+            .addToSchema().toSchema();
+        ObjectClass grandParent = schema.getObjectClass("grandParent");
+        ObjectClass parent1 = schema.getObjectClass("parent1");
+        ObjectClass parent2 = schema.getObjectClass("parent2");
+        ObjectClass child = schema.getObjectClass("child");
+
+        Assert.assertTrue(parent1.isDescendantOf(grandParent));
+        Assert.assertTrue(child.isDescendantOf(parent1));
+        Assert.assertTrue(child.isDescendantOf(parent2));
+        Assert.assertTrue(child.isDescendantOf(grandParent));
+
+        Assert.assertFalse(child.isDescendantOf(child));
+        Assert.assertFalse(parent1.isDescendantOf(child));
+        Assert.assertFalse(parent1.isDescendantOf(parent2));
+        Assert.assertFalse(parent2.isDescendantOf(grandParent));
+        Assert.assertFalse(grandParent.isDescendantOf(child));
+    }
+
+    @Test
+    public void testIsOptionalEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("testType")
+            .addToSchema().toSchema();
+        ObjectClass oc = schema.getObjectClass("testType");
+
+        Assert.assertFalse(oc.isOptional(schema.getAttributeType("at1")));
+    }
+
+    @Test
+    public void testIsOptionalNoSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("testType")
+            .optionalAttributes("at1")
+            .addToSchema().toSchema();
+        ObjectClass oc = schema.getObjectClass("testType");
+
+        Assert.assertTrue(oc.isOptional(schema.getAttributeType("at1")));
+        Assert.assertFalse(oc.isOptional(schema.getAttributeType("at2")));
+    }
+
+    @Test
+    public void testIsOptionalEmptyWithOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .optionalAttributes("at1")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Assert.assertTrue(child.isOptional(schema.getAttributeType("at1")));
+        Assert.assertFalse(child.isOptional(schema.getAttributeType("at2")));
+    }
+
+    @Test
+    public void testIsOptionalWithOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .optionalAttributes("at1")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .optionalAttributes("at2")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Assert.assertTrue(child.isOptional(schema.getAttributeType("at1")));
+        Assert.assertTrue(child.isOptional(schema.getAttributeType("at2")));
+        Assert.assertFalse(child.isOptional(schema.getAttributeType("at3")));
+    }
+
+    @Test
+    public void testIsOptionalExtensible() throws Exception {
+        Schema schema = schema();
+        ObjectClass oc = schema.getObjectClass(EXTENSIBLE_OBJECT_OBJECTCLASS_OID);
+
+        Assert.assertTrue(oc.isOptional(schema.getAttributeType("at1")));
+        Assert.assertTrue(oc.isOptional(schema.getAttributeType("at2")));
+    }
+
+    @Test
+    public void testIsRequiredEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("testType")
+            .addToSchema().toSchema();
+        ObjectClass oc = schema.getObjectClass("testType");
+
+        Assert.assertFalse(oc.isRequired(schema.getAttributeType("at1")));
+    }
+
+    @Test
+    public void testIsRequiredNoSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("testType")
+            .requiredAttributes("at1")
+            .addToSchema().toSchema();
+        ObjectClass oc = schema.getObjectClass("testType");
+
+        Assert.assertTrue(oc.isRequired(schema.getAttributeType("at1")));
+        Assert.assertFalse(oc.isRequired(schema.getAttributeType("at2")));
+    }
+
+    @Test
+    public void testIsRequiredEmptyWithOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .requiredAttributes("at1")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Assert.assertTrue(child.isRequired(schema.getAttributeType("at1")));
+        Assert.assertFalse(child.isRequired(schema.getAttributeType("at2")));
+    }
+
+    @Test
+    public void testIsRequiredWithOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .requiredAttributes("at1")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .requiredAttributes("at2")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Assert.assertTrue(child.isRequired(schema.getAttributeType("at1")));
+        Assert.assertTrue(child.isRequired(schema.getAttributeType("at2")));
+        Assert.assertFalse(child.isRequired(schema.getAttributeType("at3")));
+    }
+
+    @Test
+    public void testIsRequiredOrOptionalEmpty() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("testType")
+            .addToSchema().toSchema();
+        ObjectClass oc = schema.getObjectClass("testType");
+
+        Assert.assertFalse(oc.isRequiredOrOptional(schema.getAttributeType("at1")));
+    }
+
+    @Test
+    public void testIsRequiredOrOptionalNoSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("testType")
+            .requiredAttributes("at1")
+            .optionalAttributes("at2")
+            .addToSchema().toSchema();
+        ObjectClass oc = schema.getObjectClass("testType");
+
+        Assert.assertTrue(oc.isRequiredOrOptional(schema.getAttributeType("at1")));
+        Assert.assertTrue(oc.isRequiredOrOptional(schema.getAttributeType("at2")));
+        Assert.assertFalse(oc.isRequiredOrOptional(schema.getAttributeType("at3")));
+    }
+
+    @Test
+    public void testIsRequiredOrOptionalEmptyWithOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .requiredAttributes("at1")
+            .optionalAttributes("at2")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Assert.assertTrue(child.isRequiredOrOptional(schema.getAttributeType("at1")));
+        Assert.assertTrue(child.isRequiredOrOptional(schema.getAttributeType("at2")));
+        Assert.assertFalse(child.isRequiredOrOptional(schema.getAttributeType("at3")));
+    }
+
+    @Test
+    public void testIsRequiredOrOptionalWithOneSuperior() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent")
+            .requiredAttributes("at1")
+            .optionalAttributes("at2")
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("child")
+            .requiredAttributes("at3")
+            .optionalAttributes("at4")
+            .superiorObjectClasses("parent")
+            .addToSchema().toSchema();
+        ObjectClass child = schema.getObjectClass("child");
+
+        Assert.assertTrue(child.isRequiredOrOptional(schema.getAttributeType("at1")));
+        Assert.assertTrue(child.isRequiredOrOptional(schema.getAttributeType("at2")));
+        Assert.assertTrue(child.isRequiredOrOptional(schema.getAttributeType("at3")));
+        Assert.assertTrue(child.isRequiredOrOptional(schema.getAttributeType("at4")));
+        Assert.assertFalse(child.isRequiredOrOptional(schema.getAttributeType("at5")));
+    }
+
+    @Test
+    public void testIsRequiredOrOptionalExtensible() throws Exception {
+        Schema schema = schema();
+        ObjectClass oc = schema.getObjectClass(EXTENSIBLE_OBJECT_OBJECTCLASS_OID);
+
+        Assert.assertTrue(oc.isRequiredOrOptional(schema.getAttributeType("at1")));
+        Assert.assertTrue(oc.isRequiredOrOptional(schema.getAttributeType("at2")));
+    }
+
+    /** Test data for testing different combinations of superiors. */
+    @DataProvider
+    public Object[][] superiorData() throws Exception {
+        Schema schema = new SchemaBuilder(schema())
+            .buildObjectClass("1.2.3.1")
+            .names("parent1")
+            .type(ObjectClassType.ABSTRACT)
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.2")
+            .names("parent2")
+            .type(ObjectClassType.ABSTRACT)
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.3")
+            .names("parent3")
+            .type(ObjectClassType.STRUCTURAL)
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.4")
+            .names("parent4")
+            .type(ObjectClassType.STRUCTURAL)
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.5")
+            .names("parent5")
+            .type(ObjectClassType.AUXILIARY)
+            .addToSchema().toSchema();
+
+        schema = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.6")
+            .names("parent6")
+            .type(ObjectClassType.AUXILIARY)
+            .addToSchema().toSchema();
+
+        return new Object[][] {
+            // parent 1 name, parent2 name, type of child, schema
+            { "parent1", "parent2", ObjectClassType.ABSTRACT, schema },
+            { "parent3", "parent4", ObjectClassType.STRUCTURAL, schema },
+            { "parent5", "parent6", ObjectClassType.AUXILIARY, schema }
+        };
+    }
+
+    @Test(dataProvider = "superiorData")
+    public void testMultipleSuperiors(String parent1, String parent2, ObjectClassType type, Schema schema)
+            throws Exception {
+        ObjectClass child = new SchemaBuilder(schema)
+            .buildObjectClass("1.2.3.7")
+            .names("child")
+            .type(type)
+            .superiorObjectClasses(parent1, parent2)
+            .addToSchema().toSchema().getObjectClass("child");
+
+        assertThat(child.getSuperiorClasses()).hasSize(2);
+    }
+
+    /** Returns a schema initialized with new attributes types "at1", "at2", ..., "at9". */
+    private Schema schema() throws Exception {
+        SchemaBuilder sb = new SchemaBuilder(getCoreSchema());
+        for (int i = 1; i <= 9; i++) {
+            sb.buildAttributeType("1.2.3.4." + i).names("at" + i).addToSchema();
+        }
+        return sb.toSchema();
+    }
+
+    /** Returns attributes types from the provided schema by names (as Object[] due to usage in assertions). */
+    private Object[] attrs(Schema schema, String... names) {
+        AttributeType[] attrs = new AttributeType[names.length];
+        int i = 0;
+        for (String name : names) {
+            attrs[i++] = schema.getAttributeType(name);
+        }
+        return attrs;
+    }
+
+    /** Returns object classes from the provided schema by names (as Object[] due to usage in assertions). */
+    private Object[] objectClasses(Schema schema, String... names) {
+        ObjectClass[] attrs = new ObjectClass[names.length];
+        int i = 0;
+        for (String name : names) {
+            attrs[i++] = schema.getObjectClass(name);
+        }
+        return attrs;
+    }
 }
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestCommonSchemaElements.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestCommonSchemaElements.java
deleted file mode 100644
index a11267d..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestCommonSchemaElements.java
+++ /dev/null
@@ -1,731 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014-2016 ForgeRock AS.
- */
-package org.opends.server.types;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.opends.server.TestCaseUtils;
-import org.opends.server.util.ServerConstants;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import static org.opends.server.types.CommonSchemaElements.*;
-
-/**
- * This class defines a set of tests for the
- * {@link org.opends.server.types.CommonSchemaElements} class and
- * derived classes.
- */
-public abstract class TestCommonSchemaElements extends TypesTestCase {
-  /**
-   * Internal class to simplify construction of attribute types.
-   *
-   * @param <T>
-   *          The type of definition that this builder constructs.
-   */
-  protected static abstract class SchemaDefinitionBuilder<T extends CommonSchemaElements> {
-    /** The primary name to use for this attribute type. */
-    private String primaryName;
-
-    /** The set of names for this attribute type. */
-    private List<String> names;
-
-    /** The OID that may be used to reference this attribute type. */
-    private String oid;
-
-    /** The description for this attribute type. */
-    private String description;
-
-    /** Indicates whether this attribute type is declared "obsolete". */
-    private boolean isObsolete;
-
-    /**
-     * The set of additional name-value pairs associated with this
-     * attribute type definition.
-     */
-    private Map<String, List<String>> extraProperties;
-
-
-
-    /** Reset the builder to its initial state. */
-    private void reset() {
-      this.primaryName = null;
-      this.names = null;
-      this.oid = null;
-      this.description = null;
-      this.isObsolete = false;
-      this.extraProperties = null;
-
-      resetBuilder();
-    }
-
-
-
-    /**
-     * Create a new attribute type builder.
-     */
-    protected SchemaDefinitionBuilder() {
-      reset();
-    }
-
-
-
-    /**
-     * Create a new attribute type builder.
-     *
-     * @param primaryName
-     *          The attribute type primary name.
-     * @param oid
-     *          The attribute type OID.
-     */
-    protected SchemaDefinitionBuilder(String primaryName, String oid) {
-      reset();
-
-      this.primaryName = primaryName;
-      this.oid = oid;
-    }
-
-
-
-    /**
-     * Construct an attribute type based on the properties of the
-     * builder.
-     *
-     * @return The new attribute type.
-     */
-    public final T getInstance() {
-      if (oid == null) {
-        throw new IllegalStateException("Null OID.");
-      }
-
-      T instance = buildInstance(primaryName, names, oid,
-          description, isObsolete, extraProperties);
-
-      // Reset the internal state.
-      reset();
-
-      return instance;
-    }
-
-
-
-    /**
-     * Build a new instance using this builder.
-     *
-     * @param primaryName
-     *          The primary name.
-     * @param names
-     *          The optional names.
-     * @param oid
-     *          The OID.
-     * @param description
-     *          The optional description.
-     * @param isObsolete
-     *          Whether or not the definition is obsolete.
-     * @param extraProperties
-     *          The extra properties.
-     * @return Returns the newly constructed definition.
-     */
-    protected abstract T buildInstance(String primaryName,
-        Collection<String> names, String oid, String description,
-        boolean isObsolete, Map<String, List<String>> extraProperties);
-
-
-
-    /**
-     * Reset the internal state of the builder.
-     */
-    protected abstract void resetBuilder();
-
-
-
-    /**
-     * Set the description.
-     *
-     * @param description
-     *          The description.
-     */
-    public final void setDescription(String description) {
-      this.description = description;
-    }
-
-
-
-    /**
-     * Add extra property value(s).
-     *
-     * @param name
-     *          The name of the extra property.
-     * @param values
-     *          The value(s) of the extra property.
-     */
-    public final void addExtraProperty(String name, String... values) {
-      if (name == null) {
-        throw new NullPointerException("Null extra property name");
-      }
-
-      if (values == null) {
-        throw new NullPointerException("Null extra property values");
-      }
-
-      if (extraProperties == null) {
-        extraProperties = new HashMap<>();
-      }
-
-      List<String> l = extraProperties.get(name);
-      if (l == null) {
-        l = new ArrayList<>();
-        extraProperties.put(name, l);
-      }
-      l.addAll(Arrays.asList(values));
-    }
-
-
-
-    /**
-     * Set the isObsolete.
-     *
-     * @param isObsolete
-     *          The isObsolete.
-     */
-    public final void setObsolete(boolean isObsolete) {
-      this.isObsolete = isObsolete;
-    }
-
-
-
-    /**
-     * Set the oid.
-     *
-     * @param oid
-     *          The oid.
-     */
-    public final void setOid(String oid) {
-      if (oid == null) {
-        throw new NullPointerException("Null OID");
-      }
-
-      this.oid = oid;
-    }
-
-
-
-    /**
-     * Set the primaryName.
-     *
-     * @param primaryName
-     *          The primaryName.
-     */
-    public final void setPrimaryName(String primaryName) {
-      this.primaryName = primaryName;
-    }
-
-
-
-    /**
-     * Add attribute type name(s).
-     *
-     * @param names
-     *          The attribute type name(s) to add.
-     */
-    public final void addTypeNames(String... names) {
-      if (names == null) {
-        throw new NullPointerException("Null names");
-      }
-
-      if (this.names == null) {
-        this.names = new LinkedList<>();
-      }
-
-      this.names.addAll(Arrays.asList(names));
-    }
-  }
-
-
-
-  /**
-   * Create a new schema definition builder.
-   *
-   * @param name
-   *          The schema definition's primary name.
-   * @param oid
-   *          The OID of the schema definition.
-   * @return The new builder.
-   */
-  protected abstract SchemaDefinitionBuilder getBuilder(String name,
-      String oid);
-
-
-
-  /**
-   * Once-only initialization.
-   *
-   * @throws Exception
-   *           If an unexpected error occurred.
-   */
-  @BeforeClass
-  public final void setUp() throws Exception {
-    // This test suite depends on having the schema available, so
-    // we'll
-    // start the server.
-    TestCaseUtils.startServer();
-  }
-
-
-
-  /**
-   * Check that the primary name is added to the set of names.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testConstructorPrimaryName() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-
-    Assert.assertTrue(d.hasName("testtype"));
-    Assert.assertFalse(d.hasName("xxx"));
-  }
-
-
-
-  /**
-   * Check that the type names are accessible.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testConstructorTypeNames() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-
-    builder.addTypeNames("testNameAlias", "anotherNameAlias");
-    CommonSchemaElements d = builder.getInstance();
-
-    Assert.assertTrue(d.hasName("testtype"));
-    Assert.assertTrue(d.hasName("testnamealias"));
-    Assert.assertTrue(d.hasName("anothernamealias"));
-  }
-
-
-
-  /**
-   * Create test data for testing the
-   * {@link CommonSchemaElements#equals(Object)} method.
-   *
-   * @return Returns the array of test data.
-   */
-  @DataProvider(name = "equalsTestData")
-  public final Object[][] createEqualsTestData() {
-    return new Object[][] {
-        { "testType", "1.2.3", "testType", "1.2.3", true },
-        { "testType", "1.2.3", "xxx", "1.2.3", false },
-        { "testType", "1.2.3", "testType", "1.2.4", true },
-        { "testType", "1.2.3", "xxx", "1.2.4", false } };
-  }
-
-
-
-  /**
-   * Check that the equals operator works as expected.
-   *
-   * @param name1
-   *          The first primary name.
-   * @param oid1
-   *          The first oid.
-   * @param name2
-   *          The second primary name.
-   * @param oid2
-   *          The second oid.
-   * @param result
-   *          The expected result.
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dataProvider = "equalsTestData")
-  public final void testEquals(String name1, String oid1,
-      String name2, String oid2, boolean result) throws Exception {
-    SchemaDefinitionBuilder builder1 = getBuilder(name1, oid1);
-    CommonSchemaElements d1 = builder1.getInstance();
-
-    SchemaDefinitionBuilder builder2 = getBuilder(name2, oid2);
-    CommonSchemaElements d2 = builder2.getInstance();
-
-    Assert.assertEquals(d1.equals(d2), result);
-    Assert.assertEquals(d2.equals(d1), result);
-  }
-
-
-
-  /**
-   * Check that the hasCode method operator works as expected.
-   *
-   * @param name1
-   *          The first primary name.
-   * @param oid1
-   *          The first oid.
-   * @param name2
-   *          The second primary name.
-   * @param oid2
-   *          The second oid.
-   * @param result
-   *          The expected result.
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dataProvider = "equalsTestData")
-  public final void testHashCode(String name1, String oid1,
-      String name2, String oid2, boolean result) throws Exception {
-    SchemaDefinitionBuilder builder1 = getBuilder(name1, oid1);
-    CommonSchemaElements d1 = builder1.getInstance();
-
-    SchemaDefinitionBuilder builder2 = getBuilder(name2, oid2);
-    CommonSchemaElements d2 = builder2.getInstance();
-
-    Assert.assertEquals(d1.hashCode() == d2.hashCode(), result);
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getDescription()}
-   * method returns <code>null</code> when there is no description.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetDescriptionDefault() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("test", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertNull(d.getDescription());
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getDescription()}
-   * method returns a description.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetDescription() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("test", "1.2.3");
-    builder.setDescription("hello");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertEquals(d.getDescription(), "hello");
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getExtraProperties()} method
-   * returns <code>null</code> when there is no property.
-   */
-  @Test
-  public final void testGetExtraPropertyDefault() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("test", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertNull(d.getExtraProperties().get("test"));
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getExtraProperties()} method
-   * returns values.
-   */
-  @Test
-  public final void testGetExtraProperties() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("test", "1.2.3");
-    String[] expectedValues = new String[] { "one", "two" };
-    builder.addExtraProperty("test", expectedValues);
-    CommonSchemaElements d = builder.getInstance();
-
-    List<String> values = d.getExtraProperties().get("test");
-    Assert.assertNotNull(values);
-    for (int i = 0; i < values.size(); i++)
-    {
-      Assert.assertEquals(values.get(i), expectedValues[i]);
-    }
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link CommonSchemaElements#getExtraProperties()} method.
-   */
-  @Test
-  public final void testGetExtraPropertyNames() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("test", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertFalse(d.getExtraProperties().keySet().iterator().hasNext());
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getNameOrOID()}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetNameOrOIDReturnsOID() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder(null, "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertEquals(d.getNameOrOID(), "1.2.3");
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getNameOrOID()}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetNameOrOIDReturnsPrimaryName()
-      throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertEquals(d.getNameOrOID(), "testType");
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getNameOrOID()}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetNameOrOIDReturnsOtherName()
-      throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder(null, "1.2.3");
-    builder.addTypeNames("anotherName");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertEquals(d.getNameOrOID(), "anotherName");
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getNormalizedNames()}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetNormalizedNames() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-    builder.addTypeNames("anotherName", "yetAnotherName");
-    CommonSchemaElements d = builder.getInstance();
-
-    boolean gotTestType = false;
-    boolean gotAnotherName = false;
-    boolean gotYetAnotherName = false;
-
-    for (String name : d.getNormalizedNames()) {
-      if (name.equals("testtype")) {
-        gotTestType = true;
-      } else if (name.equals("anothername")) {
-        gotAnotherName = true;
-      } else if (name.equals("yetanothername")) {
-        gotYetAnotherName = true;
-      } else {
-        Assert.fail("Got unexpected normalized name: " + name);
-      }
-    }
-
-    Assert.assertTrue(gotTestType && gotAnotherName
-        && gotYetAnotherName);
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getUserDefinedNames()}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetUserDefinedNames() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-    builder.addTypeNames("anotherName", "yetAnotherName");
-    CommonSchemaElements d = builder.getInstance();
-
-    boolean gotTestType = false;
-    boolean gotAnotherName = false;
-    boolean gotYetAnotherName = false;
-
-    for (String name : d.getUserDefinedNames()) {
-      if (name.equals("testType")) {
-        gotTestType = true;
-      } else if (name.equals("anotherName")) {
-        gotAnotherName = true;
-      } else if (name.equals("yetAnotherName")) {
-        gotYetAnotherName = true;
-      } else {
-        Assert.fail("Got unexpected user defined name: " + name);
-      }
-    }
-
-    Assert.assertTrue(gotTestType && gotAnotherName
-        && gotYetAnotherName);
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link CommonSchemaElements#getNormalizedPrimaryNameOrOID()} method
-   * returns <code>null</code> when there is no primary name.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetNormalizedPrimaryNameOrOIDDefault()
-      throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder(null, "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertEquals(d.getNormalizedPrimaryNameOrOID(), "1.2.3");
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link CommonSchemaElements#getNormalizedPrimaryNameOrOID()} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetNormalizedPrimaryNameOrOID() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertEquals(d.getNormalizedPrimaryNameOrOID(), "testtype");
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getOID()} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetOID() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-    Assert.assertEquals(d.getOID(), "1.2.3");
-  }
-
-  /**
-   * Check that the {@link CommonSchemaElements#getSchemaFile()}
-   * method returns <code>null</code> when there is no schema file.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetSchemaFileDefault() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder(null, "1.2.3");
-    Assert.assertNull(getSchemaFile(builder.getInstance()));
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#getSchemaFile()}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testGetSchemaFile() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder(null, "1.2.3");
-    builder.addExtraProperty(
-        ServerConstants.SCHEMA_PROPERTY_FILENAME, "/foo/bar");
-    Assert.assertEquals(getSchemaFile(builder.getInstance()), "/foo/bar");
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#hasNameOrOID(String)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testHasNameOrOID() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-
-    Assert.assertTrue(d.hasNameOrOID("testtype"));
-    Assert.assertTrue(d.hasNameOrOID("1.2.3"));
-    Assert.assertFalse(d.hasNameOrOID("x.y.z"));
-  }
-
-
-
-  /**
-   * Check that the {@link CommonSchemaElements#isObsolete()} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public final void testIsObsolete() throws Exception {
-    SchemaDefinitionBuilder builder = getBuilder("testType", "1.2.3");
-    CommonSchemaElements d = builder.getInstance();
-
-    Assert.assertFalse(d.isObsolete());
-
-    builder = getBuilder("testType", "1.2.3");
-    builder.setObsolete(true);
-    d = builder.getInstance();
-
-    Assert.assertTrue(d.isObsolete());
-  }
-}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java
deleted file mode 100644
index 454ad88..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java
+++ /dev/null
@@ -1,1610 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2013-2016 ForgeRock AS.
- */
-package org.opends.server.types;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
-import org.forgerock.opendj.ldap.schema.ObjectClassType;
-import org.forgerock.util.Utils;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.schema.SchemaConstants;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * This class defines a set of tests for the
- * {@link org.forgerock.opendj.ldap.schema.ObjectClass} class.
- */
-public final class TestObjectClass extends TestCommonSchemaElements {
-  /**
-   * Internal class to simplify construction of object classes.
-   */
-  private static final class ObjectClassBuilder extends
-      SchemaDefinitionBuilder<ObjectClass> {
-    /** The superior object class from which this object class inherits. */
-    private Set<ObjectClass> superior;
-
-    /** The type of object class. */
-    private ObjectClassType objectClassType;
-
-    /** The set of required attribute types. */
-    private Set<AttributeType> requiredAttributeTypes;
-    /** The set of optional attribute types. */
-    private Set<AttributeType> optionalAttributeTypes;
-
-
-
-    /** {@inheritDoc} */
-    @Override
-    protected void resetBuilder() {
-      this.superior = null;
-      this.objectClassType = ObjectClassType.STRUCTURAL;
-      this.requiredAttributeTypes = null;
-      this.optionalAttributeTypes = null;
-    }
-
-
-
-    /**
-     * Create a new object class builder.
-     */
-    public ObjectClassBuilder() {
-      super();
-    }
-
-
-
-    /**
-     * Create a new object class builder.
-     *
-     * @param primaryName
-     *          The object class primary name.
-     * @param oid
-     *          The object class OID.
-     */
-    public ObjectClassBuilder(String primaryName, String oid) {
-      super(primaryName, oid);
-    }
-
-
-
-    /** {@inheritDoc} */
-    @Override
-    protected ObjectClass buildInstance(String primaryName,
-        Collection<String> names, String oid, String description,
-        boolean isObsolete, Map<String, List<String>> extraProperties) {
-
-      StringBuilder definition = new StringBuilder();
-      definition.append("( ");
-      definition.append(oid);
-
-      LinkedHashSet<String> nameSet = new LinkedHashSet<>();
-      if (primaryName != null)
-      {
-        nameSet.add(primaryName);
-      }
-
-      if (names != null)
-      {
-        nameSet.addAll(names);
-      }
-
-      if (! nameSet.isEmpty())
-      {
-        definition.append(" NAME ");
-        if (nameSet.size() == 1)
-        {
-          definition.append("'");
-          definition.append(nameSet.iterator().next());
-          definition.append("'");
-        }
-        else
-        {
-          definition.append("( '");
-          Utils.joinAsString(definition, "' '", nameSet);
-          definition.append("' )");
-        }
-      }
-
-      if (description != null)
-      {
-        definition.append(" DESC '");
-        definition.append(description);
-        definition.append("'");
-      }
-
-      if (isObsolete)
-      {
-        definition.append(" OBSOLETE");
-      }
-
-      if (superior != null)
-      {
-        definition.append(" SUP ");
-        Iterator<ObjectClass> iterator = superior.iterator();
-        ObjectClass oc =  iterator.next();
-
-        if(iterator.hasNext())
-        {
-          definition.append("( ");
-          definition.append(oc.getNameOrOID());
-
-          while(iterator.hasNext())
-          {
-            definition.append(" $ ");
-            definition.append(iterator.next().getNameOrOID());
-          }
-
-          definition.append(" )");
-        }
-        else
-        {
-          definition.append(oc.getNameOrOID());
-        }
-      }
-
-      if (objectClassType != null)
-      {
-        definition.append(" ");
-        definition.append(objectClassType);
-      }
-
-      append(definition, "MUST", requiredAttributeTypes);
-      append(definition, "MAY", optionalAttributeTypes);
-
-      if (extraProperties != null)
-      {
-        for (String property : extraProperties.keySet())
-        {
-          List<String> values = extraProperties.get(property);
-          if (values == null || values.isEmpty())
-          {
-            continue;
-          }
-          else if (values.size() == 1)
-          {
-            definition.append(" ");
-            definition.append(property);
-            definition.append(" '");
-            definition.append(values.get(0));
-            definition.append("'");
-          }
-          else
-          {
-            definition.append(" ");
-            definition.append(property);
-            definition.append(" (");
-            for (String value : values)
-            {
-              definition.append(" '");
-              definition.append(value);
-              definition.append("'");
-            }
-
-            definition.append(" )");
-          }
-        }
-      }
-
-      definition.append(" )");
-
-
-      return new ObjectClass(definition.toString(), primaryName, names, oid,
-                             description, superior,
-                             requiredAttributeTypes,
-                             optionalAttributeTypes, objectClassType,
-                             isObsolete, extraProperties);
-    }
-
-
-
-    private void append(StringBuilder definition, String word, Set<AttributeType> attrTypes)
-    {
-      if (attrTypes != null && !attrTypes.isEmpty())
-      {
-        definition.append(" ");
-        definition.append(word);
-        definition.append(" ");
-        if (attrTypes.size() == 1)
-        {
-          definition.append(attrTypes.iterator().next().getNameOrOID());
-        }
-        else
-        {
-          definition.append("( ");
-          Iterator<AttributeType> iterator = attrTypes.iterator();
-          definition.append(iterator.next().getNameOrOID());
-          while (iterator.hasNext())
-          {
-            definition.append(" $ ");
-            definition.append(iterator.next().getNameOrOID());
-          }
-          definition.append(" )");
-        }
-      }
-    }
-
-
-
-    /**
-     * Set the objectClassType.
-     *
-     * @param objectClassType
-     *          The objectClassType.
-     */
-    public void setObjectClassType(ObjectClassType objectClassType) {
-      this.objectClassType = objectClassType;
-    }
-
-
-
-    /**
-     * Set the superior.
-     *
-     * @param superior
-     *          The superior.
-     */
-    public void setSuperior(Set<ObjectClass> superior) {
-      this.superior = superior;
-    }
-
-
-
-    /**
-     * Add required attribute types.
-     *
-     * @param types
-     *          The required attribute type(s) to add.
-     */
-    public void addRequiredAttributeTypes(AttributeType... types) {
-      if (types == null) {
-        throw new NullPointerException("Null types");
-      }
-
-      if (this.requiredAttributeTypes == null) {
-        this.requiredAttributeTypes = new LinkedHashSet<>();
-      }
-
-      this.requiredAttributeTypes.addAll(Arrays.asList(types));
-    }
-
-
-
-    /**
-     * Add optional attribute types.
-     *
-     * @param types
-     *          The optional attribute type(s) to add.
-     */
-    public void addOptionalAttributeTypes(AttributeType... types) {
-      if (types == null) {
-        throw new NullPointerException("Null types");
-      }
-
-      if (this.optionalAttributeTypes == null) {
-        this.optionalAttributeTypes = new LinkedHashSet<>();
-      }
-
-      this.optionalAttributeTypes.addAll(Arrays.asList(types));
-    }
-  }
-
-
-
-  /** Array of attribute types to use in tests. */
-  private AttributeType[] types;
-
-
-
-  /**
-   * Once-only initialization.
-   *
-   * @throws Exception
-   *           If an unexpected error occurred.
-   */
-  @BeforeClass(dependsOnMethods = "setUp")
-  public final void setUpTypes() throws Exception {
-    types = new AttributeType[10];
-
-    for (int i = 0; i < types.length; i++) {
-      types[i] = DirectoryServer.getAttributeType("testType" + i);
-    }
-  }
-
-
-
-  /**
-   * Check that the constructor throws an NPE when mandatory
-   * parameters are not specified.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(expectedExceptions = NullPointerException.class)
-  public void testConstructorNPE() throws Exception {
-    Set<AttributeType> emptySet = Collections.emptySet();
-    Map<String, List<String>> emptyMap = Collections.emptyMap();
-
-    new ObjectClass(null, "test", Collections.singleton("test"), null,
-        "description", Collections.singleton(DirectoryServer.getTopObjectClass()),
-        emptySet,
-        emptySet, ObjectClassType.STRUCTURAL, false, emptyMap);
-  }
-
-
-
-  /**
-   * Check that the constructor does not throw an exception when all
-   * optional parameters are not specified.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testConstructorDefault() throws Exception {
-    String definition = "( 1.2.3 )";
-    ObjectClass type = new ObjectClass(definition, null, null, "1.2.3", null,
-        null, null, null, null, false, null);
-
-    Assert.assertEquals(type.getNameOrOID(), "1.2.3");
-  }
-
-
-
-  /**
-   * Create test data for testing the
-   * {@link AttributeType#isOperational()} method.
-   *
-   * @return Returns the array of test data.
-   */
-  @DataProvider(name = "getObjectClassTypeTestData")
-  public Object[][] createGetObjectClassTypeTestData() {
-    return new Object[][] { { null, ObjectClassType.STRUCTURAL },
-        { ObjectClassType.STRUCTURAL, ObjectClassType.STRUCTURAL },
-        { ObjectClassType.ABSTRACT, ObjectClassType.ABSTRACT },
-        { ObjectClassType.AUXILIARY, ObjectClassType.AUXILIARY } };
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#getObjectClassType()} method.
-   *
-   * @param type
-   *          The object class type.
-   * @param result
-   *          Expected result.
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dataProvider = "getObjectClassTypeTestData")
-  public void testGetObjectClassType(ObjectClassType type,
-      ObjectClassType result) throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    builder.setObjectClassType(type);
-    ObjectClass c = builder.getInstance();
-    Assert.assertEquals(c.getObjectClassType(), result);
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getOptionalAttributes()} method
-   * with no superior and no optional attributes.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributeChainNoSuperiorEmpty()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.getOptionalAttributes().isEmpty());
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getOptionalAttributes()} method
-   * with no superior and some optional attributes.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributeChainNoSuperior()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass c = builder.getInstance();
-
-    Set<AttributeType> chain = c.getOptionalAttributes();
-    Assert.assertEquals(chain.size(), 3);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getOptionalAttributes()} method
-   * with a superior but no optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributeChainEmpty() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Set<AttributeType> chain = child.getOptionalAttributes();
-    Assert.assertEquals(chain.size(), 3);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getOptionalAttributes()} method
-   * with multiple superiors but no optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributeChainEmptyMS() throws Exception {
-    ObjectClassBuilder builder1 = new ObjectClassBuilder("parent1",
-        "1.2.3");
-    builder1.addOptionalAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent1 = builder1.getInstance();
-
-    ObjectClassBuilder builder2 = new ObjectClassBuilder("parent2","3.4.5");
-    builder2.addOptionalAttributeTypes(types[3], types[4], types[5]);
-    ObjectClass parent2 = builder2.getInstance();
-    Set<ObjectClass> superiors = new LinkedHashSet<>();
-    superiors.add(parent1);
-    superiors.add(parent2);
-    ObjectClassBuilder builder3 = new ObjectClassBuilder("child", "6.7.8");
-    builder3.setSuperior(superiors);
-    ObjectClass child = builder3.getInstance();
-
-    Set<AttributeType> chain = child.getOptionalAttributes();
-    Assert.assertEquals(chain.size(), 6);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-    Assert.assertTrue(chain.contains(types[3]));
-    Assert.assertTrue(chain.contains(types[4]));
-    Assert.assertTrue(chain.contains(types[5]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getOptionalAttributes()} method
-   * with a superior and some optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributeChain() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.addOptionalAttributeTypes(types[3], types[4], types[5]);
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Set<AttributeType> chain = child.getOptionalAttributes();
-    Assert.assertEquals(chain.size(), 6);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-    Assert.assertTrue(chain.contains(types[3]));
-    Assert.assertTrue(chain.contains(types[4]));
-    Assert.assertTrue(chain.contains(types[5]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getOptionalAttributes()} method
-   * with multiple superiors and some optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributeChainMS() throws Exception {
-    ObjectClassBuilder builder1 = new ObjectClassBuilder("parent1",
-        "1.2.3");
-    builder1.addOptionalAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent1 = builder1.getInstance();
-
-    ObjectClassBuilder builder2 = new ObjectClassBuilder("parent2","3.4.5");
-    builder2.addOptionalAttributeTypes(types[3], types[4], types[5]);
-    ObjectClass parent2 = builder2.getInstance();
-    Set<ObjectClass> superiors = new LinkedHashSet<>();
-    superiors.add(parent1);
-    superiors.add(parent2);
-    ObjectClassBuilder builder3 = new ObjectClassBuilder("child", "6.7.8");
-    builder3.addOptionalAttributeTypes(types[6], types[7], types[8]);
-    builder3.setSuperior(superiors);
-    ObjectClass child = builder3.getInstance();
-
-    Set<AttributeType> chain = child.getOptionalAttributes();
-    Assert.assertEquals(chain.size(), 9);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-    Assert.assertTrue(chain.contains(types[3]));
-    Assert.assertTrue(chain.contains(types[4]));
-    Assert.assertTrue(chain.contains(types[5]));
-    Assert.assertTrue(chain.contains(types[6]));
-    Assert.assertTrue(chain.contains(types[7]));
-    Assert.assertTrue(chain.contains(types[8]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getDeclaredOptionalAttributes()} method with
-   * no superior and no optional attributes.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributesNoSuperiorEmpty()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.getDeclaredOptionalAttributes().isEmpty());
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getDeclaredOptionalAttributes()} method with
-   * no superior and some optional attributes.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributesNoSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass c = builder.getInstance();
-
-    Set<AttributeType> chain = c.getDeclaredOptionalAttributes();
-    Assert.assertEquals(chain.size(), 3);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getDeclaredOptionalAttributes()} method with
-   * a superior but no optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributesEmpty() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.getDeclaredOptionalAttributes().isEmpty());
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getDeclaredOptionalAttributes()} method with
-   * a superior and some optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetOptionalAttributes() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.addOptionalAttributeTypes(types[3], types[4], types[5]);
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Set<AttributeType> chain = child.getDeclaredOptionalAttributes();
-    Assert.assertEquals(chain.size(), 3);
-    Assert.assertTrue(chain.contains(types[3]));
-    Assert.assertTrue(chain.contains(types[4]));
-    Assert.assertTrue(chain.contains(types[5]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getRequiredAttributes()} method
-   * with no superior and no optional attributes.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributeChainNoSuperiorEmpty()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.getRequiredAttributes().isEmpty());
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getRequiredAttributes()} method
-   * with no superior and some optional attributes.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributeChainNoSuperior()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass c = builder.getInstance();
-
-    Set<AttributeType> chain = c.getRequiredAttributes();
-    Assert.assertEquals(chain.size(), 3);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getRequiredAttributes()} method
-   * with a superior but no optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributeChainEmpty() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Set<AttributeType> chain = child.getRequiredAttributes();
-    Assert.assertEquals(chain.size(), 3);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getRequiredAttributes()} method
-   * with multiple superiors but no optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributeChainEmptyMS() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent1",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent1 = builder.getInstance();
-
-    builder = new ObjectClassBuilder("parent2","3.4.5");
-    builder.addRequiredAttributeTypes(types[3], types[4], types[5]);
-    ObjectClass parent2 = builder.getInstance();
-    Set<ObjectClass> superiors = new LinkedHashSet<>();
-    superiors.add(parent1);
-    superiors.add(parent2);
-    builder = new ObjectClassBuilder("child", "6.7.8");
-    builder.setSuperior(superiors);
-    ObjectClass child = builder.getInstance();
-
-    Set<AttributeType> chain = child.getRequiredAttributes();
-    Assert.assertEquals(chain.size(), 6);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-    Assert.assertTrue(chain.contains(types[3]));
-    Assert.assertTrue(chain.contains(types[4]));
-    Assert.assertTrue(chain.contains(types[5]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getRequiredAttributes()} method
-   * with a superior and some optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributeChain() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.addRequiredAttributeTypes(types[3], types[4], types[5]);
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Set<AttributeType> chain = child.getRequiredAttributes();
-    Assert.assertEquals(chain.size(), 6);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-    Assert.assertTrue(chain.contains(types[3]));
-    Assert.assertTrue(chain.contains(types[4]));
-    Assert.assertTrue(chain.contains(types[5]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getRequiredAttributes()} method
-   * with multiple superiors and some optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributeChainMS() throws Exception {
-     ObjectClassBuilder builder = new ObjectClassBuilder("parent1",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent1 = builder.getInstance();
-
-    builder = new ObjectClassBuilder("parent2","3.4.5");
-    builder.addRequiredAttributeTypes(types[3], types[4], types[5]);
-    ObjectClass parent2 = builder.getInstance();
-    Set<ObjectClass> superiors = new LinkedHashSet<>();
-    superiors.add(parent1);
-    superiors.add(parent2);
-    builder = new ObjectClassBuilder("child", "6.7.8");
-    builder.addRequiredAttributeTypes(types[6], types[7], types[8]);
-    builder.setSuperior(superiors);
-    ObjectClass child = builder.getInstance();
-
-    Set<AttributeType> chain = child.getRequiredAttributes();
-    Assert.assertEquals(chain.size(), 9);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-    Assert.assertTrue(chain.contains(types[3]));
-    Assert.assertTrue(chain.contains(types[4]));
-    Assert.assertTrue(chain.contains(types[5]));
-    Assert.assertTrue(chain.contains(types[6]));
-    Assert.assertTrue(chain.contains(types[7]));
-    Assert.assertTrue(chain.contains(types[8]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getDeclaredRequiredAttributes()} method with
-   * no superior and no optional attributes.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributesNoSuperiorEmpty()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.getDeclaredRequiredAttributes().isEmpty());
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getDeclaredRequiredAttributes()} method with
-   * no superior and some optional attributes.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributesNoSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass c = builder.getInstance();
-
-    Set<AttributeType> chain = c.getDeclaredRequiredAttributes();
-    Assert.assertEquals(chain.size(), 3);
-    Assert.assertTrue(chain.contains(types[0]));
-    Assert.assertTrue(chain.contains(types[1]));
-    Assert.assertTrue(chain.contains(types[2]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getDeclaredRequiredAttributes()} method with
-   * a superior but no optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributesEmpty() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.getDeclaredRequiredAttributes().isEmpty());
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getDeclaredRequiredAttributes()} method with
-   * a superior and some optional attributes of its own.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetRequiredAttributes() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0], types[1], types[2]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.addRequiredAttributeTypes(types[3], types[4], types[5]);
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Set<AttributeType> chain = child.getDeclaredRequiredAttributes();
-    Assert.assertEquals(chain.size(), 3);
-    Assert.assertTrue(chain.contains(types[3]));
-    Assert.assertTrue(chain.contains(types[4]));
-    Assert.assertTrue(chain.contains(types[5]));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getSuperiorClasses()} method with no
-   * superior.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetSuperiorClassNoSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType",
-        "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.getSuperiorClasses().isEmpty());
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getSuperiorClasses()} method with a
-   * superior.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetSuperiorClassWithSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.getSuperiorClasses().contains(parent));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#getSuperiorClasses()} method with multiple
-   * superiors.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testGetSuperiorClassWithSuperiors() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent1",
-        "1.2.3");
-    ObjectClass parent1 = builder.getInstance();
-    builder = new ObjectClassBuilder("parent2",
-            "2.3.4");
-    ObjectClass parent2 = builder.getInstance();
-    Set<ObjectClass> superiors = new LinkedHashSet<>();
-    superiors.add(parent1);
-    superiors.add(parent2);
-    builder = new ObjectClassBuilder("child", "1.2.3.4");
-    builder.setSuperior(superiors);
-    ObjectClass child = builder.getInstance();
-    Assert.assertTrue(child.getSuperiorClasses().contains(parent1));
-    Assert.assertTrue(child.getSuperiorClasses().contains(parent2));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#isDescendantOf(ObjectClass)} method
-   * with no superior.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsDescendantOfNoSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType1",
-        "1.2.1");
-    ObjectClass c1 = builder.getInstance();
-
-    builder = new ObjectClassBuilder("testType2", "1.2.2");
-    ObjectClass c2 = builder.getInstance();
-
-    Assert.assertFalse(c1.isDescendantOf(c2));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#isDescendantOf(ObjectClass)} method
-   * with a superior.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsDescendantOfWithSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder(
-        "grandParent", "1.2.1");
-    ObjectClass grandParent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("parent", "1.2.2");
-    builder.setSuperior(Collections.singleton(grandParent));
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(parent.isDescendantOf(grandParent));
-    Assert.assertTrue(child.isDescendantOf(parent));
-    Assert.assertTrue(child.isDescendantOf(grandParent));
-
-    Assert.assertFalse(child.isDescendantOf(child));
-    Assert.assertFalse(parent.isDescendantOf(child));
-    Assert.assertFalse(grandParent.isDescendantOf(child));
-  }
-
-
-
-  /**
-   * Check the {@link ObjectClass#isDescendantOf(ObjectClass)} method
-   * with multiple superiors.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsDescendantOfWithMultipleSuperiors() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder(
-        "grandParent", "1.2.1");
-    ObjectClass grandParent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("parent1", "1.2.2");
-    builder.setSuperior(Collections.singleton(grandParent));
-    ObjectClass parent1 = builder.getInstance();
-
-    builder = new ObjectClassBuilder("parent2","2.2.2");
-    ObjectClass parent2 = builder.getInstance();
-    Set<ObjectClass> superiors = new LinkedHashSet<>();
-    superiors.add(parent1);
-    superiors.add(parent2);
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(superiors);
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(parent1.isDescendantOf(grandParent));
-    Assert.assertTrue(child.isDescendantOf(parent1));
-    Assert.assertTrue(child.isDescendantOf(parent2));
-    Assert.assertTrue(child.isDescendantOf(grandParent));
-
-    Assert.assertFalse(child.isDescendantOf(child));
-    Assert.assertFalse(parent1.isDescendantOf(child));
-    Assert.assertFalse(parent1.isDescendantOf(parent2));
-    Assert.assertFalse(grandParent.isDescendantOf(child));
-  }
-
-
-
-  /**
-   * Create test data for testing the
-   * {@link ObjectClass#isExtensibleObject()} method.
-   *
-   * @return Returns the array of test data.
-   */
-  @DataProvider(name = "isExtensibleObjectTestData")
-  public Object[][] createIsExtensibleObjectTestData() {
-    return new Object[][] { { "test", "1.2.3", false },
-        { "extensibleObject", "1.2.3", true },
-        { "test", "1.3.6.1.4.1.1466.101.120.111", true },
-        { "extensibleObject", "1.3.6.1.4.1.1466.101.120.111", true } };
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#getObjectClassType()} method.
-   *
-   * @param name
-   *          The object class name.
-   * @param oid
-   *          The object class oid.
-   * @param result
-   *          Expected result.
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dataProvider = "isExtensibleObjectTestData")
-  public void testIsExtensibleObject(String name, String oid,
-      boolean result) throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder(name, oid);
-    ObjectClass c = builder.getInstance();
-    Assert.assertEquals(c.isExtensibleObject(), result);
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isOptional(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsOptionalEmpty() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("test",
-        "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertFalse(c.isOptional(types[0]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isOptional(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsOptionalNoSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("test",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0]);
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.isOptional(types[0]));
-    Assert.assertFalse(c.isOptional(types[1]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isOptional(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsOptionalEmptyWithSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0]);
-    ObjectClass parent = builder.getInstance();
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.isOptional(types[0]));
-    Assert.assertFalse(child.isOptional(types[1]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isOptional(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsOptionalWithSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0]);
-    ObjectClass parent = builder.getInstance();
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.addOptionalAttributeTypes(types[1]);
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.isOptional(types[0]));
-    Assert.assertTrue(child.isOptional(types[1]));
-    Assert.assertFalse(child.isOptional(types[2]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isOptional(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dependsOnMethods = "testIsExtensibleObject")
-  public void testIsOptionalExtensible() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder(
-        "extensibleObject", "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.isOptional(types[0]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isOptional(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dependsOnMethods = "testIsExtensibleObject")
-  public void testIsOptionalExtensibleRequired() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder(
-        "extensibleObject", "1.2.3");
-    builder.addRequiredAttributeTypes(types[0]);
-    ObjectClass c = builder.getInstance();
-    Assert.assertFalse(c.isOptional(types[0]));
-    Assert.assertTrue(c.isOptional(types[1]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isOptional(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dependsOnMethods = "testIsExtensibleObject")
-  public void testIsOptionalExtensibleRequiredSuperior()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("extensibleObject", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass c = builder.getInstance();
-
-    Assert.assertFalse(c.isOptional(types[0]));
-    Assert.assertTrue(c.isOptional(types[1]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isRequired(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsRequiredEmpty() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("test",
-        "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertFalse(c.isRequired(types[0]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isRequired(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsRequiredNoSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("test",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0]);
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.isRequired(types[0]));
-    Assert.assertFalse(c.isRequired(types[1]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isRequired(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsRequiredEmptyWithSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0]);
-    ObjectClass parent = builder.getInstance();
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.isRequired(types[0]));
-    Assert.assertFalse(child.isRequired(types[1]));
-  }
-
-
-
-  /**
-   * Check that the {@link ObjectClass#isRequired(AttributeType)}
-   * method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsRequiredWithSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0]);
-    ObjectClass parent = builder.getInstance();
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.addRequiredAttributeTypes(types[1]);
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.isRequired(types[0]));
-    Assert.assertTrue(child.isRequired(types[1]));
-    Assert.assertFalse(child.isRequired(types[2]));
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link ObjectClass#isRequiredOrOptional(AttributeType)} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsRequiredOrOptionalEmpty() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("test",
-        "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertFalse(c.isRequiredOrOptional(types[0]));
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link ObjectClass#isRequiredOrOptional(AttributeType)} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsRequiredOrOptionalNoSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("test",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0]);
-    builder.addRequiredAttributeTypes(types[1]);
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.isRequiredOrOptional(types[0]));
-    Assert.assertTrue(c.isRequiredOrOptional(types[1]));
-    Assert.assertFalse(c.isRequiredOrOptional(types[2]));
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link ObjectClass#isRequiredOrOptional(AttributeType)} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsRequiredOrOptionalEmptyWithSuperior()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0]);
-    builder.addRequiredAttributeTypes(types[1]);
-    ObjectClass parent = builder.getInstance();
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.isRequiredOrOptional(types[0]));
-    Assert.assertTrue(child.isRequiredOrOptional(types[1]));
-    Assert.assertFalse(child.isRequiredOrOptional(types[2]));
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link ObjectClass#isRequiredOrOptional(AttributeType)} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test
-  public void testIsRequiredOrOptionalWithSuperior() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addOptionalAttributeTypes(types[0]);
-    builder.addRequiredAttributeTypes(types[1]);
-    ObjectClass parent = builder.getInstance();
-    builder = new ObjectClassBuilder("child", "1.2.3");
-    builder.addOptionalAttributeTypes(types[2]);
-    builder.addRequiredAttributeTypes(types[3]);
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass child = builder.getInstance();
-
-    Assert.assertTrue(child.isRequiredOrOptional(types[0]));
-    Assert.assertTrue(child.isRequiredOrOptional(types[1]));
-    Assert.assertTrue(child.isRequiredOrOptional(types[2]));
-    Assert.assertTrue(child.isRequiredOrOptional(types[3]));
-    Assert.assertFalse(child.isRequiredOrOptional(types[4]));
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link ObjectClass#isRequiredOrOptional(AttributeType)} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dependsOnMethods = "testIsExtensibleObject")
-  public void testIsRequiredOrOptionalExtensible() throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder(
-        "extensibleObject", "1.2.3");
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.isRequiredOrOptional(types[0]));
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link ObjectClass#isRequiredOrOptional(AttributeType)} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dependsOnMethods = "testIsExtensibleObject")
-  public void testIsRequiredOrOptionalExtensibleRequired()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder(
-        "extensibleObject", "1.2.3");
-    builder.addRequiredAttributeTypes(types[0]);
-    ObjectClass c = builder.getInstance();
-    Assert.assertTrue(c.isRequiredOrOptional(types[0]));
-    Assert.assertTrue(c.isRequiredOrOptional(types[1]));
-  }
-
-
-
-  /**
-   * Check that the
-   * {@link ObjectClass#isRequiredOrOptional(AttributeType)} method.
-   *
-   * @throws Exception
-   *           If the test failed unexpectedly.
-   */
-  @Test(dependsOnMethods = "testIsExtensibleObject")
-  public void testIsRequiredOrOptionalExtensibleRequiredSuperior()
-      throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("parent",
-        "1.2.3");
-    builder.addRequiredAttributeTypes(types[0]);
-    ObjectClass parent = builder.getInstance();
-
-    builder = new ObjectClassBuilder("extensibleObject", "1.2.3");
-    builder.setSuperior(Collections.singleton(parent));
-    ObjectClass c = builder.getInstance();
-
-    Assert.assertTrue(c.isRequiredOrOptional(types[0]));
-    Assert.assertTrue(c.isRequiredOrOptional(types[1]));
-  }
-
-  /**
-   * Create test data for testing different combinations of superiors.
-   *
-   * @return Returns the array of test data.
-   */
-  @DataProvider(name = "superiorData")
-  public Object[][] createSuperiorData() {
-    ObjectClassBuilder builder = new ObjectClassBuilder(
-        "parent1", SchemaConstants.NO_ATTRIBUTES);
-    builder.setObjectClassType(ObjectClassType.ABSTRACT);
-    ObjectClass parent1 = builder.getInstance();
-
-    builder = new ObjectClassBuilder(
-        "parent2", "1.2");
-    builder.setObjectClassType(ObjectClassType.ABSTRACT);
-    ObjectClass parent2 = builder.getInstance();
-
-    builder = new ObjectClassBuilder(
-        "parent3", "1.3");
-    builder.setObjectClassType(ObjectClassType.STRUCTURAL);
-    ObjectClass parent3 = builder.getInstance();
-
-    builder = new ObjectClassBuilder(
-        "parent4", "1.4");
-    ObjectClass parent4 = builder.getInstance();
-
-    builder = new ObjectClassBuilder(
-        "parent5", "1.5");
-    builder.setObjectClassType(ObjectClassType.AUXILIARY);
-    ObjectClass parent5 = builder.getInstance();
-
-    builder = new ObjectClassBuilder(
-        "parent6", "1.6");
-    builder.setObjectClassType(ObjectClassType.AUXILIARY);
-    ObjectClass parent6 = builder.getInstance();
-
-    return new Object[][] { { parent1, parent2, ObjectClassType.ABSTRACT,true },
-        { parent3, parent4, ObjectClassType.STRUCTURAL,true },
-        { parent5, parent6, ObjectClassType.AUXILIARY,true }
-    };
-  }
-
-
-
-  /**
-   * Check incompatible superiors.
-   *
-   * @param parent1
-   *          First superior
-   * @param parent2
-   *          Second superior
-   * @param type
-   *          The object class type.
-   * @param isValid
-   *          Whether the superior combination is valid.
-   */
-  @Test(dataProvider = "superiorData")
-  public void testMultipleSuperiors(ObjectClass parent1,
-          ObjectClass parent2,
-          ObjectClassType type,
-          boolean isValid) throws Exception {
-    ObjectClassBuilder builder = new ObjectClassBuilder("testType", "1.2.3");
-    builder.setObjectClassType(type);
-    Set<ObjectClass> superiors = new LinkedHashSet<>();
-    superiors.add(parent1);
-    superiors.add(parent2);
-    builder.setSuperior(superiors);
-    ObjectClass child = builder.getInstance();
-    Assert.assertEquals(child.getSuperiorClasses().size(), 2);
-  }
-
-
-
-  /** {@inheritDoc} */
-  @Override
-  protected SchemaDefinitionBuilder getBuilder(String name, String oid) {
-    return new ObjectClassBuilder(name, oid);
-  }
-
-}

--
Gitblit v1.10.0