View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Created by IntelliJ IDEA.
30   * User: peris
31   * Date: 5/9/11
32   * Time: 4:00 PM
33   * To change this template use File | Settings | File Templates.
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 }