You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2007/02/26 08:10:16 UTC
svn commit: r511744 [2/3] - in
/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap:
LdapNameTest.java TestLdapName.java main/AllTestLdap.java
Copied: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java (from r510411, harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestLdapName.java)
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java?view=diff&rev=511744&p1=harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestLdapName.java&r1=510411&p2=harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java&r2=511744
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestLdapName.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java Sun Feb 25 23:10:15 2007
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
/**
* @author Hugo Beilis
* @author Leonardo Soler
@@ -35,4118 +36,3537 @@
/**
*
- * <p>Test cases for all methods of the class LdapName.</p>
+ * <p>
+ * Test cases for all methods of the class LdapName.
+ * </p>
+ *
+ * <p>
+ * The next two tables contains a list of the methods to be tested, with the
+ * return of each method.
+ * </p>
+ * <table class="t" cellspacing="0"> <tbody>
+ * <th>Constructors:</th>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="LdapName(List<Rdn> rdns)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="LdapName(String name)" id="f10"></td>
+ *
+ * </tr>
+ * </tbody> <table> <tbody>
+ * <th>Method Summary:</th>
+ * <tr>
+ * <TD>Return</TD>
+ * <TD>Method</TD>
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></TD>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="add(int posn, Rdn comp)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="add(int posn, String comp)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="add(Rdn comp)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="add(String comp)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="addAll(int posn, List<Rdn> suffixRdns)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="addAll(int posn, Name suffix)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="addAll(List<Rdn> suffixRdns)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="addAll(Name suffix)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Object" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="clone()" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="int" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="compareTo(Object obj)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="boolean" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="endsWith(List<Rdn> rdns)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="boolean" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="endsWith(Name n)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="boolean" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="equals(Object obj)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="String" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="get(int posn)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Enumeration<String>" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="getAll()" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="getPrefix(int posn)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Rdn" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="getRdn(int posn)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="List<Rdn>" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="getRdns()" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Name" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="getSuffix(int posn)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="int" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="hashCode()" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="boolean" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="isEmpty()" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="Object" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="remove(int posn)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="int" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="size()" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="boolean" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="startsWith(List<Rdn> rdns)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="boolean" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="startsWith(Name n)" id="f10"></td>
+ *
+ * </tr>
+ * <tr>
+ * <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11"
+ * readonly="readonly" value="String" id="f00"></td>
+ * <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21"
+ * readonly="readonly" value="toString()" id="f10"></td>
+ *
+ * </tr>
+ * </tbody> </table>
*
- * <p>The next two tables contains a list of the methods to be tested, with the return of each method.</p>
- * <table class="t" cellspacing="0">
- <tbody><th>Constructors:</th>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="LdapName(List<Rdn> rdns)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="LdapName(String name)" id="f10"></td>
-
- </tr>
- </tbody>
- <table>
- <tbody><th>Method Summary:</th>
- <tr><TD>Return</TD><TD>Method</TD></tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></TD>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="add(int posn, Rdn comp)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="add(int posn, String comp)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="add(Rdn comp)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="add(String comp)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="addAll(int posn, List<Rdn> suffixRdns)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="addAll(int posn, Name suffix)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="addAll(List<Rdn> suffixRdns)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="addAll(Name suffix)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Object" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="clone()" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="int" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="compareTo(Object obj)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="endsWith(List<Rdn> rdns)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="endsWith(Name n)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="equals(Object obj)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="String" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="get(int posn)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Enumeration<String>" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="getAll()" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="getPrefix(int posn)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Rdn" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="getRdn(int posn)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="List<Rdn>" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="getRdns()" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Name" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="getSuffix(int posn)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="int" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="hashCode()" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="isEmpty()" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="Object" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="remove(int posn)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="int" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="size()" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="startsWith(List<Rdn> rdns)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="boolean" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="startsWith(Name n)" id="f10"></td>
-
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="String" id="f00"></td>
- <td class="c0" id="c10"><input class="a0" size="40" name="sas9nt21" readonly="readonly" value="toString()" id="f10"></td>
-
- </tr>
- </tbody>
- </table>
- *
*/
-public class TestLdapName extends TestCase {
+public class LdapNameTest extends TestCase {
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ */
+ public void testLdapNameString001() throws Exception {
+ try {
+ new LdapName((String) null);
+ fail("Failed the null argument is invalid.");
+ } catch (NullPointerException e) {}
+
+ //check that no exception happens
+ new LdapName("CN=test");
+ new LdapName("L=test,C=common");
+ new LdapName("ST=test;CN=common");
+ new LdapName("O=test+CM=common");
+ new LdapName("OU=test this");
+ new LdapName("C=test\\, this");
+ new LdapName("S=#04024869");
+ new LdapName("DC=test,T=time+CM=common V<this C>this,S=#04024869");
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive a
+ * non-null String, this string must be a valid string like
+ * SN=Lu\C4\8Di\C4\87.
+ * </p>
+ * <p>
+ * The expected result is an instance of LdapName.
+ * </p>
+ * <p>
+ * The String is an example of an RDN surname value consisting of 5 letters
+ * </p>
+ */
+ public void testLdapNameString010() throws Exception {
+ new LdapName("SN=Lu\\C4\\8Di\\C4\\87");
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive a
+ * non-null String, and the DNs must be case insensitive.
+ * </p>
+ * <p>
+ * The expected result is an assertion between two names one upper and other
+ * lower case.
+ * </p>
+ */
+ public void testLdapNameString011() throws Exception {
+ String testUpperCase = "UID=TEST";
+ String testLowerCase = "uid=test";
+ assertEquals(new LdapName(testUpperCase), new LdapName(testLowerCase));
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive a
+ * blank String.
+ * </p>
+ * <p>
+ * The expected result an empty name, not null, empty.
+ * </p>
+ */
+ public void testLdapNameString012() throws Exception {
+ LdapName ln = new LdapName("");
+ assertTrue(ln.isEmpty());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive
+ * String with correct format like "a=b", In this case we are gonna test the
+ * special characters "<" and ">".
+ * </p>
+ * <p>
+ * The expected result is an instance of ldapname.
+ * </p>
+ */
+ public void testLdapNameString013() throws Exception {
+ new LdapName("a=<");
+ new LdapName("a=<a");
+ new LdapName("a=a<");
+ new LdapName("a=a<b");
+ new LdapName("a=a<b<");
+ new LdapName("a=>");
+ new LdapName("a=>a");
+ new LdapName("a=a>");
+ new LdapName("a=a>b");
+ new LdapName("a=a>b>");
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive
+ * String with no correct format like "test".
+ * </p>
+ * <p>
+ * The expected result is an InvalidNameException.
+ * </p>
+ */
+ public void testLdapNameString014() throws Exception {
+ try {
+ new LdapName("test");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("t=test,control");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ new LdapName("t=test,");
+ try {
+ new LdapName(",t=test");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName(",t=test,");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive
+ * String with no correct format like "test".
+ * </p>
+ * <p>
+ * The expected result is an InvalidNameException.
+ * </p>
+ */
+ public void testLdapNameString015() throws Exception {
+ new LdapName("t=");
+ try {
+ new LdapName("=t");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("=");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("=t=t");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ new LdapName("a=t=");
+ try {
+ new LdapName("=a=t=");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ new LdapName("a=b=t=z");
+
+ try {
+ new LdapName(";");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ new LdapName("a=b;");
+ try {
+ new LdapName(";a=b");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("a=b;c");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName(";a=b;");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive
+ * String with no correct format like "test".
+ * </p>
+ * <p>
+ * The expected result is an InvalidNameException.
+ * </p>
+ */
+ public void testLdapNameString016() throws Exception {
+
+ new LdapName("a=a#");
+ try {
+ new LdapName("a=#a");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("#a=a");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("#a=#a");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("#a=a#");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive
+ * String notice here that here that we are testing the the special
+ * character "<".
+ * </p>
+ * <p>
+ * The expected result is an Exception.
+ * </p>
+ */
+ public void testLdapNameString036() {
+ try {
+ new LdapName("a<a");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("<a=a");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("<a=a<");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("a>c");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName(">a=c");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName(">a=c>");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive
+ * String notice here that here that we are testing the the special
+ * character "\".
+ * </p>
+ * <p>
+ * The expected result is an Exception.
+ * </p>
+ */
+ public void testLdapNameString042() {
+ try {
+ new LdapName("a=b\\");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("\\a=b");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("\\a=b\\");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("a=b\\s");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive
+ * String notice here that here that we are testing the the special
+ * character "+".
+ * </p>
+ * <p>
+ * The expected result is an instance of the class.
+ * </p>
+ */
+ public void testLdapNameString046() throws Exception {
+ new LdapName("a=b+");
+ try {
+ new LdapName("+a=b");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("+a=b+");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ new LdapName("a=b+s=");
+ try {
+ new LdapName("a=b+s");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ new LdapName("b= ");
+ try {
+ new LdapName(" =b");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+ }
- /**
- * <p>This method is not implemted.</p>
- * @param args Possible parameter to help us initiate all tests.
- */
- public static void main(String[] args) {
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method recive a null String.</p>
- * <p>The expected result is a null pointer exception.</p>
- */
- public void testLdapNameString001() {
-
- try{
- String test=null;
- LdapName ln = new LdapName(test);
- fail("Failed the null argument is invalid.");
- }catch(NullPointerException e){
-
- }catch(Throwable e){
- fail("Failed the null argument is NullPointerException.");
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method recive a non-null String,
- * this string must be a valid string of the typevalue "CN=commonName".</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameString002() {
-
- try{
- String test="CN=test";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method recive a non-null String,
- * this string must be a valid string but here we are including an special character ",", this
- * character must work like a separetor.</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameString003() {
-
- try{
- String test="L=test,C=common";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a non-null String,
- * this string must be a valid string but here we are including an special character ";", this
- * character must work like a separetor.</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameString004() {
-
- try{
- String test="ST=test;CN=common";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a non-null String,
- * this string must be a valid string but here we are including an special character "+", this
- * character must work like between type/value.</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameString005() {
-
- try{
- String test="O=test+CM=common";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a non-null String,
- * this string must be a valid string but here we are including an special character " ", this
- * character must work like a separetor between words.</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameString006() {
-
- try{
- String test="OU=test this";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a non-null String,
- * this string must be a valid string but here we are including an special character "\", this
- * character must let us to introduce another special character in the name.</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameString007() {
- try{
- String test="C=test\\, this";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a non-null String,
- * this string must be a valid string but here we are including an special character "#", this
- * is an example name in which an RDN was of an unrecognized type. The value is the BER encoding
- * of an OCTET STRING containing two bytes 0x48 and 0x69.</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameString008() {
-
- try{
- String test="S=#04024869";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a non-null String,
- * this string must be a valid string but here we are including a combination of specials characters
- * like ",", "=", "+", "<", ">", "#" and ";"</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameString009() {
-
- try{
- String test="DC=test,T=time+CM=common V<this C>this,S=#04024869";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a non-null String,
- * this string must be a valid string like SN=Lu\C4\8Di\C4\87.</p>
- * <p>The expected result is an instance of LdapName.</p>
- * <p>The String is an example of an RDN surname value consisting of 5 letters like:</p>
- <table class="t" cellspacing="0">
- <tbody>
- <tr><TD>Unicode Letter Description</TD><TD>10646 code</TD><Td>UTF-8</Td><TD>Quoted</TD></tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="LATIN CAPITAL LETTER L" id="f00"></TD>
- <td class="c0" id="c10"><input class="a0" size="20" name="sas9nt21" readonly="readonly" value="U0000004C" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="0x4C" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="L" id="f10"></td>
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="LATIN SMALL LETTER U " id="f00"></TD>
- <td class="c0" id="c10"><input class="a0" size="20" name="sas9nt21" readonly="readonly" value="U00000075" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="0x75" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="u" id="f10"></td>
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="LATIN SMALL LETTER C WITH CARON" id="f00"></TD>
- <td class="c0" id="c10"><input class="a0" size="20" name="sas9nt21" readonly="readonly" value="U0000010D" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="0xC48D" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="\C4\8D" id="f10"></td>
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="LATIN SMALL LETTER I" id="f00"></TD>
- <td class="c0" id="c10"><input class="a0" size="20" name="sas9nt21" readonly="readonly" value="U00000069" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="0x69 " id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="i" id="f10"></td>
- </tr>
- <tr>
- <td class="c0" id="c00"><input class="a0" size="40" name="sas9nt11" readonly="readonly" value="LATIN SMALL LETTER C WITH ACUTE" id="f00"></TD>
- <td class="c0" id="c10"><input class="a0" size="20" name="sas9nt21" readonly="readonly" value="U00000107" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="0xC487" id="f10"></td>
- <td class="c0" id="c10"><input class="a0" size="10" name="sas9nt21" readonly="readonly" value="\C4\87" id="f10"></td>
- </tr>
- </tbody>
- </table>
- */
- public void testLdapNameString010() {
-
- try{
- String test="SN=Lu\\C4\\8Di\\C4\\87";
- assertNotNull(new LdapName(test));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a non-null String,
- * and the DNs must be case insensitive.</p>
- * <p>The expected result is an assertion between two names one upper and other lower case.</p>
- */
- public void testLdapNameString011() {
-
- try{
- String testUpperCase="UID=TEST";
- String testLowerCase="uid=test";
- assertTrue(new LdapName(testUpperCase).equals(new LdapName(testLowerCase)));
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive a blank String.</p>
- * <p>The expected result an empty name, not null, empty.</p>
- */
- public void testLdapNameString012() {
-
- try{
- LdapName ln = new LdapName("");
- assertTrue(ln.isEmpty());
- }catch(Throwable e){
- fail("Failed with: "+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String with correct
- * format like "a=b", In this case we are gonna test the special characters "<" and ">".</p>
- * <p>The expected result is an instance of ldapname.</p>
- */
- public void testLdapNameString013() {
-
- try{
- assertNotNull(new LdapName("a=<"));
- assertNotNull(new LdapName("a=<a"));
- assertNotNull(new LdapName("a=a<"));
- assertNotNull(new LdapName("a=a<b"));
- assertNotNull(new LdapName("a=a<b<"));
- assertNotNull(new LdapName("a=>"));
- assertNotNull(new LdapName("a=>a"));
- assertNotNull(new LdapName("a=a>"));
- assertNotNull(new LdapName("a=a>b"));
- assertNotNull(new LdapName("a=a>b>"));
-
- }catch(InvalidNameException e){
- fail("Failed with:"+e);
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String with no correct
- * format like "test".</p>
- * <p>The expected result is an InvalidNameException.</p>
- */
- public void testLdapNameString014() {
-
- try{
- String test="test";
- LdapName ln = new LdapName(test);
- fail("Failed the null argument is invalid.");
- }catch(InvalidNameException e){
-
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ",".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString015() {
-
- try{
- String test="t=test,control";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ",".</p>
- * <p>The expected result is an instance of the class.</p>
- */
- public void testLdapNameString016() {
-
- try{
- String test="t=test,";
- LdapName ln = new LdapName(test);
-
- }catch(InvalidNameException e){
- fail("Failed the argument is valid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ",".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString017() {
-
- try{
- String test=",t=test";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ",".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString018() {
-
- try{
- String test=",t=test,";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "=".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString019() {
-
- try{
- String test="t=";
- LdapName ln = new LdapName(test);
-
- }catch(InvalidNameException e){
- fail("Failed the argument is valid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "=".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString020() {
-
- try{
- String test="=t";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "=".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString021() {
-
- try{
- String test="=";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "=".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString022() {
-
- try{
- String test="=t=t";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "=".</p>
- * <p>The expected result is an instance of the class.</p>
- */
- public void testLdapNameString023() {
-
- try{
- String test="a=t=";
- LdapName ln = new LdapName(test);
-
- }catch(InvalidNameException e){
- fail("Failed the argument is valid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "=".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString024() {
-
- try{
- String test="=a=t=";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "=".</p>
- * <p>The expected result is an instance of the class.</p>
- */
- public void testLdapNameString025() {
-
- try{
- String test="a=b=t=z";
- LdapName ln = new LdapName(test);
-
- }catch(InvalidNameException e){
- fail("Failed the argument is valid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ";".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString026() {
-
- try{
- String test=";";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ";".</p>
- * <p>The expected result is an instance of the class.</p>
- */
- public void testLdapNameString027() {
-
- try{
- String test="a=b;";
- LdapName ln = new LdapName(test);
-
- }catch(InvalidNameException e){
- fail("Failed the argument is valid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ";".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString028() {
-
- try{
- String test=";a=b";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ";".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString029() {
-
- try{
- String test="a=b;c";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ";".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString030() {
-
- try{
- String test=";a=b;";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "#".</p>
- * <p>The expected result is an instance of the class.</p>
- */
- public void testLdapNameString031() {
-
- try{
- String test="a=a#";
- LdapName ln = new LdapName(test);
-
- }catch(InvalidNameException e){
- fail("Failed the argument is valid."+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "#".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString032() {
-
- try{
- String test="a=#a";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }catch (IllegalArgumentException e){
-
- }
- }
-
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "#".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString033() {
-
- try{
- String test="#a=a";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "#".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString034() {
-
- try{
- String test="#a=#a";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "#".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString035() {
-
- try{
- String test="#a=a#";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "<".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString036() {
-
- try{
- String test="a<a";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "<".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString037() {
-
- try{
- String test="<a=a";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "<".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString038() {
-
- try{
- String test="<a=a<";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ">".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString039() {
-
- try{
- String test="a>c";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ">".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString040() {
-
- try{
- String test=">a=c";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character ">".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString041() {
-
- try{
- String test=">a=c>";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "\".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString042() {
-
- try{
- String test="a=b\\";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "\".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString043() {
-
- try{
- String test="\\a=b";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "\".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString044() {
-
- try{
- String test="\\a=b\\";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "\".</p>
- * <p>The expected result is an Exception.</p>
- */
- public void testLdapNameString045() {
-
- try{
- String test="a=b\\s";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
- }catch (IllegalArgumentException e){
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "+".</p>
- * <p>The expected result is an instance of the class.</p>
- */
- public void testLdapNameString046() {
-
- try{
- String test="a=b+";
- LdapName ln = new LdapName(test);
-
- }catch(InvalidNameException e){
- fail("Failed the argument is valid."+e);
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "+".</p>
- * <p>The expected result is an exception.</p>
- */
- public void testLdapNameString047() {
-
- try{
- String test="+a=b";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "+".</p>
- * <p>The expected result is an exception.</p>
- */
- public void testLdapNameString048() {
-
- try{
- String test="+a=b+";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "+".</p>
- * <p>The expected result is an exception.</p>
- */
- public void testLdapNameString049() {
-
- try{
- String test="a=b+s";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "+".</p>
- * <p>The expected result is an instance of the class.</p>
- */
- public void testLdapNameString050() {
-
- try{
- String test="a=b+s=";
- LdapName ln = new LdapName(test);
-
- }catch(InvalidNameException e){
- fail("Failed the argument is invalid.");
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character " ".</p>
- * <p>The expected result is an exception.</p>
- */
- public void testLdapNameString051() {
-
- try{
- String test=" =b";
- LdapName ln = new LdapName(test);
- fail("Failed the argument is invalid.");
- }catch(InvalidNameException e){
-
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character " ".</p>
- * <p>The expected result is an instance of the class.</p>
- */
- public void testLdapNameString052() {
-
- try{
- String test="a= ";
- LdapName ln = new LdapName(test);
- }catch(InvalidNameException e){
- fail("Failed the argument is valid."+e);
-
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing if nothing is sended between ','.</p>
- * <p>The expected result is an exception.</p>
- */
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName(String)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method, this method should recive
+ * String notice here that here that we are testing if nothing is sended
+ * between ','.
+ * </p>
+ * <p>
+ * The expected result is an exception.
+ * </p>
+ */
public void testLdapNameString053() {
- try{
- LdapName ln=new LdapName("cn=pucho,,o=fitc");
- fail("Should raise InvalidnameException");
- }catch(InvalidNameException e){
+ try {
+ new LdapName("cn=pucho,,o=fitc");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+
+ try {
+ new LdapName("cn=pucho,o=#fitc");
+ fail("InvalidNameException expected");
+ } catch (InvalidNameException e) {}
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method of LdapName reciving a list of
+ * valid names.
+ * </p>
+ * <p>
+ * The expected result is an instance of an object of LdapName.
+ * </p>
+ */
+ public void testLdapNameListOfRdn001() throws Exception {
+
+ LinkedList<Rdn> test = new LinkedList<Rdn>();
+ test.add(new Rdn("CN=commonName"));
+ test.add(new Rdn("L=localityName"));
+ test.add(new Rdn("ST=stateOrProvinceName"));
+ test.add(new Rdn("O=organizationName"));
+ test.add(new Rdn("OU=organizationalUnitName"));
+ assertNotNull(new LdapName(test));
+
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method of LdapName reciving a null
+ * list.
+ * </p>
+ * <p>
+ * The expected result is an exception of the type NullPointerException.
+ * </p>
+ */
+ public void testLdapNameListOfRdn002() {
+ LinkedList<Rdn> test = null;
+ try {
+ new LdapName(test);
+ fail("NPE expected");
+ } catch (NullPointerException e) {}
+
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method of LdapName reciving a
+ * non-null list but empty one.
+ * </p>
+ * <p>
+ * The expected result is an instance of LdapName.
+ * </p>
+ */
+ public void testLdapNameListOfRdn003() {
+ LinkedList<Rdn> test = new LinkedList<Rdn>();
+ assertNotNull(new LdapName(test));
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method of LdapName reciving a list of
+ * valid names.
+ * </p>
+ * <p>
+ * The expected result is an instance of an object of LdapName, and also
+ * that the indexing is made like the other way around.
+ * </p>
+ */
+ public void testLdapNameListOfRdn004() throws Exception {
+ LinkedList<Rdn> test = new LinkedList<Rdn>();
+ test.add(new Rdn("CN=commonName"));
+ test.add(new Rdn("L=localityName"));
+ test.add(new Rdn("ST=stateOrProvinceName"));
+ test.add(new Rdn("O=organizationName"));
+ test.add(new Rdn("OU=organizationalUnitName"));
+
+ LdapName x = new LdapName(test);
+ assertNotNull(x);
+ List t = x.getRdns();
+
+ int i = 0;
+ for (Iterator iter = test.iterator(); iter.hasNext();) {
+ Rdn element = (Rdn) iter.next();
+ assertEquals(element.toString(), t.get(i).toString());
+ i++;
+ }
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'
+ * </p>
+ * <p>
+ * Here we are testing the constructor method of LdapName reciving a
+ * non-null list but here the list contains Rdns invalids.
+ * </p>
+ * <p>
+ * The expected result is an instance of LdapName.
+ * </p>
+ */
+ public void testLdapNameListOfRdn005() throws Exception {
+ LinkedList<Rdn> test = new LinkedList<Rdn>();
+ LdapName x = null;
+
+ test.add(new Rdn("CN", new LinkedList()));
+ test.add(new Rdn("L", new LinkedList()));
+ test.add(new Rdn("ST", new LinkedList()));
+ test.add(new Rdn("O", new LinkedList()));
+ test.add(new Rdn("OU", new LinkedList()));
+
+ x = new LdapName(test);
+ assertNotNull(x);
+
+ try {
+ x.toString();
+ fail("Failed, because the list of rdn was incorrect so a class cast exception must be thrown.");
+ } catch (ClassCastException e) {}
+
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.hashCode()'
+ * </p>
+ * <p>
+ * Here we are testing the computed hash code of a blank String and the RDN
+ * in the LdapName. The String is a valid imput.
+ * </p>
+ * <p>
+ * The expected result is zero.
+ * </p>
+ */
+ public void testHashCode001() throws Exception {
+ assertEquals(0, new LdapName("").hashCode());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.hashCode()'
+ * </p>
+ * <p>
+ * Here we are testing the computed hash code of a list of RDN and the
+ * hashcode of all LdapName. The list is a valid imput.
+ * </p>
+ * <p>
+ * The expected result is an assertion between the hashcode of the all RDNs
+ * in the LdapName and the hash of the list, this method returns the sum of
+ * all Rdns hashcodes.
+ * </p>
+ */
+ public void testHashCode002() throws Exception {
+ Rdn t = new Rdn("");
+ LinkedList<Rdn> test = new LinkedList<Rdn>();
+ test.add(t);
+ LdapName ln = new LdapName(test);
+ assertEquals(0, t.hashCode() & ln.hashCode());
+ assertEquals(t.hashCode(), ln.hashCode());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.hashCode()'
+ * </p>
+ * <p>
+ * Here we are testing the computed hash code of a list of RDN and the
+ * hashcode of all LdapName. The list is valid imput.
+ * </p>
+ * <p>
+ * The expected result is an assertion between the hashcode of the all RDNs
+ * in the LdapName and the list, this method returns the sum of all Rdns
+ * hashcodes.
+ * </p>
+ */
+ public void testHashCode003() throws Exception {
+ Rdn rdn1 = new Rdn("CN=commonName");
+ Rdn rdn2 = new Rdn("t=test");
+ LinkedList<Rdn> test = new LinkedList<Rdn>();
+ test.add(rdn1);
+ test.add(rdn2);
+ LdapName ln = new LdapName(test);
+ assertEquals(rdn1.hashCode() + rdn2.hashCode(), ln.hashCode());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.hashCode()'
+ * </p>
+ * <p>
+ * Here we are testing the computed hash code of a non blank String and the
+ * RDN in the LdapName. The String is a valid imput.
+ * </p>
+ * <p>
+ * The expected result is the equals hash of two objects.
+ * </p>
+ */
+ public void testHashCode004() throws Exception {
+ String test = "t=test,h=asd";
+ LdapName x = new LdapName(test);
+ LdapName y = new LdapName(test);
+ assertNotSame(0, x.hashCode() & y.hashCode());
+ assertEquals(x.hashCode(), y.hashCode());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.equals(Object)'
+ * </p>
+ * <p>
+ * Here we are testing that two LDAP names are equal. If obj as a parameter
+ * is a LdapName Object, the expected result is the comparison between the
+ * two ldapnames.
+ * </p>
+ * <p>
+ * The expected result is a false, the name are not eqaul.
+ * </p>
+ */
+ public void testEquals003() throws Exception {
+ LdapName ln = new LdapName("o=other");
+ assertFalse(new LdapName("t=test").equals(ln));
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.equals(Object)'
+ * </p>
+ * <p>
+ * Here we are testing that two LDAP names are equal. If obj as a parameter
+ * is a LdapName Object and the same,true is returned.
+ * </p>
+ * <p>
+ * The expected result is true.
+ * </p>
+ */
+ public void testEquals004() throws Exception {
+ assertTrue(new LdapName("t=test").equals(new LdapName("t=test")));
+ assertTrue(new LdapName("t=test").equals(new LdapName("T=TEST")));
+ assertTrue(new LdapName("t=test").equals(new LdapName("T= TEST")));
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.clone()'
+ * </p>
+ * <p>
+ * Here we are testing if a clone of an object of LdapName is equal to the
+ * original.
+ * </p>
+ * <p>
+ * The expected result in this case is true.
+ * </p>
+ */
+ public void testClone001() throws Exception {
+ LdapName ln = new LdapName("t=test");
+ LdapName copy = (LdapName) ln.clone();
+ assertEquals(ln, copy);
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.clone()'
+ * </p>
+ * <p>
+ * Here we are testing if this method generates a new copy of this name.
+ * </p>
+ * <p>
+ * The expected result in this case is if a change in primary object no
+ * affect the clone.
+ * </p>
+ */
+ public void testClone002() throws Exception {
+ LdapName ln = new LdapName("t=test");
+ LdapName copy = (LdapName) ln.clone();
+ ln.add("ch=change");
+ assertNotSame(ln.toString(), copy.toString());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.clone()'
+ * </p>
+ * <p>
+ * Here we are testing if this method generates a new copy of this name.
+ * </p>
+ * <p>
+ * The expected result in this case is if a change in the clone object no
+ * affect the primary.
+ * </p>
+ */
+ public void testClone003() throws Exception {
+ LdapName ln = new LdapName("t=test");
+ LdapName copy = (LdapName) ln.clone();
+ copy.add("ch=change");
+ assertNotSame(ln.toString(), copy.toString());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.clone()'
+ * </p>
+ * <p>
+ * Here we are testing if this method generates a new copy of this name.
+ * </p>
+ * <p>
+ * The expected result in this case is if clone of an empty object is equal
+ * to its primary.
+ * </p>
+ */
+ public void testClone004() throws Exception {
+ LdapName ln = new LdapName("");
+ LdapName copy = (LdapName) ln.clone();
+ assertEquals(ln, copy);
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.toString()'
+ * </p>
+ * <p>
+ * Here we are testing if the method returns a string representation of this
+ * LDAP name in a format defined by RFC 2253.
+ * </p>
+ * <p>
+ * The expected results is a representation of this LDAP as we created it.
+ * </p>
+ */
+ public void testToString001() throws Exception {
+ LdapName ln = new LdapName("t=test");
+ assertEquals("t=test", ln.toString());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.toString()'
+ * </p>
+ * <p>
+ * Here we are testing if the method returns a string representation of this
+ * LDAP name in a format defined by RFC 2253.
+ * </p>
+ * <p>
+ * The expected results is a representation of this LDAP as we created it,
+ * in this case the in the String are three names, the ldapname should
+ * return the strings in the LIFO way.
+ * </p>
+ */
+ public void testToString002() throws Exception {
+ LinkedList<Rdn> test = new LinkedList<Rdn>();
+ test.add(new Rdn("c1=common"));
+ test.add(new Rdn("c2=common"));
+ test.add(new Rdn("c3=common"));
+ LdapName ln = new LdapName(test);
+ String comp = "";
+ for (Rdn rdn : test) {
+ if (test.getFirst() == rdn) {
+ comp = rdn.toString();
+ } else {
+ comp = rdn.toString() + "," + comp;
+ }
}
+ assertEquals(comp, ln.toString());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.toString()'
+ * </p>
+ * <p>
+ * Here we are testing if the method returns a string representation of this
+ * LDAP name in a format defined by RFC 2253.
+ * </p>
+ * <p>
+ * The expected results is that the name returns a blank.
+ * </p>
+ */
+ public void testToString003() throws Exception {
+ LdapName ln = new LdapName("");
+ assertEquals("", ln.toString());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.toString()'
+ * </p>
+ * <p>
+ * Here we are testing if the method returns a string representation of this
+ * LDAP name in a format defined by RFC 2253.
+ * </p>
+ * <p>
+ * The expected results is that the name returns the string just like it
+ * recived.
+ * </p>
+ */
+ public void testToString004() throws Exception {
+ LdapName ln = new LdapName("t=\\4c\\4c");
+ assertEquals("T=LL", ln.toString().toUpperCase());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.toString()'
+ * </p>
+ * <p>
+ * Here we are testing if the method returns a string representation of this
+ * LDAP name in a format defined by RFC 2253.
+ * </p>
+ * <p>
+ * The expected results is that the name returns the string just like it
+ * recived.
+ * </p>
+ */
+ public void testToString005() throws Exception {
+ LdapName ln = new LdapName("t=#08");
+ assertEquals("t=#08", ln.toString());
}
-
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.size()'
+ * </p>
+ * <p>
+ * Here we are testing if this method retrieves the number of components in
+ * this LDAP name.
+ * </p>
+ * <p>
+ * The expected result is zero because the name is empty.
+ * </p>
+ */
+ public void testSize001() throws Exception {
+ LdapName ln = new LdapName("");
+ assertEquals(0, ln.size());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.size()'
+ * </p>
+ * <p>
+ * Here we are testing if this method retrieves the number of components in
+ * this LDAP name.
+ * </p>
+ * <p>
+ * The expected result is the correct number of Rdns.
+ * </p>
+ */
+ public void testSize002() throws Exception {
+ String test = ("CN=commonName,L=localityName,ST=stateOrProvinceName,O=organizationName,OU=organizationalUnitName,C=countryName,STREET=streetAddress,DC=domainComponent,UID=userid");
+ LdapName ln = new LdapName(test);
+ assertEquals(9, ln.size());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.size()'
+ * </p>
+ * <p>
+ * Here we are testing if this method retrieves the number of components in
+ * this LDAP name.
+ * </p>
+ * <p>
+ * The expected result is the correct number of Rdns. In this case we are
+ * using distincts special characters to create the name. Notice that the
+ * special character "+", associates attributes Types And Values.
+ * </p>
+ */
+ public void testSize003() throws Exception {
+ LdapName ln = new LdapName("t1=test+t2=test,t3=test;t4=test");
+ assertEquals(3, ln.size());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.isEmpty()'
+ * </p>
+ * <p>
+ * Here we are testing if this method determines whether this LDAP name is
+ * empty.
+ * </p>
+ * <p>
+ * The expected result is a false.
+ * </p>
+ */
+ public void testIsEmpty001() throws Exception {
+ assertFalse(new LdapName("t=test").isEmpty());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.isEmpty()'
+ * </p>
+ * <p>
+ * Here we are testing if this method determines whether this LDAP name is
+ * empty.
+ * </p>
+ * <p>
+ * The expected result is a true.
+ * </p>
+ */
+ public void testIsEmpty002() throws Exception {
+ LdapName ln = new LdapName("t=test");
+ ln.remove(0);
+ assertTrue(ln.isEmpty());
+ }
+
/**
- * <p>Test method for 'javax.naming.ldap.LdapName(String)'</p>
- * <p>Here we are testing the constructor method, this method should recive String notice here that here
- * that we are testing the the special character "#".</p>
- * <p>The expected result is an exception.</p>
- */
- public void testLdapNameString054() {
- try{
- LdapName ln=new LdapName("cn=pucho,o=#fitc");
- fail("Should raise InvalidnameException");
- }catch(InvalidNameException e){
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.isEmpty()'
+ * </p>
+ * <p>
+ * Here we are testing if this method determines whether this LDAP name is
+ * empty.
+ * </p>
+ * <p>
+ * The expected result is a true.
+ * </p>
+ */
+ public void testIsEmpty003() throws Exception {
+ LdapName ln = new LdapName("");
+ assertTrue(ln.isEmpty());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.getAll()'
+ * </p>
+ * <p>
+ * Here we are testing if this method retrieves the components of this name
+ * as an enumeration of strings.
+ * </p>
+ * <p>
+ * The expected result is if an empty name returns a non-null enumeration.
+ * </p>
+ */
+ public void testGetAll001() throws Exception {
+ LdapName ln = new LdapName("");
+ Enumeration<String> x = ln.getAll();
+ assertNotNull(x);
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.getAll()'
+ * </p>
+ * <p>
+ * Here we are testing if this method retrieves the components of this name
+ * as an enumeration of strings.
+ * </p>
+ * <p>
+ * The expected result is if a non empty name returns a non-null
+ * enumeration, and ordered like it should be.
+ * </p>
+ */
+ public void testGetAll002() throws Exception {
+ LdapName ln = new LdapName("t=test");
+ Enumeration<String> e = ln.getAll();
+ assertEquals("t=test", e.nextElement());
+ }
+
+ /**
+ * <p>
+ * Test method for 'javax.naming.ldap.LdapName.getAll()'
+ * </p>
+ * <p>
+ * Here we are testing if this method retrieves the components of this name
+ * as an enumeration of strings.
+ * </p>
+ * <p>
+ * The expected result is if a non empty name returns a non-null
+ * enumeration, and ordered like it should be.
+ * </p>
+ */
+ public void testGetAll003() throws Exception {
+ LinkedList<Rdn> test = new LinkedList<Rdn>();
+ Rdn a = new Rdn("cn", "test");
+ Rdn b = new Rdn("uid", "test");
+ Rdn c = new Rdn("l", "test");
+ Rdn d = new Rdn("st", "test");
+ test.add(0, a);
+ test.add(1, b);
+ test.add(2, c);
+ test.add(3, d);
+ LdapName ln = new LdapName(test);
+ Enumeration<String> e = ln.getAll();
+ for (Rdn rdn : test) {
+ assertEquals(rdn.toString(), e.nextElement());
}
}
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'</p>
- * <p>Here we are testing the constructor method of LdapName reciving a list of valid names.</p>
- * <p>The expected result is an instance of an object of LdapName.</p>
- */
- public void testLdapNameListOfRdn001() {
-
- LinkedList<Rdn> test=new LinkedList<Rdn>();
- try {
- test.add(new Rdn("CN=commonName"));
- test.add(new Rdn("L=localityName"));
- test.add(new Rdn("ST=stateOrProvinceName"));
- test.add(new Rdn("O=organizationName"));
- test.add(new Rdn("OU=organizationalUnitName"));
- } catch (InvalidNameException e) {
- fail("This list is correct."+e);
- }
- assertNotNull(new LdapName(test));
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'</p>
- * <p>Here we are testing the constructor method of LdapName reciving a null list.</p>
- * <p>The expected result is an exception of the type NullPointerException.</p>
- */
- public void testLdapNameListOfRdn002() {
-
- LinkedList<Rdn> test=null;
- try{
- LdapName ln=new LdapName(test);
- fail("Failed, invalid arguments.");
- }catch(NullPointerException e){
-
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'</p>
- * <p>Here we are testing the constructor method of LdapName reciving a non-null list but empty one.</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameListOfRdn003() {
-
- LinkedList<Rdn> test=new LinkedList<Rdn>();
- try{
-
- assertNotNull(new LdapName(test));
-
- }catch(Throwable e){
- fail("Failed with:"+e);
- }
-
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'</p>
- * <p>Here we are testing the constructor method of LdapName reciving a list of valid names.</p>
- * <p>The expected result is an instance of an object of LdapName, and also that the indexing is made like the other way around.</p>
- */
- public void testLdapNameListOfRdn004() {
-
- LinkedList<Rdn> test=new LinkedList<Rdn>();
- try {
- test.add(new Rdn("CN=commonName"));
- test.add(new Rdn("L=localityName"));
- test.add(new Rdn("ST=stateOrProvinceName"));
- test.add(new Rdn("O=organizationName"));
- test.add(new Rdn("OU=organizationalUnitName"));
- } catch (InvalidNameException e) {
- fail("This list is correct."+e);
- }
- LdapName x=new LdapName(test);
- assertNotNull(x);
- List t=x.getRdns();
- int i=0;
- for (Iterator iter = test.iterator(); iter.hasNext();) {
- Rdn element = (Rdn) iter.next();
- assertEquals(element.toString(),t.get(i).toString());
- i++;
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'</p>
- * <p>Here we are testing the constructor method of LdapName reciving a non-null list but here the list contains Rdns invalids.</p>
- * <p>The expected result is an instance of LdapName.</p>
- */
- public void testLdapNameListOfRdn005() {
-
- LinkedList<Rdn> test=new LinkedList<Rdn>();
- LdapName x=null;
- try {
- test.add(new Rdn("CN",new LinkedList()));
- test.add(new Rdn("L",new LinkedList()));
- test.add(new Rdn("ST",new LinkedList()));
- test.add(new Rdn("O",new LinkedList()));
- test.add(new Rdn("OU",new LinkedList()));
- } catch (InvalidNameException e) {
- fail("This list is correct."+e);
- }
- try{
- x=new LdapName(test);
- assertNotNull(x);
- }catch(Throwable e){
- fail("Failed with:"+e);
- }
- try{
- System.out.println(x.toString());
- fail("Failed, because the list of rdn was incorrect so a class cast exception must be thrown.");
- } catch (ClassCastException e) {
-
- }
-
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.hashCode()'</p>
- * <p>Here we are testing the computed hash code of a blank String and the RDN in the LdapName.
- * The String is a valid imput.</p>
- * <p>The expected result is zero.</p>
- */
- public void testHashCode001() {
-
- String test="";
- try {
- assertEquals(0 , new LdapName(test).hashCode());
-
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.hashCode()'</p>
- * <p>Here we are testing the computed hash code of a list of RDN and the hashcode of all LdapName.
- * The list is a valid imput.</p>
- * <p>The expected result is an assertion between the hashcode of
- * the all RDNs in the LdapName and the hash of the list, this method returns the sum of all Rdns hashcodes.</p>
- */
- public void testHashCode002() {
-
- try {
- Rdn t=new Rdn("");
- LinkedList<Rdn> test=new LinkedList<Rdn>();
- test.add(t);
- LdapName ln=new LdapName(test);
- assertEquals(0,t.hashCode()&ln.hashCode());
- assertEquals(t.hashCode() , ln.hashCode());
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
-
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.hashCode()'</p>
- * <p>Here we are testing the computed hash code of a list of RDN and the hashcode of all LdapName.
- * The list is valid imput.</p>
- * <p>The expected result is an assertion between the hashcode of
- * the all RDNs in the LdapName and the list, this method returns the sum of all Rdns hashcodes.</p>
- */
- public void testHashCode003() {
-
- try {
- Rdn rdn1=new Rdn("CN=commonName");
- Rdn rdn2=new Rdn("t=test");
- LinkedList<Rdn> test=new LinkedList<Rdn>();
- test.add(rdn1);
- test.add(rdn2);
- LdapName ln=new LdapName(test);
- assertEquals(rdn1.hashCode()+rdn2.hashCode() , ln.hashCode());
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
-
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.hashCode()'</p>
- * <p>Here we are testing the computed hash code of a non blank String and the RDN in the LdapName.
- * The String is a valid imput.</p>
- * <p>The expected result is the equals hash of two objects.</p>
- */
- public void testHashCode004() {
-
- String test="t=test,h=asd";
- try {
- LdapName x=new LdapName(test);
- LdapName y=new LdapName(test);
- assertNotSame(0,x.hashCode()&y.hashCode());
- assertEquals(x.hashCode(),y.hashCode());
-
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.equals(Object)'</p>
- * <p>Here we are testing that two LDAP names are equal. If obj as a parameter is null
- * false is returned.</p>
- * <p>The expected result is a false.</p>
- */
- public void testEquals001() {
-
- try {
- assertFalse(new LdapName("t=test").equals(null));
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.equals(Object)'</p>
- * <p>Here we are testing that two LDAP names are equal. If obj as a parameter is not a LdapName
- * Object, false is returned.</p>
- * <p>The expected result is a false.</p>
- */
- public void testEquals002() {
-
- try {
- String test="t=test";
- assertFalse(new LdapName("t=test").equals(test));
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.equals(Object)'</p>
- * <p>Here we are testing that two LDAP names are equal. If obj as a parameter is a LdapName
- * Object, the expected result is the comparison between the two ldapnames.</p>
- * <p>The expected result is a false, the name are not eqaul.</p>
- */
- public void testEquals003() {
-
- try {
- LdapName ln=new LdapName("o=other");
- assertFalse(new LdapName("t=test").equals(ln));
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.equals(Object)'</p>
- * <p>Here we are testing that two LDAP names are equal. If obj as a parameter is a LdapName
- * Object and the same,true is returned.</p>
- * <p>The expected result is true.</p>
- */
- public void testEquals004() {
-
- try {
-
- assertTrue(new LdapName("t=test").equals(new LdapName("t=test")));
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.equals(Object)'</p>
- * <p>Here we are testing that two LDAP names are equal. If obj as a parameter is a LdapName
- * Object and the same,true is returned.</p>
- * <p>In this case the comparison is made with one of the name in uppercase and the other with lowercase, the
- * expected result still is true.</p>
- */
- public void testEquals005() {
-
- try {
-
- assertTrue(new LdapName("t=test").equals(new LdapName("T=TEST")));
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.equals(Object)'</p>
- * <p>Here we are testing that two LDAP names are equal. If obj as a parameter is a LdapName
- * Object and the same,true is returned.</p>
- * <p>In this case the comparison is made with one of the name in uppercase and the other with lowercase, the
- * expected result still is true.</p>
- */
- public void testEquals006() {
-
- try {
-
- assertTrue(new LdapName("t=test").equals(new LdapName("T= TEST")));
- } catch (InvalidNameException e) {
- fail("Failed with:"+e);
- }
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.clone()'</p>
- * <p>Here we are testing if a clone of an object of LdapName is equal to the original.</p>
- * <p>The expected result in this case is true.</p>
- */
- public void testClone001() {
-
- LdapName ln;
- try {
- ln = new LdapName("t=test");
- LdapName copy=(LdapName) ln.clone();
- assertEquals(ln,copy);
-
- } catch (InvalidNameException e) {
-
- }
-
- }
-
- /**
- * <p>Test method for 'javax.naming.ldap.LdapName.clone()'</p>
- * <p>Here we are testing if this method generates a new copy of this name.</p>
- * <p>The expected result in this case is if a change in primary object no affect the clone.</p>
- */
- public void testClone002() {
-
- LdapName ln;
- try {
- ln = new LdapName("t=test");
- LdapName copy=(LdapName) ln.clone();
- ln.add("ch=change");
- assertNotSame(ln.toString(),copy.toString());
-
- } catch (InvalidNameException e) {
- fail("Failed with: "+e);
- } catch (Throwable e) {
[... 4975 lines stripped ...]