You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/05/26 01:21:20 UTC

svn commit: r948249 - in /directory/shared/trunk: ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/ ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/

Author: elecharny
Date: Tue May 25 23:21:20 2010
New Revision: 948249

URL: http://svn.apache.org/viewvc?rev=948249&view=rev
Log:
Added two tests to check if an AT without MR can be added.

Modified:
    directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerAddTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java

Modified: directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerAddTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerAddTest.java?rev=948249&r1=948248&r2=948249&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerAddTest.java (original)
+++ directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/SchemaManagerAddTest.java Tue May 25 23:21:20 2010
@@ -52,7 +52,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.comparators.CsnComparator;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
-import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer;
 import org.apache.directory.shared.ldap.schema.syntaxCheckers.OctetStringSyntaxChecker;
@@ -385,6 +384,32 @@ public class SchemaManagerAddTest
 
 
     /**
+     * Try to inject an AttributeType without EQUALITY MR
+     */
+    @Test
+    public void testAddAttributeTypeNoEqualityMR() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getGlobalOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.8 " );
+        attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+
+        // It should be OK
+        assertTrue( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 0, errors.size() );
+
+        assertTrue( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
+    }
+
+
+    /**
      * Try to inject an AttributeType with an invalid ORDERING MR
      */
     @Test
@@ -998,7 +1023,7 @@ public class SchemaManagerAddTest
 
         assertEquals( 1, errors.size() );
         Throwable error = errors.get( 0 );
-        
+
         assertTrue( error instanceof LdapProtocolErrorException );
 
         assertEquals( mrrSize, schemaManager.getMatchingRuleRegistry().size() );

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java?rev=948249&r1=948248&r2=948249&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java Tue May 25 23:21:20 2010
@@ -1068,4 +1068,27 @@ public class AttributeTypeDescriptionSch
         }
     }
 
+
+    /**
+     * Tests without EQUALITY
+     * 
+     * @throws ParseException
+     */
+    @Test
+    public void testNoqualityMR() throws ParseException
+    {
+        String value = "( 2.5.4.58 NAME 'attributeCertificateAttribute' " + "DESC 'attribute certificate use ;binary' "
+            + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.8 ) ";
+        AttributeType attributeType = parser.parseAttributeTypeDescription( value );
+
+        assertEquals( "2.5.4.58", attributeType.getOid() );
+        assertEquals( 1, attributeType.getNames().size() );
+        assertEquals( "attributeCertificateAttribute", attributeType.getNames().get( 0 ) );
+        assertEquals( "attribute certificate use ;binary", attributeType.getDescription() );
+        assertNull( attributeType.getSuperiorOid() );
+        assertNull( attributeType.getEqualityOid() );
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.8", attributeType.getSyntaxOid() );
+        assertEquals( UsageEnum.USER_APPLICATIONS, attributeType.getUsage() );
+        assertEquals( 0, attributeType.getExtensions().size() );
+    }
 }