From commits-return-16453-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Tue Dec 04 21:10:32 2007 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 59325 invoked from network); 4 Dec 2007 21:10:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Dec 2007 21:10:31 -0000 Received: (qmail 28944 invoked by uid 500); 4 Dec 2007 21:10:19 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 28895 invoked by uid 500); 4 Dec 2007 21:10:19 -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 28884 invoked by uid 99); 4 Dec 2007 21:10:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 13:10:19 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 21:10:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 03E261A9832; Tue, 4 Dec 2007 13:09:44 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r601086 - in /directory/apacheds/branches/bigbang: core-integ/src/test/java/org/apache/directory/server/core/ core-integ/src/test/java/org/apache/directory/server/core/jndi/ core-unit/src/test/java/org/apache/directory/server/core/jndi/ Date: Tue, 04 Dec 2007 21:09:43 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071204210947.03E261A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: akarasulu Date: Tue Dec 4 13:09:43 2007 New Revision: 601086 URL: http://svn.apache.org/viewvc?rev=601086&view=rev Log: converted two more tests to the new framework Added: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java - copied, changed from r600818, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java - copied, changed from r600818, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java Removed: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java Modified: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java Modified: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java?rev=601086&r1=601085&r2=601086&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java (original) +++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/StockCoreISuite.java Tue Dec 4 13:09:43 2007 @@ -53,7 +53,9 @@ DIRSERVER783IT.class, DIRSERVER791IT.class, ListIT.class, + ObjStateFactoryIT.class, ExtensibleObjectIT.class, + ModifyContextIT.class, PartitionConfigurationIT.class // Leaves the server in a bad state (partition removal is incomplete) } ) @Scope ( ServiceScope.TESTSUITE ) Copied: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java (from r600818, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java) URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java?p2=directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java&p1=directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java&r1=600818&r2=601086&rev=601086&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ModifyContextITest.java (original) +++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ModifyContextIT.java Tue Dec 4 13:09:43 2007 @@ -20,14 +20,20 @@ package org.apache.directory.server.core.jndi; +import org.apache.directory.server.core.DirectoryService; +import org.apache.directory.server.core.integ.CiRunner; +import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext; +import org.apache.directory.shared.ldap.message.AttributeImpl; +import org.apache.directory.shared.ldap.message.AttributesImpl; +import static org.junit.Assert.*; +import org.junit.Test; +import org.junit.runner.RunWith; + import javax.naming.NamingException; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.directory.DirContext; - -import org.apache.directory.server.core.unit.AbstractAdminTestCase; -import org.apache.directory.shared.ldap.message.AttributeImpl; -import org.apache.directory.shared.ldap.message.AttributesImpl; +import javax.naming.ldap.LdapContext; /** @@ -37,120 +43,126 @@ * @author Apache Directory Project * @version $Rev$ */ -public class ModifyContextITest extends AbstractAdminTestCase +@RunWith ( CiRunner.class ) +public class ModifyContextIT { - protected void setUp() throws Exception + public static DirectoryService service; + + + /** + * @todo put this into an ldif annotation + * + * @throws NamingException on error + */ + protected void createData() throws NamingException { - super.setUp(); + LdapContext sysRoot = getSystemContext( service ); - try - { - /* - * create ou=testing00,ou=system - */ - Attributes attributes = new AttributesImpl( true ); - Attribute attribute = new AttributeImpl( "objectClass" ); - attribute.add( "top" ); - attribute.add( "organizationalUnit" ); - attributes.put( attribute ); - attributes.put( "ou", "testing00" ); - DirContext ctx = sysRoot.createSubcontext( "ou=testing00", attributes ); - assertNotNull( ctx ); - - ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" ); - assertNotNull( ctx ); - - attributes = ctx.getAttributes( "" ); - assertNotNull( attributes ); - assertEquals( "testing00", attributes.get( "ou" ).get() ); - attribute = attributes.get( "objectClass" ); - assertNotNull( attribute ); - assertTrue( attribute.contains( "top" ) ); - assertTrue( attribute.contains( "organizationalUnit" ) ); - - /* - * create ou=testing01,ou=system - */ - attributes = new AttributesImpl( true ); - attribute = new AttributeImpl( "objectClass" ); - attribute.add( "top" ); - attribute.add( "organizationalUnit" ); - attributes.put( attribute ); - attributes.put( "ou", "testing01" ); - ctx = sysRoot.createSubcontext( "ou=testing01", attributes ); - assertNotNull( ctx ); - - ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" ); - assertNotNull( ctx ); - - attributes = ctx.getAttributes( "" ); - assertNotNull( attributes ); - assertEquals( "testing01", attributes.get( "ou" ).get() ); - attribute = attributes.get( "objectClass" ); - assertNotNull( attribute ); - assertTrue( attribute.contains( "top" ) ); - assertTrue( attribute.contains( "organizationalUnit" ) ); - - /* - * create ou=testing02,ou=system - */ - attributes = new AttributesImpl( true ); - attribute = new AttributeImpl( "objectClass" ); - attribute.add( "top" ); - attribute.add( "organizationalUnit" ); - attributes.put( attribute ); - attributes.put( "ou", "testing02" ); - ctx = sysRoot.createSubcontext( "ou=testing02", attributes ); - assertNotNull( ctx ); - - ctx = ( DirContext ) sysRoot.lookup( "ou=testing02" ); - assertNotNull( ctx ); - - attributes = ctx.getAttributes( "" ); - assertNotNull( attributes ); - assertEquals( "testing02", attributes.get( "ou" ).get() ); - attribute = attributes.get( "objectClass" ); - assertNotNull( attribute ); - assertTrue( attribute.contains( "top" ) ); - assertTrue( attribute.contains( "organizationalUnit" ) ); - - /* - * create ou=subtest,ou=testing01,ou=system - */ - ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" ); - - attributes = new AttributesImpl( true ); - attribute = new AttributeImpl( "objectClass" ); - attribute.add( "top" ); - attribute.add( "organizationalUnit" ); - attributes.put( attribute ); - attributes.put( "ou", "subtest" ); - ctx = ctx.createSubcontext( "ou=subtest", attributes ); - assertNotNull( ctx ); - - ctx = ( DirContext ) sysRoot.lookup( "ou=subtest,ou=testing01" ); - assertNotNull( ctx ); - - attributes = ctx.getAttributes( "" ); - assertNotNull( attributes ); - assertEquals( "subtest", attributes.get( "ou" ).get() ); - attribute = attributes.get( "objectClass" ); - assertNotNull( attribute ); - assertTrue( attribute.contains( "top" ) ); - assertTrue( attribute.contains( "organizationalUnit" ) ); - } - catch ( NamingException e ) - { - } + /* + * create ou=testing00,ou=system + */ + Attributes attributes = new AttributesImpl( true ); + Attribute attribute = new AttributeImpl( "objectClass" ); + attribute.add( "top" ); + attribute.add( "organizationalUnit" ); + attributes.put( attribute ); + attributes.put( "ou", "testing00" ); + DirContext ctx = sysRoot.createSubcontext( "ou=testing00", attributes ); + assertNotNull( ctx ); + + ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" ); + assertNotNull( ctx ); + + attributes = ctx.getAttributes( "" ); + assertNotNull( attributes ); + assertEquals( "testing00", attributes.get( "ou" ).get() ); + attribute = attributes.get( "objectClass" ); + assertNotNull( attribute ); + assertTrue( attribute.contains( "top" ) ); + assertTrue( attribute.contains( "organizationalUnit" ) ); + + /* + * create ou=testing01,ou=system + */ + attributes = new AttributesImpl( true ); + attribute = new AttributeImpl( "objectClass" ); + attribute.add( "top" ); + attribute.add( "organizationalUnit" ); + attributes.put( attribute ); + attributes.put( "ou", "testing01" ); + ctx = sysRoot.createSubcontext( "ou=testing01", attributes ); + assertNotNull( ctx ); + + ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" ); + assertNotNull( ctx ); + + attributes = ctx.getAttributes( "" ); + assertNotNull( attributes ); + assertEquals( "testing01", attributes.get( "ou" ).get() ); + attribute = attributes.get( "objectClass" ); + assertNotNull( attribute ); + assertTrue( attribute.contains( "top" ) ); + assertTrue( attribute.contains( "organizationalUnit" ) ); + + /* + * create ou=testing02,ou=system + */ + attributes = new AttributesImpl( true ); + attribute = new AttributeImpl( "objectClass" ); + attribute.add( "top" ); + attribute.add( "organizationalUnit" ); + attributes.put( attribute ); + attributes.put( "ou", "testing02" ); + ctx = sysRoot.createSubcontext( "ou=testing02", attributes ); + assertNotNull( ctx ); + + ctx = ( DirContext ) sysRoot.lookup( "ou=testing02" ); + assertNotNull( ctx ); + + attributes = ctx.getAttributes( "" ); + assertNotNull( attributes ); + assertEquals( "testing02", attributes.get( "ou" ).get() ); + attribute = attributes.get( "objectClass" ); + assertNotNull( attribute ); + assertTrue( attribute.contains( "top" ) ); + assertTrue( attribute.contains( "organizationalUnit" ) ); + + /* + * create ou=subtest,ou=testing01,ou=system + */ + ctx = ( DirContext ) sysRoot.lookup( "ou=testing01" ); + + attributes = new AttributesImpl( true ); + attribute = new AttributeImpl( "objectClass" ); + attribute.add( "top" ); + attribute.add( "organizationalUnit" ); + attributes.put( attribute ); + attributes.put( "ou", "subtest" ); + ctx = ctx.createSubcontext( "ou=subtest", attributes ); + assertNotNull( ctx ); + + ctx = ( DirContext ) sysRoot.lookup( "ou=subtest,ou=testing01" ); + assertNotNull( ctx ); + + attributes = ctx.getAttributes( "" ); + assertNotNull( attributes ); + assertEquals( "subtest", attributes.get( "ou" ).get() ); + attribute = attributes.get( "objectClass" ); + assertNotNull( attribute ); + assertTrue( attribute.contains( "top" ) ); + assertTrue( attribute.contains( "organizationalUnit" ) ); } + @Test public void testModifyOperation() throws NamingException { + createData(); + + LdapContext sysRoot = getSystemContext( service ); Attributes attributes = new AttributesImpl( true ); attributes.put( "ou", "testCases" ); sysRoot.modifyAttributes( "ou=testing00", DirContext.ADD_ATTRIBUTE, attributes ); - attributes = null; DirContext ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" ); attributes = ctx.getAttributes( "" ); Copied: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java (from r600818, directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java) URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java?p2=directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java&p1=directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java&r1=600818&r2=601086&rev=601086&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryITest.java (original) +++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java Tue Dec 4 13:09:43 2007 @@ -20,7 +20,18 @@ package org.apache.directory.server.core.jndi; -import java.util.Hashtable; +import org.apache.directory.server.core.DirectoryService; +import org.apache.directory.server.core.integ.CiRunner; +import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext; +import static org.apache.directory.server.core.integ.IntegrationUtils.getUserAddLdif; +import static org.apache.directory.server.core.integ.IntegrationUtils.getRootContext; +import org.apache.directory.shared.ldap.message.AttributeImpl; +import org.apache.directory.shared.ldap.message.AttributesImpl; +import org.apache.directory.shared.ldap.util.ArrayUtils; +import org.apache.directory.shared.ldap.ldif.Entry; +import static org.junit.Assert.*; +import org.junit.Test; +import org.junit.runner.RunWith; import javax.naming.Context; import javax.naming.Name; @@ -28,13 +39,10 @@ import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.directory.SchemaViolationException; +import javax.naming.ldap.LdapContext; import javax.naming.spi.DirObjectFactory; import javax.naming.spi.DirStateFactory; - -import org.apache.directory.server.core.unit.AbstractAdminTestCase; -import org.apache.directory.shared.ldap.message.AttributeImpl; -import org.apache.directory.shared.ldap.message.AttributesImpl; -import org.apache.directory.shared.ldap.util.ArrayUtils; +import java.util.Hashtable; /** @@ -43,13 +51,22 @@ * @author Apache Directory Project * @version $Rev$ */ -public class ObjStateFactoryITest extends AbstractAdminTestCase +@RunWith ( CiRunner.class ) +public class ObjStateFactoryIT { + public static DirectoryService service; + + + @Test public void testObjectFactory() throws NamingException { - super.sysRoot.addToEnvironment( Context.OBJECT_FACTORIES, PersonObjectFactory.class.getName() ); - Object obj = super.sysRoot.lookup( "uid=akarasulu, ou=users" ); - Attributes attrs = super.sysRoot.getAttributes( "uid=akarasulu, ou=users" ); + Entry akarasulu = getUserAddLdif(); + getRootContext( service ).createSubcontext( akarasulu.getDn(), akarasulu.getAttributes() ); + + LdapContext sysRoot = getSystemContext( service ); + sysRoot.addToEnvironment( Context.OBJECT_FACTORIES, PersonObjectFactory.class.getName() ); + Object obj = sysRoot.lookup( "uid=akarasulu, ou=users" ); + Attributes attrs = sysRoot.getAttributes( "uid=akarasulu, ou=users" ); assertEquals( Person.class, obj.getClass() ); Person me = ( Person ) obj; assertEquals( attrs.get( "sn" ).get(), me.getLastname() ); @@ -61,12 +78,15 @@ } + @Test public void testStateFactory() throws NamingException { - super.sysRoot.addToEnvironment( Context.STATE_FACTORIES, PersonStateFactory.class.getName() ); + LdapContext sysRoot = getSystemContext( service ); + + sysRoot.addToEnvironment( Context.STATE_FACTORIES, PersonStateFactory.class.getName() ); Person p = new Person( "Rodriguez", "Mr. Kerberos", "noices", "555-1212", "sn=erodriguez", "committer" ); - super.sysRoot.bind( "uid=erodriguez, ou=users", p ); - Attributes attrs = super.sysRoot.getAttributes( "uid=erodriguez, ou=users" ); + sysRoot.bind( "uid=erodriguez, ou=users", p ); + Attributes attrs = sysRoot.getAttributes( "uid=erodriguez, ou=users" ); assertEquals( "Rodriguez", attrs.get( "sn" ).get() ); assertEquals( "Mr. Kerberos", attrs.get( "cn" ).get() ); assertTrue( ArrayUtils.isEquals( attrs.get( "userPassword" ).get(), "noices".getBytes() ) ); @@ -75,6 +95,7 @@ assertEquals( "committer", attrs.get( "description" ).get() ); } + public static class PersonStateFactory implements DirStateFactory { public Result getStateToBind( Object obj, Name name, Context nameCtx, Hashtable environment, Attributes inAttrs ) @@ -155,6 +176,7 @@ throw new UnsupportedOperationException( "Please use directory support overload with Attributes argument." ); } } + public static class PersonObjectFactory implements DirObjectFactory { Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java?rev=601086&r1=601085&r2=601086&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java (original) +++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java Tue Dec 4 13:09:43 2007 @@ -80,20 +80,17 @@ super.setUp(); } - + public void testSearch() throws NamingException { SearchControls sc = new SearchControls(); sc.setSearchScope( SearchControls.SUBTREE_SCOPE ); NamingEnumeration ne = sysRoot.search( "", "(objectClass=*)", sc ); - assertTrue( "Search should return at least one entry.", ne.hasMore() ); SearchResult sr = ( SearchResult ) ne.next(); - assertEquals( "The entry returned should be the root entry.", suffix, sr.getName() ); - assertFalse( "Search should return no more entries.", ne.hasMore() ); } @@ -116,13 +113,10 @@ sc.setSearchScope( SearchControls.OBJECT_SCOPE ); NamingEnumeration ne = sysRoot.search( dn, "(objectClass=*)", sc ); - assertTrue( "Search should return at least one entry.", ne.hasMore() ); SearchResult sr = ( SearchResult ) ne.next(); - assertEquals( "The entry returned should be the entry added earlier.", dn + "," + suffix, sr.getName() ); - assertFalse( "Search should return no more entries.", ne.hasMore() ); } @@ -152,18 +146,15 @@ sc.setSearchScope( SearchControls.OBJECT_SCOPE ); NamingEnumeration ne = sysRoot.search( dn, "(objectClass=*)", sc ); - assertTrue( "Search should return at least one entry.", ne.hasMore() ); SearchResult sr = ( SearchResult ) ne.next(); - assertEquals( "The entry returned should be the entry added earlier.", dn + "," + suffix, sr.getName() ); attributes = sr.getAttributes(); attribute = attributes.get( "description" ); assertEquals( "The description attribute should contain the new value.", description, attribute.get() ); - assertFalse( "Search should return no more entries.", ne.hasMore() ); } @@ -190,14 +181,11 @@ try { sysRoot.search( dn, "(objectClass=*)", sc ); - fail( "Search should throw exception." ); - } catch ( LdapNameNotFoundException e ) { // ignore } } - }