| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public final void testSchemaBuilderDoesntAllowNullEntry() throws Exception { |
| | | final Entry e = null; |
| | | @SuppressWarnings("unused") |
| | | final SchemaBuilder builder = new SchemaBuilder(e); |
| | | new SchemaBuilder((Entry) null); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertThat(e.getAttribute(Schema.ATTR_DIT_STRUCTURE_RULES)).isNull(); |
| | | assertThat(e.getAttribute(Schema.ATTR_NAME_FORMS)).isNull(); |
| | | |
| | | builder.addSchema(Schema.getCoreSchema(), false); |
| | | Schema schema = builder.toSchema(); |
| | | // Need to add the core schema for the standards attributes. |
| | | schema = Schema.getCoreSchema(); |
| | | |
| | | assertThat(schema.getAttributeType("myCustomAttribute")).isNotNull(); |
| | | assertThat(schema.getAttributeType("myCustomAttribute").getNameOrOID()).isEqualTo( |
| | |
| | | assertThat(schema.getAttributeType("myCustomAttribute").getUsage().toString()).isEqualTo( |
| | | "userApplications"); |
| | | |
| | | assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotNull(); |
| | | assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertThat(e.getAttribute(Schema.ATTR_OBJECT_CLASSES)).isNotNull(); |
| | | |
| | | Schema schema = builder.toSchema(); |
| | | // Warnings expected. |
| | | assertThat(schema.getWarnings()).isNotEmpty(); |
| | | assertThat(schema.getAttributeType("myCustomAttribute")).isNotNull(); |
| | | } |
| | | |
| | |
| | | Schema schema = builder.toSchema(); |
| | | // No warnings |
| | | assertThat(schema.getWarnings()).isEmpty(); |
| | | assertThat(schema.getSyntaxes()).isNotNull(); |
| | | assertThat(schema.getSyntaxes()).isNotEmpty(); |
| | | assertThat(schema.getSyntax("1.3.6.1.4.1.1466.115.121.1.15").getDescription()).isEqualTo( |
| | | "Add a new ldapsyntax"); |
| | | } |
| | |
| | | final Entry e = new LinkedHashMapEntry(strEntry); |
| | | final SchemaBuilder builder = new SchemaBuilder(); |
| | | builder.addSchema(Schema.getCoreSchema(), false); |
| | | builder.addSchema(e, true); |
| | | builder.addSchema(e, false); |
| | | |
| | | assertThat(e.getAttribute(Schema.ATTR_LDAP_SYNTAXES)).isNotNull(); |
| | | assertThat(e.getAttribute(Schema.ATTR_ATTRIBUTE_TYPES)).isNull(); |
| | |
| | | final Entry e = new LinkedHashMapEntry(strEntry); |
| | | final SchemaBuilder builder = new SchemaBuilder(); |
| | | builder.addSchema(Schema.getCoreSchema(), false); |
| | | builder.addSchema(e, true); |
| | | builder.addSchema(e, false); |
| | | |
| | | assertThat(e.getAttribute(Schema.ATTR_LDAP_SYNTAXES)).isNull(); |
| | | assertThat(e.getAttribute(Schema.ATTR_ATTRIBUTE_TYPES)).isNull(); |
| | |
| | | |
| | | Schema schema = builder.toSchema(); |
| | | |
| | | assertThat(schema.getMatchingRuleUses()).isNotNull(); |
| | | assertThat(schema.getMatchingRuleUses()).isNotEmpty(); |
| | | assertThat(schema.getMatchingRuleUse("bitStringMatch").toString()).isEqualTo( |
| | | "( 2.5.13.16 NAME 'bitStringMatch' APPLIES ( givenName $ surname ) )"); |
| | | // The schema do not contain warnings. |
| | |
| | | final Entry e = new LinkedHashMapEntry(strEntry); |
| | | final SchemaBuilder builder = new SchemaBuilder(); |
| | | builder.addSchema(Schema.getCoreSchema(), false); |
| | | builder.addSchema(e, true); |
| | | builder.addSchema(e, false); |
| | | |
| | | assertThat(e.getAttribute(Schema.ATTR_LDAP_SYNTAXES)).isNull(); |
| | | assertThat(e.getAttribute(Schema.ATTR_ATTRIBUTE_TYPES)).isNull(); |
| | |
| | | |
| | | Schema schema = builder.toSchema(); |
| | | |
| | | assertThat(schema.getMatchingRuleUses()).isNotNull(); |
| | | assertThat(schema.getMatchingRules()).isNotEmpty(); |
| | | assertThat(schema.getMatchingRule("bitStringMatch").toString()).isEqualTo( |
| | | "( 2.5.13.16 NAME 'bitStringMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )"); |
| | | // The schema do not contain warnings. |
| | |
| | | |
| | | Schema schema = builder.toSchema(); |
| | | |
| | | assertThat(schema.getDITContentRules()).isNotNull(); |
| | | assertThat(schema.getDITContentRules()).isNotEmpty(); |
| | | assertThat(schema.getDITContentRule("2.5.6.4").toString()) |
| | | .isEqualTo( |
| | | "( 2.5.6.4 DESC 'content rule for organization' NOT ( x121Address $ telexNumber ) )"); |
| | |
| | | assertThat(schema.getAttributeType("myCustomAttribute").getDescription().toString()) |
| | | .isEqualTo("A short description"); |
| | | |
| | | assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotNull(); |
| | | assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | "userApplications"); |
| | | assertThat(schema.getAttributeType("myCustomAttribute").getDescription().toString()) |
| | | .isEqualTo("A short description"); |
| | | |
| | | assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotNull(); |
| | | assertThat(schema.getObjectClassesWithName("myCustomObjClass")).isNotEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | new SchemaBuilder(Schema.getDefaultSchema()) |
| | | .addMatchingRuleUse( |
| | | "( 2.5.13.16 NAME 'bitStringMatch' APPLIES ( givenName $ name ) )", true) |
| | | .addMatchingRuleUse(// from RFC 4517 |
| | | .addMatchingRuleUse( |
| | | "( 2.5.13.16 NAME 'bitStringMatch' APPLIES ( givenName $ surname ) )", true) |
| | | .toSchema(); |
| | | // @formatter:on |
| | |
| | | boolean isRemoved = scBuild.removeAttributeType("myCustomAttribute"); |
| | | assertThat(isRemoved).isTrue(); |
| | | Schema schema = scBuild.toSchema(); |
| | | // The following line throws an exception.: |
| | | // The following line throws an exception : |
| | | assertThat(schema.getAttributeType("myCustomAttribute")).isNull(); |
| | | } |
| | | |
| | |
| | | assertThat(sc.getNameForms()).isNotNull(); |
| | | assertThat(sc.getNameForms()).isEmpty(); |
| | | |
| | | |
| | | connection.close(); |
| | | } |
| | | } |