source: trunk/src/test/java/omq/test/stopBroker/StopBrokerTest.java @ 62

Last change on this file since 62 was 62, checked in by gguerrero, 11 years ago
File size: 2.7 KB
Line 
1package omq.test.stopBroker;
2
3import java.util.Arrays;
4import java.util.Collection;
5import java.util.Properties;
6
7import omq.common.broker.Broker;
8import omq.common.util.ParameterQueue;
9import omq.common.util.Serializer;
10
11import org.junit.After;
12import org.junit.BeforeClass;
13import org.junit.Test;
14import org.junit.runner.RunWith;
15import org.junit.runners.Parameterized;
16import org.junit.runners.Parameterized.Parameters;
17
18@RunWith(value = Parameterized.class)
19public class StopBrokerTest {
20
21        private static Broker broker;
22        private static BrokerKiller bk;
23
24        public StopBrokerTest(String type) throws Exception {
25                Properties env = new Properties();
26                env.setProperty(ParameterQueue.USER_NAME, "guest");
27                env.setProperty(ParameterQueue.USER_PASS, "guest");
28
29                // Set host info of rabbimq (where it is)
30                env.setProperty(ParameterQueue.SERVER_HOST, "127.0.0.1");
31                env.setProperty(ParameterQueue.SERVER_PORT, "5672");
32                env.setProperty(ParameterQueue.DURABLE_QUEUES, "false");
33                env.setProperty(ParameterQueue.SERIALIZER_NAME, type);
34                env.setProperty(ParameterQueue.ENABLECOMPRESSION, "false");
35
36                // Set info about where the message will be sent
37                env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");
38                // env.setProperty(ParameterQueue.DEBUGFILE, "c:\\middlewareDebug");
39
40                // Set info about the queue & the exchange where the ResponseListener
41                // will listen to.
42                env.setProperty(ParameterQueue.RPC_REPLY_QUEUE, "reply_queue");
43                env.setProperty(ParameterQueue.EVENT_REPLY_QUEUE, "event_queue");
44                env.setProperty(ParameterQueue.RETRY_TIME_CONNECTION, "5000");
45
46                broker = new Broker(env);
47                bk = broker.lookup("bk", BrokerKiller.class);
48        }
49
50        @Parameters
51        public static Collection<Object[]> data() {
52                Object[][] data = new Object[][] { { Serializer.JAVA }, { Serializer.GSON }, { Serializer.KRYO } };
53                return Arrays.asList(data);
54        }
55
56        @BeforeClass
57        public static void server() throws Exception {
58                Properties env = new Properties();
59                env.setProperty(ParameterQueue.USER_NAME, "guest");
60                env.setProperty(ParameterQueue.USER_PASS, "guest");
61
62                // Get host info of rabbimq (where it is)
63                env.setProperty(ParameterQueue.SERVER_HOST, "127.0.0.1");
64                env.setProperty(ParameterQueue.SERVER_PORT, "5672");
65                env.setProperty(ParameterQueue.DURABLE_QUEUES, "false");
66                env.setProperty(ParameterQueue.ENABLECOMPRESSION, "false");
67
68                // Set info about where the message will be sent
69                env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");
70                env.setProperty(ParameterQueue.RETRY_TIME_CONNECTION, "2000");
71
72                Broker broker = new Broker(env);
73                BrokerKillerImpl bki = new BrokerKillerImpl(broker);
74                broker.bind("bk", bki);
75        }
76
77        @After
78        public void stop() throws Exception {
79                broker.stopBroker();
80        }
81
82        @Test
83        public void stopBroker() throws Exception {
84                bk.killServerBroker();
85        }
86
87}
Note: See TracBrowser for help on using the repository browser.