directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r434478 - in /directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src: main/schema/car.schema test/java/SchemaTest.java
Date Thu, 24 Aug 2006 19:38:12 GMT
Author: akarasulu
Date: Thu Aug 24 12:38:08 2006
New Revision: 434478

URL: http://svn.apache.org/viewvc?rev=434478&view=rev
Log:
filling in test case methods to test and use the new schema

Modified:
    directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/main/schema/car.schema
    directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/test/java/SchemaTest.java

Modified: directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/main/schema/car.schema
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/main/schema/car.schema?rev=434478&r1=434477&r2=434478&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/main/schema/car.schema
(original)
+++ directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/main/schema/car.schema
Thu Aug 24 12:38:08 2006
@@ -35,7 +35,7 @@
     EQUALITY integerMatch
     SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
 
-objectclass ( 1.2.6.1.4.1.18060.1.1.1.4.1000
+objectclass ( 1.2.6.1.4.1.18060.1.1.1.4.1001
     NAME 'car'
     SUP top
     STRUCTURAL

Modified: directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/test/java/SchemaTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/test/java/SchemaTest.java?rev=434478&r1=434477&r2=434478&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/test/java/SchemaTest.java
(original)
+++ directory/branches/apacheds/1.0/schema-archetype/src/main/resources/archetype-resources/src/test/java/SchemaTest.java
Thu Aug 24 12:38:08 2006
@@ -20,12 +20,19 @@
 package ${groupId};
 
 
-import javax.naming.directory.*;
+import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
 
 import org.apache.directory.server.unit.AbstractServerTest;
 
+import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Set;
 
 
 /**
@@ -49,8 +56,12 @@
         // Setup our schema to load       
         // -------------------------------------------------------------------
 
-        // todo 
-
+        Set schemas = configuration.getBootstrapSchemas();
+        Set newset = new HashSet();
+        newset.addAll( schemas );
+        newset.add( new CarSchema() );
+        configuration.setBootstrapSchemas( newset );
+        
         super.setUp();
 
         // -------------------------------------------------------------------
@@ -83,6 +94,55 @@
      */
     public void testSchemaPresence() throws NamingException
     {
+        Attributes attrs = ctx.getAttributes( "cn=schema", new String[] { "attributeTypes",
"objectClasses" } );
+
+        // -------------------------------------------------------------------
+        // Check that our 3 attributeTypes are present in cn=schema,ou=system
+        // -------------------------------------------------------------------
+        
+        Attribute attributeTypes = attrs.get( "attributeTypes" );
+        boolean isCarMakeFound = false;
+        boolean isCarModelFound = false;
+        boolean isCarYearFound = false;
+        for ( NamingEnumeration ii = attributeTypes.getAll(); ii.hasMore(); /**/ )
+        {
+            String id = ( String ) ii.next();
+
+            if ( id.indexOf( "1.2.6.1.4.1.18060.1.1.1.3.1001" ) != -1 )
+            {
+                isCarMakeFound = true;
+            }
+            
+            if ( id.indexOf( "1.2.6.1.4.1.18060.1.1.1.3.1002" ) != -1 )
+            {
+                isCarModelFound = true;
+            }
+            
+            if ( id.indexOf( "1.2.6.1.4.1.18060.1.1.1.3.1003" ) != -1 )
+            {
+                isCarYearFound = true;
+            }
+        }
+        assertTrue( isCarMakeFound );
+        assertTrue( isCarModelFound );
+        assertTrue( isCarYearFound );
+        
+        // -------------------------------------------------------------------
+        // Check that our 1 objectClass is present in cn=schema,ou=system
+        // -------------------------------------------------------------------
+        
+        Attribute objectClasses = attrs.get( "objectClasses" );
+        boolean isCarFound = false;
+        for ( NamingEnumeration ii = objectClasses.getAll(); ii.hasMore(); /**/ )
+        {
+            String id = ( String ) ii.next();
+
+            if ( id.indexOf( "1.2.6.1.4.1.18060.1.1.1.4.1001" ) != -1 )
+            {
+                isCarFound = true;
+            }
+        }
+        assertTrue( isCarFound );
     }
 
 
@@ -91,5 +151,16 @@
      */
     public void testAddCar() throws NamingException
     {
+        Attributes newCar = new BasicAttributes( "objectClass", "car", true );
+        newCar.put( "carMake", "Porsche" );
+        newCar.put( "carModel", "Boxter" );
+        newCar.put( "carYear", "2006" );
+        ctx.createSubcontext( "carMake=Porsche", newCar );
+        
+        Attributes porsche = ctx.getAttributes( "carMake=Porsche" );
+        assertNotNull( porsche );
+        assertEquals( "Porsche", porsche.get( "carMake" ).get() );
+        assertEquals( "Boxter", porsche.get( "carModel" ).get() );
+        assertEquals( "2006", porsche.get( "carYear" ).get() );
     }
 }



Mime
View raw message