Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 14002 invoked from network); 24 Aug 2006 19:38:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Aug 2006 19:38:35 -0000 Received: (qmail 5421 invoked by uid 500); 24 Aug 2006 19:38:34 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 5397 invoked by uid 500); 24 Aug 2006 19:38:34 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 5386 invoked by uid 99); 24 Aug 2006 19:38:34 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Aug 2006 12:38:34 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Aug 2006 12:38:33 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id BDC611A981A; Thu, 24 Aug 2006 12:38:13 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060824193813.BDC611A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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() ); } }