KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > naming > NamingDirectorTest


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * NamingDirectorTest.java
20  *
21  * JUnit based test
22  */

23
24 package com.rift.coad.lib.naming;
25
26 // java imports
27
import java.util.Set JavaDoc;
28 import java.util.HashSet JavaDoc;
29
30 // junit imports
31
import junit.framework.*;
32
33 // coadunation imports
34
import com.rift.coad.lib.naming.*;
35 import com.rift.coad.lib.interceptor.InterceptorFactory;
36 import com.rift.coad.lib.security.RoleManager;
37 import com.rift.coad.lib.security.ThreadsPermissionContainer;
38 import com.rift.coad.lib.security.ThreadPermissionSession;
39 import com.rift.coad.lib.security.UserSession;
40 import com.rift.coad.lib.security.user.UserSessionManager;
41 import com.rift.coad.lib.security.user.UserStoreManager;
42 import com.rift.coad.lib.security.SessionManager;
43 import com.rift.coad.lib.security.login.LoginManager;
44 import com.rift.coad.lib.thread.CoadunationThreadGroup;
45
46
47 /**
48  *
49  * @author Brett Chaldecott
50  */

51 public class NamingDirectorTest extends TestCase {
52     
53     public NamingDirectorTest(String JavaDoc testName) {
54         super(testName);
55     }
56
57     protected void setUp() throws Exception JavaDoc {
58     }
59
60     protected void tearDown() throws Exception JavaDoc {
61     }
62
63     public static Test suite() {
64         TestSuite suite = new TestSuite(NamingDirectorTest.class);
65         
66         return suite;
67     }
68
69     /**
70      * Test of init method, of class com.rift.coad.lib.naming.NamingDirector.
71      */

72     public void testInit() throws Exception JavaDoc {
73         System.out.println("init");
74         
75         // init the session information
76
ThreadsPermissionContainer permissions = new ThreadsPermissionContainer();
77         SessionManager.init(permissions);
78         UserStoreManager userStoreManager = new UserStoreManager();
79         UserSessionManager sessionManager = new UserSessionManager(permissions,
80                 userStoreManager);
81         LoginManager.init(sessionManager,userStoreManager);
82         // instanciate the thread manager
83
CoadunationThreadGroup threadGroup = new CoadunationThreadGroup(sessionManager,
84             userStoreManager);
85         
86         // add a user to the session for the current thread
87
RoleManager.getInstance();
88         
89         InterceptorFactory.init(permissions,sessionManager,userStoreManager);
90         
91         // add a new user object and add to the permission
92
Set JavaDoc set = new HashSet JavaDoc();
93         set.add("test");
94         UserSession user = new UserSession("test1", set);
95         permissions.putSession(new Long JavaDoc(Thread.currentThread().getId()),
96                 new ThreadPermissionSession(
97                 new Long JavaDoc(Thread.currentThread().getId()),user));
98         
99         
100         NamingDirector.init(threadGroup);
101         
102         System.out.println("jndi [" +
103                 NamingDirector.getInstance().getJNDIBase() + "]");
104         
105         NamingDirector.getInstance().shutdown();
106     }
107     
108 }
109
Popular Tags