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: F_AccessControlEC2.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.BaseEHome;
035: import org.objectweb.jonas.jtests.beans.secured.BaseS;
036:
037: /**
038: * Security Management Suite with a stateless session as first bean
039: *
040: * @author Ph.Coq, Ph.Durieux, H.Joanin
041: *
042: */
043:
044: public class F_AccessControlEC2 extends A_AccessControl {
045:
046: private static String BEAN_HOME = "securedBaseEC2Home";
047: protected static BaseEHome home = null;
048:
049: public F_AccessControlEC2(String name) {
050: super (name);
051: }
052:
053: /**
054: * return the Home
055: */
056:
057: public BaseEHome getHome() {
058: if (home == null) {
059: try {
060: home = (BaseEHome) PortableRemoteObject.narrow(ictx
061: .lookup(BEAN_HOME), BaseEHome.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(name, name + "_info");
071: }
072:
073: public void removeBaseS(String name) throws Exception {
074: getHome().remove(name + "_info");
075: }
076:
077: /**
078: * init environment:
079: * - load beans
080: */
081: protected void setUp() {
082: super .setUp();
083: useBeans("secured", true);
084: }
085:
086: /**
087: * This suite is all BMP test cases
088: */
089: public static Test suite() {
090: return new TestSuite(F_AccessControlEC2.class);
091: }
092:
093: public static void main(String args[]) {
094: String testtorun = null;
095: // Get args
096: for (int argn = 0; argn < args.length; argn++) {
097: String s_arg = args[argn];
098: Integer i_arg;
099: if (s_arg.equals("-n")) {
100: testtorun = args[++argn];
101: }
102: }
103: if (testtorun == null) {
104: junit.textui.TestRunner.run(suite());
105: } else {
106: junit.textui.TestRunner.run(new F_AccessControlEC2(
107: testtorun));
108: }
109: }
110: }
|