Package org.apache.directory.shared.ldap.model.name

Examples of org.apache.directory.shared.ldap.model.name.FastDnParser


     * run into infinite loops.
     */
    @Test
    public void testLdapDNIncomplete() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();

        // empty Dn is ok
        dnParser.parse( " " );

        // test DNs starting with an descr
        try
        {
            dnParser.parse( " a" );
            fail();
        }
        catch ( LdapException ine )
        {
            // expected
        }
        try
        {
            dnParser.parse( " a " );
            fail();
        }
        catch ( LdapException ine )
        {
            // expected
        }
        try
        {
            dnParser.parse( " a- " );
            fail();
        }
        catch ( LdapException ine )
        {
            // expected
        }
        dnParser.parse( " a =" );
        dnParser.parse( " a = " );
        dnParser.parse( " a = b" );

        // test DNs starting with an OID
        try
        {
            dnParser.parse( " 1 = b " );
            fail( "OID must contain at least on dot." );
        }
        catch ( LdapException ine )
        {
            // expected
        }
        try
        {
            dnParser.parse( " 0" );
            fail();
        }
        catch ( LdapException ine )
        {
            // expected
        }
        try
        {
            dnParser.parse( " 0." );
            fail();
        }
        catch ( LdapException ine )
        {
            // expected
        }
        try
        {
            dnParser.parse( " 0.5" );
            fail();
        }
        catch ( LdapException ine )
        {
            // expected
        }
        try
        {
            dnParser.parse( " 0.5 " );
            fail();
        }
        catch ( LdapException ine )
        {
            // expected
        }
       
        dnParser.parse( " 0.5=" );
        dnParser.parse( " 0.5 = " );
        dnParser.parse( " 0.5 = b" );
    }
View Full Code Here


     * test a simple Dn : a = b
     */
    @Test
    public void testLdapDNSimple() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        Dn dn = (Dn) dnParser.parse( "a = b" );

        assertEquals( "a = b", dn.getName() );
        assertEquals( "a=b", dn.getNormName() );
        assertEquals( "a = b", dn.toString() );

View Full Code Here

     * test a composite Dn : a = b, d = e
     */
    @Test
    public void testLdapDNComposite() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        Dn dn = (Dn) dnParser.parse( "a = b, c = d" );
        assertEquals( "a=b,c=d", dn.getNormName() );
        assertEquals( "a = b, c = d", dn.getName() );
    }
View Full Code Here

     * test a composite Dn with or without spaces: a=b, a =b, a= b, a = b, a = b
     */
    @Test
    public void testLdapDNCompositeWithSpace() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        Dn dn = (Dn) dnParser.parse( "a=b, a =b, a= b, a = b, a  =  b" );
        assertEquals( "a=b,a=b,a=b,a=b,a=b", dn.getNormName() );
        assertEquals( "a=b, a =b, a= b, a = b, a  =  b", dn.getName() );
    }
View Full Code Here

     * return a=b,c=d,e=f (the ';' is replaced by a ',')
     */
    @Test
    public void testLdapDNCompositeSepators() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        Dn dn = (Dn) dnParser.parse( "a=b;c=d,e=f" );
        assertEquals( "a=b,c=d,e=f", dn.getNormName() );
        assertEquals( "a=b;c=d,e=f", dn.getName() );
    }
View Full Code Here

     * test a simple Dn with multiple NameComponents : a = b + c = d
     */
    @Test
    public void testLdapDNSimpleMultivaluedAttribute() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        try
        {
            dnParser.parse( "a = b + c = d" );
            fail( "Multivalued Rdn not supported by fast parser" );
        }
        catch ( TooComplexException tce )
        {
            // expected
View Full Code Here

     * i=j
     */
    @Test
    public void testLdapDNCompositeMultivaluedAttribute() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        try
        {
            dnParser.parse( "a=b+c=d, e=f + g=h + i=j" );
            fail( "Multivalued Rdn not supported by fast parser" );
        }
        catch ( TooComplexException tce )
        {
            // expected
View Full Code Here

     * test a simple Dn with an oid prefix (uppercase) : OID.12.34.56 = azerty
     */
    @Test
    public void testLdapDNOidUpper() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        try
        {
            dnParser.parse( "OID.12.34.56 = azerty" );
            fail( "OID prefix not supported by fast parser" );
        }
        catch ( Exception e )
        {
            // expected
View Full Code Here

     * test a simple Dn with an oid prefix (lowercase) : oid.12.34.56 = azerty
     */
    @Test
    public void testLdapDNOidLower() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        try
        {
            dnParser.parse( "oid.12.34.56 = azerty" );
            fail( "OID prefix not supported by fast parser" );
        }
        catch ( Exception e )
        {
            // expected
View Full Code Here

     * azerty
     */
    @Test
    public void testLdapDNOidWithoutPrefix() throws LdapException
    {
        FastDnParser dnParser = FastDnParser.getNameParser();
        Dn dn = (Dn) dnParser.parse( "12.34.56 = azerty" );
        assertEquals( "12.34.56=azerty", dn.getNormName() );
        assertEquals( "12.34.56 = azerty", dn.getName() );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.name.FastDnParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.