KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ubermq > jms > server > ServerTestCase


1 /*
2  * Contents copyright 2002-03 Rhombus Technologies.
3  */

4 package com.ubermq.jms.server;
5
6 import java.util.*;
7
8 import javax.jms.*;
9
10 import junit.framework.*;
11
12 import com.ubermq.jms.client.*;
13 import com.ubermq.jms.client.test.*;
14
15 /**
16  * Tests various aspects of the server, such as clustering and direct pipe connections.<P>
17  * @author jp
18  * @since 2.4
19  */

20 public class ServerTestCase extends TestCase
21 {
22     public ServerTestCase(String JavaDoc arg0)
23     {
24         super(arg0);
25     }
26
27     /**
28      * Tests Clustering.
29      */

30     public void testClustering() throws JMSException
31     {
32         Properties p = new Properties();
33         p.put("server.port", "5001");
34
35         MessageServer ms = new MessageServer(p);
36         ms.addStandardProtocols();
37         ms.run();
38
39         p.put("server.port", "5002");
40         p.put("clustering.enable", "true");
41         p.put("clustering.forward", "ubermq://localhost:5001");
42
43         MessageServer ms2 = new MessageServer(p);
44         ms2.addStandardProtocols();
45         ms2.run();
46
47         TopicConnectionFactory localFactory = new URLTopicConnectionFactory("ubermq://localhost:5001"),
48             remoteFactory = new URLTopicConnectionFactory("ubermq://localhost:5002");
49
50         RegressionTestCase.sendAndReceive(localFactory, remoteFactory, "A", "A", null, 20, 20);
51         RegressionTestCase.sendAndReceive(localFactory, "hello", "hello", null, 20, 20);
52         RegressionTestCase.sendAndReceive(localFactory, "B", "B", "where ordinal != 2", 10, 9);
53         RegressionTestCase.sendAndReceive(remoteFactory, localFactory, "B", "B", null, 20, 20);
54
55     }
56
57     /**
58      * Tests pipe connections and makes sure they work w/ themselves, and others.
59      */

60     public void testPipes() throws JMSException
61     {
62         Properties p = new Properties();
63         p.put("server.port", "5003");
64
65         MessageServer ms = new MessageServer(p);
66         ms.addStandardProtocols();
67         ms.run();
68
69         TopicConnectionFactory localFactory = new PipeConnectionFactory(ms),
70             remoteFactory = new URLTopicConnectionFactory(ms.getServiceUrl());
71
72         System.out.println("testPipes");
73         RegressionTestCase.sendAndReceive(localFactory, remoteFactory, "A", "A", null, 20, 20);
74         RegressionTestCase.sendAndReceive(localFactory, "hello", "hello", null, 20, 20);
75         RegressionTestCase.sendAndReceive(localFactory, "B", "B", "where ordinal != 2", 10, 9);
76         RegressionTestCase.sendAndReceive(remoteFactory, localFactory, "B", "B", null, 20, 20);
77     }
78 }
79
Popular Tags