01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.jca.inflow;
23:
24: import java.util.Timer;
25: import java.util.TimerTask;
26:
27: import javax.resource.spi.endpoint.MessageEndpoint;
28:
29: /**
30: * Management interface of TestResourceAdapter.
31: *
32: * @author <a href="adrian@jboss.com">Adrian Brock</a>
33: * @version $Revision: 57211 $
34: */
35: public class TestResourceAdapterTimer {
36: TestResourceAdapter adapter;
37:
38: public TestResourceAdapterTimer(TestResourceAdapter adapter) {
39: this .adapter = adapter;
40: }
41:
42: public TestResourceAdapterTimerResults run() throws Exception {
43: TestResourceAdapterTimerResults results = new TestResourceAdapterTimerResults();
44: try {
45: basicTest();
46: results.basicTest.pass();
47: } catch (Throwable t) {
48: results.basicTest.fail(t);
49: }
50:
51: return results;
52: }
53:
54: public void basicTest() throws Exception {
55: Timer timer = adapter.ctx.createTimer();
56: TestTimerTask task = new TestTimerTask();
57: timer.schedule(task, 5000l);
58: Thread.sleep(10000);
59: if (task.complete == false)
60: throw new Exception("Task was not run");
61: }
62:
63: public class TestTimerTask extends TimerTask {
64: public boolean complete = false;
65:
66: public void run() {
67: complete = true;
68: }
69: }
70: }
|