directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r683606 - in /directory/shared/branches/bigbang/ldap/src: main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java test/java/org/apache/directory/shared/ldap/codec/util/LdapUrlTest.java
Date Thu, 07 Aug 2008 13:01:28 GMT
Author: elecharny
Date: Thu Aug  7 06:01:27 2008
New Revision: 683606

URL: http://svn.apache.org/viewvc?rev=683606&view=rev
Log:
Fixed DIRSHARED-17.
Added 56 tests to cover all the cases

Modified:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
    directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/codec/util/LdapUrlTest.java

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java?rev=683606&r1=683605&r2=683606&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
Thu Aug  7 06:01:27 2008
@@ -563,7 +563,8 @@
      */
     private int parseHostPort( char[] chars, int pos )
     {
-
+        int hostPos = pos;
+        
         if ( ( pos = parseHost( chars, pos ) ) == -1 )
         {
             return -1;
@@ -572,6 +573,12 @@
         // We may have a port.
         if ( StringTools.isCharASCII( chars, pos, ':' ) )
         {
+            if ( pos == hostPos )
+            {
+                // We should not have a port if we have no host
+                return -1;
+            }
+            
             pos++;
         }
         else
@@ -995,10 +1002,14 @@
         }
         else if ( StringTools.isCharASCII( chars, pos, '?' ) )
         {
-
             // An empty scope. This is valid
             return pos;
         }
+        else if ( pos == chars.length )
+        {
+            // An empty scope at the end of the URL. This is valid
+            return pos;
+        }
 
         // The scope is not one of "one", "sub" or "base". It's an error
         return -1;
@@ -1318,8 +1329,15 @@
                                     isFirst = false;
                                 }
 
-                                sb.append( urlEncode( key, false ) ).append( '=' ).append(
-                                    urlEncode( criticalExtensions.get( key ), true ) );
+                                sb.append( urlEncode( key, false ) );
+                                
+                                String value = criticalExtensions.get( key );
+                                
+                                if ( value != null )
+                                {
+                                    sb.append( '=' ).append(
+                                    urlEncode( value, true ) );
+                                }
                             }
                         }
                     }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/codec/util/LdapUrlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/codec/util/LdapUrlTest.java?rev=683606&r1=683605&r2=683606&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/codec/util/LdapUrlTest.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/codec/util/LdapUrlTest.java
