| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.NameForm; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of generic tests that may be used to examine the |
| | | * server schema. |
| | | */ |
| | | /** This class defines a set of generic tests that may be used to examine the server schema. */ |
| | | public class GenericSchemaTestCase |
| | | extends SchemaTestCase |
| | | { |
| | |
| | | } |
| | | |
| | | LDIFImportConfig importConfig = new LDIFImportConfig(f.getAbsolutePath()); |
| | | LDIFReader reader = new LDIFReader(importConfig); |
| | | Entry e = reader.readEntry(); |
| | | reader.close(); |
| | | |
| | | if (e == null) |
| | | Entry e; |
| | | try (LDIFReader reader = new LDIFReader(importConfig)) |
| | | { |
| | | // An empty schema file. This is OK. |
| | | continue; |
| | | e = reader.readEntry(); |
| | | if (e == null) |
| | | { |
| | | // An empty schema file. This is OK. |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType("objectclasses"); |
| | | assertNotNull(attrType); |
| | | List<Attribute> attrList = e.getAttribute(attrType); |
| | | List<Attribute> attrList = e.getAttribute("objectclasses"); |
| | | if (attrList.isEmpty()) |
| | | { |
| | | // No attribute types in the schema file. This is OK. |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | ObjectClass oc = ObjectClassSyntax.decodeObjectClass( |
| | | v, DirectoryServer.getSchema(), true); |
| | | ObjectClass oc = DirectoryServer.getSchema().parseObjectClass(v.toString()); |
| | | if (! isNumericOID(oc.getOID())) |
| | | { |
| | | invalidOIDs.add(oc.getNameOrOID()); |
| | |
| | | |
| | | if (! invalidOIDs.isEmpty()) |
| | | { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("All object classes defined in OpenDS must have valid ").append("OIDs assigned."); |
| | | message.append(EOL); |
| | | message.append("Object classes without valid OIDs:"); |
| | | message.append(EOL); |
| | | StringBuilder message = new StringBuilder() |
| | | .append("All object classes defined in OpenDS must have valid OIDs assigned.").append(EOL) |
| | | .append("Object classes without valid OIDs:").append(EOL); |
| | | for (String s : invalidOIDs) |
| | | { |
| | | message.append("- ").append(s); |
| | | message.append(EOL); |
| | | message.append("- ").append(s).append(EOL); |
| | | } |
| | | |
| | | throw new AssertionError(message.toString()); |
| | | } |
| | | } |