{
SchemaManager schemaManager = loadSystem();
int mrrSize = schemaManager.getMatchingRuleRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MatchingRule matchingRule = new MatchingRule( "2.5.13.0" );
matchingRule.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
// It should fail (oid already registered)
assertFalse( schemaManager.add( matchingRule ) );
List<Throwable> errors = schemaManager.getErrors();
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
assertTrue( error instanceof LdapSchemaException );
// Check that the existing MR has not been replaced
assertTrue( isMRPresent( schemaManager, "2.5.13.0" ) );
MatchingRule existing = schemaManager.lookupMatchingRuleRegistry( "2.5.13.0" );
assertEquals( "objectIdentifierMatch", existing.getName() );
assertEquals( mrrSize, schemaManager.getMatchingRuleRegistry().size() );
assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}