Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 72607 invoked from network); 18 Aug 2007 15:46:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Aug 2007 15:46:26 -0000 Received: (qmail 22709 invoked by uid 500); 18 Aug 2007 15:46:24 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 22675 invoked by uid 500); 18 Aug 2007 15:46:23 -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 22664 invoked by uid 99); 18 Aug 2007 15:46:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Aug 2007 08:46:23 -0700 X-ASF-Spam-Status: No, hits=-98.8 required=10.0 tests=ALL_TRUSTED,DNS_FROM_DOB,RCVD_IN_DOB 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; Sat, 18 Aug 2007 15:46:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 169AF1A981A; Sat, 18 Aug 2007 08:46:02 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r567280 - in /directory/apacheds/trunk/server-unit/src/test: java/org/apache/directory/server/DIRSERVER951ITest.java resources/org/apache/directory/server/DIRSERVER951ITest.ldif Date: Sat, 18 Aug 2007 15:46:01 -0000 To: commits@directory.apache.org From: malderson@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070818154602.169AF1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: malderson Date: Sat Aug 18 08:46:01 2007 New Revision: 567280 URL: http://svn.apache.org/viewvc?view=rev&rev=567280 Log: Test case for DIRSERVER-951. Added: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/DIRSERVER951ITest.ldif Added: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java?view=auto&rev=567280 ============================================================================== --- directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java (added) +++ directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java Sat Aug 18 08:46:01 2007 @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.server; + + +import java.util.HashSet; +import java.util.Set; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.SearchControls; +import javax.naming.directory.SearchResult; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.server.core.partition.Oid; +import org.apache.directory.server.core.partition.PartitionNexus; +import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration; +import org.apache.directory.server.unit.AbstractServerTest; +import org.apache.directory.shared.ldap.constants.SchemaConstants; +import org.apache.directory.shared.ldap.message.AttributeImpl; +import org.apache.directory.shared.ldap.message.AttributesImpl; +import org.apache.directory.shared.ldap.util.DateUtils; +import org.apache.directory.shared.ldap.util.NamespaceTools; + + +/** + * A set of tests to make sure the negation operator is working + * properly when included in search filters. Created in response + * to JIRA issue + * DIRSERVER-951. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class DIRSERVER951ITest extends AbstractServerTest +{ + private LdapContext ctx = null; + + + /** + * Create context and entries for tests. + */ + public void setUp() throws Exception + { + MutableBTreePartitionConfiguration systemCfg = new MutableBTreePartitionConfiguration(); + systemCfg.setId( "system" ); + + // @TODO need to make this configurable for the system partition + systemCfg.setCacheSize( 500 ); + + systemCfg.setSuffix( PartitionNexus.SYSTEM_PARTITION_SUFFIX ); + + // Add indexed attributes for system partition + Set indexedAttrs = new HashSet(); + indexedAttrs.add( Oid.ALIAS ); + indexedAttrs.add( Oid.EXISTANCE ); + indexedAttrs.add( Oid.HIERARCHY ); + indexedAttrs.add( Oid.NDN ); + indexedAttrs.add( Oid.ONEALIAS ); + indexedAttrs.add( Oid.SUBALIAS ); + indexedAttrs.add( Oid.UPDN ); + indexedAttrs.add( SchemaConstants.OBJECT_CLASS_AT ); + indexedAttrs.add( SchemaConstants.CN_AT ); + systemCfg.setIndexedAttributes( indexedAttrs ); + + // Add context entry for system partition + Attributes systemEntry = new AttributesImpl(); + Attribute objectClassAttr = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT ); + objectClassAttr.add( SchemaConstants.TOP_OC ); + objectClassAttr.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC ); + objectClassAttr.add( SchemaConstants.EXTENSIBLE_OBJECT_OC ); + systemEntry.put( objectClassAttr ); + systemEntry.put( SchemaConstants.CREATORS_NAME_AT, PartitionNexus.ADMIN_PRINCIPAL ); + systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); + systemEntry.put( NamespaceTools.getRdnAttribute( PartitionNexus.SYSTEM_PARTITION_SUFFIX ), + NamespaceTools.getRdnValue( PartitionNexus.SYSTEM_PARTITION_SUFFIX ) ); + systemCfg.setContextEntry( systemEntry ); + + configuration.setSystemPartitionConfiguration( systemCfg ); + + super.setUp(); + super.loadTestLdif( true ); + ctx = getWiredContext(); + assertNotNull( ctx ); + } + + + /** + * Closes context and destroys server. + */ + public void tearDown() throws Exception + { + ctx.close(); + ctx = null; + super.tearDown(); + } + + + /** + * Tests to make sure a negated search for CN of "test1" returns + * those entries that do not have the CN attribute or do not have + * an "A" value for CN if the attribute exists. + */ + public void testSearchNotCN() throws Exception + { + //NOTE: This test is disabled while waiting for a fix to DIRSERVER-951. Uncomment to re-enable. +// Set results = getResults( "(!(cn=test1))" ); +// assertFalse( contains( "uid=test1,ou=test,ou=system", results ) ); +// assertTrue( contains( "uid=test2,ou=test,ou=system", results ) ); +// assertTrue( contains( "uid=testNoCN,ou=test,ou=system", results ) ); + } + + + boolean contains( String dn, Set results ) + { + for ( SearchResult result : results ) + { + if ( result.getNameInNamespace().equals( dn ) ) + { + return true; + } + } + + return false; + } + + + Set getResults( String filter ) throws NamingException + { + Set results = new HashSet(); + SearchControls controls = new SearchControls(); + controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); + NamingEnumeration namingEnumeration = ctx.search( "ou=system", filter, controls ); + while( namingEnumeration.hasMore() ) + { + results.add( namingEnumeration.next() ); + } + + return results; + } +} Added: directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/DIRSERVER951ITest.ldif URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/DIRSERVER951ITest.ldif?view=auto&rev=567280 ============================================================================== --- directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/DIRSERVER951ITest.ldif (added) +++ directory/apacheds/trunk/server-unit/src/test/resources/org/apache/directory/server/DIRSERVER951ITest.ldif Sat Aug 18 08:46:01 2007 @@ -0,0 +1,22 @@ +dn: ou=test,ou=system +objectClass: top +objectClass: organizationalUnit +ou: test + +dn: uid=test1,ou=test,ou=system +objectClass: top +objectClass: extensibleObject +uid: test1 +cn: test1 + +dn: uid=test2,ou=test,ou=system +objectClass: top +objectClass: extensibleObject +uid: test2 +cn: test2 + +dn: uid=testNoCN,ou=test,ou=system +objectClass: top +objectClass: extensibleObject +uid: testNoCN +