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: * WebServiceLoaderTest.java
020: *
021: * JUnit based test
022: */
023:
024: package com.rift.coad.lib.deployment.webservice;
025:
026: import junit.framework.*;
027: import java.util.Map;
028: import java.util.HashMap;
029: import java.util.HashSet;
030: import java.util.Iterator;
031: import java.util.Set;
032:
033: // log 4 j
034: import org.apache.log4j.BasicConfigurator;
035:
036: // axis imports
037: import org.apache.axis.AxisEngine;
038: import org.apache.axis.server.AxisServer;
039: import org.apache.axis.management.ServiceAdmin;
040: import org.apache.axis.configuration.EngineConfigurationFactoryFinder;
041: import org.apache.axis.EngineConfiguration;
042:
043: // coadunation imports
044: import com.rift.coad.lib.deployment.DeploymentLoader;
045: import com.rift.coad.lib.webservice.WebServiceWrapper;
046: import com.rift.coad.lib.thirdparty.axis.AxisManager;
047: import com.rift.coad.lib.deployment.DeploymentLoader;
048: import com.rift.coad.lib.thirdparty.axis.AxisManager;
049: import com.rift.coad.lib.interceptor.InterceptorFactory;
050: import com.rift.coad.lib.naming.NamingDirector;
051: import com.rift.coad.lib.security.RoleManager;
052: import com.rift.coad.lib.security.SessionManager;
053: import com.rift.coad.lib.security.ThreadPermissionSession;
054: import com.rift.coad.lib.security.ThreadsPermissionContainer;
055: import com.rift.coad.lib.security.UserSession;
056: import com.rift.coad.lib.security.login.LoginManager;
057: import com.rift.coad.lib.security.user.UserSessionManager;
058: import com.rift.coad.lib.security.user.UserStoreManager;
059: import com.rift.coad.lib.thread.CoadunationThreadGroup;
060: import com.rift.coad.lib.transaction.TransactionDirector;
061:
062: /**
063: *
064: * @author mincemeat
065: */
066: public class WebServiceLoaderTest extends TestCase {
067:
068: public WebServiceLoaderTest(String testName) {
069: super (testName);
070: BasicConfigurator.configure();
071: }
072:
073: protected void setUp() throws Exception {
074: }
075:
076: protected void tearDown() throws Exception {
077: }
078:
079: public static Test suite() {
080: TestSuite suite = new TestSuite(WebServiceLoaderTest.class);
081:
082: return suite;
083: }
084:
085: /**
086: * Test of of class com.rift.coad.lib.deployment.webservice.WebServiceLoader.
087: */
088: public void testWebServiceLoader() throws Exception {
089: System.out.println("getServices");
090:
091: // init the session information
092: ThreadsPermissionContainer permissions = new ThreadsPermissionContainer();
093: SessionManager.init(permissions);
094: UserStoreManager userStoreManager = new UserStoreManager();
095: UserSessionManager sessionManager = new UserSessionManager(
096: permissions, userStoreManager);
097: LoginManager.init(sessionManager, userStoreManager);
098: // instanciate the thread manager
099: CoadunationThreadGroup threadGroup = new CoadunationThreadGroup(
100: sessionManager, userStoreManager);
101:
102: // add a user to the session for the current thread
103: RoleManager.getInstance();
104:
105: InterceptorFactory.init(permissions, sessionManager,
106: userStoreManager);
107:
108: // add a new user object and add to the permission
109: Set set = new HashSet();
110: set.add("test");
111: UserSession user = new UserSession("test1", set);
112: permissions.putSession(
113: new Long(Thread.currentThread().getId()),
114: new ThreadPermissionSession(new Long(Thread
115: .currentThread().getId()), user));
116:
117: // init the naming director
118: NamingDirector.init(threadGroup);
119:
120: // instanciate the transaction director
121: TransactionDirector transactionDirector = TransactionDirector
122: .init();
123:
124: // instanciate the deployment loader
125: DeploymentLoader deploymentLoader = new DeploymentLoader(
126: new java.io.File(System.getProperty("test.jar")));
127:
128: // instanciate the axis engine
129: AxisManager.init();
130: ServiceAdmin.setEngine(AxisManager.getInstance().getServer(),
131: "test");
132:
133: WebServiceLoader instance = new WebServiceLoader(
134: deploymentLoader);
135: }
136:
137: }
|