You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/09/12 01:41:42 UTC
svn commit: r280212 - in /directory/apacheds/trunk/core/src:
main/java/org/apache/ldap/server/exception/ExceptionService.java
test/org/apache/ldap/server/jndi/MixedCaseTest.java
Author: akarasulu
Date: Sun Sep 11 16:41:34 2005
New Revision: 280212
URL: http://svn.apache.org/viewcvs?rev=280212&view=rev
Log:
comming patch from Endi on DIREVE-245 here http://issues.apache.org/jira/browse/DIREVE-245
Added:
directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/MixedCaseTest.java (with props)
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java?rev=280212&r1=280211&r2=280212&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/exception/ExceptionService.java Sun Sep 11 16:41:34 2005
@@ -84,8 +84,7 @@
throw ne;
}
- Name parentDn = new LdapName( upName );
- parentDn = parentDn.getSuffix( 1 );
+ Name parentDn = normName.getSuffix( 1 );
// check if we don't have the parent to add to
assertHasEntry( nextInterceptor, "Attempt to add under non-existant parent: ", parentDn );
Added: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/MixedCaseTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/MixedCaseTest.java?rev=280212&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/MixedCaseTest.java (added)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/MixedCaseTest.java Sun Sep 11 16:41:34 2005
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.ldap.server.jndi;
+
+
+import javax.naming.NamingException;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.*;
+
+import org.apache.ldap.server.AbstractAdminTestCase;
+import org.apache.ldap.server.configuration.MutableContextPartitionConfiguration;
+import org.apache.ldap.common.exception.LdapNameNotFoundException;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * Tests various operations against a partition whose suffix contains both upper and lower case letters.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MixedCaseTest extends AbstractAdminTestCase
+{
+ String suffix = "dc=Apache,dc=Org";
+
+ public void setUp() throws Exception
+ {
+
+ MutableContextPartitionConfiguration partition = new MutableContextPartitionConfiguration();
+ partition.setName( "apache" );
+ partition.setSuffix( suffix );
+
+ Set indexedAttributes = new HashSet();
+ indexedAttributes.add( "objectClass" );
+ indexedAttributes.add( "ou" );
+ indexedAttributes.add( "uid" );
+ partition.setIndexedAttributes( indexedAttributes );
+
+ Attributes attrs = new BasicAttributes( true );
+ Attribute objectClass = new BasicAttribute( "objectClass" );
+ objectClass.add( "top" );
+ objectClass.add( "domain" );
+ objectClass.add( "extensibleObject" );
+ attrs.put( objectClass );
+ attrs.put( "dc", "Apache" );
+
+ partition.setContextEntry( attrs );
+
+ Set partitions = new HashSet();
+ partitions.add( partition );
+
+ configuration.setContextPartitionConfigurations( partitions );
+ super.overrideEnvironment( Context.PROVIDER_URL, suffix );
+
+ 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() );
+ }
+
+ public void testAdd() throws NamingException
+ {
+ String dn = "ou=Test";
+
+ Attributes attributes = new BasicAttributes( true );
+ Attribute attribute = new BasicAttribute( "objectClass" );
+ attribute.add( "top" );
+ attribute.add( "organizationalUnit" );
+ attributes.put( attribute );
+ attributes.put( "ou", "Test" );
+
+ DirContext ctx = sysRoot.createSubcontext( dn, attributes );
+ assertNotNull( ctx );
+
+ SearchControls sc = new SearchControls();
+ 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() );
+ }
+
+ public void testModify() throws NamingException
+ {
+ String dn = "ou=Test";
+ String description = "New Value";
+
+ Attributes attributes = new BasicAttributes( true );
+ Attribute attribute = new BasicAttribute( "objectClass" );
+ attribute.add( "top" );
+ attribute.add( "organizationalUnit" );
+ attributes.put( attribute );
+ attributes.put( "ou", "Test" );
+ attributes.put( "description", "Old Value" );
+
+ DirContext ctx = sysRoot.createSubcontext( dn, attributes );
+ assertNotNull( ctx );
+
+ ModificationItem[] mods = new ModificationItem[1];
+ mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute( "description", description ));
+
+ sysRoot.modifyAttributes( dn, mods );
+
+ SearchControls sc = new SearchControls();
+ 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() );
+ }
+
+ public void testDelete() throws NamingException
+ {
+ String dn = "ou=Test";
+
+ Attributes attributes = new BasicAttributes( true );
+ Attribute attribute = new BasicAttribute( "objectClass" );
+ attribute.add( "top" );
+ attribute.add( "organizationalUnit" );
+ attributes.put( attribute );
+ attributes.put( "ou", "Test" );
+
+ DirContext ctx = sysRoot.createSubcontext( dn, attributes );
+ assertNotNull( ctx );
+
+ sysRoot.destroySubcontext( dn );
+
+ SearchControls sc = new SearchControls();
+ sc.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ try {
+ sysRoot.search( dn, "(objectClass=*)", sc );
+
+ fail( "Search should throw exception.");
+
+ } catch (LdapNameNotFoundException e) {
+ // ignore
+ }
+ }
+
+}
+
Propchange: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/MixedCaseTest.java
------------------------------------------------------------------------------
svn:eol-style = native