KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > exception > cannotconnect > http > 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.test.remoting.exception.cannotconnect.http;
8
9 import org.jboss.logging.Logger;
10 import org.jboss.remoting.CannotConnectException;
11 import org.jboss.remoting.Client;
12 import org.jboss.remoting.InvokerLocator;
13 import org.jboss.remoting.invocation.NameBasedInvocation;
14
15 import junit.framework.TestCase;
16
17 /**
18  * @author <a HREF="mailto:tom.elrod@jboss.com">Tom Elrod</a>
19  */

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