001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: G_AccessControlSL.java 5579 2004-10-08 12:12:20Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.security;
027:
028: import javax.naming.NamingException;
029: import javax.rmi.PortableRemoteObject;
030:
031: import junit.framework.Test;
032: import junit.framework.TestSuite;
033:
034: import org.objectweb.jonas.jtests.beans.secured.BaseS;
035: import org.objectweb.jonas.jtests.beans.secured.BaseSHome;
036:
037: /**
038: * Security Management Suite with a stateless session as first bean
039: *
040: * @author Ph.Coq, Ph.Durieux
041: *
042: */
043:
044: public class G_AccessControlSL extends B_AccessControl {
045:
046: private static String BEAN_HOME = "securedBaseSLHome";
047: protected static BaseSHome home = null;
048:
049: public G_AccessControlSL(String name) {
050: super (name);
051: }
052:
053: /**
054: * return the Home
055: */
056:
057: public BaseSHome getHome() {
058: if (home == null) {
059: try {
060: home = (BaseSHome) PortableRemoteObject.narrow(ictx
061: .lookup(BEAN_HOME), BaseSHome.class);
062: } catch (NamingException e) {
063: fail("Cannot get bean home " + BEAN_HOME);
064: }
065: }
066: return home;
067: }
068:
069: public BaseS getBaseS(String name) throws Exception {
070: return getHome().create();
071: }
072:
073: public void removeBaseS(String name) throws Exception {
074: // cannot remove session.
075: }
076:
077: /**
078: * init environment:
079: * - load beans
080: */
081: protected void setUp() {
082: super .setUp();
083: useBeans("secured", true);
084: }
085:
086: public void testEmpty() throws Exception {
087: }
088:
089: /**
090: * This suite is all BMP test cases
091: */
092: public static Test suite() {
093: return new TestSuite(G_AccessControlSL.class);
094: }
095:
096: public static void main(String args[]) {
097: String testtorun = null;
098: // Get args
099: for (int argn = 0; argn < args.length; argn++) {
100: String s_arg = args[argn];
101: Integer i_arg;
102: if (s_arg.equals("-n")) {
103: testtorun = args[++argn];
104: }
105: }
106: if (testtorun == null) {
107: junit.textui.TestRunner.run(suite());
108: } else {
109: junit.textui.TestRunner
110: .run(new G_AccessControlSL(testtorun));
111: }
112: }
113: }
|