Thu Aug  7 06:01:27 2008
@@ -32,6 +32,7 @@
 import org.apache.directory.shared.ldap.codec.util.LdapURL;
 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.junit.Test;
 
 
 /**
@@ -787,4 +788,1203 @@
         Assert.assertEquals( "ldap:///dc=example,dc=com", url.toString() );
     }
 
-}
+    
+    /**
+     * test a LdapURL without a scheme
+     *
+     */
+    @Test
+    public void testLdapURLNoScheme()
+    {
+        try
+        {
+            new LdapURL( "/ou=system" );
+            fail();
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    /**
+     * test a LdapURL without a host but with a DN
+     *
+     */
+    @Test
+    public void testLdapURLNoHostDN()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap:///ou=system" );
+            
+            assertEquals( "ldap:///ou=system", url.toString() );
+            
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a host, no port, and a DN
+     *
+     */
+    @Test
+    public void testLdapURLHostNoPortDN()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost/ou=system" );
+            
+            assertEquals( "ldap://localhost/ou=system", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+    
+    /**
+     * test a LdapURL with no host, a port, and a DN
+     *
+     */
+    @Test
+    public void testLdapURLNoHostPortDN()
+    {
+        try
+        {
+            new LdapURL( "ldap://:123/ou=system" );
+            
+            fail();
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            assertTrue( true );
+        }
+    }
+
+    
+    /**
+     * test a LdapURL with no DN
+     *
+     */
+    @Test
+    public void testLdapURLNoDN()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/" );
+            
+            assertEquals( "ldap://localhost:123/", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN and no attributes 
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrs()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?" );
+            
+            assertEquals( "ldap://localhost:123/", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes and no scope 
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsNoScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??" );
+            
+            assertEquals( "ldap://localhost:123/", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, no scope and no filter 
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsNoScopeNoFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/???" );
+            
+            assertEquals( "ldap://localhost:123/", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+    
+    
+    /**
+     * test a LdapURL with no DN and attributes
+     *
+     */
+    @Test
+    public void testLdapURLDN()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system" );
+            
+            assertEquals( "ldap://localhost:123/ou=system", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+    
+    /**
+     * test a LdapURL with a DN and attributes
+     *
+     */
+    @Test
+    public void testLdapURLDNAttrs()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?ou,dc,cn" );
+            
+            assertEquals( "ldap://localhost:123/ou=system?ou,dc,cn", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN and attributes
+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrs()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?ou,dc,cn" );
+            
+            assertEquals( "ldap://localhost:123/?ou,dc,cn", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes an scope
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??sub" );
+            
+            assertEquals( "ldap://localhost:123/??sub", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes an scope base
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsScopeBase()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??base" );
+            
+            assertEquals( "ldap://localhost:123/", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes an default scope
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsDefaultScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??" );
+            
+            assertEquals( "ldap://localhost:123/", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes an scope
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??sub" );
+            
+            assertEquals( "ldap://localhost:123/ou=system??sub", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes an scope base
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsScopeBase()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??base" );
+            
+            assertEquals( "ldap://localhost:123/ou=system", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes an default scope
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsDefaultScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??" );
+            
+            assertEquals( "ldap://localhost:123/ou=system", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes an scope
+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?ou,cn?sub" );
+            
+            assertEquals( "ldap://localhost:123/?ou,cn?sub", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes an scope base
+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsScopeBase()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?ou,cn?base" );
+            
+            assertEquals( "ldap://localhost:123/?ou,cn", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes an default scope
+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsDefaultScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?ou,cn?" );
+            
+            assertEquals( "ldap://localhost:123/?ou,cn", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes an scope
+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?ou,cn?sub" );
+            
+            assertEquals( "ldap://localhost:123/ou=system?ou,cn?sub", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes an scope base
+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsScopeBase()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?ou,cn?base" );
+            
+            assertEquals( "ldap://localhost:123/ou=system?ou,cn", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes an default scope
+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsDefaultScope()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?ou,cn?" );
+            
+            assertEquals( "ldap://localhost:123/ou=system?ou,cn", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, no scope and filter
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsNoScopeFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/???(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/???(cn=test)", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, no scope and filter
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsNoScopeFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system???(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/ou=system???(cn=test)", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, no scope and filter
+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsNoScopeFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,ou,dc??(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/?cn,ou,dc??(cn=test)", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, a scope and filter
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsScopeFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??sub?(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/??sub?(cn=test)", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, a base scope, and filter
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsScopeBaseFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??base?(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/???(cn=test)", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, a scope and filter
+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsScopeFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,ou,dc?sub?(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/?cn,ou,dc?sub?(cn=test)", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, a base scope, and filter
+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsScopeBaseFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,ou,dc?base?(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/?cn,ou,dc??(cn=test)", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, a scope and filter
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsScopeFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??sub?(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/ou=system??sub?(cn=test)", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, a base scope, and filter
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsScopeBaseFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??base?(cn=test)" );
+            
+            assertEquals( "ldap://localhost:123/ou=system???(cn=test)", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, no scope and filter
+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsNoScopeFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,dc,ou??(cn=test)"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,dc,ou??(cn=test)", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, a scope and filter
+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsScopeFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,ou,dc?sub?(cn=test)"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,ou,dc?sub?(cn=test)", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, a base scope, and filter
+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsScopeBaseFilter()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,ou,dc?base?(cn=test)"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,ou,dc??(cn=test)", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, no scope, no filter and no extension 
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsNoScopeNoFilterNoExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/????" );
+            
+            assertEquals( "ldap://localhost:123/", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, no scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsNoScopeNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/????!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/????!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, no scope, a filter and some extensions 
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsNoScopeFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/???(cn=test)?!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/???(cn=test)?!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, a scope, no filter and some extensions 
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsScopeNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??sub??!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/??sub??!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, a base scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsScopeBaseNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??base??!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/????!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, a scope, a filter and some extensions 
+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsScopeFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??sub?(cn=test)?!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/??sub?(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, no attributes, a base scope, a filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNNoAttrsScopeBaseFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/??base?(cn=test)?!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/???(cn=test)?!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, no scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsNoScopeNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,dc,ou???!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/?cn,dc,ou???!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, no scope, a filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsNoScopeFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,dc,ou??(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/?cn,dc,ou??(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, a scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsScopeNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,dc,ou?sub??!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/?cn,dc,ou?sub??!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, a base scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsScopeBaseNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,dc,ou?base??!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/?cn,dc,ou???!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, a scope, a filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsScopeFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,dc,ou?sub?(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/?cn,dc,ou?sub?(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with no DN, some attributes, a base scope, a filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLNoDNAttrsScopeBaseFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/?cn,dc,ou?base?(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/?cn,dc,ou??(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, no scope, no filter and some extensions 
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsNoScopeNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system????!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/ou=system????!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, no scope, a filter and some extensions 
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsNoScopeFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system???(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system???(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, a scope, no filter and some extensions 
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsScopeNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??sub??!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/ou=system??sub??!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, a base scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsScopeBaseNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??base??!a=b,!c" );
+            
+            assertEquals( "ldap://localhost:123/ou=system????!a=b,!c", url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, a scope, a filter and some extensions 
+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsScopeFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??sub?(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system??sub?(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, no attributes, a base scope, a filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLDNNoAttrsScopeBaseFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system??base?(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system???(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, no scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsNoScopeNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,ou,dc???!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,ou,dc???!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, no scope, a filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsNoScopeFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,ou,dc??(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,ou,dc??(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, a scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsScopeNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,ou,dc?sub??!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,ou,dc?sub??!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, a base scope, no filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsScopeBaseNoFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,ou,dc?base??!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,ou,dc???!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, a scope, a filter and some extensions 
+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsScopeFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,ou,dc?sub?(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,ou,dc?sub?(cn=test)?!a=b,!c",
url.toString() );
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+
+
+    /**
+     * test a LdapURL with a DN, some attributes, a base scope, a filter and some extensions

+     *
+     */
+    @Test
+    public void testLdapURLDNAttrsScopeBaseFilterExtension()
+    {
+        try
+        {
+            LdapURL url = new LdapURL( "ldap://localhost:123/ou=system?cn,ou,dc?base?(cn=test)?!a=b,!c"
);
+            
+            assertEquals( "ldap://localhost:123/ou=system?cn,ou,dc??(cn=test)?!a=b,!c", url.toString()
);
+        }
+        catch ( LdapURLEncodingException luee )
+        {
+            fail();
+        }
+    }
+}
\ No newline at end of file



Mime
View raw message