01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.services.persondir.support.legacy;
07:
08: import java.util.Map;
09:
10: import org.jasig.portal.services.persondir.IPersonAttributeDao;
11:
12: import junit.framework.TestCase;
13:
14: /**
15: * Testcase for the adaptor from PersonDirInfo JavaBeans to IPersonAttributeDao.
16: * @author andrew.petro@yale.edu
17: * @version $Revision: 36668 $ $Date: 2006-08-02 09:57:52 -0700 (Wed, 02 Aug 2006) $
18: */
19: public class PersonDirInfoAdaptorTest extends TestCase {
20:
21: /**
22: * Test adapting from a PersonDirInfo instance that represents a
23: * directly-configured LDAP source.
24: *
25: * This testcase will stop working on that fateful day when Susan Bramhall
26: * is no longer listed in Yale University's LDAP.
27: */
28: public void testLdap() {
29: PersonDirInfo pdi = new PersonDirInfo();
30:
31: pdi.setUrl("ldap://mrfrumble.its.yale.edu:389/o=yale.edu");
32: pdi.setUidquery("(uid={0})");
33: pdi.setUsercontext("");
34: pdi.setAttributenames(new String[] { "mail" });
35: pdi.setAttributealiases(new String[] { "emailfromldap" });
36:
37: IPersonAttributeDao dao = PersonDirInfoAdaptor.adapt(pdi);
38:
39: Map attributes = dao.getUserAttributes("susan");
40:
41: assertFalse(attributes.isEmpty());
42: assertEquals("susan.bramhall@yale.edu", attributes
43: .get("emailfromldap"));
44:
45: }
46: }
|