< prev index next >

test/jdk/javax/naming/ldap/LdapName/LdapNameConstruction.java

Print this page


   1 /*
   2  * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  49 
  50         Rdn rdn2 = new Rdn(rdn1);
  51         System.out.println("rdn2:" + rdn2.toString());
  52 
  53         Attributes attrs = new BasicAttributes();
  54         attrs.put("ou", "Juicy, Fruit");
  55         attrs.put("cn", "Mango");
  56         Rdn rdn3 = new Rdn(attrs);
  57         System.out.println("rdn3:" + rdn3.toString());
  58 
  59         Rdn rdn4 = new Rdn("ou", "Juicy, Fruit");
  60         System.out.println("rdn4:" + rdn4.toString());
  61 
  62         // Rdn with unicode value
  63         Rdn rdn5 = new Rdn("SN=Lu\\C4\\8Di\\C4\\87");
  64         System.out.println("rdn5:" + rdn5.toString());
  65 
  66         /**
  67          * LdapName creation tests
  68          */
  69         List rdns = new ArrayList();
  70         rdns.add(new Rdn("o=Food"));
  71         rdns.add(new Rdn("ou=Fruits"));
  72         rdns.add(rdn3);
  73         LdapName name1 = new LdapName(rdns);
  74         System.out.println("ldapname1:" + name1.toString());
  75 
  76         LdapName name2 = new LdapName(
  77                 "ou=Juicy\\, Fruit + cn = Mango, ou=Fruits, o=Food");
  78         System.out.println("ldapName2:" + name2.toString());
  79 
  80         if (!name2.equals(name1)) {
  81             throw new Exception("ldapname1 does not equals ldapname2");
  82         }
  83         System.out.println("ldapname1 and ldapname2 are equal");
  84 
  85         LdapName name = new LdapName(new ArrayList());
  86         System.out.println("Empty ldapname:" + name);
  87     }
  88 }
   1 /*
   2  * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  49 
  50         Rdn rdn2 = new Rdn(rdn1);
  51         System.out.println("rdn2:" + rdn2.toString());
  52 
  53         Attributes attrs = new BasicAttributes();
  54         attrs.put("ou", "Juicy, Fruit");
  55         attrs.put("cn", "Mango");
  56         Rdn rdn3 = new Rdn(attrs);
  57         System.out.println("rdn3:" + rdn3.toString());
  58 
  59         Rdn rdn4 = new Rdn("ou", "Juicy, Fruit");
  60         System.out.println("rdn4:" + rdn4.toString());
  61 
  62         // Rdn with unicode value
  63         Rdn rdn5 = new Rdn("SN=Lu\\C4\\8Di\\C4\\87");
  64         System.out.println("rdn5:" + rdn5.toString());
  65 
  66         /**
  67          * LdapName creation tests
  68          */
  69         List<Rdn> rdns = new ArrayList<>();
  70         rdns.add(new Rdn("o=Food"));
  71         rdns.add(new Rdn("ou=Fruits"));
  72         rdns.add(rdn3);
  73         LdapName name1 = new LdapName(rdns);
  74         System.out.println("ldapname1:" + name1.toString());
  75 
  76         LdapName name2 = new LdapName(
  77                 "ou=Juicy\\, Fruit + cn = Mango, ou=Fruits, o=Food");
  78         System.out.println("ldapName2:" + name2.toString());
  79 
  80         if (!name2.equals(name1)) {
  81             throw new Exception("ldapname1 does not equals ldapname2");
  82         }
  83         System.out.println("ldapname1 and ldapname2 are equal");
  84 
  85         LdapName name = new LdapName(new ArrayList<>());
  86         System.out.println("Empty ldapname:" + name);
  87     }
  88 }
< prev index next >