001: /*
002: * CoadunationLib: The coaduntion implementation library.
003: * Copyright (C) 2006 Rift IT Contracting
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
018: *
019: * NamingDirectorTest.java
020: *
021: * JUnit based test
022: */
023:
024: package com.rift.coad.lib.naming;
025:
026: // java imports
027: import java.util.Set;
028: import java.util.HashSet;
029:
030: // junit imports
031: import junit.framework.*;
032:
033: // coadunation imports
034: import com.rift.coad.lib.naming.*;
035: import com.rift.coad.lib.interceptor.InterceptorFactory;
036: import com.rift.coad.lib.security.RoleManager;
037: import com.rift.coad.lib.security.ThreadsPermissionContainer;
038: import com.rift.coad.lib.security.ThreadPermissionSession;
039: import com.rift.coad.lib.security.UserSession;
040: import com.rift.coad.lib.security.user.UserSessionManager;
041: import com.rift.coad.lib.security.user.UserStoreManager;
042: import com.rift.coad.lib.security.SessionManager;
043: import com.rift.coad.lib.security.login.LoginManager;
044: import com.rift.coad.lib.thread.CoadunationThreadGroup;
045:
046: /**
047: *
048: * @author Brett Chaldecott
049: */
050: public class NamingDirectorTest extends TestCase {
051:
052: public NamingDirectorTest(String testName) {
053: super (testName);
054: }
055:
056: protected void setUp() throws Exception {
057: }
058:
059: protected void tearDown() throws Exception {
060: }
061:
062: public static Test suite() {
063: TestSuite suite = new TestSuite(NamingDirectorTest.class);
064:
065: return suite;
066: }
067:
068: /**
069: * Test of init method, of class com.rift.coad.lib.naming.NamingDirector.
070: */
071: public void testInit() throws Exception {
072: System.out.println("init");
073:
074: // init the session information
075: ThreadsPermissionContainer permissions = new ThreadsPermissionContainer();
076: SessionManager.init(permissions);
077: UserStoreManager userStoreManager = new UserStoreManager();
078: UserSessionManager sessionManager = new UserSessionManager(
079: permissions, userStoreManager);
080: LoginManager.init(sessionManager, userStoreManager);
081: // instanciate the thread manager
082: CoadunationThreadGroup threadGroup = new CoadunationThreadGroup(
083: sessionManager, userStoreManager);
084:
085: // add a user to the session for the current thread
086: RoleManager.getInstance();
087:
088: InterceptorFactory.init(permissions, sessionManager,
089: userStoreManager);
090:
091: // add a new user object and add to the permission
092: Set set = new HashSet();
093: set.add("test");
094: UserSession user = new UserSession("test1", set);
095: permissions.putSession(
096: new Long(Thread.currentThread().getId()),
097: new ThreadPermissionSession(new Long(Thread
098: .currentThread().getId()), user));
099:
100: NamingDirector.init(threadGroup);
101:
102: System.out.println("jndi ["
103: + NamingDirector.getInstance().getJNDIBase() + "]");
104:
105: NamingDirector.getInstance().shutdown();
106: }
107:
108: }
|