KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > marshall > dynamic > remote > http > MarshallerLoadingClient


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.marshall.dynamic.remote.http;
8
9 import org.jboss.remoting.Client;
10 import org.jboss.remoting.InvokerLocator;
11
12 import junit.framework.TestCase;
13
14 /**
15  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
16  */

17 public class MarshallerLoadingClient extends TestCase implements MarshallerLoadingConstants
18 {
19    public void testInvocation() throws Throwable JavaDoc
20    {
21       Client remotingClient = null;
22
23       // first, make sure can not load marshaller from current classpath
24
try
25       {
26          Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.http.TestMarshaller");
27          assertTrue("Was able to load the TestMarshaller class locally, when it should NOT be on the classpath.", false);
28          return;
29       }
30       catch(ClassNotFoundException JavaDoc e)
31       {
32          assertTrue("Was not able to load TestMarshaller from local classpath as expected.", true);
33       }
34
35       try
36       {
37          InvokerLocator locator = new InvokerLocator(locatorURI);
38          System.out.println("Calling remoting server with locator uri of: " + locatorURI);
39
40          remotingClient = new Client(locator, null);
41          Object JavaDoc response = remotingClient.invoke("Do something", null);
42          assertTrue(true);
43
44          System.out.println("Invocation response: " + response);
45       }
46       finally
47       {
48          if(remotingClient != null)
49          {
50             remotingClient.disconnect();
51          }
52       }
53    }
54
55    public static void main(String JavaDoc[] args)
56    {
57       MarshallerLoadingClient client = new MarshallerLoadingClient();
58       try
59       {
60          client.testInvocation();
61       }
62       catch(Throwable JavaDoc throwable)
63       {
64          throwable.printStackTrace();
65       }
66    }
67
68    /**
69     * Can pass transport and port to be used as parameters.
70     * Valid transports are 'rmi' and 'socket'.
71     *
72     * @param args
73     */

74 // public static void main(String[] args)
75
// {
76
// org.apache.log4j.BasicConfigurator.configure();
77
// org.apache.log4j.Category.getRoot().setLevel(Level.INFO);
78
// org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
79
//
80
// /*
81
// if(args != null && args.length == 2)
82
// {
83
// transport = args[0];
84
// port = Integer.parseInt(args[1]);
85
// }
86
// */
87
// MarshallerLoadingClient client = new MarshallerLoadingClient(MarshallerLoadingClient.class.getName());
88
// try
89
// {
90
// MultipleTestRunner runner = new MultipleTestRunner();
91
// runner.doRun(client, true);
92
// }
93
// catch(Throwable e)
94
// {
95
// e.printStackTrace();
96
// System.exit(1);
97
// }
98
// System.exit(0);
99
// }
100
//
101

102 }
Popular Tags