Package javax.naming.ldap

Examples of javax.naming.ldap.LdapName


     * 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) {}
    }
View Full Code Here


     * <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) {}

        LdapName ldapName = new LdapName("cn=a+");
        assertEquals("cn=a+", ldapName.toString());
        assertEquals("cn=a", ldapName.getRdns().get(0).toString());
       
        ldapName = new LdapName("cn=\\+");
        assertEquals("cn=\\+", ldapName.toString());
        assertEquals("cn=\\+", ldapName.getRdns().get(0).toString());
    }
View Full Code Here

     * The expected result is an exception.
     * </p>
     */
    public void testLdapNameString053() {
        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) {}
    }
View Full Code Here

     * <p>
     * The expected result is an instance of the class.
     * </p>
     */
    public void testLdapNameString054() throws Exception {
        LdapName ldapName;
        String stringName;
       
        stringName = "dc=apacheorg\"";
        ldapName = new LdapName(stringName);
        assertEquals(stringName, ldapName.toString());
       
        stringName = "dc=\"apache,org\"";
        ldapName = new LdapName(stringName);
        assertEquals(stringName, ldapName.toString());
       
        stringName = "dc=\"apache;org\"";
        ldapName = new LdapName(stringName);
        assertEquals(stringName, ldapName.toString());
       
        stringName = "dc=\"apache\\\";org\"";
        ldapName = new LdapName(stringName);
        assertEquals(stringName, ldapName.toString());
       
        stringName = "dc=apache\\\"org,O=org";
        ldapName = new LdapName(stringName);
        assertEquals(stringName, ldapName.toString());
       
        stringName = "\"az=a,O=a\"";
        try{
            new LdapName(stringName);
            fail("Should throw InvalidNameException");
        }catch(InvalidNameException e){
            //expected
        }
       
        stringName = "dc=apache\\\";org,O=org";
        try{
            new LdapName(stringName);
            fail("Should throw InvalidNameException");
        }catch(InvalidNameException e){
            //expected
        }
       
        try{
            new LdapName("dc=apache,org");
            fail("Should throw InvalidNameException");
        }catch(InvalidNameException e){
            //expected
        }
       
        try{
            new LdapName("dc=apache;org");
            fail("Should throw InvalidNameException");
        }catch(InvalidNameException e){
            //expected
        }
       
        try{
            new LdapName("dc=\"apache\"harmony\"org\"");
            fail("Should throw InvalidNameException");
        }catch(InvalidNameException e){
            //expected
        }
       
        stringName = "DC=\"Apache,org\",DC=\"Apacheorg\"";
        String expectedRdnsName = "DC=\"Apache,org\",DC=\"Apacheorg\"";
        ldapName = new LdapName(stringName);
        List rdns = ldapName.getRdns();
        assertEquals(2, rdns.size());
        assertEquals(expectedRdnsName, ldapName.toString());
       
        stringName= "abc=\"DC:O=ab,DC=COM\",cn=apache\"org,O=harmony";
        new LdapName(stringName);

        try {
            stringName = "DC=A\"pache,org\",DC=\"Apacheorg\"";
            ldapName = new LdapName(stringName);
            fail("Should throw InvalidNameException");
        } catch (InvalidNameException e) {
            // expected
        }

        try {
            stringName = "DC=\"Apache,org,DC=\"Apacheorg\"";
            ldapName = new LdapName(stringName);
            fail("Should throw InvalidNameException");
        } catch (InvalidNameException e) {
            // expected
        }

        try {
            stringName = "DC=\"Apache,org,DC=\"Apacheorg";
            ldapName = new LdapName(stringName);
            fail("Should throw InvalidNameException");
        } catch (InvalidNameException e) {
            // expected
        }
       
        try {
            stringName = "+";
            ldapName = new LdapName(stringName);
            fail("Should throw InvalidNameException");
        } catch (InvalidNameException e) {
            // expected
        }
       
        try {
            stringName = ";";
            ldapName = new LdapName(stringName);
            fail("Should throw InvalidNameException");
        } catch (InvalidNameException e) {
            // expected
        }
    }
View Full Code Here

     * <p>
     * The expected result is an instance of the class.
     * </p>
     */
    public void testLdapNameString055() throws Exception {
        LdapName ldapName;
        String stringName;
        String expectedName;
        String expectedRndName;
        List<Rdn> rdns;
       
        // Test \\*
        stringName = "dc=\\*";
        expectedName = "dc=\\*";
        expectedRndName = "dc=*";
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedRndName, rdns.get(0).toString());
       
        stringName = "dc=\"\\*\"";
        expectedName = "dc=\"\\*\"";
        expectedRndName = "dc=*";
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedRndName, rdns.get(0).toString());
       
        stringName = "dc=\\\\*";
        expectedName = "dc=\\\\*";
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedName, rdns.get(0).toString());
       
        // Test \\%
        stringName = "dc=\\%";
        expectedName = "dc=\\%";
        expectedRndName = "dc=%";      
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedRndName, rdns.get(0).toString());
       
        stringName = "dc=\"\\%\"";
        expectedName = "dc=\"\\%\"";
        expectedRndName = "dc=%";
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedRndName, rdns.get(0).toString());
       
        stringName = "dc=\\\\%";
        expectedName = "dc=\\\\%";
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedName, rdns.get(0).toString());
       
        // Test \\_
        stringName = "dc=\\_";
        expectedName = "dc=\\_";
        expectedRndName = "dc=_";      
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedRndName, rdns.get(0).toString());
       
        stringName = "dc=\"\\_\"";
        expectedName = "dc=\"\\_\"";
        expectedRndName = "dc=_";
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedRndName, rdns.get(0).toString());
       
        stringName = "dc=\\\\_";
        expectedName = "dc=\\\\_";
        ldapName = new LdapName(stringName);
        assertEquals(expectedName, ldapName.toString());
        rdns = ldapName.getRdns();
        assertEquals(expectedName, rdns.get(0).toString());
    }
View Full Code Here

        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));

    }
View Full Code Here

     * </p>
     */
    public void testLdapNameListOfRdn002() {
        LinkedList<Rdn> test = null;
        try {
            new LdapName(test);
            fail("NPE expected");
        } catch (NullPointerException e) {}

    }
View Full Code Here

     * The expected result is an instance of LdapName.
     * </p>
     */
    public void testLdapNameListOfRdn003() {
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        assertNotNull(new LdapName(test));
    }
View Full Code Here

        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());
View Full Code Here

     * 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) {}

    }
View Full Code Here

TOP

Related Classes of javax.naming.ldap.LdapName

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.