~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPushTestClient.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.jboss.test.remoting.callback.push.unidirectional;
2
 
 
3
 
import junit.framework.TestCase;
4
 
import org.jboss.remoting.Client;
5
 
import org.jboss.remoting.InvokerLocator;
6
 
import org.jboss.remoting.callback.Callback;
7
 
import org.jboss.remoting.callback.HandleCallbackException;
8
 
import org.jboss.remoting.callback.InvokerCallbackHandler;
9
 
 
10
 
import java.util.HashMap;
11
 
 
12
 
/**
13
 
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
14
 
 */
15
 
public abstract class CallbackPushTestClient extends TestCase
16
 
{
17
 
   private boolean gotCallback = false;
18
 
 
19
 
   public void testCallback() throws Throwable
20
 
   {
21
 
      Client client = new Client(new InvokerLocator(getLocatorUri()));
22
 
      client.connect();
23
 
      InvokerCallbackHandler testCallbackHandler = new TestCallbackHandler();
24
 
      client.addListener(testCallbackHandler, new HashMap(), null, true);
25
 
      client.invoke("foobar");
26
 
 
27
 
      Thread.sleep(5000);
28
 
 
29
 
      client.removeListener(testCallbackHandler);
30
 
      client.disconnect();
31
 
 
32
 
      assertTrue(gotCallback);
33
 
   }
34
 
 
35
 
   private String getLocatorUri()
36
 
   {
37
 
      return getTransport() + "://" + getHost() + ":" + getPort();
38
 
   }
39
 
 
40
 
   public abstract String getTransport();
41
 
 
42
 
   public String getHost()
43
 
   {
44
 
      return "localhost";
45
 
   }
46
 
 
47
 
   public int getPort()
48
 
   {
49
 
      return 6999;
50
 
   }
51
 
 
52
 
 
53
 
   public class TestCallbackHandler implements InvokerCallbackHandler
54
 
   {
55
 
 
56
 
      public void handleCallback(Callback callback) throws HandleCallbackException
57
 
      {
58
 
         System.out.println("callback = " + callback);
59
 
         gotCallback = true;
60
 
      }
61
 
   }
62
 
}