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.Ignore;
22  import org.junit.Test;
23  
24  import javax.jcr.Session;
25  
26  import static junit.framework.Assert.assertNotNull;
27  import static org.junit.Assert.assertTrue;
28  
29  /**
30   * Created by IntelliJ IDEA.
31   * User: peris
32   * Date: 5/9/11
33   * Time: 4:00 PM
34   * To change this template use File | Settings | File Templates.
35   */
36  @Ignore
37  @Deprecated
38  public class RepositoryManager_UT
39          extends BaseTestCase {
40  
41      @Before
42      public void setUp() {
43          System.getProperties().put("app.environment", "local");
44      }
45  
46      @After
47      public void tearDown() throws Exception {
48          System.getProperties().remove("app.environment");
49          RepositoryManager.getRepositoryManager().shutdown();
50      }
51  
52  
53      @Test
54      public void testGetRepositoryManager() throws Exception {
55          RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
56          assertNotNull(repositoryManager);
57      }
58  
59      @Test
60      public void testGetSession() throws Exception {
61          RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
62          Session session = repositoryManager.getSession();
63          repositoryManager.logout(session);
64          assertNotNull(session);
65      }
66  
67      @Test
68      public void testGetSessionWithUserName() throws Exception {
69          RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
70          Session session = repositoryManager.getSession("mockUser", "test");
71          repositoryManager.logout(session);
72          assertNotNull(session);
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      @Test
88      public void testGetMultipleSessionsWithMultipleUsers() throws Exception {
89          RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
90          Session session = repositoryManager.getSession("mockUser", "test");
91          Session session1 = repositoryManager.getSession("mockUser1", "test");
92          assertNotNull(session);
93          repositoryManager.logout(session);
94          repositoryManager.logout(session1);
95          assertTrue(!session.isLive());
96          assertTrue(!session1.isLive());
97      }
98  
99      @Test
100     public void testLogout() throws Exception {
101         RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
102         Session session = repositoryManager.getSession();
103         repositoryManager.logout(session);
104         assertTrue(!session.isLive());
105     }
106 
107     @Test
108     public void testGetTransientRepository() throws Exception {
109         RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
110         TransientRepository transientRepository = repositoryManager.getTransientRepository();
111         assertNotNull(transientRepository);
112     }
113 
114     @Test
115     public void testShutdownRepository() throws Exception {
116         RepositoryManager repositoryManager = RepositoryManager.getRepositoryManager();
117         repositoryManager.shutdownRepository();
118     }
119 }