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_TimerFromSF.java 5679 2004-10-27 07:49:09Z durieuxp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.clients.timer;
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.folder.Folder;
035: import org.objectweb.jonas.jtests.beans.folder.FolderHome;
036: import org.objectweb.jonas.jtests.util.JTestCase;
037:
038: /**
039: * This is test of the TimerService.
040: * @author Philippe Durieux (jonas team)
041: */
042: public class F_TimerFromSF extends JTestCase {
043:
044: protected static FolderHome fhome = null;
045: protected Folder folder = null;
046:
047: /**
048: * constructor
049: * @param name name of the test suite.
050: */
051: public F_TimerFromSF(String name) {
052: super (name);
053: }
054:
055: /**
056: * init environment:
057: * - load beans
058: * - get the home for session beans
059: */
060: protected void setUp() {
061: super .setUp();
062: if (fhome == null) {
063: useBeans("folder", true);
064: try {
065: fhome = (FolderHome) PortableRemoteObject.narrow(ictx
066: .lookup("FolderSYHome"), FolderHome.class);
067: assertNotNull(fhome);
068: } catch (NamingException e) {
069: fail("Cannot get bean home");
070: }
071: }
072: if (folder == null) {
073: try {
074: folder = fhome.create();
075: assertNotNull(folder);
076: } catch (Exception e) {
077: fail("Cannot create folder session " + e);
078: }
079: }
080: }
081:
082: public void testAccessRemovedTimer() throws Exception {
083: boolean ok = folder.testTimerRemoved("timerfile");
084: assertTrue("Timer Still Accessed after bean remove", ok);
085: }
086:
087: public void testAccessCanceledTimer() throws Exception {
088: boolean ok = folder.testTimerCancel("timerfile2");
089: assertTrue("Timer Still Accessed after cancel", ok);
090: }
091:
092: public static Test suite() {
093: return new TestSuite(F_TimerFromSF.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 sarg = args[argn];
101: if (sarg.equals("-n")) {
102: testtorun = args[++argn];
103: }
104: }
105: if (testtorun == null) {
106: junit.textui.TestRunner.run(suite());
107: } else {
108: junit.textui.TestRunner.run(new F_TimerFromSF(testtorun));
109: }
110: }
111: }
|