01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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:
17: package org.kuali.core;
18:
19: import org.kuali.core.exceptions.UserNotFoundException;
20: import org.kuali.kfs.context.KualiTestBase;
21: import org.kuali.test.ConfigureContext;
22:
23: import edu.iu.uis.eden.exception.ResourceUnavailableException;
24: import edu.iu.uis.eden.exception.WorkflowException;
25:
26: /**
27: * This class is used to test UserSession.
28: */
29: @ConfigureContext
30: public class UserSessionTest extends KualiTestBase {
31:
32: public void testUsersAreDistinct() {
33: assertFalse("Sample user ids are the same",
34: TestConstants.Data4.USER_ID1
35: .equals(TestConstants.Data4.USER_ID2));
36: }
37:
38: public void testNewUserSession()
39: throws ResourceUnavailableException, WorkflowException,
40: UserNotFoundException {
41: UserSession userSession = new UserSession(
42: TestConstants.Data4.USER_ID1);
43: assertNotNull("userSession should not be null", userSession);
44: assertNotNull("kualiUser should not be null", userSession
45: .getUniversalUser());
46: assertNotNull("workflowUser shoiuld not be null", userSession
47: .getWorkflowUser());
48: assertEquals(TestConstants.Data4.USER_ID1.toLowerCase(),
49: userSession.getNetworkId().toLowerCase());
50: }
51:
52: public void testBackdoorId() throws ResourceUnavailableException,
53: WorkflowException, UserNotFoundException {
54: UserSession userSession = new UserSession(
55: TestConstants.Data4.USER_ID1);
56: assertFalse(userSession.isBackdoorInUse());
57: userSession.setBackdoorUser(TestConstants.Data4.USER_ID2);
58: assertTrue("User should not be null",
59: TestConstants.Data4.USER_ID2
60: .equalsIgnoreCase(userSession.getNetworkId()));
61: assertTrue(userSession.isBackdoorInUse());
62: userSession.clearBackdoorUser();
63: assertFalse(userSession.isBackdoorInUse());
64: }
65:
66: public void testGetLoggedInUserNetworkId()
67: throws ResourceUnavailableException, WorkflowException,
68: UserNotFoundException {
69: UserSession userSession = new UserSession(
70: TestConstants.Data4.USER_ID1);
71: assertFalse(userSession.isBackdoorInUse());
72: assertEquals(userSession.getLoggedInUserNetworkId(),
73: TestConstants.Data4.USER_ID1);
74: userSession.setBackdoorUser(TestConstants.Data4.USER_ID2);
75: assertTrue("User should not be null",
76: TestConstants.Data4.USER_ID2
77: .equalsIgnoreCase(userSession.getNetworkId()));
78: assertTrue(userSession.isBackdoorInUse());
79: assertEquals(userSession.getLoggedInUserNetworkId(),
80: TestConstants.Data4.USER_ID1);
81: userSession.clearBackdoorUser();
82: assertFalse(userSession.isBackdoorInUse());
83: assertEquals(userSession.getLoggedInUserNetworkId(),
84: TestConstants.Data4.USER_ID1);
85: }
86: }
|