You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/07/26 18:44:00 UTC
svn commit: r979356 [1/3] - in /directory:
apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/
apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/
apacheds/trunk/core-integ/src/test/java/org/apache/...
Author: elecharny
Date: Mon Jul 26 16:44:00 2010
New Revision: 979356
URL: http://svn.apache.org/viewvc?rev=979356&view=rev
Log:
o Added methods in the LdapConnection classes (to be able to pass a DN as a String)
o Modified the impacted tests
o Fixed some failing tests due to the modifications done in the collective attribte handling in the schema manager (see DIRSERVER-1529/30/31)
Modified:
directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java
directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java?rev=979356&r1=979355&r2=979356&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java Mon Jul 26 16:44:00 2010
@@ -101,7 +101,7 @@ public class LdapCoreSessionConnection i
private DirectoryService directoryService;
private static final Logger LOG = LoggerFactory.getLogger( LdapCoreSessionConnection.class );
-
+
public LdapCoreSessionConnection()
{
@@ -127,7 +127,7 @@ public class LdapCoreSessionConnection i
{
throw new IOException( e.getMessage() );
}
-
+
return true;
}
@@ -148,7 +148,7 @@ public class LdapCoreSessionConnection i
return result;
}
-
+
private LdapResult getDefaultCompareResult()
{
LdapResult result = new LdapResult();
@@ -156,7 +156,7 @@ public class LdapCoreSessionConnection i
return result;
}
-
+
/**
* {@inheritDoc}
*/
@@ -287,19 +287,7 @@ public class LdapCoreSessionConnection i
*/
public CompareResponse compare( String dn, String attributeName, byte[] value ) throws LdapException
{
- CompareResponse resp = new CompareResponse();
- resp.setLdapResult( getDefaultCompareResult() );
-
- try
- {
- session.compare( new DN( dn ), attributeName, value );
- }
- catch ( Exception e )
- {
- resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
- }
-
- return resp;
+ return compare( new DN( dn ), attributeName, value );
}
@@ -308,19 +296,7 @@ public class LdapCoreSessionConnection i
*/
public CompareResponse compare( String dn, String attributeName, String value ) throws LdapException
{
- CompareResponse resp = new CompareResponse();
- resp.setLdapResult( getDefaultCompareResult() );
-
- try
- {
- session.compare( new DN( dn ), attributeName, value );
- }
- catch ( Exception e )
- {
- resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
- }
-
- return resp;
+ return compare( new DN( dn ), attributeName, value );
}
@@ -350,19 +326,7 @@ public class LdapCoreSessionConnection i
*/
public CompareResponse compare( String dn, String attributeName, Value<?> value ) throws LdapException
{
- CompareResponse resp = new CompareResponse();
- resp.setLdapResult( getDefaultCompareResult() );
-
- try
- {
- session.compare( new DN( dn ), attributeName, value.get() );
- }
- catch ( Exception e )
- {
- resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
- }
-
- return resp;
+ return compare( new DN( dn ), attributeName, value );
}
@@ -395,7 +359,7 @@ public class LdapCoreSessionConnection i
{
DeleteResponse resp = new DeleteResponse();
resp.setLdapResult( getDefaultResult() );
-
+
try
{
session.delete( dn );
@@ -414,18 +378,7 @@ public class LdapCoreSessionConnection i
*/
public DeleteResponse delete( String dn ) throws LdapException
{
- DeleteResponse resp = new DeleteResponse();
- resp.setLdapResult( getDefaultResult() );
- try
- {
- session.delete( new DN( dn ) );
- }
- catch ( Exception e )
- {
- resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
- }
-
- return resp;
+ return delete( new DN( dn ) );
}
@@ -495,13 +448,13 @@ public class LdapCoreSessionConnection i
/**
* {@inheritDoc}
*/
- public SearchResponse lookup( String dn, String... attributes ) throws LdapException
+ public SearchResponse lookup( DN dn, String... attributes ) throws LdapException
{
SearchResultEntry resp = null;
-
+
try
{
- Entry entry = session.lookup( new DN( dn ), attributes );
+ Entry entry = session.lookup( dn, attributes );
resp = new SearchResultEntry();
resp.setEntry( entry );
}
@@ -518,12 +471,22 @@ public class LdapCoreSessionConnection i
/**
* {@inheritDoc}
*/
- public SearchResponse lookup( String dn ) throws LdapException
+ public SearchResponse lookup( String dn, String... attributes ) throws LdapException
+ {
+ return lookup( new DN( dn ), attributes );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SearchResponse lookup( DN dn ) throws LdapException
{
SearchResultEntry resp = null;
+
try
{
- Entry entry = session.lookup( new DN( dn ) );
+ Entry entry = session.lookup( dn );
resp = new SearchResultEntry();
resp.setEntry( entry );
}
@@ -540,6 +503,15 @@ public class LdapCoreSessionConnection i
/**
* {@inheritDoc}
*/
+ public SearchResponse lookup( String dn ) throws LdapException
+ {
+ return lookup( new DN( dn ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public ModifyResponse modify( DN dn, Modification... modifications ) throws LdapException
{
ModifyResponse resp = new ModifyResponse();
@@ -567,6 +539,15 @@ public class LdapCoreSessionConnection i
/**
* {@inheritDoc}
*/
+ public ModifyResponse modify( String dn, Modification... modifications ) throws LdapException
+ {
+ return modify( new DN( dn ), modifications );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public ModifyResponse modify( Entry entry, ModificationOperation modOp ) throws LdapException
{
ModifyResponse resp = new ModifyResponse();
@@ -628,7 +609,7 @@ public class LdapCoreSessionConnection i
{
ModifyDnResponse resp = new ModifyDnResponse();
resp.setLdapResult( getDefaultResult() );
-
+
try
{
InternalModifyDnRequest iModDnReq = new ModifyDnRequestImpl( modDnRequest.getMessageId() );
@@ -655,7 +636,7 @@ public class LdapCoreSessionConnection i
{
ModifyDnResponse resp = new ModifyDnResponse();
resp.setLdapResult( getDefaultResult() );
-
+
try
{
session.move( entryDn, newSuperiorDn );
@@ -674,19 +655,7 @@ public class LdapCoreSessionConnection i
*/
public ModifyDnResponse move( String entryDn, String newSuperiorDn ) throws LdapException
{
- ModifyDnResponse resp = new ModifyDnResponse();
- resp.setLdapResult( getDefaultResult() );
-
- try
- {
- session.move( new DN( entryDn ), new DN( newSuperiorDn ) );
- }
- catch ( Exception e )
- {
- resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
- }
-
- return resp;
+ return move( new DN( entryDn ), new DN( newSuperiorDn ) );
}
@@ -697,7 +666,7 @@ public class LdapCoreSessionConnection i
{
ModifyDnResponse resp = new ModifyDnResponse();
resp.setLdapResult( getDefaultResult() );
-
+
try
{
session.rename( entryDn, newRdn, deleteOldRdn );
@@ -718,7 +687,7 @@ public class LdapCoreSessionConnection i
{
ModifyDnResponse resp = new ModifyDnResponse();
resp.setLdapResult( getDefaultResult() );
-
+
try
{
session.rename( entryDn, newRdn, false );
@@ -737,48 +706,22 @@ public class LdapCoreSessionConnection i
*/
public ModifyDnResponse rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
{
- ModifyDnResponse resp = new ModifyDnResponse();
- resp.setLdapResult( getDefaultResult() );
-
- try
- {
- session.rename( new DN( entryDn ), new RDN( newRdn ), deleteOldRdn );
- }
- catch ( Exception e )
- {
- resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
- }
-
- return resp;
+ return rename( new DN( entryDn ), new RDN( newRdn ), deleteOldRdn );
}
/**
* {@inheritDoc}
*/
- public ModifyDnResponse rename( String entryDn, String rdn ) throws LdapException
+ public ModifyDnResponse rename( String entryDn, String newRdn ) throws LdapException
{
- ModifyDnResponse resp = new ModifyDnResponse();
- resp.setLdapResult( getDefaultResult() );
-
- try
- {
- DN newDn = new DN( entryDn );
- RDN newRdn = new RDN( rdn );
- session.rename( newDn, newRdn, false );
- }
- catch ( Exception e )
- {
- resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
- }
-
- return resp;
+ return rename( new DN( entryDn ), new RDN( newRdn ) );
}
/**
* Moves and renames the given entryDn.The old RDN will be deleted
- *
+ *
* @see #moveAndRename(DN, DN, boolean)
*/
public ModifyDnResponse moveAndRename( DN entryDn, DN newDn ) throws LdapException
@@ -789,7 +732,7 @@ public class LdapCoreSessionConnection i
/**
* Moves and renames the given entryDn.The old RDN will be deleted
- *
+ *
* @see #moveAndRename(DN, DN, boolean)
*/
public ModifyDnResponse moveAndRename( String entryDn, String newDn ) throws LdapException
@@ -800,7 +743,7 @@ public class LdapCoreSessionConnection i
/**
* Moves and renames the given entryDn.The old RDN will be deleted if requested
- *
+ *
* @param entryDn The original entry DN
* @param newDn The new Entry DN
* @param deleteOldRdn Tells if the old RDN must be removed
@@ -808,26 +751,26 @@ public class LdapCoreSessionConnection i
public ModifyDnResponse moveAndRename( DN entryDn, DN newDn, boolean deleteOldRdn ) throws LdapException
{
// Check the parameters first
- if ( entryDn == null )
+ if ( entryDn == null )
{
throw new IllegalArgumentException( "The entry DN must not be null" );
}
-
+
if ( entryDn.isRootDSE() )
{
throw new IllegalArgumentException( "The RootDSE cannot be moved" );
}
-
- if ( newDn == null )
+
+ if ( newDn == null )
{
throw new IllegalArgumentException( "The new DN must not be null" );
}
-
+
if ( newDn.isRootDSE() )
{
throw new IllegalArgumentException( "The RootDSE cannot be the target" );
}
-
+
ModifyDnResponse resp = new ModifyDnResponse();
resp.setLdapResult( getDefaultResult() );
@@ -846,7 +789,7 @@ public class LdapCoreSessionConnection i
/**
* Moves and renames the given entryDn.The old RDN will be deleted if requested
- *
+ *
* @param entryDn The original entry DN
* @param newDn The new Entry DN
* @param deleteOldRdn Tells if the old RDN must be removed
@@ -897,10 +840,10 @@ public class LdapCoreSessionConnection i
/**
* {@inheritDoc}
*/
- public Cursor<SearchResponse> search( String baseDn, String filter, SearchScope scope, String... attributes )
+ public Cursor<SearchResponse> search( DN baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
- // generate some random operation number
+ // generate some random operation number
SearchRequest searchRequest = new SearchRequest();
searchRequest.setMessageId( ( int ) System.currentTimeMillis() );
searchRequest.setBaseDn( baseDn );
@@ -916,6 +859,16 @@ public class LdapCoreSessionConnection i
/**
* {@inheritDoc}
*/
+ public Cursor<SearchResponse> search( String baseDn, String filter, SearchScope scope, String... attributes )
+ throws LdapException
+ {
+ return search( new DN( baseDn ), filter, scope, attributes );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public void unBind() throws Exception
{
if( session != null )
@@ -1015,7 +968,7 @@ public class LdapCoreSessionConnection i
{
LOG.warn( e.getMessage(), e );
}
-
+
return null;
}
@@ -1041,7 +994,7 @@ public class LdapCoreSessionConnection i
{
LOG.warn( e.getMessage(), e );
}
-
+
return null;
}
@@ -1062,7 +1015,7 @@ public class LdapCoreSessionConnection i
LOG.warn( e.getMessage(), e );
throw e;
}
-
+
return null;
}
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java?rev=979356&r1=979355&r2=979356&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java Mon Jul 26 16:44:00 2010
@@ -261,7 +261,7 @@ public class OperationalAttributeService
Modification modifyOp = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
new DefaultEntryAttribute( "description", "Singer Songwriter" ) );
- connection.modify( new DN( DN_KATE_BUSH ), modifyOp );
+ connection.modify( DN_KATE_BUSH, modifyOp );
Cursor<SearchResponse> responses = connection.search( DN_KATE_BUSH, "(objectClass=*)", SearchScope.OBJECT, "modifiersName", "modifyTimestamp" );
responses.next();
@@ -285,7 +285,7 @@ public class OperationalAttributeService
Modification modifyAddOp = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
new DefaultEntryAttribute( "description", "an English singer, songwriter, musician" ) );
- connection.modify( new DN( DN_KATE_BUSH ), modifyAddOp );
+ connection.modify( DN_KATE_BUSH, modifyAddOp );
// Determine modifyTimestamp
Cursor<SearchResponse> responses = connection.search( DN_KATE_BUSH, "(objectClass=*)", SearchScope.OBJECT, "modifyTimestamp" );
@@ -296,14 +296,14 @@ public class OperationalAttributeService
assertNotNull( modifyTimestamp );
String oldTimestamp = modifyTimestamp.getString();
- // Wait 500 milliseconds
- Thread.sleep( 500 );
+ // Wait 2000 milliseconds
+ Thread.sleep( 2000 );
// Change value of attribute description
Modification modifyOp = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
new DefaultEntryAttribute( "description", "one of England's most successful solo female performers" ) );
- connection.modify( new DN( DN_KATE_BUSH ), modifyOp );
+ connection.modify( DN_KATE_BUSH, modifyOp );
// Determine modifyTimestamp after modification
responses = connection.search( DN_KATE_BUSH, "(objectClass=*)", SearchScope.OBJECT, "modifyTimestamp" );
@@ -330,7 +330,7 @@ public class OperationalAttributeService
Modification modifyOp = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
new DefaultEntryAttribute( "modifiersName", "cn=Tori Amos,dc=example,dc=com" ) );
- connection.modify( new DN( DN_KATE_BUSH ), modifyOp );
+ connection.modify( DN_KATE_BUSH, modifyOp );
}
@@ -345,7 +345,7 @@ public class OperationalAttributeService
Modification modifyOp = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
new DefaultEntryAttribute( "creatorsName" ) );
- ModifyResponse response = connection.modify( new DN( DN_KATE_BUSH ), modifyOp );
+ ModifyResponse response = connection.modify( DN_KATE_BUSH, modifyOp );
assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, response.getLdapResult().getResultCode() );
}
@@ -362,7 +362,7 @@ public class OperationalAttributeService
Modification modifyOp = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
new DefaultEntryAttribute( "creatorsName", "cn=Tori Amos,dc=example,dc=com" ) );
- ModifyResponse response = connection.modify( new DN( DN_KATE_BUSH ), modifyOp );
+ ModifyResponse response = connection.modify( DN_KATE_BUSH, modifyOp );
assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, response.getLdapResult().getResultCode() );
}
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java?rev=979356&r1=979355&r2=979356&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/lookup/LookupIT.java Mon Jul 26 16:44:00 2010
@@ -20,14 +20,20 @@
package org.apache.directory.server.core.operations.lookup;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.message.SearchResultEntry;
import org.apache.directory.server.core.annotations.ApplyLdifs;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.integ.IntegrationUtils;
import org.apache.directory.shared.ldap.entry.Entry;
-import org.apache.directory.shared.ldap.name.DN;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,10 +49,26 @@ import org.junit.runner.RunWith;
"dn: cn=test,ou=system",
"objectClass: person",
"cn: test",
- "sn: sn_test"
+ "sn: sn_test"
})
public class LookupIT extends AbstractLdapTestUnit
{
+ /** The ldap connection */
+ private LdapConnection connection;
+
+ @Before
+ public void setup() throws Exception
+ {
+ connection = IntegrationUtils.getAdminConnection( service );
+ }
+
+
+ @After
+ public void shutdown() throws Exception
+ {
+ connection.close();
+ }
+
/**
* Test a lookup( DN, "*") operation
@@ -54,14 +76,14 @@ public class LookupIT extends AbstractLd
@Test
public void testLookupStar() throws Exception
{
- DN dn = new DN( "cn=test,ou=system" );
- Entry entry = service.getAdminSession().lookup( dn, new String[]{ "*" } );
-
+ SearchResultEntry result = (SearchResultEntry)connection.lookup( "cn=test,ou=system", "*" );
+ Entry entry = result.getEntry();
+
assertNotNull( entry );
-
+
// Check that we don't have any operational attributes :
// We should have only 3 attributes : objectClass, cn and sn
- assertEquals( 3, entry.size() );
+ assertEquals( 3, entry.size() );
// Check that all the user attributes are present
assertEquals( "test", entry.get( "cn" ).getString() );
@@ -77,22 +99,22 @@ public class LookupIT extends AbstractLd
public void testLookupPlus() throws Exception
{
service.setDenormalizeOpAttrsEnabled( true );
- DN dn = new DN( "cn=test,ou=system" );
- Entry entry = service.getAdminSession().lookup( dn, new String[]{ "+" } );
-
+ SearchResultEntry result = (SearchResultEntry)connection.lookup( "cn=test,ou=system", "+" );
+ Entry entry = result.getEntry();
+
assertNotNull( entry );
-
+
// We should have 5 attributes
- assertEquals( 7, entry.size() );
+ assertEquals( 7, entry.size() );
// Check that all the user attributes are present
assertEquals( "test", entry.get( "cn" ).getString() );
assertEquals( "sn_test", entry.get( "sn" ).getString() );
assertTrue( entry.contains( "objectClass", "top", "person" ) );
-
+
// Check that we have all the operational attributes :
// We should have 3 users attributes : objectClass, cn and sn
- // and 2 operational attributes : createTime and createUser
+ // and 2 operational attributes : createTime and createUser
assertNotNull( entry.get( "createTimestamp" ).getString() );
assertEquals( "uid=admin,ou=system", entry.get( "creatorsName" ).getString() );
}
@@ -104,13 +126,13 @@ public class LookupIT extends AbstractLd
@Test
public void testLookupEmptyAtrid() throws Exception
{
- DN dn = new DN( "cn=test,ou=system" );
- Entry entry = service.getAdminSession().lookup( dn, new String[]{} );
-
+ SearchResultEntry result = (SearchResultEntry)connection.lookup( "cn=test,ou=system", (String[])null );
+ Entry entry = result.getEntry();
+
assertNotNull( entry );
-
+
// We should have 3 attributes
- assertEquals( 3, entry.size() );
+ assertEquals( 3, entry.size() );
// Check that all the user attributes are present
assertEquals( "test", entry.get( "cn" ).getString() );
@@ -125,17 +147,39 @@ public class LookupIT extends AbstractLd
@Test
public void testLookup() throws Exception
{
- DN dn = new DN( "cn=test,ou=system" );
- Entry entry = service.getAdminSession().lookup( dn );
-
+ SearchResultEntry result = (SearchResultEntry)connection.lookup( "cn=test,ou=system" );
+ Entry entry = result.getEntry();
+
assertNotNull( entry );
-
+
// We should have 3 attributes
- assertEquals( 3, entry.size() );
+ assertEquals( 3, entry.size() );
// Check that all the user attributes are present
assertEquals( "test", entry.get( "cn" ).getString() );
assertEquals( "sn_test", entry.get( "sn" ).getString() );
assertTrue( entry.contains( "objectClass", "top", "person" ) );
}
+
+
+ /**
+ * Test a lookup( DN ) operation with a list of attributes
+ */
+ @Test
+ @Ignore
+ public void testLookupWithAttrs() throws Exception
+ {
+ SearchResultEntry result = (SearchResultEntry)connection.lookup( "cn=test,ou=system", "name" );
+ Entry entry = result.getEntry();
+
+ assertNotNull( entry );
+
+ // We should have 3 attributes
+ assertEquals( 2, entry.size() );
+
+ // Check that all the user attributes are present
+ assertEquals( "test", entry.get( "cn" ).getString() );
+ assertEquals( "sn_test", entry.get( "sn" ).getString() );
+ assertFalse( entry.containsAttribute( "objectClass" ) );
+ }
}
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java?rev=979356&r1=979355&r2=979356&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java Mon Jul 26 16:44:00 2010
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.server.core.operations.search;
@@ -83,7 +83,7 @@ import org.junit.runner.RunWith;
@RunWith(FrameworkRunner.class)
@CreateDS(name = "SearchDS")
@ApplyLdifs(
- {
+ {
"dn: m-oid=2.2.0, ou=attributeTypes, cn=apachemeta, ou=schema",
"objectclass: metaAttributeType",
"objectclass: metaTop",
@@ -280,9 +280,9 @@ public class SearchIT extends AbstractLd
*/
private static DirContext addNisPosixGroup( String name, int gid ) throws Exception
{
- Attributes attrs = LdifUtils.createAttributes(
- "objectClass: top",
- "objectClass: posixGroup",
+ Attributes attrs = LdifUtils.createAttributes(
+ "objectClass: top",
+ "objectClass: posixGroup",
"cn", name,
"gidNumber", String.valueOf( gid ) );
@@ -680,11 +680,11 @@ public class SearchIT extends AbstractLd
*/
protected Attributes getPersonAttributes( String sn, String cn ) throws LdapException
{
- Attributes attributes = LdifUtils.createAttributes(
- "objectClass: top",
+ Attributes attributes = LdifUtils.createAttributes(
+ "objectClass: top",
"objectClass: top",
- "objectClass: person",
- "cn", cn,
+ "objectClass: person",
+ "cn", cn,
"sn", sn );
return attributes;
@@ -718,7 +718,7 @@ public class SearchIT extends AbstractLd
enm = sysRoot.search( "", "(userCertificate=\\34\\56\\4E\\5F)", controls );
assertTrue( enm.hasMore() );
- sr = ( SearchResult ) enm.next();
+ sr = enm.next();
assertNotNull( sr );
assertFalse( enm.hasMore() );
assertEquals( "cn=Kate Bush,ou=system", sr.getName() );
@@ -947,6 +947,48 @@ public class SearchIT extends AbstractLd
/**
+ * Search an entry and fetch an attribute and all its subtypes
+ * @throws NamingException if there are errors
+ */
+ @Test
+ public void testSearchFetchAttributeAndSubTypes() throws Exception
+ {
+ SearchControls ctls = new SearchControls();
+ ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
+ ctls.setReturningAttributes( new String[]
+ { "name" } );
+
+ NamingEnumeration<SearchResult> result = sysRoot.search( RDN, FILTER, ctls );
+
+ if ( result.hasMore() )
+ {
+ SearchResult entry = result.next();
+ Attributes attrs = entry.getAttributes();
+
+ // We should have get cn and sn only
+ assertEquals( 2, attrs.size() );
+
+ // Check CN
+ Attribute cn = attrs.get( "cn" );
+
+ assertNotNull( cn );
+ assertEquals( "Heather Nova", cn.get().toString() );
+
+ // Assert SN
+ Attribute sn = attrs.get( "sn" );
+ assertNotNull( sn );
+ assertEquals( "Nova", sn.get().toString() );
+ }
+ else
+ {
+ fail( "entry " + RDN + " not found" );
+ }
+
+ result.close();
+ }
+
+
+ /**
* Search an entry and fetch an attribute with twice the same attributeType
* @throws NamingException if there are errors
*/
@@ -985,7 +1027,7 @@ public class SearchIT extends AbstractLd
// controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
// controls.setDerefLinkFlag( false );
// sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES, AliasDerefMode.NEVER_DEREF_ALIASES );
- //
+ //
// List map = new ArrayList();
// NamingEnumeration list = sysRoot.search( "", "(name=*)", controls );
// while ( list.hasMore() )
@@ -994,20 +1036,20 @@ public class SearchIT extends AbstractLd
// map.add( result.getName() );
// }
// assertEquals( "size of results", 14, map.size() );
- // assertTrue( "contains ou=testing00,ou=system", map.contains( "ou=testing00,ou=system" ) );
- // assertTrue( "contains ou=testing01,ou=system", map.contains( "ou=testing01,ou=system" ) );
- // assertTrue( "contains ou=testing02,ou=system", map.contains( "ou=testing01,ou=system" ) );
- // assertTrue( "contains uid=akarasulu,ou=users,ou=system", map.contains( "uid=akarasulu,ou=users,ou=system" ) );
- // assertTrue( "contains ou=configuration,ou=system", map.contains( "ou=configuration,ou=system" ) );
- // assertTrue( "contains ou=groups,ou=system", map.contains( "ou=groups,ou=system" ) );
- // assertTrue( "contains ou=interceptors,ou=configuration,ou=system", map.contains( "ou=interceptors,ou=configuration,ou=system" ) );
- // assertTrue( "contains ou=partitions,ou=configuration,ou=system", map.contains( "ou=partitions,ou=configuration,ou=system" ) );
- // assertTrue( "contains ou=services,ou=configuration,ou=system", map.contains( "ou=services,ou=configuration,ou=system" ) );
- // assertTrue( "contains ou=subtest,ou=testing01,ou=system", map.contains( "ou=subtest,ou=testing01,ou=system" ) );
- // assertTrue( "contains ou=system", map.contains( "ou=system" ) );
- // assertTrue( "contains ou=users,ou=system", map.contains( "ou=users,ou=system" ) );
- // assertTrue( "contains uid=admin,ou=system", map.contains( "uid=admin,ou=system" ) );
- // assertTrue( "contains cn=administrators,ou=groups,ou=system", map.contains( "cn=administrators,ou=groups,ou=system" ) );
+ // assertTrue( "contains ou=testing00,ou=system", map.contains( "ou=testing00,ou=system" ) );
+ // assertTrue( "contains ou=testing01,ou=system", map.contains( "ou=testing01,ou=system" ) );
+ // assertTrue( "contains ou=testing02,ou=system", map.contains( "ou=testing01,ou=system" ) );
+ // assertTrue( "contains uid=akarasulu,ou=users,ou=system", map.contains( "uid=akarasulu,ou=users,ou=system" ) );
+ // assertTrue( "contains ou=configuration,ou=system", map.contains( "ou=configuration,ou=system" ) );
+ // assertTrue( "contains ou=groups,ou=system", map.contains( "ou=groups,ou=system" ) );
+ // assertTrue( "contains ou=interceptors,ou=configuration,ou=system", map.contains( "ou=interceptors,ou=configuration,ou=system" ) );
+ // assertTrue( "contains ou=partitions,ou=configuration,ou=system", map.contains( "ou=partitions,ou=configuration,ou=system" ) );
+ // assertTrue( "contains ou=services,ou=configuration,ou=system", map.contains( "ou=services,ou=configuration,ou=system" ) );
+ // assertTrue( "contains ou=subtest,ou=testing01,ou=system", map.contains( "ou=subtest,ou=testing01,ou=system" ) );
+ // assertTrue( "contains ou=system", map.contains( "ou=system" ) );
+ // assertTrue( "contains ou=users,ou=system", map.contains( "ou=users,ou=system" ) );
+ // assertTrue( "contains uid=admin,ou=system", map.contains( "uid=admin,ou=system" ) );
+ // assertTrue( "contains cn=administrators,ou=groups,ou=system", map.contains( "cn=administrators,ou=groups,ou=system" ) );
// }
/**
@@ -1235,11 +1277,11 @@ public class SearchIT extends AbstractLd
public void testSearchWithEscapedCharsInFilter() throws Exception
{
// Create entry cn=Sid Vicious, ou=system
- Attributes vicious = LdifUtils.createAttributes(
- "objectClass: top",
- "objectClass: person",
- "cn: Sid Vicious",
- "sn: Vicious",
+ Attributes vicious = LdifUtils.createAttributes(
+ "objectClass: top",
+ "objectClass: person",
+ "cn: Sid Vicious",
+ "sn: Vicious",
"description: (sex*pis\\tols)" );
DirContext ctx = sysRoot.createSubcontext( "cn=Sid Vicious", vicious );
@@ -1285,11 +1327,11 @@ public class SearchIT extends AbstractLd
public void testSubstringSearchWithEscapedCharsInFilter() throws Exception
{
// Create entry cn=Sid Vicious, ou=system
- Attributes vicious = LdifUtils.createAttributes(
- "objectClass: top",
- "objectClass: person",
- "cn: Sid Vicious",
- "sn: Vicious",
+ Attributes vicious = LdifUtils.createAttributes(
+ "objectClass: top",
+ "objectClass: person",
+ "cn: Sid Vicious",
+ "sn: Vicious",
"description: (sex*pis\\tols)" );
DirContext ctx = sysRoot.createSubcontext( "cn=Sid Vicious", vicious );
@@ -1337,11 +1379,11 @@ public class SearchIT extends AbstractLd
@Test
public void testSubstringSearchWithEscapedAsterisksInFilter_DIRSERVER_1181() throws Exception
{
- Attributes vicious = LdifUtils.createAttributes(
- "objectClass: top",
- "objectClass: person",
+ Attributes vicious = LdifUtils.createAttributes(
+ "objectClass: top",
+ "objectClass: person",
"cn: x*y*z*",
- "sn: x*y*z*",
+ "sn: x*y*z*",
"description: (sex*pis\\tols)" );
sysRoot.createSubcontext( "cn=x*y*z*", vicious );
@@ -1393,7 +1435,7 @@ public class SearchIT extends AbstractLd
* Search operation with a base DN with quotes
* Commented as it's not valid by RFC 5514
@Test
- public void testSearchWithQuotesInBase() throws NamingException
+ public void testSearchWithQuotesInBase() throws NamingException
{
LdapContext sysRoot = getSystemContext( service );
createData( sysRoot );
@@ -1411,8 +1453,8 @@ public class SearchIT extends AbstractLd
// Check entry
NamingEnumeration<SearchResult> result = sysRoot.search( base, filter, ctls );
assertTrue( result.hasMore() );
-
- while ( result.hasMore() )
+
+ while ( result.hasMore() )
{
SearchResult sr = result.next();
Attributes attrs = sr.getAttributes();
@@ -1420,7 +1462,7 @@ public class SearchIT extends AbstractLd
assertNotNull(sn);
assertTrue( sn.contains( "Amos" ) );
}
- } catch (Exception e)
+ } catch (Exception e)
{
fail( e.getMessage() );
}
@@ -1431,7 +1473,7 @@ public class SearchIT extends AbstractLd
* Added to test correct comparison of integer attribute types when searching.
* testGreaterThanSearch and testLesserThanSearch fail to detect the problem using values less than 10.
* Ref. DIRSERVER-1296
- *
+ *
* @throws Exception
*/
@Test
@@ -1451,7 +1493,7 @@ public class SearchIT extends AbstractLd
* Added to test correct comparison of integer attribute types when searching.
* testGreaterThanSearch and testLesserThanSearch fail to detect the problem using values less than 10.
* Ref. DIRSERVER-1296
- *
+ *
* @throws Exception
*/
@Test
@@ -1471,7 +1513,7 @@ public class SearchIT extends AbstractLd
* Added to test correct comparison of integer attribute types when searching.
* testGreaterThanSearch and testLesserThanSearch fail to detect the problem using values less than 10.
* Ref. DIRSERVER-1296
- *
+ *
* @throws Exception
*/
@Test
@@ -1491,7 +1533,7 @@ public class SearchIT extends AbstractLd
* Added to test correct comparison of integer attribute types when searching.
* testGreaterThanSearch and testLesserThanSearch fail to detect the problem using values less than 10.
* Ref. DIRSERVER-1296
- *
+ *
* @throws Exception
*/
@Test
@@ -1563,10 +1605,10 @@ public class SearchIT extends AbstractLd
.getJndiValue() );
// Create an entry which does not match
- Attributes attrs = LdifUtils.createAttributes(
- "objectClass: top",
- "objectClass: groupOfUniqueNames",
- "cn: testGroup3",
+ Attributes attrs = LdifUtils.createAttributes(
+ "objectClass: top",
+ "objectClass: groupOfUniqueNames",
+ "cn: testGroup3",
"uniqueMember: uid=admin,ou=system" );
getSystemContext( service ).createSubcontext( "cn=testGroup3,ou=groups", attrs );
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java?rev=979356&r1=979355&r2=979356&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java Mon Jul 26 16:44:00 2010
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.server.core.schema;
@@ -54,7 +54,7 @@ import org.junit.runner.RunWith;
/**
- * An integration test class for testing persistence for various operations
+ * An integration test class for testing persistence for various operations
* on the subschemaSubentry with server restarts.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -68,7 +68,7 @@ public class SchemaPersistenceIT extends
/**
- * Tests to see if an attributeType is persisted when added, then server
+ * Tests to see if an attributeType is persisted when added, then server
* is shutdown, then restarted again.
*
* @throws Exception on error
@@ -85,22 +85,22 @@ public class SchemaPersistenceIT extends
// test successful add with everything
// -------------------------------------------------------------------
- descriptions.add(
+ descriptions.add(
"( 1.3.6.1.4.1.18060.0.4.1.2.10000 " +
- " NAME 'type0' " +
+ " NAME 'type0' " +
" OBSOLETE SUP 2.5.4.41 " +
- " EQUALITY caseExactIA5Match " +
+ " EQUALITY caseExactIA5Match " +
" ORDERING octetStringOrderingMatch " +
" SUBSTR caseExactIA5SubstringsMatch " +
- " COLLECTIVE " +
+ " COLLECTIVE " +
" SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " +
- " SINGLE-VALUE USAGE userApplications " +
+ " USAGE userApplications " +
" X-SCHEMA 'nis' )" );
-
- descriptions.add(
+
+ descriptions.add(
"( 1.3.6.1.4.1.18060.0.4.1.2.10001 " +
" NAME ( 'type1' 'altName' ) " +
- " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " +
+ " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " +
" SUP 2.5.4.41 " +
" USAGE userApplications " +
" X-SCHEMA 'nis' )" );
@@ -131,14 +131,14 @@ public class SchemaPersistenceIT extends
// -----------------------------------------------------------------------
- // Private Utility Methods
+ // Private Utility Methods
// -----------------------------------------------------------------------
private void modify( int op, List<String> descriptions, String opAttr ) throws Exception
{
DN dn = new DN( getSubschemaSubentryDN() );
Attribute attr = new BasicAttribute( opAttr );
-
+
for ( String description : descriptions )
{
attr.add( description );
@@ -163,7 +163,7 @@ public class SchemaPersistenceIT extends
/**
* Get's the subschemaSubentry attribute value from the rootDSE.
- *
+ *
* @return the subschemaSubentry distinguished name
* @throws NamingException if there are problems accessing the RootDSE
*/
@@ -184,8 +184,8 @@ public class SchemaPersistenceIT extends
/**
* Gets the subschemaSubentry attributes for the global schema.
- *
- * @return all operational attributes of the subschemaSubentry
+ *
+ * @return all operational attributes of the subschemaSubentry
* @throws NamingException if there are problems accessing this entry
*/
private Attributes getSubschemaSubentryAttributes() throws Exception
@@ -212,11 +212,11 @@ public class SchemaPersistenceIT extends
Attributes attrs = getSubschemaSubentryAttributes();
Attribute attrTypes = attrs.get( "attributeTypes" );
AttributeType attributeType = null;
-
+
for ( int ii = 0; ii < attrTypes.size(); ii++ )
{
String desc = ( String ) attrTypes.get( ii );
-
+
if ( desc.indexOf( oid ) != -1 )
{
attributeType = ATTRIBUTE_TYPE_DESCRIPTION_SCHEMA_PARSER