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 2015/10/14 00:17:24 UTC
svn commit: r1708527 [2/3] - in /directory/apacheds/trunk:
core-api/src/main/java/org/apache/directory/server/core/api/authn/ppolicy/
core-api/src/main/java/org/apache/directory/server/core/api/schema/registries/synchronizers/
core-integ/src/main/java/...
Added: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionSingeValueAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionSingeValueAttribute.java?rev=1708527&view=auto
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionSingeValueAttribute.java (added)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionSingeValueAttribute.java Tue Oct 13 22:17:22 2015
@@ -0,0 +1,1239 @@
+/*
+ * 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.core.partition.ldif;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.csn.CsnFactory;
+import org.apache.directory.api.ldap.model.entry.Attribute;
+import org.apache.directory.api.ldap.model.entry.DefaultAttribute;
+import org.apache.directory.api.ldap.model.entry.DefaultEntry;
+import org.apache.directory.api.ldap.model.entry.DefaultModification;
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.entry.Modification;
+import org.apache.directory.api.ldap.model.entry.ModificationOperation;
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.filter.ExprNode;
+import org.apache.directory.api.ldap.model.filter.FilterParser;
+import org.apache.directory.api.ldap.model.ldif.LdifEntry;
+import org.apache.directory.api.ldap.model.ldif.LdifReader;
+import org.apache.directory.api.ldap.model.ldif.LdifUtils;
+import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.name.Rdn;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.ldap.model.schema.normalizers.ConcreteNameComponentNormalizer;
+import org.apache.directory.api.ldap.model.schema.normalizers.NameComponentNormalizer;
+import org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor;
+import org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
+import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.api.util.exception.Exceptions;
+import org.apache.directory.server.core.api.CacheService;
+import org.apache.directory.server.core.api.CoreSession;
+import org.apache.directory.server.core.api.DirectoryService;
+import org.apache.directory.server.core.api.DnFactory;
+import org.apache.directory.server.core.api.LdapPrincipal;
+import org.apache.directory.server.core.api.MockCoreSession;
+import org.apache.directory.server.core.api.MockDirectoryService;
+import org.apache.directory.server.core.api.entry.ClonedServerEntry;
+import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
+import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
+import org.apache.directory.server.core.api.normalization.FilterNormalizingVisitor;
+import org.apache.directory.server.core.shared.DefaultDnFactory;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+
+/**
+ * Unit test cases for the partition implementation backed by a single LDIF file. We try
+ * to rename a, entry which use a SingleValue AttributeType in its RDN, the old value must
+ * be removed, whether the deleteOldRdn flag is set or not.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+//NOTE: do not use junit concurrent annotations
+public class SingleFileLdifPartitionSingeValueAttribute
+{
+ private static SchemaManager schemaManager = null;
+
+ private static DnFactory dnFactory;
+
+ private static CsnFactory defaultCSNFactory;
+
+ private static CoreSession mockSession;
+
+ private static Entry contextEntry;
+
+ private static LdifReader reader = new LdifReader();
+
+ /** the file in use during the current test method's execution */
+ private File ldifFileInUse;
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
+
+ private static CacheService cacheService;
+
+
+ @BeforeClass
+ public static void init() throws Exception
+ {
+ String workingDirectory = System.getProperty( "workingDirectory" );
+
+ if ( workingDirectory == null )
+ {
+ String path = SingleFileLdifPartitionTest.class.getResource( "" ).getPath();
+ int targetPos = path.indexOf( "target" );
+ workingDirectory = path.substring( 0, targetPos + 6 );
+ }
+
+ File schemaRepository = new File( workingDirectory, "schema" );
+ SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+ extractor.extractOrCopy( true );
+ LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+ schemaManager = new DefaultSchemaManager( loader );
+
+ boolean loaded = schemaManager.loadAllEnabled();
+
+ if ( !loaded )
+ {
+ fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
+ }
+
+ defaultCSNFactory = new CsnFactory( 0 );
+
+ Dn adminDn = new Dn( schemaManager, "uid=admin,ou=system" );
+ DirectoryService directoryService = new MockDirectoryService( 1 );
+ directoryService.setSchemaManager( schemaManager );
+ mockSession = new MockCoreSession( new LdapPrincipal( schemaManager, adminDn,
+ AuthenticationLevel.STRONG ),
+ directoryService );
+
+ String contextEntryStr =
+ "dn: ou=test, ou=system\n" +
+ "objectclass: organizationalUnit\n" +
+ "objectclass: top\n" +
+ "ou: test\n" +
+ "entryUUID: 8c7b24a6-1687-461c-88ea-4d30fc234f9b\n" +
+ "entryCSN: 20100919005926.530000Z#000000#000#000000";
+
+ LdifEntry ldifEntry = reader.parseLdif( contextEntryStr ).get( 0 );
+
+ contextEntry = new ClonedServerEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
+
+ cacheService = new CacheService();
+ cacheService.initialize( null );
+ dnFactory = new DefaultDnFactory( schemaManager, cacheService.getCache( "dnCache" ) );
+ }
+
+
+ @Before
+ public void createStore() throws Exception
+ {
+ ldifFileInUse = folder.newFile( "partition.ldif" );
+ }
+
+
+ private Entry createEntry( String dn ) throws Exception
+ {
+ Entry entry = new DefaultEntry( schemaManager );
+ entry.setDn( new Dn( schemaManager, dn ) );
+ entry.put( SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString() );
+ entry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
+
+ Entry clonedEntry = new ClonedServerEntry( entry );
+
+ return clonedEntry;
+ }
+
+
+ private long getEntryLdifLen( Entry entry ) throws LdapException
+ {
+ // Remove the entryDn attribute
+ Entry copy = entry.clone();
+ copy.removeAttributes( "entryDn" );
+
+ // while writing to the file 1 extra newline char will be added
+
+ String ldif = LdifUtils.convertToLdif( copy ) + "\n";
+ byte[] data = Strings.getBytesUtf8( ldif );
+
+ return data.length;
+ }
+
+
+ /**
+ * creates a partition from the given ldif file. If the ldif file name is null
+ * then creates a new file and initializes the partition. If the truncate flag is true
+ * and the given file exists then it erases all the contents of the ldif file before
+ * initializing the partition
+ *
+ * @param fileName the full path to the ldif file to be loaded
+ * @param truncate the flag to determine to truncate the file or not
+ * @return the ldif partition after loading all the data
+ * @throws Exception
+ */
+ private SingleFileLdifPartition createPartition( String fileName, boolean truncate ) throws Exception
+ {
+ if ( fileName == null )
+ {
+ fileName = ldifFileInUse.getAbsolutePath();
+ }
+
+ if ( truncate )
+ {
+ RandomAccessFile rf = new RandomAccessFile( fileName, "rws" );
+ rf.setLength( 0 );
+
+ rf.close();
+ }
+
+ SingleFileLdifPartition partition = new SingleFileLdifPartition( schemaManager, dnFactory );
+ partition.setId( "test-ldif" );
+ partition.setPartitionPath( new File( fileName ).toURI() );
+ partition.setSuffixDn( new Dn( "ou=test,ou=system" ) );
+ partition.setSchemaManager( schemaManager );
+ partition.setCacheService( cacheService );
+ partition.initialize();
+
+ return partition;
+ }
+
+
+ private SingleFileLdifPartition reloadPartition() throws Exception
+ {
+ return createPartition( ldifFileInUse.getAbsolutePath(), false );
+ }
+
+
+ private void assertExists( SingleFileLdifPartition partition, Entry entry ) throws LdapException
+ {
+ LookupOperationContext opCtx = new LookupOperationContext( mockSession, SchemaConstants.ALL_ATTRIBUTES_ARRAY );
+ opCtx.setDn( entry.getDn() );
+
+ Entry fetched = partition.lookup( opCtx );
+
+ assertNotNull( fetched );
+
+ // Check the EntryDn attribute
+ Attribute entryDn = fetched.get( "entryDn" );
+
+ assertNotNull( entryDn );
+ assertEquals( entryDn.getString(), entry.getDn().getName() );
+
+ if ( !entry.contains( entryDn ) )
+ {
+ // Removed the entryDn attribute to be able to compare the entries
+ fetched.removeAttributes( "entryDn" );
+ }
+
+ if ( !entry.containsAttribute( SchemaConstants.CONTEXT_CSN_AT ) )
+ {
+ // Removed the entryDn attribute to be able to compare the entries
+ fetched.removeAttributes( SchemaConstants.CONTEXT_CSN_AT );
+ }
+
+ assertEquals( entry, fetched );
+ }
+
+
+ private void assertExists( SingleFileLdifPartition partition, String dn ) throws LdapException
+ {
+ LookupOperationContext opCtx = new LookupOperationContext( mockSession );
+ opCtx.setDn( new Dn( schemaManager, dn ) );
+
+ Entry fetched = partition.lookup( opCtx );
+
+ assertNotNull( fetched );
+ }
+
+
+ private void assertNotExists( SingleFileLdifPartition partition, Entry entry ) throws LdapException
+ {
+ LookupOperationContext opCtx = new LookupOperationContext( mockSession );
+ opCtx.setDn( entry.getDn() );
+
+ Entry fetched = partition.lookup( opCtx );
+
+ assertNull( fetched );
+ }
+
+
+ //-------------------------------------------------------------------------
+ // Partition.add() tests
+ //-------------------------------------------------------------------------
+
+ @Test
+ public void testAddContextEntry() throws Exception
+ {
+ SingleFileLdifPartition partition = createPartition( null, true );
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ String id = partition.getEntryId( contextEntry.getDn() );
+ assertNotNull( id );
+
+ Entry fetched = partition.fetch( id );
+
+ //remove the entryDn cause it is not present in the above hand made contextEntry
+ fetched.removeAttributes( SchemaConstants.ENTRY_DN_AT );
+
+ assertEquals( contextEntry, fetched );
+
+ RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath() ), "r" );
+
+ assertEquals( getEntryLdifLen( contextEntry ), file.length() );
+
+ file.close();
+
+ partition = reloadPartition();
+ assertExists( partition, contextEntry );
+ }
+
+
+ /**
+ * Test some entries creation
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testAddEntries() throws Exception
+ {
+ SingleFileLdifPartition partition = createPartition( null, true );
+
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "domain" );
+ entry1.put( "dc", "test" );
+ addCtx.setEntry( entry1 );
+
+ partition.add( addCtx );
+
+ Entry entry2 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "domain" );
+ entry2.put( "dc", "test" );
+ addCtx.setEntry( entry2 );
+
+ partition.add( addCtx );
+
+ Entry entryMvrdn = createEntry( "dc=mvrdn+objectClass=domain,dc=test,ou=test,ou=system" );
+ entryMvrdn.put( "ObjectClass", "top", "domain" );
+ entryMvrdn.put( "dc", "mvrdn" );
+ addCtx.setEntry( entryMvrdn );
+
+ partition.add( addCtx );
+
+ partition = reloadPartition();
+ assertExists( partition, contextEntry );
+ assertExists( partition, entry1 );
+ assertExists( partition, entry2 );
+ assertExists( partition, entryMvrdn );
+ }
+
+
+ /**
+ * Test modifying an entry present at various positions in the LDIF file
+ * 1. Single entry at the start of the file
+ * 2. modify an entry with and without causing the changes to its size
+ * 3.modify an entry present in the middle of the file with increasing/decresing
+ * size
+ * @throws Exception
+ */
+ @Test
+ public void testModifyEntry() throws Exception
+ {
+ SingleFileLdifPartition partition = createPartition( null, true );
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ ModifyOperationContext modOpCtx = new ModifyOperationContext( mockSession );
+ modOpCtx.setEntry( contextEntry );
+
+ List<Modification> modItems = new ArrayList<Modification>();
+
+ Attribute attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
+ attribute.add( "this is description" );
+
+ Modification mod = new DefaultModification();
+ mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
+ mod.setAttribute( attribute );
+
+ modItems.add( mod );
+ modOpCtx.setModItems( modItems );
+
+ modOpCtx.setDn( contextEntry.getDn() );
+
+ partition.modify( modOpCtx );
+ RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath() ), "r" );
+ assertEquals( getEntryLdifLen( modOpCtx.getAlteredEntry() ), file.length() );
+
+ // perform the above operation, this time without causing change to the entry's size
+ modOpCtx = new ModifyOperationContext( mockSession );
+ modOpCtx.setEntry( new ClonedServerEntry( contextEntry ) );
+
+ modItems = new ArrayList<Modification>();
+
+ attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
+ attribute.add( "siht si noitpircsed" ); // reversed "this is description"
+
+ mod = new DefaultModification();
+ mod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
+ mod.setAttribute( attribute );
+
+ modItems.add( mod );
+ modOpCtx.setModItems( modItems );
+
+ modOpCtx.setDn( contextEntry.getDn() );
+
+ partition.modify( modOpCtx );
+ assertEquals( getEntryLdifLen( modOpCtx.getAlteredEntry() ), file.length() );
+
+ Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "domain" );
+ entry1.put( "dc", "test" );
+ addCtx.setEntry( entry1 );
+
+ partition.add( addCtx );
+
+ Entry entry2 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "domain" );
+ entry2.put( "dc", "test" );
+ addCtx.setEntry( entry2 );
+
+ partition.add( addCtx );
+
+ // now perform a modification on the entry present in middle of LDIF file
+ modOpCtx = new ModifyOperationContext( mockSession );
+ modOpCtx.setEntry( new ClonedServerEntry( entry1 ) );
+ modOpCtx.setDn( entry1.getDn() );
+
+ modItems = new ArrayList<Modification>();
+
+ attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
+ attribute.add( "desc of entry1" ); // reversed "this is description"
+
+ mod = new DefaultModification();
+ mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
+ mod.setAttribute( attribute );
+
+ modItems.add( mod );
+ modOpCtx.setModItems( modItems );
+
+ partition.modify( modOpCtx );
+
+ long ctxEntryLen = getEntryLdifLen( contextEntry );
+ long entry1Len = getEntryLdifLen( entry1 );
+
+ file.seek( ctxEntryLen );
+
+ byte[] entry1Data = new byte[( int ) entry1Len];
+
+ file.read( entry1Data );
+
+ String ldif = Strings.utf8ToString( entry1Data );
+
+ LdifEntry ldifEntry = reader.parseLdif( ldif ).get( 0 );
+
+ // Remove the EntryDN
+ entry1.removeAttributes( "entryDn" );
+
+ assertEquals( entry1, new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
+
+ //"description: desc of entry1\n"
+
+ modOpCtx = new ModifyOperationContext( mockSession );
+ modOpCtx.setEntry( new ClonedServerEntry( entry1 ) );
+ modOpCtx.setDn( entry1.getDn() );
+
+ modItems = new ArrayList<Modification>();
+
+ attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
+ attribute.add( "desc of entry1" ); // reversed "this is description"
+
+ mod = new DefaultModification();
+ mod.setOperation( ModificationOperation.REMOVE_ATTRIBUTE );
+ mod.setAttribute( attribute );
+
+ modItems.add( mod );
+ modOpCtx.setModItems( modItems );
+
+ partition.modify( modOpCtx );
+
+ file.seek( ctxEntryLen );
+
+ entry1Len = getEntryLdifLen( entry1 );
+ entry1Data = new byte[( int ) entry1Len];
+
+ file.read( entry1Data );
+
+ ldif = Strings.utf8ToString( entry1Data );
+
+ ldifEntry = reader.parseLdif( ldif ).get( 0 );
+
+ // Remove the EntryDN
+ entry1.removeAttributes( "entryDn" );
+
+ assertEquals( entry1, new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
+
+ partition = reloadPartition();
+ assertExists( partition, contextEntry );
+ assertExists( partition, entry1 );
+ assertExists( partition, entry2 );
+
+ file.close();
+ }
+
+
+ /**
+ * Test that we can't add an existing entry
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testLdifAddExistingEntry() throws Exception
+ {
+ SingleFileLdifPartition partition = createPartition( null, true );
+
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "domain" );
+ entry1.put( "dc", "test" );
+ addCtx.setEntry( entry1 );
+
+ partition.add( addCtx );
+
+ Entry entry2 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "domain" );
+ entry2.put( "dc", "test" );
+ addCtx.setEntry( entry2 );
+
+ partition.add( addCtx );
+
+ Entry entry3 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
+ entry3.put( "ObjectClass", "top", "domain" );
+ entry3.put( "dc", "test" );
+ addCtx.setEntry( entry3 );
+
+ try
+ {
+ partition.add( addCtx );
+ fail();
+ }
+ catch ( LdapException ne )
+ {
+ assertTrue( true );
+ }
+
+ partition = reloadPartition();
+ assertExists( partition, contextEntry );
+ assertExists( partition, entry1 );
+ assertExists( partition, entry2 );
+ }
+
+
+ //-------------------------------------------------------------------------
+ // Partition.delete() tests
+ //-------------------------------------------------------------------------
+ /**
+ * Test that we can delete an existing entry
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testLdifDeleteExistingEntry() throws Exception
+ {
+ SingleFileLdifPartition partition = createPartition( null, true );
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ DeleteOperationContext delOpCtx = new DeleteOperationContext( mockSession );
+ delOpCtx.setDn( contextEntry.getDn() );
+
+ partition.delete( delOpCtx );
+ RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath() ), "r" );
+
+ assertEquals( 0L, file.length() );
+
+ file.close();
+
+ addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "domain" );
+ entry1.put( "dc", "test" );
+ addCtx.setEntry( entry1 );
+
+ partition.add( addCtx );
+
+ Entry entry2 = createEntry( "dc=test1,dc=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "domain" );
+ entry2.put( "dc", "test1" );
+ addCtx.setEntry( entry2 );
+
+ partition.add( addCtx );
+
+ Entry entry3 = createEntry( "dc=test2,dc=test,ou=test,ou=system" );
+ entry3.put( "ObjectClass", "top", "domain" );
+ entry3.put( "dc", "test2" );
+ addCtx.setEntry( entry3 );
+
+ partition.add( addCtx );
+
+ Entry entryMvrdn = createEntry( "dc=mvrdn+objectClass=domain,dc=test,ou=test,ou=system" );
+ entryMvrdn.put( "ObjectClass", "top", "domain" );
+ entryMvrdn.put( "dc", "mvrdn" );
+ addCtx.setEntry( entryMvrdn );
+
+ partition.add( addCtx );
+
+ DeleteOperationContext delCtx = new DeleteOperationContext( mockSession );
+ delCtx.setDn( entryMvrdn.getDn() );
+
+ partition.delete( delCtx );
+
+ partition = reloadPartition();
+ assertExists( partition, entry1 );
+ assertExists( partition, entry2 );
+ assertExists( partition, entry3 );
+ }
+
+
+ //-------------------------------------------------------------------------
+ // Partition.delete() tests
+ //-------------------------------------------------------------------------
+ /**
+ * Test that we can search for an existing entry
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testLdifSearchExistingEntry() throws Exception
+ {
+ SingleFileLdifPartition partition = createPartition( null, true );
+
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "domain" );
+ entry1.put( "dc", "test" );
+ addCtx.setEntry( entry1 );
+
+ partition.add( addCtx );
+
+ Entry entry2 = createEntry( "dc=test1,dc=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "domain" );
+ entry2.put( "dc", "test1" );
+ addCtx.setEntry( entry2 );
+
+ partition.add( addCtx );
+
+ Entry entry3 = createEntry( "dc=test2,dc=test,ou=test,ou=system" );
+ entry3.put( "ObjectClass", "top", "domain" );
+ entry3.put( "dc", "test2" );
+ addCtx.setEntry( entry3 );
+
+ partition.add( addCtx );
+
+ SearchOperationContext searchCtx = new SearchOperationContext( mockSession );
+
+ Dn dn = new Dn( "dc=test,ou=test,ou=system" );
+ dn.apply( schemaManager );
+ searchCtx.setDn( dn );
+ ExprNode filter = FilterParser.parse( schemaManager, "(ObjectClass=domain)" );
+ NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
+ FilterNormalizingVisitor visitor = new FilterNormalizingVisitor( ncn, schemaManager );
+ filter.accept( visitor );
+ searchCtx.setFilter( filter );
+ searchCtx.setScope( SearchScope.SUBTREE );
+
+ EntryFilteringCursor cursor = partition.search( searchCtx );
+
+ assertNotNull( cursor );
+
+ Set<String> expectedDns = new HashSet<String>();
+ expectedDns.add( entry1.getDn().getNormName() );
+ expectedDns.add( entry2.getDn().getNormName() );
+ expectedDns.add( entry3.getDn().getNormName() );
+
+ cursor.beforeFirst();
+ int nbRes = 0;
+
+ while ( cursor.next() )
+ {
+ Entry entry = cursor.get();
+ assertNotNull( entry );
+ nbRes++;
+
+ expectedDns.remove( entry.getDn().getNormName() );
+ }
+
+ assertEquals( 3, nbRes );
+ assertEquals( 0, expectedDns.size() );
+
+ cursor.close();
+ }
+
+
+ @Test
+ public void testLdifMoveEntry() throws Exception
+ {
+ SingleFileLdifPartition partition = injectEntries();
+
+ Entry childEntry1 = partition.fetch( partition.getEntryId( new Dn( schemaManager,
+ "dc=child1,ou=test,ou=system" ) ) );
+ Entry childEntry2 = partition.fetch( partition.getEntryId( new Dn( schemaManager,
+ "dc=child2,ou=test,ou=system" ) ) );
+
+ MoveOperationContext moveOpCtx = new MoveOperationContext( mockSession, childEntry1.getDn(),
+ childEntry2.getDn() );
+ partition.move( moveOpCtx );
+
+ partition = reloadPartition();
+ assertExists( partition, childEntry2 );
+ assertNotExists( partition, childEntry1 );
+
+ assertExists( partition, "dc=child1,dc=child2,ou=test,ou=system" );
+ assertExists( partition, "dc=grandChild11,dc=child1,dc=child2,ou=test,ou=system" );
+ assertExists( partition, "dc=grandChild12,dc=child1,dc=child2,ou=test,ou=system" );
+ assertExists( partition, "dc=greatGrandChild111,dc=grandChild11,dc=child1,dc=child2,ou=test,ou=system" );
+ }
+
+
+ @Test
+ public void testLdifMoveSubChildEntry() throws Exception
+ {
+ SingleFileLdifPartition partition = injectEntries();
+
+ Entry childEntry1 = partition.fetch( partition.getEntryId( new Dn( schemaManager,
+ "dc=grandChild11,dc=child1,ou=test,ou=system" ) ) );
+ Entry childEntry2 = partition.fetch( partition.getEntryId( new Dn( schemaManager,
+ "dc=child2,ou=test,ou=system" ) ) );
+
+ MoveOperationContext moveOpCtx = new MoveOperationContext( mockSession, childEntry1.getDn(),
+ childEntry2.getDn() );
+ partition.move( moveOpCtx );
+
+ partition = reloadPartition();
+ assertExists( partition, childEntry2 );
+ assertNotExists( partition, childEntry1 );
+
+ assertExists( partition, "dc=child1,ou=test,ou=system" );
+ assertExists( partition, "dc=child2,ou=test,ou=system" );
+ assertExists( partition, "dc=grandChild11,dc=child2,ou=test,ou=system" );
+ assertExists( partition, "dc=grandChild12,dc=child1,ou=test,ou=system" );
+ assertExists( partition, "dc=greatGrandChild111,dc=grandChild11,dc=child2,ou=test,ou=system" );
+ }
+
+
+ @Test
+ public void testLdifRenameAndDeleteOldRDN() throws Exception
+ {
+ SingleFileLdifPartition partition = injectEntries();
+
+ Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+
+ Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "renamedChild1" );
+ RenameOperationContext renameOpCtx = new RenameOperationContext( mockSession, childDn1, newRdn, true );
+ partition.rename( renameOpCtx );
+
+ partition = reloadPartition();
+
+ childDn1 = new Dn( schemaManager, "dc=renamedChild1,ou=test,ou=system" );
+
+ Entry entry = partition.lookup( new LookupOperationContext( mockSession, childDn1 ) );
+
+ assertNotNull( entry );
+ assertFalse( entry.get( "dc" ).contains( "child1" ) );
+ }
+
+
+ @Test
+ public void testLdifRenameAndRetainOldRDN() throws Exception
+ {
+ SingleFileLdifPartition partition = injectEntries();
+
+ Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+
+ Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "renamedChild1" );
+ RenameOperationContext renameOpCtx = new RenameOperationContext( mockSession, childDn1, newRdn, false );
+ partition.rename( renameOpCtx );
+
+ partition = reloadPartition();
+
+ childDn1 = new Dn( schemaManager, "dc=renamedChild1,ou=test,ou=system" );
+
+ Entry entry = partition.lookup( new LookupOperationContext( mockSession, childDn1 ) );
+
+ assertNotNull( entry );
+ assertFalse( entry.get( "dc" ).contains( "child1" ) );
+ assertTrue( entry.get( "dc" ).contains( "renamedchild1" ) );
+ }
+
+
+ @Test
+ public void testLdifMoveAndRenameWithDeletingOldRDN() throws Exception
+ {
+ SingleFileLdifPartition partition = injectEntries();
+
+ Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+
+ Dn childDn2 = new Dn( schemaManager, "dc=child2,ou=test,ou=system" );
+
+ Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "movedChild1" );
+ MoveAndRenameOperationContext moveAndRenameOpCtx = new MoveAndRenameOperationContext( mockSession, childDn1,
+ childDn2, newRdn, true );
+ partition.moveAndRename( moveAndRenameOpCtx );
+
+ partition = reloadPartition();
+
+ childDn1 = new Dn( schemaManager, "dc=movedChild1,dc=child2,ou=test,ou=system" );
+
+ Entry entry = partition.lookup( new LookupOperationContext( mockSession, childDn1 ) );
+
+ assertNotNull( entry );
+ Attribute dc = entry.get( "dc" );
+ assertFalse( dc.contains( "child1" ) );
+ assertTrue( dc.contains( "movedChild1" ) );
+ }
+
+
+ @Test
+ public void testLdifMoveAndRenameRetainingOldRDN() throws Exception
+ {
+ SingleFileLdifPartition partition = injectEntries();
+
+ Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+
+ Dn childDn2 = new Dn( schemaManager, "dc=child2,ou=test,ou=system" );
+
+ Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "movedChild1" );
+ MoveAndRenameOperationContext moveAndRenameOpCtx = new MoveAndRenameOperationContext( mockSession, childDn1,
+ childDn2, newRdn, false );
+ partition.moveAndRename( moveAndRenameOpCtx );
+
+ partition = reloadPartition();
+
+ childDn1 = new Dn( schemaManager, "dc=movedChild1,dc=child2,ou=test,ou=system" );
+
+ Entry entry = partition.lookup( new LookupOperationContext( mockSession, childDn1 ) );
+
+ assertNotNull( entry );
+ Attribute dc = entry.get( "dc" );
+ assertFalse( dc.contains( "child1" ) );
+ assertTrue( dc.contains( "movedchild1" ) );
+ }
+
+
+ @Test
+ public void testEnableRewritingFlag() throws Exception
+ {
+ SingleFileLdifPartition partition = createPartition( null, true );
+
+ // disable writing
+ partition.setEnableRewriting( false );
+
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ // search works fine
+ String id = partition.getEntryId( contextEntry.getDn() );
+ assertNotNull( id );
+
+ Entry fetched = partition.fetch( id );
+
+ //remove the entryDn cause it is not present in the above hand made contextEntry
+ fetched.removeAttributes( SchemaConstants.ENTRY_DN_AT );
+
+ assertEquals( contextEntry, fetched );
+
+ RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath() ), "r" );
+
+ // but the file will be empty
+ assertFalse( getEntryLdifLen( contextEntry ) == file.length() );
+
+ partition = reloadPartition();
+ assertNotExists( partition, contextEntry );
+
+ // try adding on the reloaded partition
+ partition.add( addCtx );
+
+ // eable writing, this will let the partition write data back to disk
+ partition.setEnableRewriting( false );
+ assertTrue( getEntryLdifLen( contextEntry ) == file.length() );
+
+ file.close();
+ }
+
+
+ /**
+ * An important test to check the stability of the partition
+ * under high concurrency
+ *
+ * @throws Exception
+ */
+ @Test
+ @Ignore("Taking way too much time and very timing dependent")
+ public void testConcurrentOperations() throws Exception
+ {
+ SingleFileLdifPartition partition = injectEntries();
+
+ ThreadGroup tg = new ThreadGroup( "singlefileldifpartitionTG" );
+
+ Thread modifyTask = new Thread( tg, getModifyTask( partition ), "modifyTaskThread" );
+ Thread addAndDeleteTask = new Thread( tg, getAddAndDeleteTask( partition ), "addAndDeleteTaskThread" );
+ Thread renameTask = new Thread( tg, getRenameTask( partition ), "renameTaskThread" );
+ Thread moveTask = new Thread( tg, getMoveTask( partition ), "moveTaskThread" );
+
+ modifyTask.start();
+ addAndDeleteTask.start();
+ renameTask.start();
+ moveTask.start();
+
+ while ( tg.activeCount() > 0 )
+ {
+ Thread.sleep( 2000 );
+ }
+
+ // tests to be performed after the threads finish their work
+ partition = reloadPartition();
+
+ // test the work of modify thread
+ LookupOperationContext lookupCtx = new LookupOperationContext( mockSession );
+ lookupCtx.setDn( new Dn( "dc=threadDoModify,ou=test,ou=system" ) );
+
+ Entry entry = partition.lookup( lookupCtx );
+ assertNotNull( entry );
+ assertEquals( "description no 999", entry.get( "description" ).getString() );
+ assertExists( partition, contextEntry.getDn().getName() );
+ assertExists( partition, "dc=child1,ou=test,ou=system" );
+ assertExists( partition, "dc=child2,ou=test,ou=system" );
+ assertExists( partition, "dc=grandChild11,dc=child1,ou=test,ou=system" );
+ assertExists( partition, "dc=grandChild12,dc=child1,ou=test,ou=system" );
+ assertExists( partition, "dc=greatGrandChild111,dc=grandChild11,dc=child1,ou=test,ou=system" );
+ }
+
+
+ /**
+ * add and keep modifying an attribute's value for 1000 times
+ */
+ private Runnable getModifyTask( final SingleFileLdifPartition partition )
+ {
+ Runnable r = new Runnable()
+ {
+
+ public void run()
+ {
+ int i = 0;
+
+ try
+ {
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+
+ Entry childEntry1 = createEntry( "dc=threadDoModify,ou=test,ou=system" );
+ childEntry1.put( "ObjectClass", "top", "domain" );
+ childEntry1.put( "dc", "threadDoModify" );
+ addCtx.setEntry( childEntry1 );
+ partition.add( addCtx );
+
+ ModifyOperationContext modOpCtx = new ModifyOperationContext( mockSession );
+ modOpCtx.setEntry( childEntry1 );
+
+ List<Modification> modItems = new ArrayList<Modification>();
+
+ Attribute attribute = new DefaultAttribute(
+ schemaManager.lookupAttributeTypeRegistry( "description" ) );
+
+ Modification mod = new DefaultModification();
+ mod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
+ mod.setAttribute( attribute );
+
+ modItems.add( mod );
+ modOpCtx.setModItems( modItems );
+
+ modOpCtx.setDn( childEntry1.getDn() );
+
+ for ( ; i < 1000; i++ )
+ {
+ attribute.clear();
+ attribute.add( "description no " + i );
+ partition.modify( modOpCtx );
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ fail( "error while running ModifyTask at iteration count " + i );
+ }
+
+ }
+
+ };
+
+ return r;
+ }
+
+
+ /**
+ * adds and deletes the same entry 1000 times
+ */
+ private Runnable getAddAndDeleteTask( final SingleFileLdifPartition partition )
+ {
+ Runnable r = new Runnable()
+ {
+
+ public void run()
+ {
+ int i = 0;
+
+ try
+ {
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ DeleteOperationContext deleteCtx = new DeleteOperationContext( mockSession );
+
+ for ( ; i < 1000; i++ )
+ {
+ Entry entry = createEntry( "dc=threadDoAddAndDelete,ou=test,ou=system" );
+ entry.put( "ObjectClass", "top", "domain" );
+ entry.put( "dc", "threadDoAddAndDelete" );
+ addCtx.setEntry( entry );
+
+ // add first
+ partition.add( addCtx );
+
+ // then delete, net affect on the count of entries at the end is zero
+ deleteCtx.setDn( entry.getDn() );
+ partition.delete( deleteCtx );
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ fail( "error while running AddAndDeleteTask at iteration count " + i );
+ }
+ }
+
+ };
+
+ return r;
+
+ }
+
+
+ /**
+ * performs rename operation on an entry 1000 times, at the end of the
+ * last iteration the original entry should remain with the old Dn it has
+ * before starting this method
+ */
+ private Runnable getRenameTask( final SingleFileLdifPartition partition )
+ {
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ int i = 0;
+
+ try
+ {
+ Dn dn = new Dn( schemaManager, "dc=grandChild12,dc=child1,ou=test,ou=system" );
+
+ Rdn oldRdn = new Rdn( SchemaConstants.DC_AT + "=" + "grandChild12" );
+
+ Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "renamedGrandChild12" );
+
+ Dn tmpDn = dn;
+ Rdn tmpRdn = newRdn;
+
+ for ( ; i < 500; i++ )
+ {
+ RenameOperationContext renameOpCtx = new RenameOperationContext( mockSession, tmpDn, tmpRdn,
+ true );
+
+ partition.rename( renameOpCtx );
+ tmpDn = dn.getParent();
+ tmpDn = tmpDn.add( newRdn );
+ tmpRdn = oldRdn;
+
+ renameOpCtx = new RenameOperationContext( mockSession, tmpDn, tmpRdn, true );
+ partition.rename( renameOpCtx );
+ tmpDn = dn;
+ tmpRdn = newRdn;
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ fail( "error while running RenameTask at iteration count " + i );
+ }
+ }
+
+ };
+
+ return r;
+ }
+
+
+ /**
+ * performs move operation on an entry 1000 times, at the end of the
+ * last iteration the original entry should remain at the place where it
+ * was before starting this method
+ */
+ private Runnable getMoveTask( final SingleFileLdifPartition partition )
+ {
+ Runnable r = new Runnable()
+ {
+
+ public void run()
+ {
+ int i = 0;
+
+ try
+ {
+ Dn originalDn = new Dn( schemaManager, "dc=grandChild11,dc=child1,ou=test,ou=system" );
+
+ Dn originalParent = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+ Dn newParent = new Dn( schemaManager, "dc=child2,ou=test,ou=system" );
+
+ Dn tmpDn = originalDn;
+ Dn tmpParentDn = newParent;
+
+ for ( ; i < 500; i++ )
+ {
+ MoveOperationContext moveOpCtx = new MoveOperationContext( mockSession, tmpDn, tmpParentDn );
+ partition.move( moveOpCtx );
+ tmpDn = moveOpCtx.getNewDn();
+ tmpParentDn = originalParent;
+
+ moveOpCtx = new MoveOperationContext( mockSession, tmpDn, tmpParentDn );
+ partition.move( moveOpCtx );
+ tmpDn = moveOpCtx.getNewDn();
+ tmpParentDn = newParent;
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ fail( "error while running MoveTask at iteration count " + i );
+ }
+ }
+
+ };
+
+ return r;
+ }
+
+
+ private SingleFileLdifPartition injectEntries() throws Exception
+ {
+ SingleFileLdifPartition partition = createPartition( null, true );
+ AddOperationContext addCtx = new AddOperationContext( mockSession );
+ addCtx.setEntry( contextEntry );
+
+ partition.add( addCtx );
+
+ Entry childEntry1 = createEntry( "dc=child1,ou=test,ou=system" );
+ childEntry1.put( "ObjectClass", "top", "domain" );
+ childEntry1.put( "dc", "child1" );
+ addCtx.setEntry( childEntry1 );
+
+ partition.add( addCtx );
+
+ Entry childEntry2 = createEntry( "dc=child2,ou=test,ou=system" );
+ childEntry2.put( "ObjectClass", "top", "domain" );
+ childEntry2.put( "dc", "child2" );
+ addCtx.setEntry( childEntry2 );
+
+ partition.add( addCtx );
+
+ Entry grandChild11 = createEntry( "dc=grandChild11,dc=child1,ou=test,ou=system" );
+ grandChild11.put( "ObjectClass", "top", "domain" );
+ grandChild11.put( "dc", "grandChild11" );
+ addCtx.setEntry( grandChild11 );
+
+ partition.add( addCtx );
+
+ Entry grandChild12 = createEntry( "dc=grandChild12,dc=child1,ou=test,ou=system" );
+ grandChild12.put( "ObjectClass", "top", "domain" );
+ grandChild12.put( "dc", "grandChild12" );
+ addCtx.setEntry( grandChild12 );
+
+ partition.add( addCtx );
+
+ Entry greatGrandChild111 = createEntry( "dc=greatGrandChild111,dc=grandChild11,dc=child1,ou=test,ou=system" );
+ greatGrandChild111.put( "ObjectClass", "top", "domain" );
+ greatGrandChild111.put( "dc", "greatGrandChild111" );
+ addCtx.setEntry( greatGrandChild111 );
+
+ partition.add( addCtx );
+
+ return partition;
+ }
+}
Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java Tue Oct 13 22:17:22 2015
@@ -353,23 +353,23 @@ public class SingleFileLdifPartitionTest
partition.add( addCtx );
- Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
- entry1.put( "ObjectClass", "top", "domain" );
- entry1.put( "dc", "test" );
+ Entry entry1 = createEntry( "cn=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "person" );
+ entry1.put( "cn", "test" );
addCtx.setEntry( entry1 );
partition.add( addCtx );
- Entry entry2 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
- entry2.put( "ObjectClass", "top", "domain" );
- entry2.put( "dc", "test" );
+ Entry entry2 = createEntry( "cn=test,cn=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "person" );
+ entry2.put( "cn", "test" );
addCtx.setEntry( entry2 );
partition.add( addCtx );
- Entry entryMvrdn = createEntry( "dc=mvrdn+objectClass=domain,dc=test,ou=test,ou=system" );
- entryMvrdn.put( "ObjectClass", "top", "domain" );
- entryMvrdn.put( "dc", "mvrdn" );
+ Entry entryMvrdn = createEntry( "cn=mvrdn+objectClass=person,cn=test,ou=test,ou=system" );
+ entryMvrdn.put( "ObjectClass", "top", "person" );
+ entryMvrdn.put( "cn", "mvrdn" );
addCtx.setEntry( entryMvrdn );
partition.add( addCtx );
@@ -441,16 +441,16 @@ public class SingleFileLdifPartitionTest
partition.modify( modOpCtx );
assertEquals( getEntryLdifLen( modOpCtx.getAlteredEntry() ), file.length() );
- Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
- entry1.put( "ObjectClass", "top", "domain" );
- entry1.put( "dc", "test" );
+ Entry entry1 = createEntry( "cn=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "person" );
+ entry1.put( "cn", "test" );
addCtx.setEntry( entry1 );
partition.add( addCtx );
- Entry entry2 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
- entry2.put( "ObjectClass", "top", "domain" );
- entry2.put( "dc", "test" );
+ Entry entry2 = createEntry( "cn=test,cn=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "person" );
+ entry2.put( "cn", "test" );
addCtx.setEntry( entry2 );
partition.add( addCtx );
@@ -552,23 +552,23 @@ public class SingleFileLdifPartitionTest
partition.add( addCtx );
- Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
- entry1.put( "ObjectClass", "top", "domain" );
- entry1.put( "dc", "test" );
+ Entry entry1 = createEntry( "cn=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "person" );
+ entry1.put( "cn", "test" );
addCtx.setEntry( entry1 );
partition.add( addCtx );
- Entry entry2 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
- entry2.put( "ObjectClass", "top", "domain" );
- entry2.put( "dc", "test" );
+ Entry entry2 = createEntry( "cn=test,cn=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "person" );
+ entry2.put( "cn", "test" );
addCtx.setEntry( entry2 );
partition.add( addCtx );
- Entry entry3 = createEntry( "dc=test,dc=test,ou=test,ou=system" );
- entry3.put( "ObjectClass", "top", "domain" );
- entry3.put( "dc", "test" );
+ Entry entry3 = createEntry( "cn=test,cn=test,ou=test,ou=system" );
+ entry3.put( "ObjectClass", "top", "person" );
+ entry3.put( "cn", "test" );
addCtx.setEntry( entry3 );
try
@@ -620,30 +620,30 @@ public class SingleFileLdifPartitionTest
partition.add( addCtx );
- Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
- entry1.put( "ObjectClass", "top", "domain" );
- entry1.put( "dc", "test" );
+ Entry entry1 = createEntry( "cn=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "person" );
+ entry1.put( "cn", "test" );
addCtx.setEntry( entry1 );
partition.add( addCtx );
- Entry entry2 = createEntry( "dc=test1,dc=test,ou=test,ou=system" );
- entry2.put( "ObjectClass", "top", "domain" );
- entry2.put( "dc", "test1" );
+ Entry entry2 = createEntry( "cn=test1,cn=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "person" );
+ entry2.put( "cn", "test1" );
addCtx.setEntry( entry2 );
partition.add( addCtx );
- Entry entry3 = createEntry( "dc=test2,dc=test,ou=test,ou=system" );
- entry3.put( "ObjectClass", "top", "domain" );
- entry3.put( "dc", "test2" );
+ Entry entry3 = createEntry( "cn=test2,cn=test,ou=test,ou=system" );
+ entry3.put( "ObjectClass", "top", "person" );
+ entry3.put( "cn", "test2" );
addCtx.setEntry( entry3 );
partition.add( addCtx );
- Entry entryMvrdn = createEntry( "dc=mvrdn+objectClass=domain,dc=test,ou=test,ou=system" );
- entryMvrdn.put( "ObjectClass", "top", "domain" );
- entryMvrdn.put( "dc", "mvrdn" );
+ Entry entryMvrdn = createEntry( "cn=mvrdn+objectClass=person,cn=test,ou=test,ou=system" );
+ entryMvrdn.put( "ObjectClass", "top", "person" );
+ entryMvrdn.put( "cn", "mvrdn" );
addCtx.setEntry( entryMvrdn );
partition.add( addCtx );
@@ -678,33 +678,33 @@ public class SingleFileLdifPartitionTest
partition.add( addCtx );
- Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
- entry1.put( "ObjectClass", "top", "domain" );
- entry1.put( "dc", "test" );
+ Entry entry1 = createEntry( "cn=test,ou=test,ou=system" );
+ entry1.put( "ObjectClass", "top", "person" );
+ entry1.put( "cn", "test" );
addCtx.setEntry( entry1 );
partition.add( addCtx );
- Entry entry2 = createEntry( "dc=test1,dc=test,ou=test,ou=system" );
- entry2.put( "ObjectClass", "top", "domain" );
- entry2.put( "dc", "test1" );
+ Entry entry2 = createEntry( "cn=test1,cn=test,ou=test,ou=system" );
+ entry2.put( "ObjectClass", "top", "person" );
+ entry2.put( "cn", "test1" );
addCtx.setEntry( entry2 );
partition.add( addCtx );
- Entry entry3 = createEntry( "dc=test2,dc=test,ou=test,ou=system" );
- entry3.put( "ObjectClass", "top", "domain" );
- entry3.put( "dc", "test2" );
+ Entry entry3 = createEntry( "cn=test2,cn=test,ou=test,ou=system" );
+ entry3.put( "ObjectClass", "top", "person" );
+ entry3.put( "cn", "test2" );
addCtx.setEntry( entry3 );
partition.add( addCtx );
SearchOperationContext searchCtx = new SearchOperationContext( mockSession );
- Dn dn = new Dn( "dc=test,ou=test,ou=system" );
+ Dn dn = new Dn( "cn=test,ou=test,ou=system" );
dn.apply( schemaManager );
searchCtx.setDn( dn );
- ExprNode filter = FilterParser.parse( schemaManager, "(ObjectClass=domain)" );
+ ExprNode filter = FilterParser.parse( schemaManager, "(ObjectClass=person)" );
NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
FilterNormalizingVisitor visitor = new FilterNormalizingVisitor( ncn, schemaManager );
filter.accept( visitor );
@@ -745,9 +745,9 @@ public class SingleFileLdifPartitionTest
SingleFileLdifPartition partition = injectEntries();
Entry childEntry1 = partition.fetch( partition.getEntryId( new Dn( schemaManager,
- "dc=child1,ou=test,ou=system" ) ) );
+ "cn=child1,ou=test,ou=system" ) ) );
Entry childEntry2 = partition.fetch( partition.getEntryId( new Dn( schemaManager,
- "dc=child2,ou=test,ou=system" ) ) );
+ "cn=child2,ou=test,ou=system" ) ) );
MoveOperationContext moveOpCtx = new MoveOperationContext( mockSession, childEntry1.getDn(),
childEntry2.getDn() );
@@ -757,10 +757,10 @@ public class SingleFileLdifPartitionTest
assertExists( partition, childEntry2 );
assertNotExists( partition, childEntry1 );
- assertExists( partition, "dc=child1,dc=child2,ou=test,ou=system" );
- assertExists( partition, "dc=grandChild11,dc=child1,dc=child2,ou=test,ou=system" );
- assertExists( partition, "dc=grandChild12,dc=child1,dc=child2,ou=test,ou=system" );
- assertExists( partition, "dc=greatGrandChild111,dc=grandChild11,dc=child1,dc=child2,ou=test,ou=system" );
+ assertExists( partition, "cn=child1,cn=child2,ou=test,ou=system" );
+ assertExists( partition, "cn=grandChild11,cn=child1,cn=child2,ou=test,ou=system" );
+ assertExists( partition, "cn=grandChild12,cn=child1,cn=child2,ou=test,ou=system" );
+ assertExists( partition, "cn=greatGrandChild111,cn=grandChild11,cn=child1,cn=child2,ou=test,ou=system" );
}
@@ -770,9 +770,9 @@ public class SingleFileLdifPartitionTest
SingleFileLdifPartition partition = injectEntries();
Entry childEntry1 = partition.fetch( partition.getEntryId( new Dn( schemaManager,
- "dc=grandChild11,dc=child1,ou=test,ou=system" ) ) );
+ "cn=grandChild11,cn=child1,ou=test,ou=system" ) ) );
Entry childEntry2 = partition.fetch( partition.getEntryId( new Dn( schemaManager,
- "dc=child2,ou=test,ou=system" ) ) );
+ "cn=child2,ou=test,ou=system" ) ) );
MoveOperationContext moveOpCtx = new MoveOperationContext( mockSession, childEntry1.getDn(),
childEntry2.getDn() );
@@ -782,11 +782,11 @@ public class SingleFileLdifPartitionTest
assertExists( partition, childEntry2 );
assertNotExists( partition, childEntry1 );
- assertExists( partition, "dc=child1,ou=test,ou=system" );
- assertExists( partition, "dc=child2,ou=test,ou=system" );
- assertExists( partition, "dc=grandChild11,dc=child2,ou=test,ou=system" );
- assertExists( partition, "dc=grandChild12,dc=child1,ou=test,ou=system" );
- assertExists( partition, "dc=greatGrandChild111,dc=grandChild11,dc=child2,ou=test,ou=system" );
+ assertExists( partition, "cn=child1,ou=test,ou=system" );
+ assertExists( partition, "cn=child2,ou=test,ou=system" );
+ assertExists( partition, "cn=grandChild11,cn=child2,ou=test,ou=system" );
+ assertExists( partition, "cn=grandChild12,cn=child1,ou=test,ou=system" );
+ assertExists( partition, "cn=greatGrandChild111,cn=grandChild11,cn=child2,ou=test,ou=system" );
}
@@ -795,20 +795,20 @@ public class SingleFileLdifPartitionTest
{
SingleFileLdifPartition partition = injectEntries();
- Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+ Dn childDn1 = new Dn( schemaManager, "cn=child1,ou=test,ou=system" );
- Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "renamedChild1" );
+ Rdn newRdn = new Rdn( SchemaConstants.CN_AT + "=" + "renamedChild1" );
RenameOperationContext renameOpCtx = new RenameOperationContext( mockSession, childDn1, newRdn, true );
partition.rename( renameOpCtx );
partition = reloadPartition();
- childDn1 = new Dn( schemaManager, "dc=renamedChild1,ou=test,ou=system" );
+ childDn1 = new Dn( schemaManager, "cn=renamedChild1,ou=test,ou=system" );
Entry entry = partition.lookup( new LookupOperationContext( mockSession, childDn1 ) );
assertNotNull( entry );
- assertFalse( entry.get( "dc" ).contains( "child1" ) );
+ assertFalse( entry.get( "cn" ).contains( "child1" ) );
}
@@ -817,20 +817,20 @@ public class SingleFileLdifPartitionTest
{
SingleFileLdifPartition partition = injectEntries();
- Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+ Dn childDn1 = new Dn( schemaManager, "cn=child1,ou=test,ou=system" );
- Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "renamedChild1" );
+ Rdn newRdn = new Rdn( SchemaConstants.CN_AT + "=" + "renamedChild1" );
RenameOperationContext renameOpCtx = new RenameOperationContext( mockSession, childDn1, newRdn, false );
partition.rename( renameOpCtx );
partition = reloadPartition();
- childDn1 = new Dn( schemaManager, "dc=renamedChild1,ou=test,ou=system" );
+ childDn1 = new Dn( schemaManager, "cn=renamedChild1,ou=test,ou=system" );
Entry entry = partition.lookup( new LookupOperationContext( mockSession, childDn1 ) );
assertNotNull( entry );
- assertTrue( entry.get( "dc" ).contains( "child1" ) );
+ assertTrue( entry.get( "cn" ).contains( "child1" ) );
}
@@ -839,23 +839,23 @@ public class SingleFileLdifPartitionTest
{
SingleFileLdifPartition partition = injectEntries();
- Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+ Dn childDn1 = new Dn( schemaManager, "cn=child1,ou=test,ou=system" );
- Dn childDn2 = new Dn( schemaManager, "dc=child2,ou=test,ou=system" );
+ Dn childDn2 = new Dn( schemaManager, "cn=child2,ou=test,ou=system" );
- Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "movedChild1" );
+ Rdn newRdn = new Rdn( SchemaConstants.CN_AT + "=" + "movedChild1" );
MoveAndRenameOperationContext moveAndRenameOpCtx = new MoveAndRenameOperationContext( mockSession, childDn1,
childDn2, newRdn, true );
partition.moveAndRename( moveAndRenameOpCtx );
partition = reloadPartition();
- childDn1 = new Dn( schemaManager, "dc=movedChild1,dc=child2,ou=test,ou=system" );
+ childDn1 = new Dn( schemaManager, "cn=movedChild1,cn=child2,ou=test,ou=system" );
Entry entry = partition.lookup( new LookupOperationContext( mockSession, childDn1 ) );
assertNotNull( entry );
- Attribute dc = entry.get( "dc" );
+ Attribute dc = entry.get( "cn" );
assertFalse( dc.contains( "child1" ) );
assertTrue( dc.contains( "movedChild1" ) );
}
@@ -866,25 +866,25 @@ public class SingleFileLdifPartitionTest
{
SingleFileLdifPartition partition = injectEntries();
- Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
+ Dn childDn1 = new Dn( schemaManager, "cn=child1,ou=test,ou=system" );
- Dn childDn2 = new Dn( schemaManager, "dc=child2,ou=test,ou=system" );
+ Dn childDn2 = new Dn( schemaManager, "cn=child2,ou=test,ou=system" );
- Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "movedChild1" );
+ Rdn newRdn = new Rdn( SchemaConstants.CN_AT + "=" + "movedChild1" );
MoveAndRenameOperationContext moveAndRenameOpCtx = new MoveAndRenameOperationContext( mockSession, childDn1,
childDn2, newRdn, false );
partition.moveAndRename( moveAndRenameOpCtx );
partition = reloadPartition();
- childDn1 = new Dn( schemaManager, "dc=movedChild1,dc=child2,ou=test,ou=system" );
+ childDn1 = new Dn( schemaManager, "cn=movedChild1,cn=child2,ou=test,ou=system" );
Entry entry = partition.lookup( new LookupOperationContext( mockSession, childDn1 ) );
assertNotNull( entry );
- Attribute dc = entry.get( "dc" );
- assertTrue( dc.contains( "child1" ) );
- assertTrue( dc.contains( "movedChild1" ) );
+ Attribute cn = entry.get( "cn" );
+ assertTrue( cn.contains( "child1" ) );
+ assertTrue( cn.contains( "movedchild1" ) );
}
@@ -965,17 +965,17 @@ public class SingleFileLdifPartitionTest
// test the work of modify thread
LookupOperationContext lookupCtx = new LookupOperationContext( mockSession );
- lookupCtx.setDn( new Dn( "dc=threadDoModify,ou=test,ou=system" ) );
+ lookupCtx.setDn( new Dn( "cn=threadDoModify,ou=test,ou=system" ) );
Entry entry = partition.lookup( lookupCtx );
assertNotNull( entry );
assertEquals( "description no 999", entry.get( "description" ).getString() );
assertExists( partition, contextEntry.getDn().getName() );
- assertExists( partition, "dc=child1,ou=test,ou=system" );
- assertExists( partition, "dc=child2,ou=test,ou=system" );
- assertExists( partition, "dc=grandChild11,dc=child1,ou=test,ou=system" );
- assertExists( partition, "dc=grandChild12,dc=child1,ou=test,ou=system" );
- assertExists( partition, "dc=greatGrandChild111,dc=grandChild11,dc=child1,ou=test,ou=system" );
+ assertExists( partition, "cn=child1,ou=test,ou=system" );
+ assertExists( partition, "cn=child2,ou=test,ou=system" );
+ assertExists( partition, "cn=grandChild11,cn=child1,ou=test,ou=system" );
+ assertExists( partition, "cn=grandChild12,cn=child1,ou=test,ou=system" );
+ assertExists( partition, "cn=greatGrandChild111,cn=grandChild11,cn=child1,ou=test,ou=system" );
}
@@ -995,9 +995,9 @@ public class SingleFileLdifPartitionTest
{
AddOperationContext addCtx = new AddOperationContext( mockSession );
- Entry childEntry1 = createEntry( "dc=threadDoModify,ou=test,ou=system" );
- childEntry1.put( "ObjectClass", "top", "domain" );
- childEntry1.put( "dc", "threadDoModify" );
+ Entry childEntry1 = createEntry( "cn=threadDoModify,ou=test,ou=system" );
+ childEntry1.put( "ObjectClass", "top", "person" );
+ childEntry1.put( "cn", "threadDoModify" );
addCtx.setEntry( childEntry1 );
partition.add( addCtx );
@@ -1058,9 +1058,9 @@ public class SingleFileLdifPartitionTest
for ( ; i < 1000; i++ )
{
- Entry entry = createEntry( "dc=threadDoAddAndDelete,ou=test,ou=system" );
- entry.put( "ObjectClass", "top", "domain" );
- entry.put( "dc", "threadDoAddAndDelete" );
+ Entry entry = createEntry( "cn=threadDoAddAndDelete,ou=test,ou=system" );
+ entry.put( "ObjectClass", "top", "person" );
+ entry.put( "cn", "threadDoAddAndDelete" );
addCtx.setEntry( entry );
// add first
@@ -1100,11 +1100,11 @@ public class SingleFileLdifPartitionTest
try
{
- Dn dn = new Dn( schemaManager, "dc=grandChild12,dc=child1,ou=test,ou=system" );
+ Dn dn = new Dn( schemaManager, "cn=grandChild12,cn=child1,ou=test,ou=system" );
- Rdn oldRdn = new Rdn( SchemaConstants.DC_AT + "=" + "grandChild12" );
+ Rdn oldRdn = new Rdn( SchemaConstants.CN_AT + "=" + "grandChild12" );
- Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "renamedGrandChild12" );
+ Rdn newRdn = new Rdn( SchemaConstants.CN_AT + "=" + "renamedGrandChild12" );
Dn tmpDn = dn;
Rdn tmpRdn = newRdn;
@@ -1154,10 +1154,10 @@ public class SingleFileLdifPartitionTest
try
{
- Dn originalDn = new Dn( schemaManager, "dc=grandChild11,dc=child1,ou=test,ou=system" );
+ Dn originalDn = new Dn( schemaManager, "cn=grandChild11,cn=child1,ou=test,ou=system" );
- Dn originalParent = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
- Dn newParent = new Dn( schemaManager, "dc=child2,ou=test,ou=system" );
+ Dn originalParent = new Dn( schemaManager, "cn=child1,ou=test,ou=system" );
+ Dn newParent = new Dn( schemaManager, "cn=child2,ou=test,ou=system" );
Dn tmpDn = originalDn;
Dn tmpParentDn = newParent;
@@ -1196,37 +1196,42 @@ public class SingleFileLdifPartitionTest
partition.add( addCtx );
- Entry childEntry1 = createEntry( "dc=child1,ou=test,ou=system" );
- childEntry1.put( "ObjectClass", "top", "domain" );
- childEntry1.put( "dc", "child1" );
+ Entry childEntry1 = createEntry( "cn=child1,ou=test,ou=system" );
+ childEntry1.put( "ObjectClass", "top", "person" );
+ childEntry1.put( "cn", "child1" );
+ childEntry1.put( "sn", "child1" );
addCtx.setEntry( childEntry1 );
partition.add( addCtx );
- Entry childEntry2 = createEntry( "dc=child2,ou=test,ou=system" );
- childEntry2.put( "ObjectClass", "top", "domain" );
- childEntry2.put( "dc", "child2" );
+ Entry childEntry2 = createEntry( "cn=child2,ou=test,ou=system" );
+ childEntry2.put( "ObjectClass", "top", "person" );
+ childEntry2.put( "cn", "child2" );
+ childEntry1.put( "sn", "child2" );
addCtx.setEntry( childEntry2 );
partition.add( addCtx );
- Entry grandChild11 = createEntry( "dc=grandChild11,dc=child1,ou=test,ou=system" );
- grandChild11.put( "ObjectClass", "top", "domain" );
- grandChild11.put( "dc", "grandChild11" );
+ Entry grandChild11 = createEntry( "cn=grandChild11,cn=child1,ou=test,ou=system" );
+ grandChild11.put( "ObjectClass", "top", "person" );
+ grandChild11.put( "cn", "grandChild11" );
+ childEntry1.put( "sn", "grandChild11" );
addCtx.setEntry( grandChild11 );
partition.add( addCtx );
- Entry grandChild12 = createEntry( "dc=grandChild12,dc=child1,ou=test,ou=system" );
- grandChild12.put( "ObjectClass", "top", "domain" );
- grandChild12.put( "dc", "grandChild12" );
+ Entry grandChild12 = createEntry( "cn=grandChild12,cn=child1,ou=test,ou=system" );
+ grandChild12.put( "ObjectClass", "top", "person" );
+ grandChild12.put( "cn", "grandChild12" );
+ childEntry1.put( "sn", "grandChild12" );
addCtx.setEntry( grandChild12 );
partition.add( addCtx );
- Entry greatGrandChild111 = createEntry( "dc=greatGrandChild111,dc=grandChild11,dc=child1,ou=test,ou=system" );
- greatGrandChild111.put( "ObjectClass", "top", "domain" );
- greatGrandChild111.put( "dc", "greatGrandChild111" );
+ Entry greatGrandChild111 = createEntry( "cn=greatGrandChild111,cn=grandChild11,cn=child1,ou=test,ou=system" );
+ greatGrandChild111.put( "ObjectClass", "top", "person" );
+ greatGrandChild111.put( "cn", "greatGrandChild111" );
+ greatGrandChild111.put( "sn", "greatGrandChild111" );
addCtx.setEntry( greatGrandChild111 );
partition.add( addCtx );
Modified: directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/LdifBulkLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/LdifBulkLoaderTest.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/LdifBulkLoaderTest.java (original)
+++ directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/LdifBulkLoaderTest.java Tue Oct 13 22:17:22 2015
@@ -97,7 +97,7 @@ public class LdifBulkLoaderTest
}
- String userBranch = ouTemplate.replace( "{ou}", rdn.getValue().getString() );
+ String userBranch = ouTemplate.replace( "{ou}", rdn.getValue() );
userBranch = userBranch.replace( "{ouDn}", currentDn.getName() );
fw.write( userBranch );
Modified: directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java (original)
+++ directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java Tue Oct 13 22:17:22 2015
@@ -615,7 +615,7 @@ public class MavibotStoreTest
dn = new Dn( schemaManager, "sn=James,ou=Engineering,o=Good Times Co." );
Entry renamed = store.lookup( new LookupOperationContext( session, dn ) );
assertNotNull( renamed );
- assertEquals( "James", renamed.getDn().getRdn().getValue().getString() );
+ assertEquals( "James", renamed.getDn().getRdn().getValue() );
}
@@ -643,7 +643,7 @@ public class MavibotStoreTest
String id = store.getEntryId( dn2 );
assertNotNull( id );
Entry entry2 = store.fetch( id, dn2 );
- assertEquals( "Ja+es", entry2.get( "sn" ).getString() );
+ assertEquals( "ja+es", entry2.get( "sn" ).getString() );
}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/SyncReplRequestHandler.java Tue Oct 13 22:17:22 2015
@@ -1206,7 +1206,7 @@ public class SyncReplRequestHandler impl
private ReplicaEventLog getEventLog( OperationContext opCtx )
{
Dn consumerLogDn = opCtx.getDn();
- String name = ReplicaEventLog.REPLICA_EVENT_LOG_NAME_PREFIX + consumerLogDn.getRdn().getValue().getString();
+ String name = ReplicaEventLog.REPLICA_EVENT_LOG_NAME_PREFIX + consumerLogDn.getRdn().getNormValue();
for ( ReplicaEventLog log : replicaLogMap.values() )
{
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java Tue Oct 13 22:17:22 2015
@@ -1246,7 +1246,7 @@ public class AddIT extends AbstractLdapT
javax.naming.directory.Attribute cnAttribute = res.next().getAttributes().get( "cn" );
assertEquals( 2, cnAttribute.size() );
assertTrue( cnAttribute.contains( "Tori,Amos" ) );
- assertTrue( cnAttribute.contains( "Amos,Tori" ) );
+ assertTrue( cnAttribute.contains( "Amos\\,Tori" ) );
assertFalse( res.hasMore() );
// search for the implicit added userPassword
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java Tue Oct 13 22:17:22 2015
@@ -198,12 +198,12 @@ public class AddingEntriesWithSpecialCha
{
LdapConnection connection = getAdminConnection( getLdapServer() );
- Entry entry = getOrgUnitEntry( "AC\\DC" );
- String dn = "ou=AC\\\\DC,ou=system";
+ Entry entry = getOrgUnitEntry( "AC\\2B" );
+ String dn = "ou=AC\\\\2B,ou=system";
entry.setDn( new Dn( dn ) );
connection.add( entry );
- EntryCursor cursor = connection.search( "ou=system", "(ou=AC\\5CDC)", SearchScope.SUBTREE, "*" );
+ EntryCursor cursor = connection.search( "ou=system", "(ou=AC\\5C2B)", SearchScope.SUBTREE, "*" );
boolean entryFound = false;
while ( cursor.next() )
@@ -214,7 +214,7 @@ public class AddingEntriesWithSpecialCha
Attribute ou = sr.get( "ou" );
assertNotNull( ou );
- assertTrue( ou.contains( "AC\\DC" ) );
+ assertTrue( ou.contains( "AC\\2B" ) );
}
cursor.close();
@@ -407,8 +407,8 @@ public class AddingEntriesWithSpecialCha
assertEquals( "Name", addedEntry.get( "sn" ).getString() );
assertEquals( "User", addedEntry.get( "cn" ).getString() );
- assertEquals( 1, addedEntry.get( "cn" ).size() );
+ assertEquals( 2, addedEntry.get( "cn" ).size() );
assertTrue( addedEntry.contains( "cn", "User" ) );
- assertFalse( addedEntry.contains( "cn", " User" ) );
+ assertTrue( addedEntry.contains( "cn", "\\ User" ) );
}
}
\ No newline at end of file
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java Tue Oct 13 22:17:22 2015
@@ -301,7 +301,7 @@ public class SaslBindIT extends Abstract
connection.setTimeOut( 0L );
SaslCramMd5Request request = new SaslCramMd5Request();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "secret" );
BindResponse resp = connection.bind( request );
@@ -324,7 +324,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
SaslCramMd5Request request = new SaslCramMd5Request();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "badsecret" );
BindResponse resp = connection.bind( request );
@@ -343,7 +343,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
SaslDigestMd5Request request = new SaslDigestMd5Request();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "secret" );
request.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
BindResponse resp = connection.bind( request );
@@ -367,7 +367,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
SaslDigestMd5Request request = new SaslDigestMd5Request();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "secret" );
request.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
request.setQualityOfProtection( SaslQoP.AUTH );
@@ -393,7 +393,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
SaslDigestMd5Request request = new SaslDigestMd5Request();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "secret" );
request.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
request.setQualityOfProtection( SaslQoP.AUTH_INT );
@@ -419,7 +419,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
SaslDigestMd5Request request = new SaslDigestMd5Request();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "secret" );
request.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
request.setQualityOfProtection( SaslQoP.AUTH_CONF );
@@ -443,7 +443,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
SaslDigestMd5Request request = new SaslDigestMd5Request();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "secret" );
request.setRealmName( "badrealm.com" );
BindResponse resp = connection.bind( request );
@@ -463,7 +463,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
SaslDigestMd5Request request = new SaslDigestMd5Request();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "badsecret" );
request.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
BindResponse resp = connection.bind( request );
@@ -487,7 +487,7 @@ public class SaslBindIT extends Abstract
kdcServer.getConfig().setPaEncTimestampRequired( false );
SaslGssApiRequest request = new SaslGssApiRequest();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "secret" );
request.setRealmName( ldapServer.getSaslRealms().get( 0 ).toUpperCase() );
request.setKdcHost( InetAddress.getLocalHost().getHostName() );
@@ -512,7 +512,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
SaslGssApiRequest request = new SaslGssApiRequest();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "secret" );
request.setRealmName( "badrealm.com" );
request.setKdcHost( InetAddress.getLocalHost().getHostName() );
@@ -542,7 +542,7 @@ public class SaslBindIT extends Abstract
LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
SaslGssApiRequest request = new SaslGssApiRequest();
- request.setUsername( userDn.getRdn().getValue().getString() );
+ request.setUsername( userDn.getRdn().getValue() );
request.setCredentials( "badsecret" );
request.setRealmName( ldapServer.getSaslRealms().get( 0 ).toUpperCase() );
request.setKdcHost( InetAddress.getLocalHost().getHostName() );
@@ -633,7 +633,7 @@ public class SaslBindIT extends Abstract
// Digest-MD5
connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
SaslDigestMd5Request digetDigestMd5Request = new SaslDigestMd5Request();
- digetDigestMd5Request.setUsername( userDn.getRdn().getValue().getString() );
+ digetDigestMd5Request.setUsername( userDn.getRdn().getValue() );
digetDigestMd5Request.setCredentials( "secret" );
digetDigestMd5Request.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
resp = connection.bind( digetDigestMd5Request );
@@ -645,7 +645,7 @@ public class SaslBindIT extends Abstract
// Cram-MD5
connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
SaslCramMd5Request cramMd5Request = new SaslCramMd5Request();
- cramMd5Request.setUsername( userDn.getRdn().getValue().getString() );
+ cramMd5Request.setUsername( userDn.getRdn().getValue() );
cramMd5Request.setCredentials( "secret" );
resp = connection.bind( cramMd5Request );
assertEquals( ResultCodeEnum.SUCCESS, resp.getLdapResult().getResultCode() );
@@ -656,7 +656,7 @@ public class SaslBindIT extends Abstract
// GSSAPI
connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
SaslGssApiRequest gssApiRequest = new SaslGssApiRequest();
- gssApiRequest.setUsername( userDn.getRdn().getValue().getString() );
+ gssApiRequest.setUsername( userDn.getRdn().getValue() );
gssApiRequest.setCredentials( "secret" );
gssApiRequest.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
gssApiRequest.setKdcHost( InetAddress.getLocalHost().getHostName() );
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java?rev=1708527&r1=1708526&r2=1708527&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java Tue Oct 13 22:17:22 2015
@@ -1256,7 +1256,7 @@ public class AddIT extends AbstractLdapT
javax.naming.directory.Attribute cnAttribute = res.next().getAttributes().get( "cn" );
assertEquals( 2, cnAttribute.size() );
assertTrue( cnAttribute.contains( "Tori,Amos" ) );
- assertTrue( cnAttribute.contains( "Amos,Tori" ) );
+ assertTrue( cnAttribute.contains( "Amos\\,Tori" ) );
assertFalse( res.hasMore() );
// search for the implicit added userPassword