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

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/SocketFactoryTestClient.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.transport.rmi.connection.socketfactory;
 
2
 
 
3
import junit.framework.TestCase;
 
4
import org.jboss.remoting.Client;
 
5
import org.jboss.remoting.InvokerLocator;
 
6
 
 
7
/**
 
8
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
9
 */
 
10
public class SocketFactoryTestClient extends TestCase
 
11
{
 
12
   // Default locator values
 
13
   private static String transport = "rmi";
 
14
   private static String host = "localhost";
 
15
   private static int port = 5400;
 
16
 
 
17
   public void testInvocations() throws Throwable
 
18
   {
 
19
      Client remotingClient = null;
 
20
 
 
21
      try
 
22
      {
 
23
 
 
24
 
 
25
         String locatorURI = transport + "://" + host + ":" + port;
 
26
         //String locatorURI = transport + "://" + host + ":" + port;
 
27
 
 
28
         // create InvokerLocator with the url type string
 
29
         // indicating the target remoting server to call upon.
 
30
         InvokerLocator locator = new InvokerLocator(locatorURI);
 
31
         System.out.println("Calling remoting server with locator uri of: " + locatorURI);
 
32
 
 
33
         remotingClient = new Client(locator);
 
34
         remotingClient.connect();
 
35
         String request = "Do something";
 
36
         System.out.println("Invoking server with request of '" + request + "'");
 
37
 
 
38
         long startTime = System.currentTimeMillis();
 
39
 
 
40
         Object response = remotingClient.invoke(request);
 
41
         System.out.println("Invocation response: " + response);
 
42
 
 
43
      }
 
44
      finally
 
45
      {
 
46
         if(remotingClient != null)
 
47
         {
 
48
            remotingClient.disconnect();
 
49
         }
 
50
      }
 
51
 
 
52
   }
 
53
 
 
54
   /**
 
55
    * Can pass transport and port to be used as parameters.
 
56
    * Valid transports are 'rmi' and 'socket'.
 
57
    *
 
58
    * @param args
 
59
    */
 
60
   public static void main(String[] args)
 
61
   {
 
62
      if(args != null && args.length == 3)
 
63
      {
 
64
         transport = args[0];
 
65
         host = args[1];
 
66
         port = Integer.parseInt(args[2]);
 
67
      }
 
68
      SocketFactoryTestClient client = new SocketFactoryTestClient();
 
69
      try
 
70
      {
 
71
         client.testInvocations();
 
72
      }
 
73
      catch(Throwable e)
 
74
      {
 
75
         e.printStackTrace();
 
76
      }
 
77
   }
 
78
 
 
79
 
 
80
}