KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > exception > cannotconnect > socket > CannotConnectTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.remoting.exception.cannotconnect.socket;
8
9 import junit.framework.TestCase;
10 import org.jboss.logging.Logger;
11 import org.jboss.remoting.CannotConnectException;
12 import org.jboss.remoting.Client;
13 import org.jboss.remoting.InvokerLocator;
14 import org.jboss.remoting.invocation.NameBasedInvocation;
15
16 /**
17  * @author <a HREF="mailto:tom.elrod@jboss.com">Tom Elrod</a>
18  */

19 public class CannotConnectTestCase extends TestCase
20 {
21    private static final Logger log = Logger.getLogger(CannotConnectTestCase.class);
22
23    public void testCannotConnect()
24    {
25
26       try
27       {
28          log.debug("running testCannotConnect()");
29
30          InvokerLocator locator = new InvokerLocator("socket://localhost:8829");
31          Client client = new Client(locator, "mock");
32          client.connect();
33
34          log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator());
35
36          Object JavaDoc ret = client.invoke(new NameBasedInvocation("foo",
37                new Object JavaDoc[]{"bar"},
38                new String JavaDoc[]{String JavaDoc.class.getName()}),
39                null);
40       }
41       catch (CannotConnectException cce)
42       {
43          log.debug("Got CannotConnectException as expected.");
44          assertTrue(true);
45       }
46       catch (Throwable JavaDoc tr)
47       {
48          tr.printStackTrace();
49          assertTrue("Did not catch CannotConnectException as expected.", false);
50       }
51    }
52 }
Popular Tags