1
2
3
4
5 package org.kuali.mobility.people.service;
6
7 import static org.junit.Assert.assertTrue;
8 import org.apache.log4j.Logger;
9 import org.junit.AfterClass;
10 import org.junit.Test;
11 import org.junit.BeforeClass;
12 import org.kuali.mobility.people.entity.Group;
13 import org.kuali.mobility.people.entity.Person;
14 import org.springframework.context.ApplicationContext;
15 import org.springframework.context.support.FileSystemXmlApplicationContext;
16
17
18
19
20
21 public class DirectoryServiceImplTest {
22
23 private static final Logger LOG = Logger.getLogger(DirectoryServiceImplTest.class);
24 private static ApplicationContext applicationContext;
25
26 @BeforeClass
27 public static void setUpClass() throws Exception {
28 DirectoryServiceImplTest.setApplicationContext(new FileSystemXmlApplicationContext(getConfigLocations()));
29 }
30
31 private static String[] getConfigLocations() {
32 return new String[]{"classpath:/DirectorySpringBeans.xml"};
33 }
34
35 @AfterClass
36 public static void tearDownClass() throws Exception {
37 }
38
39
40
41
42 public static ApplicationContext getApplicationContext() {
43 return applicationContext;
44 }
45
46
47
48
49 public static void setApplicationContext(ApplicationContext aApplicationContext) {
50 applicationContext = aApplicationContext;
51 }
52
53 @Test
54 public void testLookupPerson() {
55 DirectoryService service = (DirectoryService)getApplicationContext().getBean("directoryService");
56
57 Person person = service.personLookup("joseswan");
58
59 LOG.debug( "Person object "+(null==person?"is":"is not")+" null");
60
61 assertTrue( "Could not find joseswan.", person != null || person.getUserName().isEmpty() );
62 }
63
64 @Test
65 public void testFindSimpleGroup() {
66 }
67
68 @Test
69 public void testFindEntries() {
70 }
71
72 @Test
73 public void testLookupGroup() {
74 DirectoryService service = (DirectoryService)getApplicationContext().getBean("directoryService");
75
76 Group group = service.groupLookup("cn=ITS Android Dev,ou=User Groups,ou=Groups,dc=umich,dc=edu");
77
78 LOG.debug( "Group object "+(null==group?"is":"is not")+" null");
79
80 assertTrue( "Could not find ITS Android Dev.", group != null || group.getDisplayName().isEmpty() );
81 }
82 }