1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole;
17
18 import org.apache.jackrabbit.core.TransientRepository;
19 import org.junit.After;
20 import org.junit.Before;
21 import org.junit.Test;
22
23 import javax.jcr.Session;
24
25 import static junit.framework.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
27
28
29
30
31
32
33
34
35 public class RepositoryManager_UT
36 extends BaseTestCase {
37
38 @Before
39 public void setUp() {
40 System.getProperties().put("app.environment", "local");
41 }
42
43 @After
44 public void tearDown() throws Exception {
45 System.getProperties().remove("app.environment");
46 RepositoryManager.getRepositoryManager().shutdown();
47 }
48
49
50 @Test
51 public void testGetRepositoryManager() throws Exception {
52 RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
53 assertNotNull(repositoryManager);
54
55 }
56
57 @Test
58 public void testGetSession() throws Exception {
59 RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
60 Session session = repositoryManager.getSession();
61 repositoryManager.logout(session);
62 assertNotNull(session);
63
64 }
65
66 @Test
67 public void testGetSessionWithUserName() throws Exception {
68 RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
69 Session session = repositoryManager.getSession("mockUser", "test");
70 repositoryManager.logout(session);
71 assertNotNull(session);
72
73 }
74
75 @Test
76 public void testGetMultipleSessions() throws Exception {
77 RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
78 Session session = repositoryManager.getSession();
79 Session session1 = repositoryManager.getSession();
80 assertNotNull(session);
81 repositoryManager.logout(session);
82 repositoryManager.logout(session1);
83 assertTrue(!session.isLive());
84 assertTrue(!session1.isLive());
85
86 }
87
88 @Test
89 public void testGetMultipleSessionsWithMultipleUsers() throws Exception {
90 RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
91 Session session = repositoryManager.getSession("mockUser", "test");
92 Session session1 = repositoryManager.getSession("mockUser1", "test");
93 assertNotNull(session);
94 repositoryManager.logout(session);
95 repositoryManager.logout(session1);
96 assertTrue(!session.isLive());
97 assertTrue(!session1.isLive());
98
99 }
100
101 @Test
102 public void testLogout() throws Exception {
103 RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
104 Session session = repositoryManager.getSession();
105 repositoryManager.logout(session);
106 assertTrue(!session.isLive());
107
108 }
109
110 @Test
111 public void testGetTransientRepository() throws Exception {
112 RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
113 TransientRepository transientRepository = repositoryManager.getTransientRepository();
114 assertNotNull(transientRepository);
115 }
116
117 }