KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > interceptor > InterceptorTestCase


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.interceptor;
8
9 import junit.framework.TestCase;
10 import org.jboss.remoting.InvokerLocator;
11 import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
12
13 import java.net.MalformedURLException JavaDoc;
14
15 /**
16  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
17  */

18 public class InterceptorTestCase extends TestCase
19 {
20    private boolean continueRun = true;
21
22    public InterceptorTestCase(String JavaDoc name)
23    {
24       super(name);
25    }
26
27    protected void setUp() throws Exception JavaDoc
28    {
29       super.setUp();
30       continueRun = true;
31       new Thread JavaDoc()
32       {
33          public void run()
34          {
35             startServer();
36          }
37       }.start();
38    }
39
40    public void testClient() throws Exception JavaDoc
41    {
42       try
43       {
44          ClientInterceptorTest test = new ClientInterceptorTest();
45          test.runTest();
46          boolean passed = test.isTestPassing();
47          assertTrue("ClientInterceptorTest failed.", passed);
48       }
49       catch(MalformedURLException JavaDoc e)
50       {
51          e.printStackTrace();
52       }
53
54    }
55
56    protected void tearDown() throws Exception JavaDoc
57    {
58       super.tearDown();
59       continueRun = false;
60
61    }
62
63
64    public void startServer()
65    {
66       try
67       {
68          int port = 8081;
69          String JavaDoc transport = "socket";
70 // InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port + "/?" +
71
// InvokerLocator.DATATYPE + "=" + SerializableUnMarshaller.DATATYPE);
72
InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port + "/?" +
73                                                      InvokerLocator.DATATYPE + "=" + SerializableUnMarshaller.DATATYPE);
74
75          ServerInterceptorTest server = new ServerInterceptorTest();
76          server.setLocator(locator);
77          server.setup();
78
79          while(continueRun)
80          {
81             Thread.sleep(1000);
82          }
83       }
84       catch(Exception JavaDoc e)
85       {
86          e.printStackTrace();
87       }
88    }
89
90 }
Popular Tags