directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r161414 - directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/utils/LdapDNTest.java
Date Fri, 15 Apr 2005 06:04:54 GMT
Author: elecharny
Date: Thu Apr 14 23:04:53 2005
New Revision: 161414

URL: http://svn.apache.org/viewcvs?view=rev&rev=161414
Log:
Cleaned the incubator reference
Change the tests to deal with MutableString

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/utils/LdapDNTest.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/utils/LdapDNTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/utils/LdapDNTest.java?view=diff&r1=161413&r2=161414
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/utils/LdapDNTest.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/test/org/apache/asn1/ldap/codec/utils/LdapDNTest.java
Thu Apr 14 23:04:53 2005
@@ -20,7 +20,9 @@
 import junit.framework.TestCase;
 
 import org.apache.asn1.ldap.codec.DecoderException;
-import org.apache.asn1.ldap.codec.utils.LdapDN;
+import org.apache.asn1.ldap.codec.primitives.LdapDN;
+import org.apache.asn1.util.pools.LocalPoolManager;
+import org.apache.asn1.util.pools.PoolManager;
 
 
 /**
@@ -30,77 +32,103 @@
  */
 public class LdapDNTest extends TestCase
 {
-	private char[] getChars(String value)
-	{
-		char[] charArray = new char[value.length()];
-		
-		value.getChars(0, value.length(), charArray, 0);
-		return charArray;
-	}
-	
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The logger */
+    private PoolManager poolMgr;
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Setup the test
+     */
+    protected void setUp()
+    {
+        poolMgr = new LocalPoolManager( true );
+    }
+
+    /**
+     * Utility function that return a char array from a String
+     *
+     * @param value The String 
+     *
+     * @return A char[] representing the String
+     */
+    private char[] getChars( String value )
+    {
+
+        char[] charArray = new char[value.length()];
+
+        value.getChars( 0, value.length(), charArray, 0 );
+        return charArray;
+    }
+
     /**
      * Test a null DN
      */
     public void testLdapDNNull() throws DecoderException
     {
-        Assert.assertEquals("", LdapDN.parseDN(null) );
+        Assert.assertEquals( "", LdapDN.parseDN( poolMgr, null ).toString() );
     }
-	
+
     /**
      * test an empty DN
      */
     public void testLdapDNEmpty() throws DecoderException
     {
-        Assert.assertEquals("", LdapDN.parseDN(getChars("")) );
+        Assert.assertEquals( "", LdapDN.parseDN( poolMgr, "".getBytes() ).toString() );
     }
-	
+
     /**
      * test a simple DN : a = b
      */
     public void testLdapDNSimple() throws DecoderException
     {
-        Assert.assertEquals("a = b", LdapDN.parseDN(getChars("a = b")) );
+        Assert.assertEquals( "a = b", LdapDN.parseDN( poolMgr, "a = b".getBytes() ).toString()
);
     }
-	
+
     /**
      * test a composite DN : a = b, d = e
      */
     public void testLdapDNComposite() throws DecoderException
     {
-        Assert.assertEquals("a = b, c = d", LdapDN.parseDN(getChars("a = b, c = d")) );
+        Assert.assertEquals( "a = b, c = d", LdapDN.parseDN( poolMgr, "a = b, c = d".getBytes()
).toString() );
     }
-	
+
     /**
      * test a composite DN with or without spaces: a=b, a =b, a= b, a = b, a  =  b
      */
     public void testLdapDNCompositeWithSpace() throws DecoderException
     {
-        Assert.assertEquals("a=b, a =b, a= b, a = b, a  =  b", LdapDN.parseDN(getChars("a=b,
a =b, a= b, a = b, a  =  b")) );
+        Assert.assertEquals( "a=b, a =b, a= b, a = b, a  =  b",
+            LdapDN.parseDN( poolMgr, "a=b, a =b, a= b, a = b, a  =  b".getBytes() ).toString()
);
     }
-	
+
     /**
      * test a composite DN with differents separators : a=b;c=d,e=f
      * It should return a=b,c=d,e=f (the ';' is replaced by a ',')
      */
     public void testLdapDNCompositeSepators() throws DecoderException
     {
-        Assert.assertEquals("a=b,c=d,e=f", LdapDN.parseDN(getChars("a=b;c=d,e=f")) );
+        Assert.assertEquals( "a=b,c=d,e=f", LdapDN.parseDN( poolMgr, "a=b;c=d,e=f".getBytes()
).toString() );
     }
-	
+
     /**
      * test a simple DN with differents separators : a = b + c = d
      */
     public void testLdapDNSimpleMultivaluedAttribute() throws DecoderException
     {
-        Assert.assertEquals("a = b + c = d", LdapDN.parseDN(getChars("a = b + c = d")) );
+        Assert.assertEquals( "a = b + c = d",
+            LdapDN.parseDN( poolMgr, "a = b + c = d".getBytes() ).toString() );
     }
-	
+
     /**
      * test a composite DN with differents separators : a=b+c=d, e=f + g=h + i=j
      */
     public void testLdapDNCompositeMultivaluedAttribute() throws DecoderException
     {
-        Assert.assertEquals("a=b+c=d, e=f + g=h + i=j", LdapDN.parseDN(getChars("a=b+c=d,
e=f + g=h + i=j")) );
+        Assert.assertEquals( "a=b+c=d, e=f + g=h + i=j",
+            LdapDN.parseDN( poolMgr, "a=b+c=d, e=f + g=h + i=j".getBytes() ).toString() );
     }
 
     /**
@@ -108,7 +136,8 @@
      */
     public void testLdapDNOidUpper() throws DecoderException
     {
-        Assert.assertEquals("OID.12.34.56 = azerty", LdapDN.parseDN(getChars("OID.12.34.56
= azerty")) );
+        Assert.assertEquals( "OID.12.34.56 = azerty",
+            LdapDN.parseDN( poolMgr, "OID.12.34.56 = azerty".getBytes() ).toString() );
     }
 
     /**
@@ -116,7 +145,8 @@
      */
     public void testLdapDNOidLower() throws DecoderException
     {
-        Assert.assertEquals("oid.12.34.56 = azerty", LdapDN.parseDN(getChars("oid.12.34.56
= azerty")) );
+        Assert.assertEquals( "oid.12.34.56 = azerty",
+            LdapDN.parseDN( poolMgr, "oid.12.34.56 = azerty".getBytes() ).toString() );
     }
 
     /**
@@ -124,7 +154,8 @@
      */
     public void testLdapDNOidWithoutPrefix() throws DecoderException
     {
-        Assert.assertEquals("12.34.56 = azerty", LdapDN.parseDN(getChars("12.34.56 = azerty"))
);
+        Assert.assertEquals( "12.34.56 = azerty",
+            LdapDN.parseDN( poolMgr, "12.34.56 = azerty".getBytes() ).toString() );
     }
 
     /**
@@ -132,7 +163,8 @@
      */
     public void testLdapDNCompositeOidWithoutPrefix() throws DecoderException
     {
-        Assert.assertEquals("12.34.56 = azerty, 7.8 = test", LdapDN.parseDN(getChars("12.34.56
= azerty; 7.8 = test")) );
+        Assert.assertEquals( "12.34.56 = azerty, 7.8 = test",
+            LdapDN.parseDN( poolMgr, "12.34.56 = azerty; 7.8 = test".getBytes() ).toString()
);
     }
 
     /**
@@ -140,7 +172,8 @@
      */
     public void testLdapDNPairCharAttributeValue() throws DecoderException
     {
-        Assert.assertEquals("a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00", LdapDN.parseDN(getChars("a
= \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00")) );
+        Assert.assertEquals( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00",
+            LdapDN.parseDN( poolMgr, "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\A0\\00".getBytes()
).toString() );
     }
 
     /**
@@ -148,7 +181,8 @@
      */
     public void testLdapDNHexStringAttributeValue() throws DecoderException
     {
-        Assert.assertEquals("a = #0010A0AAFF", LdapDN.parseDN(getChars("a = #0010A0AAFF"))
);
+        Assert.assertEquals( "a = #0010A0AAFF",
+            LdapDN.parseDN( poolMgr, "a = #0010A0AAFF".getBytes() ).toString() );
     }
 
     /**
@@ -156,6 +190,7 @@
      */
     public void testLdapDNQuotedAttributeValue() throws DecoderException
     {
-        Assert.assertEquals("a = quoted \\\"value", LdapDN.parseDN(getChars("a = quoted \\\"value"))
);
+        Assert.assertEquals( "a = quoted \\\"value",
+            LdapDN.parseDN( poolMgr, "a = quoted \\\"value".getBytes() ).toString() );
     }
 }



Mime
View raw message