1 | package multiProcessTest; |
---|
2 | |
---|
3 | import static org.junit.Assert.assertEquals; |
---|
4 | |
---|
5 | import java.util.Properties; |
---|
6 | |
---|
7 | import omq.common.broker.Broker; |
---|
8 | import omq.common.util.ParameterQueue; |
---|
9 | import omq.common.util.Serializer; |
---|
10 | |
---|
11 | import org.junit.BeforeClass; |
---|
12 | import org.junit.Test; |
---|
13 | |
---|
14 | public class ClientTest { |
---|
15 | // Execute ServerTest.java 2 times before start this test |
---|
16 | public static Number remoteNumber; |
---|
17 | |
---|
18 | @BeforeClass |
---|
19 | public static void startClient() throws Exception { |
---|
20 | Properties env = new Properties(); |
---|
21 | env.setProperty(ParameterQueue.USER_NAME, "guest"); |
---|
22 | env.setProperty(ParameterQueue.USER_PASS, "guest"); |
---|
23 | |
---|
24 | // Set host info of rabbimq (where it is) |
---|
25 | env.setProperty(ParameterQueue.SERVER_HOST, "127.0.0.1"); |
---|
26 | env.setProperty(ParameterQueue.SERVER_PORT, "5672"); |
---|
27 | env.setProperty(ParameterQueue.DURABLE_QUEUES, "false"); |
---|
28 | env.setProperty(ParameterQueue.SERIALIZER_NAME, Serializer.java); |
---|
29 | env.setProperty(ParameterQueue.ENABLECOMPRESSION, "false"); |
---|
30 | |
---|
31 | // Set info about where the message will be sent |
---|
32 | env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange"); |
---|
33 | |
---|
34 | // Set info about the queue & the exchange where the ResponseListener |
---|
35 | // will listen to. |
---|
36 | env.setProperty(ParameterQueue.RPC_REPLY_QUEUE, "reply_queue"); |
---|
37 | env.setProperty(ParameterQueue.EVENT_REPLY_QUEUE, "event_queue"); |
---|
38 | |
---|
39 | Broker.initBroker(env); |
---|
40 | remoteNumber = Broker.lookup("number", Number.class); |
---|
41 | } |
---|
42 | |
---|
43 | @Test |
---|
44 | public void test() { |
---|
45 | int x = 10; |
---|
46 | remoteNumber.setNumber(x); |
---|
47 | int a = remoteNumber.getNumer(); |
---|
48 | assertEquals(a, 0); |
---|
49 | int b = remoteNumber.getNumer(); |
---|
50 | assertEquals(x, b); |
---|
51 | } |
---|
52 | |
---|
53 | } |
---|