KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > clients > timer > F_TimerFromSF


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: F_TimerFromSF.java,v 1.2 2004/10/27 07:48:41 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.clients.timer;
27
28
29 import javax.naming.NamingException JavaDoc;
30 import javax.rmi.PortableRemoteObject JavaDoc;
31
32 import junit.framework.Test;
33 import junit.framework.TestSuite;
34
35 import org.objectweb.jonas.jtests.beans.folder.Folder;
36 import org.objectweb.jonas.jtests.beans.folder.FolderHome;
37 import org.objectweb.jonas.jtests.util.JTestCase;
38
39 /**
40  * This is test of the TimerService.
41  * @author Philippe Durieux (jonas team)
42  */

43 public class F_TimerFromSF extends JTestCase {
44
45     protected static FolderHome fhome = null;
46     protected Folder folder = null;
47     
48     /**
49      * constructor
50      * @param name name of the test suite.
51      */

52     public F_TimerFromSF(String JavaDoc name) {
53         super(name);
54     }
55
56     /**
57      * init environment:
58      * - load beans
59      * - get the home for session beans
60      */

61     protected void setUp() {
62         super.setUp();
63         if (fhome == null) {
64             useBeans("folder", true);
65             try {
66                 fhome = (FolderHome) PortableRemoteObject.narrow(ictx.lookup("FolderSYHome"), FolderHome.class);
67                 assertNotNull(fhome);
68             } catch (NamingException JavaDoc e) {
69                 fail("Cannot get bean home");
70             }
71         }
72         if (folder == null) {
73             try {
74                 folder = fhome.create();
75                 assertNotNull(folder);
76             } catch (Exception JavaDoc e) {
77                 fail("Cannot create folder session " + e);
78             }
79         }
80     }
81
82     public void testAccessRemovedTimer() throws Exception JavaDoc {
83         boolean ok = folder.testTimerRemoved("timerfile");
84         assertTrue("Timer Still Accessed after bean remove", ok);
85     }
86     
87     public void testAccessCanceledTimer() throws Exception JavaDoc {
88         boolean ok = folder.testTimerCancel("timerfile2");
89         assertTrue("Timer Still Accessed after cancel", ok);
90     }
91     
92     public static Test suite() {
93         return new TestSuite(F_TimerFromSF.class);
94     }
95
96     public static void main (String JavaDoc args[]) {
97         String JavaDoc testtorun = null;
98         // Get args
99
for (int argn = 0; argn < args.length; argn++) {
100             String JavaDoc 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 }
112
113
Popular Tags