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.asynch;
23:
24: import junit.framework.Test;
25: import junit.framework.TestSuite;
26: import org.jboss.aspects.asynch.AsynchProvider;
27: import org.jboss.aspects.asynch.Future;
28: import org.jboss.test.JBossTestCase;
29: import org.jboss.test.aop.test.AOPTestSetup;
30:
31: /**
32: * Comment
33: *
34: * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
35: * @version $Revision: 57186 $
36: */
37: public class AsynchTestCase extends JBossTestCase {
38: org.apache.log4j.Category log = getLog();
39:
40: static boolean deployed = false;
41: static int test = 0;
42:
43: public AsynchTestCase(String name) {
44:
45: super (name);
46:
47: }
48:
49: public void testRemote() throws Exception {
50: try {
51: POJO pojo = (POJO) getInitialContext().lookup("pojo");
52:
53: AsynchProvider asynch = (AsynchProvider) pojo;
54: pojo.testMethod(5);
55:
56: Future future = asynch.getFuture();
57: int rtn = (Integer) future.get();
58: assertEquals(rtn, 5);
59:
60: pojo.testMethod("hello");
61:
62: future = asynch.getFuture();
63: String srtn = (String) future.get();
64: assertEquals("hello", srtn);
65: } catch (Exception e) {
66: throw new RuntimeException(e);
67: }
68:
69: }
70:
71: public void testLocal() throws Exception {
72: POJO pojo = (POJO) getInitialContext().lookup("pojo");
73:
74: pojo.test();
75: }
76:
77: public void testCollocated() throws Exception {
78: POJO pojo = (POJO) getInitialContext().lookup("pojo");
79:
80: pojo.testCollocated();
81: }
82:
83: public static Test suite() throws Exception {
84: TestSuite suite = new TestSuite();
85: suite.addTest(new TestSuite(AsynchTestCase.class));
86:
87: AOPTestSetup setup = new AOPTestSetup(suite, "asynch-test.sar");
88: return setup;
89: }
90:
91: }
|