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 2012/02/17 20:05:15 UTC
svn commit: r1245708 [1/2] - in /directory:
apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/rename/
apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
apacheds/tru...
Author: elecharny
Date: Fri Feb 17 19:05:14 2012
New Revision: 1245708
URL: http://svn.apache.org/viewvc?rev=1245708&view=rev
Log:
Fix for DIRSERVER-1696 : its now forbidden to create an entry with a RDN containing an AT more than once
Modified:
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/rename/RenamePerfIT.java
directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java
directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifRevertorTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnParserTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/rename/RenamePerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/rename/RenamePerfIT.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/rename/RenamePerfIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/rename/RenamePerfIT.java Fri Feb 17 19:05:14 2012
@@ -28,7 +28,9 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.server.core.integ.IntegrationUtils;
import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.model.entry.DefaultModification;
import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
import org.apache.directory.shared.ldap.model.name.Dn;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,26 +42,26 @@ import org.junit.runner.RunWith;
* @version $Rev$
*/
@RunWith(FrameworkRunner.class)
-@CreateDS(name = "RenamePerfDS",
- partitions =
- {
- @CreatePartition(
- name = "example",
- suffix = "dc=example,dc=com",
- contextEntry =
+@CreateDS(name = "RenamePerfDS",
+ partitions =
+ {
+ @CreatePartition(
+ name = "example",
+ suffix = "dc=example,dc=com",
+ contextEntry =
@ContextEntry(
- entryLdif =
+ entryLdif =
"dn: dc=example,dc=com\n" +
- "dc: example\n" +
- "objectClass: top\n" +
- "objectClass: domain\n\n"),
+ "dc: example\n" +
+ "objectClass: top\n" +
+ "objectClass: domain\n\n"),
indexes =
- {
- @CreateIndex(attribute = "objectClass"),
+ {
+ @CreateIndex(attribute = "objectClass"),
@CreateIndex(attribute = "sn"),
- @CreateIndex(attribute = "cn")
+ @CreateIndex(attribute = "cn")
})
- },
+ },
enableChangeLog = false)
public class RenamePerfIT extends AbstractLdapTestUnit
{
@@ -107,7 +109,7 @@ public class RenamePerfIT extends Abstra
connection.rename( oldDn, newRdn, true );
long ttt1 = System.nanoTime();
- oldDn = newRdn + ",ou=system";
+ oldDn = newRdn + ",ou=system";
//System.out.println("added " + i + ", delta = " + (ttt1-ttt0)/1000);
}
@@ -118,4 +120,30 @@ public class RenamePerfIT extends Abstra
connection.close();
}
+
+ @Test
+ public void testRenameUperCase() throws Exception
+ {
+ LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
+
+ String oldDn = "cn=test,ou=system";
+
+ Dn dn = new Dn( oldDn );
+ Entry entry = new DefaultEntry( getService().getSchemaManager(), dn );
+ entry.add( "ObjectClass", "top", "person" );
+ entry.add( "sn", "TEST" );
+ entry.add( "cn", "test0" );
+
+ connection.add( entry );
+
+ Entry original = connection.lookup( oldDn );
+
+ System.out.println( "Original : " + original );
+
+ connection.modify( oldDn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "cn", "TEST" ) );
+
+ Entry renamed = connection.lookup( oldDn );
+
+ System.out.println( "Renamed : " + renamed );
+ }
}
Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Fri Feb 17 19:05:14 2012
@@ -761,7 +761,7 @@ public class JdbmStoreTest
Long id = store.getEntryId( dn2 );
assertNotNull( id );
Entry entry2 = store.lookup( id );
- assertEquals( "ja+es", entry2.get( "sn" ).getString() );
+ assertEquals( "Ja\\+es", entry2.get( "sn" ).getString() );
}
Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java Fri Feb 17 19:05:14 2012
@@ -491,7 +491,7 @@ public class LdifPartitionTest
Dn childDn1 = new Dn( schemaManager, "dc=child1,ou=test,ou=system" );
- Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "renamedChild1" );
+ Rdn newRdn = new Rdn( "dc=renamedChild1" );
RenameOperationContext renameOpCtx = new RenameOperationContext( session, childDn1, newRdn, false );
partition.rename( renameOpCtx );
@@ -512,7 +512,7 @@ public class LdifPartitionTest
// the renamed LDIF must contain the old an new Rdn attribute
String content = FileUtils.readFileToString( new File( wkdir, "ou=test,ou=system/dc=renamedchild1.ldif" ) );
assertTrue( content.contains( "dc: child1" ) );
- assertTrue( content.contains( "dc: renamedchild1" ) );
+ assertTrue( content.contains( "dc: renamedChild1" ) );
}
@@ -555,7 +555,7 @@ public class LdifPartitionTest
Dn childDn2 = new Dn( schemaManager, "dc=child2,ou=test,ou=system" );
- Rdn newRdn = new Rdn( SchemaConstants.DC_AT + "=" + "movedChild1" );
+ Rdn newRdn = new Rdn( "dc=movedChild1" );
MoveAndRenameOperationContext moveAndRenameOpCtx = new MoveAndRenameOperationContext( session, childDn1,
childDn2, newRdn, false );
partition.moveAndRename( moveAndRenameOpCtx );
@@ -578,7 +578,7 @@ public class LdifPartitionTest
String content = FileUtils
.readFileToString( new File( wkdir, "ou=test,ou=system/dc=child2/dc=movedchild1.ldif" ) );
assertTrue( content.contains( "dc: child1" ) );
- assertTrue( content.contains( "dc: movedchild1" ) );
+ assertTrue( content.contains( "dc: movedChild1" ) );
}
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyRdnIT.java Fri Feb 17 19:05:14 2012
@@ -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.operations.modifydn;
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import javax.naming.NameNotFoundException;
@@ -37,13 +38,16 @@ import javax.naming.directory.SchemaViol
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
+import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.annotations.CreateDS;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.integ.ServerIntegrationUtils;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
-import org.apache.directory.shared.util.Strings;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -103,44 +107,51 @@ public class ModifyRdnIT extends Abstrac
@Test
public void testModifyRdnAndDeleteOld() throws Exception
{
- DirContext ctx = ( DirContext ) getWiredContext( getLdapServer() ).lookup( BASE );
+ LdapConnection connection = ServerIntegrationUtils.getAdminConnection( getLdapServer() );
+ connection.setTimeOut( 0L );
+ //connection.loadSchema();
// Create a person, cn value is rdn
String oldCn = "Myra Ellen Amos";
String oldRdn = "cn=" + oldCn;
- Attributes attributes = this.getPersonAttributes( "Amos", oldCn );
- ctx.createSubcontext( oldRdn, attributes );
+ String oldDn = oldRdn + ", " + BASE;
+
+ Entry entry = new DefaultEntry( oldDn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn", oldCn,
+ "sn: Amos",
+ "description", oldCn + " is a person." );
+
+ connection.add( entry );
+
+ Entry tori = connection.lookup( oldDn );
+
+ assertNotNull( tori );
+ assertTrue( tori.contains( "cn", "Myra Ellen Amos" ) );
// modify Rdn
String newCn = "Tori Amos";
String newRdn = "cn=" + newCn;
- ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
- ctx.rename( oldRdn, newRdn );
+ String newDn = newRdn + "," + BASE;
+
+ connection.rename( oldDn, newRdn, true );
// Check, whether old Entry does not exists
- try
- {
- ctx.lookup( oldRdn );
- fail( "Entry must not exist" );
- }
- catch ( NameNotFoundException ignored )
- {
- // expected behaviour
- assertTrue( true );
- }
+ assertNull( connection.lookup( oldDn ) );
// Check, whether new Entry exists
- DirContext tori = ( DirContext ) ctx.lookup( newRdn );
+ tori = connection.lookup( newDn );
+
assertNotNull( tori );
// Check values of cn
- Attribute cn = tori.getAttributes( "" ).get( "cn" );
- assertTrue( cn.contains( Strings.toLowerCase( newCn ) ) );
- assertTrue( !cn.contains( oldCn ) ); // old value is gone
- assertEquals( 1, cn.size() );
+ assertTrue( tori.contains( "cn", newCn ) );
+ assertFalse( tori.contains( "cn", oldCn ) ); // old value is gone
+ assertEquals( 1, tori.get( "cn" ).size() );
// Remove entry (use new rdn)
- ctx.unbind( newRdn );
+ connection.delete( newDn );
}
@@ -184,7 +195,7 @@ public class ModifyRdnIT extends Abstrac
// Check values of cn
Attribute cn = tori.getAttributes( "" ).get( "cn" );
- assertTrue( cn.contains( Strings.toLowerCase( newCn ) ) );
+ assertTrue( cn.contains( newCn ) );
assertTrue( cn.contains( oldCn ) ); // old value is still there
assertEquals( 2, cn.size() );
@@ -231,7 +242,7 @@ public class ModifyRdnIT extends Abstrac
// Check values of cn
Attribute cn = tori.getAttributes( "" ).get( "cn" );
- assertTrue( cn.contains( Strings.toLowerCase( newCn ) ) );
+ assertTrue( cn.contains( newCn ) );
assertTrue( cn.contains( oldCn ) ); // old value is still there
assertEquals( 2, cn.size() );
@@ -286,7 +297,7 @@ public class ModifyRdnIT extends Abstrac
// Check values of cn
cn = tori.getAttributes( "" ).get( "cn" );
- assertTrue( cn.contains( Strings.toLowerCase( newCn ) ) );
+ assertTrue( cn.contains( newCn ) );
assertTrue( !cn.contains( oldCn ) ); // old value is gone
assertTrue( cn.contains( alternateCn ) ); // alternate value is still available
assertEquals( 2, cn.size() );
@@ -425,7 +436,7 @@ public class ModifyRdnIT extends Abstrac
// Check values of ou
Attribute ou = org.getAttributes( "" ).get( "ou" );
- assertTrue( ou.contains( Strings.toLowerCase( newOu ) ) );
+ assertTrue( ou.contains( newOu ) );
assertTrue( !ou.contains( oldOu ) ); // old value is gone
assertEquals( 1, ou.size() );
@@ -495,7 +506,7 @@ public class ModifyRdnIT extends Abstrac
Attribute cn = newCtx.getAttributes( "" ).get( "cn" );
assertEquals( "Number of cn occurences", 1, cn.size() );
String expectedCn = new String( new byte[]
- { ( byte ) 0xC3, ( byte ) 0xA4, '+' }, "UTF-8" );
+ { ( byte ) 0xC3, ( byte ) 0xA4, '\\', '+' }, "UTF-8" );
assertTrue( cn.contains( expectedCn ) );
// Remove entry (use new rdn)
@@ -546,7 +557,7 @@ public class ModifyRdnIT extends Abstrac
// Check that cn contains the unescaped value
Attribute cn = newCtx.getAttributes( "" ).get( "cn" );
assertEquals( "Number of cn occurences", 1, cn.size() );
- assertTrue( cn.contains( "#test" ) );
+ assertTrue( cn.contains( "\\#test" ) );
// Remove entry (use new rdn)
ctx.unbind( newRdn );
@@ -560,7 +571,7 @@ public class ModifyRdnIT extends Abstrac
* - Old Rdn: cn
* - New Rdn: cn+sn
* - Keep old Rdn
- * - Attributes: cn, sn, description must exist
+ * - Attributes: cn, sn, description must exist
*/
@Test
public void testModifyMultiValuedRdnVariant1() throws Exception
@@ -600,7 +611,7 @@ public class ModifyRdnIT extends Abstrac
* - Old Rdn: cn
* - New Rdn: cn+sn
* - Delete old Rdn
- * - Attributes: cn, sn, description must exist
+ * - Attributes: cn, sn, description must exist
*/
@Test
public void testModifyMultiValuedRdnVariant2() throws Exception
@@ -640,7 +651,7 @@ public class ModifyRdnIT extends Abstrac
* - Old Rdn: description
* - New Rdn: cn+sn
* - Keep old Rdn
- * - Attributes: cn, sn, description must exist
+ * - Attributes: cn, sn, description must exist
*/
@Test
public void testModifyMultiValuedRdnVariant3() throws Exception
@@ -680,7 +691,7 @@ public class ModifyRdnIT extends Abstrac
* - Old Rdn: description
* - New Rdn: cn+sn
* - Delete old Rdn
- * - Attributes: cn, sn must exist; descriptions must not exist
+ * - Attributes: cn, sn must exist; descriptions must not exist
*/
@Test
public void testModifyMultiValuedRdnVariant4() throws Exception
@@ -720,7 +731,7 @@ public class ModifyRdnIT extends Abstrac
* - Old Rdn: cn
* - New Rdn: sn+telephoneNumber
* - Keep old Rdn
- * - Attributes: cn, sn, description, telephoneNumber must exist
+ * - Attributes: cn, sn, description, telephoneNumber must exist
*
* @throws org.apache.directory.shared.ldap.model.exception.LdapException
*/
@@ -826,7 +837,7 @@ public class ModifyRdnIT extends Abstrac
* - Old Rdn: cn+sn
* - New Rdn: cn
* - Keep old Rdn
- * - Attributes: cn, sn, description must exist
+ * - Attributes: cn, sn, description must exist
*
* @throws org.apache.directory.shared.ldap.model.exception.LdapException
*/
@@ -947,7 +958,7 @@ public class ModifyRdnIT extends Abstrac
ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "false" );
ctx.rename( oldRdn, newRdn );
- // rename back to old Rdn, enable deleteOldRdn,
+ // rename back to old Rdn, enable deleteOldRdn,
// must fail with NoPermisionException
ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
try
@@ -988,7 +999,7 @@ public class ModifyRdnIT extends Abstrac
ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "false" );
ctx.rename( oldRdn, newRdn );
- // rename back to old Rdn, enable deleteOldRdn,
+ // rename back to old Rdn, enable deleteOldRdn,
// must fail with NoPermisionException
ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
try
Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java Fri Feb 17 19:05:14 2012
@@ -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.xdbm.impl.avl;
@@ -656,7 +656,8 @@ public class AvlPartitionTest
Long id = partition.getEntryId( dn2 );
assertNotNull( id );
Entry entry2 = partition.lookup( id );
- assertEquals( "ja+es", entry2.get( "sn" ).getString() );
+ assertEquals( "Ja\\+es", entry2.get( "sn" ).getString() );
+ assertEquals( "ja\\+es", entry2.get( "sn" ).get().getNormValue() );
}
@@ -680,7 +681,7 @@ public class AvlPartitionTest
partition.moveAndRename( childDn, parentDn, rdn, new ClonedServerEntry( childEntry ), true );
- // to drop the alias indices
+ // to drop the alias indices
childDn = new Dn( schemaManager, "commonName=Jim Bean,ou=Apache,ou=Board of Directors,o=Good Times Co." );
parentDn = new Dn( schemaManager, "ou=Engineering,o=Good Times Co." );
Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java Fri Feb 17 19:05:14 2012
@@ -1150,8 +1150,8 @@ public class DnTest
@Test
public void testAttributeTypeEqualsIsCaseInsensitive() throws Exception
{
- Dn name1 = new Dn( "cn=HomeDir+cn=WorkDir" );
- Dn name2 = new Dn( "cn=HomeDir+CN=WorkDir" );
+ Dn name1 = new Dn( "cn=HomeDir+Sn=WorkDir" );
+ Dn name2 = new Dn( "cn=HomeDir+SN=WorkDir" );
assertTrue( name1.equals( name2 ) );
}
@@ -1161,8 +1161,8 @@ public class DnTest
public void testNameEqualsIsInsensitiveToAttributesOrder() throws Exception
{
- Dn name1 = new Dn( "cn=HomeDir+cn=WorkDir" );
- Dn name2 = new Dn( "cn=WorkDir+cn=HomeDir" );
+ Dn name1 = new Dn( "cn=HomeDir+sn=WorkDir" );
+ Dn name2 = new Dn( "sn=WorkDir+cn=HomeDir" );
assertTrue( name1.equals( name2 ) );
}
@@ -1181,8 +1181,8 @@ public class DnTest
@Test
public void testAttributeTypeComparisonIsCaseInsensitive() throws Exception
{
- Dn name1 = new Dn( "cn=HomeDir+cn=WorkDir" );
- Dn name2 = new Dn( "cn=HomeDir+CN=WorkDir" );
+ Dn name1 = new Dn( "cn=HomeDir+sn=WorkDir" );
+ Dn name2 = new Dn( "cn=HomeDir+SN=WorkDir" );
assertEquals( name1, name2 );
}
@@ -1192,8 +1192,8 @@ public class DnTest
public void testNameComparisonIsInsensitiveToAttributesOrder() throws Exception
{
- Dn name1 = new Dn( "cn=HomeDir+cn=WorkDir" );
- Dn name2 = new Dn( "cn=WorkDir+cn=HomeDir" );
+ Dn name1 = new Dn( "cn=HomeDir+sn=WorkDir" );
+ Dn name2 = new Dn( "sn=WorkDir+cn=HomeDir" );
assertEquals( name1, name2 );
}
@@ -1203,8 +1203,8 @@ public class DnTest
public void testNameComparisonIsInsensitiveToAttributesOrderFailure() throws Exception
{
- Dn name1 = new Dn( "cn= HomeDir+cn=Workdir" );
- Dn name2 = new Dn( "cn = Work+cn=HomeDir" );
+ Dn name1 = new Dn( "cn= HomeDir+sn=Workdir" );
+ Dn name2 = new Dn( "sn = Work+cn=HomeDir" );
assertNotSame( name1, name2 );
}
@@ -2638,19 +2638,19 @@ public class DnTest
@Test
public void testNormalizeAsciiComposite() throws Exception
{
- Dn dn = new Dn( " ou = Example + ou = TEST , ou = COM " );
+ Dn dn = new Dn( " ou = Example + cn = TEST , ou = COM " );
dn.apply( schemaManager );
- assertEquals( "2.5.4.11=example+2.5.4.11=test,2.5.4.11=com", dn.getNormName() );
- assertEquals( " ou = Example + ou = TEST , ou = COM ", dn.getName() );
+ assertEquals( "2.5.4.11=example+2.5.4.3=test,2.5.4.11=com", dn.getNormName() );
+ assertEquals( " ou = Example + cn = TEST , ou = COM ", dn.getName() );
Rdn rdn = dn.getRdn();
assertEquals( "2.5.4.11", rdn.getNormType() );
assertEquals( "example", rdn.getNormValue().getString() );
- assertEquals( "2.5.4.11=example+2.5.4.11=test", rdn.getNormName() );
+ assertEquals( "2.5.4.11=example+2.5.4.3=test", rdn.getNormName() );
assertEquals( "ou", rdn.getUpType() );
assertEquals( " Example ", rdn.getUpValue().getString() );
- assertEquals( " ou = Example + ou = TEST ", rdn.getName() );
+ assertEquals( " ou = Example + cn = TEST ", rdn.getName() );
// The first ATAV
Ava atav = rdn.getAva();
@@ -2675,13 +2675,13 @@ public class DnTest
continue;
}
- assertEquals( "2.5.4.11=test", ava.getNormName() );
- assertEquals( "2.5.4.11", ava.getNormType() );
+ assertEquals( "2.5.4.3=test", ava.getNormName() );
+ assertEquals( "2.5.4.3", ava.getNormType() );
assertEquals( "test", ava.getNormValue().getValue() );
- assertEquals( "ou", ava.getUpType() );
+ assertEquals( "cn", ava.getUpType() );
assertEquals( " TEST ", ava.getUpValue().getValue() );
- assertEquals( " ou = TEST ", ava.getUpName() );
+ assertEquals( " cn = TEST ", ava.getUpName() );
}
}
@@ -2719,17 +2719,17 @@ public class DnTest
@Test
public void testNormalizeCompositeWithEscaped() throws Exception
{
- Dn dn = new Dn( " OU = Ex\\+mple + ou = T\\+ST\\ , ou = COM " );
+ Dn dn = new Dn( " OU = Ex\\+mple + cn = T\\+ST\\ , ou = COM " );
// ------------------------------------------------------------------
// Before normalization
- assertEquals( " OU = Ex\\+mple + ou = T\\+ST\\ , ou = COM ", dn.getName() );
- assertEquals( "ou=Ex\\+mple+ou=T\\+ST\\ ,ou=COM", dn.getNormName() );
+ assertEquals( " OU = Ex\\+mple + cn = T\\+ST\\ , ou = COM ", dn.getName() );
+ assertEquals( "ou=Ex\\+mple+cn=T\\+ST\\ ,ou=COM", dn.getNormName() );
// Check the first Rdn
Rdn rdn = dn.getRdn();
- assertEquals( " OU = Ex\\+mple + ou = T\\+ST\\ ", rdn.getName() );
- assertEquals( "ou=Ex\\+mple+ou=T\\+ST\\ ", rdn.getNormName() );
+ assertEquals( " OU = Ex\\+mple + cn = T\\+ST\\ ", rdn.getName() );
+ assertEquals( "ou=Ex\\+mple+cn=T\\+ST\\ ", rdn.getNormName() );
assertEquals( "OU", rdn.getUpType() );
assertEquals( "ou", rdn.getNormType() );
@@ -2760,11 +2760,11 @@ public class DnTest
continue;
}
- assertEquals( " ou = T\\+ST\\ ", ava.getUpName() );
- assertEquals( "ou=T\\+ST\\ ", ava.getNormName() );
+ assertEquals( " cn = T\\+ST\\ ", ava.getUpName() );
+ assertEquals( "cn=T\\+ST\\ ", ava.getNormName() );
- assertEquals( "ou", ava.getUpType() );
- assertEquals( "ou", ava.getNormType() );
+ assertEquals( "cn", ava.getUpType() );
+ assertEquals( "cn", ava.getNormType() );
assertEquals( " T\\+ST\\ ", ava.getUpValue().getValue() );
assertEquals( "T+ST ", ava.getNormValue().getValue() );
@@ -2774,13 +2774,13 @@ public class DnTest
// Now normalize the Dn
dn.apply( schemaManager );
- assertEquals( " OU = Ex\\+mple + ou = T\\+ST\\ , ou = COM ", dn.getName() );
- assertEquals( "2.5.4.11=ex\\+mple+2.5.4.11=t\\+st,2.5.4.11=com", dn.getNormName() );
+ assertEquals( " OU = Ex\\+mple + cn = T\\+ST\\ , ou = COM ", dn.getName() );
+ assertEquals( "2.5.4.11=ex\\+mple+2.5.4.3=t\\+st,2.5.4.11=com", dn.getNormName() );
// Check the first Rdn
rdn = dn.getRdn();
- assertEquals( " OU = Ex\\+mple + ou = T\\+ST\\ ", rdn.getName() );
- assertEquals( "2.5.4.11=ex\\+mple+2.5.4.11=t\\+st", rdn.getNormName() );
+ assertEquals( " OU = Ex\\+mple + cn = T\\+ST\\ ", rdn.getName() );
+ assertEquals( "2.5.4.11=ex\\+mple+2.5.4.3=t\\+st", rdn.getNormName() );
assertEquals( "OU", rdn.getUpType() );
assertEquals( "2.5.4.11", rdn.getNormType() );
@@ -2811,11 +2811,11 @@ public class DnTest
continue;
}
- assertEquals( " ou = T\\+ST\\ ", ava.getUpName() );
- assertEquals( "2.5.4.11=t\\+st", ava.getNormName() );
+ assertEquals( " cn = T\\+ST\\ ", ava.getUpName() );
+ assertEquals( "2.5.4.3=t\\+st", ava.getNormName() );
- assertEquals( "ou", ava.getUpType() );
- assertEquals( "2.5.4.11", ava.getNormType() );
+ assertEquals( "cn", ava.getUpType() );
+ assertEquals( "2.5.4.3", ava.getNormType() );
assertEquals( " T\\+ST\\ ", ava.getUpValue().getValue() );
assertEquals( "t+st", ava.getNormValue().getValue() );
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java Fri Feb 17 19:05:14 2012
@@ -544,7 +544,7 @@ public class Rdn implements Cloneable, E
// WARNING : The protection level is left unspecified intentionally.
// We need this method to be visible from the DnParser class, but not
// from outside this package.
- /* Unspecified protection */void addAVA( SchemaManager schemaManager, Ava value )
+ /* Unspecified protection */void addAVA( SchemaManager schemaManager, Ava value ) throws LdapInvalidDnException
{
this.schemaManager = schemaManager;
String normalizedType = value.getNormType();
@@ -563,6 +563,12 @@ public class Rdn implements Cloneable, E
case 1:
// We already have an Ava. We have to put it in the HashMap
// before adding a new one.
+ // Check that the first AVA is not for the same attribute
+ if ( avaType.equals( normalizedType ) )
+ {
+ throw new LdapInvalidDnException( "Invalid RDN: the " + normalizedType + " is already present in the RDN" );
+ }
+
// First, create the HashMap,
avas = new ArrayList<Ava>();
@@ -577,6 +583,12 @@ public class Rdn implements Cloneable, E
// NO BREAK !!!
default:
+ // Check that the AT is not already present
+ if ( avaTypes.containsKey( normalizedType ) )
+ {
+ throw new LdapInvalidDnException( "Invalid RDN: the " + normalizedType + " is already present in the RDN" );
+ }
+
// add a new Ava
avas.add( value );
avaTypes.put( normalizedType, value );
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifRevertorTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifRevertorTest.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifRevertorTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifRevertorTest.java Fri Feb 17 19:05:14 2012
@@ -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.shared.ldap.model.ldif;
@@ -30,9 +30,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttributes;
-
import com.mycila.junit.concurrent.Concurrency;
import com.mycila.junit.concurrent.ConcurrentJunitRunner;
import org.apache.directory.shared.ldap.model.entry.*;
@@ -63,13 +60,14 @@ public class LdifRevertorTest
/**
* Helper method to build a basic entry used by the Modify tests
*/
- private Entry buildEntry()
+ private Entry buildEntry() throws LdapException
{
- Entry entry = new DefaultEntry();
- entry.put( "objectclass", "top", "person" );
- entry.put( "cn", "test" );
- entry.put( "sn", "joe doe" );
- entry.put( "l", "USA" );
+ Entry entry = new DefaultEntry( "",
+ "objectclass: top",
+ "objectclass: person",
+ "cn: test",
+ "sn: joe doe",
+ "l: USA" );
return entry;
}
@@ -78,7 +76,7 @@ public class LdifRevertorTest
/**
* Test a AddRequest reverse
*
- * @throws LdapInvalidDnException
+ * @throws LdapInvalidDnException
*/
@Test
public void testReverseAdd() throws LdapInvalidDnException
@@ -95,23 +93,19 @@ public class LdifRevertorTest
/**
* Test a DelRequest reverse
- * @throws LdapException
+ * @throws LdapException
*/
@Test
public void testReverseDel() throws LdapException
{
Dn dn = new Dn( "dc=apache, dc=com" );
- Entry deletedEntry = new DefaultEntry( dn );
-
- Attribute oc = new DefaultAttribute( "objectClass" );
- oc.add( "top", "person" );
-
- deletedEntry.put( oc );
-
- deletedEntry.put( "cn", "test" );
- deletedEntry.put( "sn", "apache" );
- deletedEntry.put( "dc", "apache" );
+ Entry deletedEntry = new DefaultEntry( dn ,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: apache",
+ "dc: apache" );
LdifEntry reversed = LdifRevertor.reverseDel( dn, deletedEntry );
@@ -131,9 +125,7 @@ public class LdifRevertorTest
{
Entry modifiedEntry = buildEntry();
- Attribute ou = new DefaultAttribute( "ou" );
- ou.add( "apache", "acme corp" );
- modifiedEntry.put( ou );
+ modifiedEntry.put( "ou", "apache", "acme corp" );
Dn dn = new Dn( "cn=test, ou=system" );
@@ -175,9 +167,7 @@ public class LdifRevertorTest
{
Entry modifiedEntry = buildEntry();
- Attribute ou = new DefaultAttribute( "ou" );
- ou.add( "apache", "acme corp" );
- modifiedEntry.put( ou );
+ modifiedEntry.put( "ou", "apache", "acme corp" );
Dn dn = new Dn( "cn=test, ou=system" );
@@ -207,7 +197,7 @@ public class LdifRevertorTest
assertNotNull( attr );
assertEquals( "ou", attr.getId() );
- assertEquals( ou, attr );
+ assertTrue( attr.contains( "apache", "acme corp" ) );
}
@@ -249,7 +239,7 @@ public class LdifRevertorTest
assertNotNull( attr );
assertEquals( "ou", attr.getId() );
- assertEquals( ou, attr );
+ assertTrue( ou.contains( "apache", "acme corp" ) );
}
@@ -261,15 +251,12 @@ public class LdifRevertorTest
{
Entry modifiedEntry = buildEntry();
- Attribute ou = new DefaultAttribute( "ou" );
- ou.add( "apache", "acme corp" );
+ Attribute ou = new DefaultAttribute( "ou", "apache", "acme corp" );
modifiedEntry.put( ou );
Dn dn = new Dn( "cn=test, ou=system" );
- Attribute ouModified = new DefaultAttribute( "ou" );
- ouModified.add( "directory" );
- ouModified.add( "BigCompany inc." );
+ Attribute ouModified = new DefaultAttribute( "ou", "directory", "BigCompany inc." );
Modification mod = new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE, ouModified );
@@ -308,9 +295,7 @@ public class LdifRevertorTest
Dn dn = new Dn( "cn=test, ou=system" );
- Attribute newOu = new DefaultAttribute( "ou" );
- newOu.add( "apache" );
- newOu.add( "acme corp" );
+ Attribute newOu = new DefaultAttribute( "ou", "apache", "acme corp" );
Modification mod = new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE, newOu );
@@ -349,10 +334,7 @@ public class LdifRevertorTest
{
Entry modifiedEntry = buildEntry();
- Attribute ou = new DefaultAttribute( "ou" );
- ou.add( "apache" );
- ou.add( "acme corp" );
- modifiedEntry.put( ou );
+ modifiedEntry.put( "ou", "apache", "acme corp" );
Dn dn = new Dn( "cn=test, ou=system" );
@@ -381,7 +363,7 @@ public class LdifRevertorTest
assertNotNull( attr );
assertEquals( "ou", attr.getId() );
- assertEquals( ou, attr );
+ assertTrue( attr.contains( "apache", "acme corp" ) );
}
@@ -404,7 +386,7 @@ public class LdifRevertorTest
* - add the 'l=FR' attribute
* - replace the 'l=FR' by a 'l=USA' attribute
* - replace the 'ou' attribute with 'apache' value.
- *
+ *
* The modify ldif will be :
*
* dn: cn=test, ou=system
@@ -423,7 +405,7 @@ public class LdifRevertorTest
* replace: ou
* ou: apache
* -
- *
+ *
* At the end, the entry will looks like :
* dn: cn=test, ou=system
* objectclass: top
@@ -432,7 +414,7 @@ public class LdifRevertorTest
* sn: joe doe
* l: USA
* ou: apache
- *
+ *
* and the reversed LDIF will be :
*
* dn: cn=test, ou=system
@@ -450,7 +432,7 @@ public class LdifRevertorTest
* add: l
* l: USA
* -
- * delete: ou
+ * delete: ou
* ou: BigCompany inc.
* -
*
@@ -485,7 +467,6 @@ public class LdifRevertorTest
List<Modification> modifications = new ArrayList<Modification>();
// First, inject the 'ou'
-
Modification mod = new DefaultModification(
ModificationOperation.ADD_ATTRIBUTE, new DefaultAttribute( "ou", "BigCompany inc." ) );
modifications.add( mod );
@@ -552,10 +533,7 @@ public class LdifRevertorTest
{
Entry modifiedEntry = buildEntry();
- Attribute ou = new DefaultAttribute( "ou" );
- ou.add( "apache" );
- ou.add( "acme corp" );
- modifiedEntry.put( ou );
+ modifiedEntry.put( "ou", "apache", "acme corp" );
Dn dn = new Dn( "cn=test, ou=system" );
Modification mod = new DefaultModification(
@@ -652,13 +630,6 @@ public class LdifRevertorTest
Dn newSuperior = new Dn( "ou=system" );
Rdn rdn = new Rdn( "cn=john doe" );
- Attributes attrs = new BasicAttributes( "objectClass", "person", true );
- attrs.get( "objectClass" ).add( "uidObject" );
- attrs.put( "cn", "john doe" );
- attrs.put( "cn", "jack doe" );
- attrs.put( "sn", "doe" );
- attrs.put( "uid", "jdoe" );
-
LdifEntry reversed = LdifRevertor.reverseMove( newSuperior, dn );
assertNotNull( reversed );
@@ -683,7 +654,7 @@ public class LdifRevertorTest
* objectclass: top
* objectclass: person
* cn: test
- * sn: This is a test
+ * sn: This is a test
*
* new Rdn : cn=joe
*
@@ -696,10 +667,11 @@ public class LdifRevertorTest
Rdn oldRdn = new Rdn( "cn=test" );
Rdn newRdn = new Rdn( "cn=joe" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -727,7 +699,7 @@ public class LdifRevertorTest
* objectclass: person
* cn: test
* cn: small
- * sn: This is a test
+ * sn: This is a test
*
* new Rdn : cn=small
*
@@ -740,10 +712,12 @@ public class LdifRevertorTest
Rdn oldRdn = new Rdn( "cn=test" );
Rdn newRdn = new Rdn( "cn=small" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -770,7 +744,7 @@ public class LdifRevertorTest
* objectclass: top
* objectclass: person
* cn: test
- * sn: This is a test
+ * sn: This is a test
*
* new Rdn : cn=joe
*
@@ -783,10 +757,11 @@ public class LdifRevertorTest
Rdn oldRdn = new Rdn( "cn=test" );
Rdn newRdn = new Rdn( "cn=joe" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -814,7 +789,7 @@ public class LdifRevertorTest
* objectclass: person
* cn: test
* cn: small
- * sn: This is a test
+ * sn: This is a test
*
* new Rdn : cn=small
*
@@ -827,10 +802,12 @@ public class LdifRevertorTest
Rdn oldRdn = new Rdn( "cn=test" );
Rdn newRdn = new Rdn( "cn=small" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -854,12 +831,12 @@ public class LdifRevertorTest
* Covers case 3 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
* new Rdn : cn=joe
*
@@ -868,14 +845,16 @@ public class LdifRevertorTest
@Test
public void test3ReverseRenameCompositeSimpleNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
Rdn newRdn = new Rdn( "cn=joe" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -899,13 +878,13 @@ public class LdifRevertorTest
* Covers case 3 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
* cn: big
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
* new Rdn : cn=big
*
@@ -914,14 +893,17 @@ public class LdifRevertorTest
@Test
public void test3ReverseRenameCompositeSimpleNotOverlappingKeepOldRdnExistsInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
Rdn newRdn = new Rdn( "cn=big" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small", "big" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -945,12 +927,12 @@ public class LdifRevertorTest
* Covers case 4 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: c,=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
* new Rdn : cn=joe
*
@@ -959,14 +941,16 @@ public class LdifRevertorTest
@Test
public void test4ReverseRenameCompositeSimpleNotOverlappingDeleteOldRdnDontExistsInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
Rdn newRdn = new Rdn( "cn=joe" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -990,13 +974,13 @@ public class LdifRevertorTest
* Covers case 4 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
* cn: big
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
* new Rdn : cn=big
*
@@ -1005,14 +989,17 @@ public class LdifRevertorTest
@Test
public void test4ReverseRenameCompositeSimpleNotOverlappingDeleteOldRdnExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
Rdn newRdn = new Rdn( "cn=big" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small", "big" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1035,12 +1022,12 @@ public class LdifRevertorTest
* Covers case 5 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
* new Rdn : cn=test
*
@@ -1049,14 +1036,16 @@ public class LdifRevertorTest
@Test
public void test5ReverseRenameCompositeSimpleOverlappingKeepOldRdn() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
Rdn newRdn = new Rdn( "cn=test" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1079,12 +1068,12 @@ public class LdifRevertorTest
* Covers case 5 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
* new Rdn : cn=test
*
@@ -1093,14 +1082,16 @@ public class LdifRevertorTest
@Test
public void test5ReverseRenameCompositeSimpleOverlappingDeleteOldRdn() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
Rdn newRdn = new Rdn( "cn=test" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1129,9 +1120,9 @@ public class LdifRevertorTest
* objectclass: person
* cn: test
* cn: small
- * sn: This is a test
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=plumber
+ * new Rdn : cn=joe+sn=plumber
*
* @throws LdapException on error
*/
@@ -1140,12 +1131,14 @@ public class LdifRevertorTest
{
Dn dn = new Dn( "cn=test,ou=system" );
Rdn oldRdn = new Rdn( "cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=plumber" );
+ Rdn newRdn = new Rdn( "cn=joe+sn=plumber" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1153,7 +1146,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=plumber,ou=system", reversed.getDn().getName() );
+ assertEquals( "cn=joe+sn=plumber,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1173,10 +1166,10 @@ public class LdifRevertorTest
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=small
+ * new Rdn : cn=joe+sn=small
*
* @throws LdapException on error
*/
@@ -1185,12 +1178,14 @@ public class LdifRevertorTest
{
Dn dn = new Dn( "cn=test,ou=system" );
Rdn oldRdn = new Rdn( "cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=small" );
+ Rdn newRdn = new Rdn( "cn=joe+sn=small" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1198,7 +1193,7 @@ public class LdifRevertorTest
assertEquals( 2, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=small,ou=system", reversed.getDn().getName() );
+ assertEquals( "cn=joe+sn=small,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1232,9 +1227,9 @@ public class LdifRevertorTest
* objectclass: person
* cn: test
* cn: small
- * sn: This is a test
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=plumber
+ * new Rdn : cn=joe+sn=plumber
*
* @throws LdapException on error
*/
@@ -1243,12 +1238,14 @@ public class LdifRevertorTest
{
Dn dn = new Dn( "cn=test,ou=system" );
Rdn oldRdn = new Rdn( "cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=plumber" );
+ Rdn newRdn = new Rdn( "cn=joe+sn=plumber" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1256,7 +1253,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=plumber,ou=system", reversed.getDn().getName() );
+ assertEquals( "cn=joe+sn=plumber,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1276,10 +1273,10 @@ public class LdifRevertorTest
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=small
+ * new Rdn : cn=joe+sn=small
*
* @throws LdapException on error
*/
@@ -1288,12 +1285,14 @@ public class LdifRevertorTest
{
Dn dn = new Dn( "cn=test,ou=system" );
Rdn oldRdn = new Rdn( "cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=small" );
+ Rdn newRdn = new Rdn( "cn=joe+sn=small" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1301,7 +1300,7 @@ public class LdifRevertorTest
assertEquals( 2, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=small,ou=system", reversed.getDn().getName() );
+ assertEquals( "cn=joe+sn=small,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1335,9 +1334,9 @@ public class LdifRevertorTest
* objectclass: person
* cn: test
* cn: big
- * sn: This is a test
+ * sn: This is a test
*
- * new Rdn : cn=small+cn=test
+ * new Rdn : sn=small+cn=test
*
* @throws LdapException on error
*/
@@ -1346,12 +1345,14 @@ public class LdifRevertorTest
{
Dn dn = new Dn( "cn=test,ou=system" );
Rdn oldRdn = new Rdn( "cn=test" );
- Rdn newRdn = new Rdn( "cn=small+cn=test" );
+ Rdn newRdn = new Rdn( "sn=small+cn=test" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: big",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1359,7 +1360,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=small+cn=test,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=small+cn=test,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1379,10 +1380,10 @@ public class LdifRevertorTest
* objectclass: top
* objectclass: person
* cn: test
- * cn: big
- * sn: This is a test
+ * sn: This is a test
+ * seeAlso: big
*
- * new Rdn : cn=small+cn=test
+ * new Rdn : sn=small+cn=test+seeAlso=big
*
* @throws LdapException on error
*/
@@ -1391,12 +1392,14 @@ public class LdifRevertorTest
{
Dn dn = new Dn( "cn=test,ou=system" );
Rdn oldRdn = new Rdn( "cn=test" );
- Rdn newRdn = new Rdn( "cn=small+cn=test+cn=big" );
+ Rdn newRdn = new Rdn( "sn=small+cn=test+seeAlso=big" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "seeAlso: big",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1404,7 +1407,7 @@ public class LdifRevertorTest
assertEquals( 2, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=small+cn=test+cn=big,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=small+cn=test+seeAlso=big,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1420,7 +1423,7 @@ public class LdifRevertorTest
assertEquals( 1, mods.length );
assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() );
assertNotNull( mods[0].getAttribute() );
- assertEquals( "cn", mods[0].getAttribute().getId() );
+ assertEquals( "sn", mods[0].getAttribute().getId() );
assertEquals( "small", mods[0].getAttribute().getString() );
}
@@ -1438,9 +1441,9 @@ public class LdifRevertorTest
* objectclass: person
* cn: test
* cn: big
- * sn: This is a test
+ * sn: This is a test
*
- * new Rdn : cn=small+cn=test
+ * new Rdn : sn=small+cn=test
*
* @throws LdapException on error
*/
@@ -1449,12 +1452,14 @@ public class LdifRevertorTest
{
Dn dn = new Dn( "cn=test,ou=system" );
Rdn oldRdn = new Rdn( "cn=test" );
- Rdn newRdn = new Rdn( "cn=small+cn=test" );
+ Rdn newRdn = new Rdn( "sn=small+cn=test" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: big",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1462,7 +1467,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=small+cn=test,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=small+cn=test,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1482,8 +1487,8 @@ public class LdifRevertorTest
* objectclass: top
* objectclass: person
* cn: test
- * cn: big
- * sn: This is a test
+ * seeAlso: big
+ * sn: This is a test
*
* new Rdn : cn=small+cn=test+cn=big
*
@@ -1494,12 +1499,14 @@ public class LdifRevertorTest
{
Dn dn = new Dn( "cn=test,ou=system" );
Rdn oldRdn = new Rdn( "cn=test" );
- Rdn newRdn = new Rdn( "cn=small+cn=test+cn=big" );
+ Rdn newRdn = new Rdn( "sn=small+cn=test+seeAlso=big" );
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "seeAlso: big",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1507,7 +1514,7 @@ public class LdifRevertorTest
assertEquals( 2, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=small+cn=test+cn=big,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=small+cn=test+seeAlso=big,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1523,7 +1530,7 @@ public class LdifRevertorTest
assertEquals( 1, mods.length );
assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() );
assertNotNull( mods[0].getAttribute() );
- assertEquals( "cn", mods[0].getAttribute().getId() );
+ assertEquals( "sn", mods[0].getAttribute().getId() );
assertEquals( "small", mods[0].getAttribute().getString() );
}
@@ -1536,13 +1543,13 @@ public class LdifRevertorTest
* Covers case 10.1 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
* cn: big
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
* new Rdn : cn=joe+cn=plumber
*
@@ -1551,14 +1558,17 @@ public class LdifRevertorTest
@Test
public void test101ReverseRenameCompositeCompositeNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=plumber" );
-
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
+ Rdn newRdn = new Rdn( "cn=joe+sn=plumber" );
+
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1566,7 +1576,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=plumber,ou=system", reversed.getDn().getName() );
+ assertEquals( "cn=joe+sn=plumber,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1582,29 +1592,32 @@ public class LdifRevertorTest
* Covers case 10.2 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
* cn: big
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=big
+ * new Rdn : sn=joe+cn=big
*
* @throws LdapException on error
*/
@Test
public void test102ReverseRenameCompositeCompositeNotOverlappingKeepOldRdnExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=big" );
-
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
+ Rdn newRdn = new Rdn( "sn=joe+cn=big" );
+
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1612,7 +1625,7 @@ public class LdifRevertorTest
assertEquals( 2, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=big,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=joe+cn=big,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1620,7 +1633,7 @@ public class LdifRevertorTest
reversed = reverseds.get( 1 );
- assertEquals( "cn=small+cn=test,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=small+cn=test,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.Modify, reversed.getChangeType() );
Modification[] mods = reversed.getModificationArray();
@@ -1628,7 +1641,7 @@ public class LdifRevertorTest
assertEquals( 1, mods.length );
assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation() );
assertNotNull( mods[0].getAttribute() );
- assertEquals( "cn", mods[0].getAttribute().getId() );
+ assertEquals( "sn", mods[0].getAttribute().getId() );
assertEquals( "joe", mods[0].getAttribute().getString() );
}
@@ -1641,29 +1654,32 @@ public class LdifRevertorTest
* Covers case 11.1 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * cn: big
- * sn: This is a test
+ * sn: big
+ * sn: small
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=plumber
+ * new Rdn : cn=joe+sn=plumber
*
* @throws LdapException on error
*/
@Test
public void test111ReverseRenameCompositeCompositeNotOverlappingDeleteOldRdnDontExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=plumber" );
-
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
+ Rdn newRdn = new Rdn( "cn=joe+sn=plumber" );
+
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1671,7 +1687,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=plumber,ou=system", reversed.getDn().getName() );
+ assertEquals( "cn=joe+sn=plumber,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1687,29 +1703,32 @@ public class LdifRevertorTest
* Covers case 11.2 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * cn: big
- * sn: This is a test
+ * sn: big
+ * sn: small
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=plumber
+ * new Rdn : cn=joe+sn=big
*
* @throws LdapException on error
*/
@Test
public void test112ReverseRenameCompositeCompositeNotOverlappingDeleteOldRdnExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=big" );
-
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
+ Rdn newRdn = new Rdn( "cn=joe+sn=big" );
+
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1717,7 +1736,7 @@ public class LdifRevertorTest
assertEquals( 2, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=big,ou=system", reversed.getDn().getName() );
+ assertEquals( "cn=joe+sn=big,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1725,7 +1744,7 @@ public class LdifRevertorTest
reversed = reverseds.get( 1 );
- assertEquals( "cn=small+cn=test,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=small+cn=test,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.Modify, reversed.getChangeType() );
Modification[] mods = reversed.getModificationArray();
@@ -1746,13 +1765,13 @@ public class LdifRevertorTest
* Covers case 12.1 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
* cn: big
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
* new Rdn : cn=joe+cn=test
*
@@ -1761,14 +1780,17 @@ public class LdifRevertorTest
@Test
public void test121ReverseRenameCompositeCompositeOverlappingKeepOldRdnDontExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=test" );
-
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
+ Rdn newRdn = new Rdn( "sn=joe+cn=test" );
+
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1776,7 +1798,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=test,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=joe+cn=test,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1792,29 +1814,32 @@ public class LdifRevertorTest
* Covers case 12.2 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * cn: big
- * sn: This is a test
+ * sn: big
+ * sn: small
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=test
+ * new Rdn : sn=big+cn=test
*
* @throws LdapException on error
*/
@Test
public void test122ReverseRenameCompositeCompositeOverlappingKeepOldRdnExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
- Rdn newRdn = new Rdn( "cn=big+cn=test" );
-
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
+ Rdn newRdn = new Rdn( "sn=big+cn=test" );
+
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );
@@ -1822,7 +1847,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=big+cn=test,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=big+cn=test,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1838,29 +1863,32 @@ public class LdifRevertorTest
* Covers case 13.1 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
* cn: big
- * sn: This is a test
+ * sn: small
+ * sn: This is a test
*
- * new Rdn : cn=joe+cn=test
+ * new Rdn : sn=joe+cn=test
*
* @throws LdapException on error
*/
@Test
public void test131ReverseRenameCompositeCompositeOverlappingDeleteOldRdnDontExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
- Rdn newRdn = new Rdn( "cn=joe+cn=test" );
-
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
+ Rdn newRdn = new Rdn( "sn=joe+cn=test" );
+
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "cn: big",
+ "sn: small",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1868,7 +1896,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=joe+cn=test,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=joe+cn=test,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertTrue( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
@@ -1884,29 +1912,32 @@ public class LdifRevertorTest
* Covers case 13.1 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
- * dn: cn=small+cn=test,ou=system
+ * dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
- * cn: small
- * cn: big
- * sn: This is a test
+ * sn: small
+ * sn: big
+ * sn: This is a test
*
- * new Rdn : cn=big+cn=test
+ * new Rdn : sn=big+cn=test
*
* @throws LdapException on error
*/
@Test
public void test132ReverseRenameCompositeCompositeOverlappingDeleteOldRdnExistInEntry() throws LdapException
{
- Dn dn = new Dn( "cn=small+cn=test,ou=system" );
- Rdn oldRdn = new Rdn( "cn=small+cn=test" );
- Rdn newRdn = new Rdn( "cn=big+cn=test" );
-
- Entry entry = new DefaultEntry( dn );
- entry.put( "cn", "test", "big", "small" );
- entry.put( "objectClass", "person", "top" );
- entry.put( "sn", "this is a test" );
+ Dn dn = new Dn( "sn=small+cn=test,ou=system" );
+ Rdn oldRdn = new Rdn( "sn=small+cn=test" );
+ Rdn newRdn = new Rdn( "sn=big+cn=test" );
+
+ Entry entry = new DefaultEntry( dn,
+ "objectClass: top",
+ "objectClass: person",
+ "cn: test",
+ "sn: small",
+ "sn: big",
+ "sn: this is a test" );
List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.DELETE_OLD_RDN );
@@ -1914,7 +1945,7 @@ public class LdifRevertorTest
assertEquals( 1, reverseds.size() );
LdifEntry reversed = reverseds.get( 0 );
- assertEquals( "cn=big+cn=test,ou=system", reversed.getDn().getName() );
+ assertEquals( "sn=big+cn=test,ou=system", reversed.getDn().getName() );
assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
assertFalse( reversed.isDeleteOldRdn() );
assertEquals( oldRdn.getName(), reversed.getNewRdn() );
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnParserTest.java?rev=1245708&r1=1245707&r2=1245708&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnParserTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/DnParserTest.java Fri Feb 17 19:05:14 2012
@@ -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.shared.ldap.model.name;
@@ -357,7 +357,7 @@ public class DnParserTest
assertEquals( "RFC1779_1 : ",
"CN=Marshall T. Rose, O=Dover Beach Consulting, L=Santa Clara, ST=California, C=US",
- ( ( Dn ) nameRFC1779_1 ).getName() );
+ nameRFC1779_1.getName() );
assertEquals( "RFC1779_1 : ", "cn=Marshall T. Rose,o=Dover Beach Consulting,l=Santa Clara,st=California,c=US",
nameRFC1779_1.getNormName() );
}
@@ -374,7 +374,7 @@ public class DnParserTest
{
Dn nameRFC2253_1 = new Dn( "CN=Steve Kille,O=Isode limited,C=GB" );
- assertEquals( "RFC2253_1 : ", "CN=Steve Kille,O=Isode limited,C=GB", ( ( Dn ) nameRFC2253_1 ).getName() );
+ assertEquals( "RFC2253_1 : ", "CN=Steve Kille,O=Isode limited,C=GB", nameRFC2253_1.getName() );
}
@@ -387,11 +387,11 @@ public class DnParserTest
@Test
public final void testParseStringRFC2253_2() throws LdapException
{
- Dn nameRFC2253_2 = new Dn( "CN = Sales + CN = J. Smith , O = Widget Inc. , C = US" );
+ Dn nameRFC2253_2 = new Dn( "OU = Sales + CN = J. Smith , O = Widget Inc. , C = US" );
- assertEquals( "RFC2253_2 : ", "CN = Sales + CN = J. Smith , O = Widget Inc. , C = US",
- ( ( Dn ) nameRFC2253_2 ).getName() );
- assertEquals( "RFC2253_2 : ", "cn=Sales+cn=J. Smith,o=Widget Inc.,c=US", nameRFC2253_2.getNormName() );
+ assertEquals( "RFC2253_2 : ", "OU = Sales + CN = J. Smith , O = Widget Inc. , C = US",
+ nameRFC2253_2.getName() );
+ assertEquals( "RFC2253_2 : ", "ou=Sales+cn=J. Smith,o=Widget Inc.,c=US", nameRFC2253_2.getNormName() );
}
@@ -406,7 +406,7 @@ public class DnParserTest
{
Dn nameRFC2253_3 = new Dn( "CN=L. Eagle, O=Sue\\, Grabbit and Runn, C=GB" );
- assertEquals( "RFC2253_3 : ", "CN=L. Eagle, O=Sue\\, Grabbit and Runn, C=GB", ( ( Dn ) nameRFC2253_3 )
+ assertEquals( "RFC2253_3 : ", "CN=L. Eagle, O=Sue\\, Grabbit and Runn, C=GB", nameRFC2253_3
.getName() );
assertEquals( "RFC2253_3 : ", "cn=L. Eagle,o=Sue\\, Grabbit and Runn,c=GB", nameRFC2253_3.getNormName() );
}
@@ -422,7 +422,7 @@ public class DnParserTest
public final void testParseStringRFC2253_4() throws LdapException
{
Dn nameRFC2253_4 = new Dn( "CN=Before\\0DAfter,O=Test,C=GB" );
- assertEquals( "RFC2253_4 : ", "CN=Before\\0DAfter,O=Test,C=GB", ( ( Dn ) nameRFC2253_4 ).getName() );
+ assertEquals( "RFC2253_4 : ", "CN=Before\\0DAfter,O=Test,C=GB", nameRFC2253_4.getName() );
}
@@ -437,7 +437,7 @@ public class DnParserTest
{
Dn nameRFC2253_5 = new Dn( "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB" );
- assertEquals( "RFC2253_5 : ", "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB", ( ( Dn ) nameRFC2253_5 )
+ assertEquals( "RFC2253_5 : ", "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB", nameRFC2253_5
.getName() );
}
@@ -453,7 +453,7 @@ public class DnParserTest
{
Dn nameRFC2253_6 = new Dn( "SN=Lu\\C4\\8Di\\C4\\87" );
- assertEquals( "RFC2253_6 : ", "SN=Lu\\C4\\8Di\\C4\\87", ( ( Dn ) nameRFC2253_6 ).getName() );
+ assertEquals( "RFC2253_6 : ", "SN=Lu\\C4\\8Di\\C4\\87", nameRFC2253_6.getName() );
}