2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
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.
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.
23
package org.jboss.test.remoting.oneway;
25
import java.rmi.server.UID;
26
import org.jboss.logging.Logger;
27
import org.jboss.remoting.Client;
28
import org.jboss.remoting.InvokerLocator;
29
import org.jboss.remoting.invocation.NameBasedInvocation;
31
import junit.framework.TestCase;
34
* This is the actual concrete test for the invoker client to test oneway calls (client and server based).
36
* @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
38
public class OnewayInvokerClientTest extends TestCase
40
private static final Logger log = Logger.getLogger(OnewayInvokerClientTest.class);
42
private String transport = "socket";
43
private int port = 8081;
45
private String sessionId = new UID().toString();
47
private Client client;
53
InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port);
54
client = new Client(locator, "test");
59
log.error(e.getMessage(), e);
63
public void setUp() throws Exception
68
public void tearDown() throws Exception
77
* Test simple oneway client invocation
81
public void testOnewayServerInvocation() throws Throwable
83
log.debug("running testOnewayClientCallback()");
85
sessionId = client.getSessionId();
87
log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator());
91
makeServerOnewayInvocation("saveInvocationParameter", param);
92
Thread.currentThread().sleep(4000);
93
Object obj = makeInvocation("getLastInvocationParameter", null);
95
checkAssertion(param, obj);
98
protected void checkAssertion(String param, Object obj)
100
assertEquals(param, obj);
103
protected void makeServerOnewayInvocation(String method, String param) throws Throwable
105
client.invokeOneway(new NameBasedInvocation(method,
107
new String[]{String.class.getName()}),
114
* Test simple oneway client invocation
118
public void testOnewayClientInvocation() throws Throwable
120
log.debug("running testOnewayClientCallback()");
122
sessionId = client.getSessionId();
124
log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator());
127
String param = "bar";
128
makeClientOnewayInvocation("saveInvocationParameter", param);
129
Thread.currentThread().sleep(1000);
130
Object obj = makeInvocation("getLastInvocationParameter", null);
132
checkAssertion(param, obj);
137
* Test simple oneway client invocation
141
public void testClientInvocation() throws Throwable
143
log.debug("running testInvocation()");
145
sessionId = client.getSessionId();
147
log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator());
150
String param = "bar";
151
Object resp = makeClientInvocation("saveInvocationParameter", param);
153
Object obj = makeInvocation("getLastInvocationParameter", null);
154
Thread.currentThread().sleep(1000);
155
checkAssertion(param, obj);
159
protected void makeClientOnewayInvocation(String method, String param) throws Throwable
161
client.invokeOneway(new NameBasedInvocation(method,
163
new String[]{String.class.getName()}),
169
protected Object makeClientInvocation(String method, String param) throws Throwable
171
Object ret = client.invoke(new NameBasedInvocation(method,
173
new String[]{String.class.getName()}),
180
protected Object makeInvocation(String method, String param) throws Throwable
182
Object ret = client.invoke(new NameBasedInvocation(method,
184
new String[]{String.class.getName()}),