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

« back to all changes in this revision

Viewing changes to tests/org/jboss/test/remoting/transport/socket/ssl/connection_check/InvokerClientTest.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.socket.ssl.connection_check;
2
 
 
3
 
import junit.framework.TestCase;
4
 
import org.apache.log4j.Level;
5
 
import org.jboss.logging.Logger;
6
 
import org.jboss.remoting.Client;
7
 
import org.jboss.remoting.InvokerLocator;
8
 
import org.jboss.remoting.invocation.NameBasedInvocation;
9
 
import org.jboss.remoting.transport.socket.SocketServerInvoker;
10
 
import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants;
11
 
 
12
 
/**
13
 
 * This is the actual concrete test for the invoker client.  Uses socket transport by default.
14
 
 *
15
 
 * @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
16
 
 */
17
 
public class InvokerClientTest extends TestCase implements SSLInvokerConstants
18
 
{
19
 
   private Client client;
20
 
   private static final Logger log = Logger.getLogger(InvokerClientTest.class);
21
 
 
22
 
   public void init()
23
 
   {
24
 
      try
25
 
      {
26
 
         // since doing basic (using default ssl server socket factory)
27
 
         // need to set the system properties to the truststore
28
 
         String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile();
29
 
         System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath);
30
 
 
31
 
         InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + getPort() + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.TRUE);
32
 
         client = new Client(locator, "mock");
33
 
         client.connect();
34
 
      }
35
 
      catch (Exception e)
36
 
      {
37
 
         InvokerClientTest.log.error(e.getMessage(), e);
38
 
      }
39
 
   }
40
 
 
41
 
   public void testRemoteCall() throws Throwable
42
 
   {
43
 
      InvokerClientTest.log.debug("running testRemoteCall()");
44
 
 
45
 
      InvokerClientTest.log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator());
46
 
 
47
 
      // simple invoke, should return bar
48
 
      Object ret = makeInvocation("foo", "bar");
49
 
      assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret));
50
 
      if ("bar".equals(ret))
51
 
      {
52
 
         InvokerClientTest.log.debug("PASS");
53
 
      }
54
 
      else
55
 
      {
56
 
         InvokerClientTest.log.debug("FAILED");
57
 
      }
58
 
      assertEquals("bar", ret);
59
 
 
60
 
   }
61
 
 
62
 
   protected String getTransport()
63
 
   {
64
 
      return transport;
65
 
   }
66
 
   
67
 
   protected int getPort()
68
 
   {
69
 
      return port;
70
 
   }
71
 
 
72
 
   private Object makeInvocation(String method, String param) throws Throwable
73
 
   {
74
 
      Object ret = client.invoke(new NameBasedInvocation(method,
75
 
                                                         new Object[]{param},
76
 
                                                         new String[]{String.class.getName()}),
77
 
                                 null);
78
 
 
79
 
      return ret;
80
 
   }
81
 
 
82
 
   public void setUp() throws Exception
83
 
   {
84
 
      org.apache.log4j.BasicConfigurator.configure();
85
 
      org.apache.log4j.Category.getRoot().setLevel(Level.INFO);
86
 
      org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO);
87
 
      org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
88
 
      org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG);
89
 
 
90
 
      init();
91
 
   }
92
 
 
93
 
   public void tearDown() throws Exception
94
 
   {
95
 
      if (client != null)
96
 
      {
97
 
         client.disconnect();
98
 
         client = null;
99
 
      }
100
 
   }
101
 
 
102
 
}