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 2023/03/28 23:11:42 UTC
[directory-ldap-api] 01/02: o Fixed a wrongly created upName o Added a test
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git
commit f094f29e4076d9a80097b94346444737f470e3fd
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Wed Mar 29 01:10:31 2023 +0200
o Fixed a wrongly created upName
o Added a test
---
.../apache/directory/api/ldap/model/name/Dn.java | 3 +-
.../directory/api/ldap/model/name/DnTest.java | 69 ++++++++++++++++++++++
2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java
index 40685134a..ffbe894d4 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Dn.java
@@ -1003,7 +1003,6 @@ public class Dn implements Iterable<Rdn>, Externalizable
clonedDn.rdns.add( 0, new Rdn( schemaManager, newRdn ) );
clonedDn.toUpName();
- clonedDn.upName = newRdn.upName + ',' + upName;
return clonedDn;
}
@@ -1032,7 +1031,7 @@ public class Dn implements Iterable<Rdn>, Externalizable
newDn.rdns.add( rdns.get( i ) );
}
- newDn.upName = removeUpName( rdns.get( 0 ).upName, LEFT );
+ newDn.toUpName();// = removeUpName( rdns.get( 0 ).upName, LEFT );
return newDn;
}
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/DnTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/DnTest.java
new file mode 100644
index 000000000..e5bfdccb2
--- /dev/null
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/name/DnTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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
+ *
+ * https://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.api.ldap.model.name;
+
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Iterator;
+
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.util.Strings;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Execution;
+import org.junit.jupiter.api.parallel.ExecutionMode;
+
+
+/**
+ * Test the class Dn
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@Execution(ExecutionMode.CONCURRENT)
+public class DnTest
+{
+ /** A null schemaManager used in tests */
+ SchemaManager schemaManager = null;
+
+
+ @Test
+ public void testAddRdn() throws LdapInvalidDnException
+ {
+ Dn dn = new Dn( "B=b,A=a" );
+ Rdn rdn = new Rdn( "C=c" );
+
+ dn = dn.add( rdn );
+
+ assertEquals( "C=c,B=b,A=a", dn.getName() );
+ assertEquals( "c=c,b=b,a=a", dn.getNormName() );
+ }
+}