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

Last change on this file was 84, checked in by stoda, 11 years ago

Default queues added, default exchange enabled, more control in remote queues added.
Tests verified and changed Persistent test to show how to make persistent messages.

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/**
19 *
20 * @author Sergi Toda <sergi.toda@estudiants.urv.cat>
21 *
22 */
23@RunWith(value = Parameterized.class)
24public class StopBrokerTest {
25
26        private static Broker broker;
27        private static BrokerKiller bk;
28
29        public StopBrokerTest(String type) throws Exception {
30                Properties env = new Properties();
31                env.setProperty(ParameterQueue.USER_NAME, "guest");
32                env.setProperty(ParameterQueue.USER_PASS, "guest");
33
34                // Set host info of rabbimq (where it is)
35                env.setProperty(ParameterQueue.RABBIT_HOST, "127.0.0.1");
36                env.setProperty(ParameterQueue.RABBIT_PORT, "5672");
37                env.setProperty(ParameterQueue.DURABLE_QUEUE, "false");
38                env.setProperty(ParameterQueue.PROXY_SERIALIZER, type);
39                env.setProperty(ParameterQueue.ENABLE_COMPRESSION, "false");
40
41                // Set info about where the message will be sent
42                env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");
43                // env.setProperty(ParameterQueue.DEBUGFILE, "c:\\middlewareDebug");
44
45                // Set info about the queue & the exchange where the ResponseListener
46                // will listen to.
47                env.setProperty(ParameterQueue.RPC_REPLY_QUEUE, "reply_queue");
48                env.setProperty(ParameterQueue.RETRY_TIME_CONNECTION, "5000");
49
50                broker = new Broker(env);
51                bk = broker.lookup("bk", BrokerKiller.class);
52        }
53
54        @Parameters
55        public static Collection<Object[]> data() {
56                Object[][] data = new Object[][] { { Serializer.JAVA }, { Serializer.GSON }, { Serializer.KRYO } };
57                return Arrays.asList(data);
58        }
59
60        @BeforeClass
61        public static void server() throws Exception {
62                Properties env = new Properties();
63                env.setProperty(ParameterQueue.USER_NAME, "guest");
64                env.setProperty(ParameterQueue.USER_PASS, "guest");
65
66                // Get host info of rabbimq (where it is)
67                env.setProperty(ParameterQueue.RABBIT_HOST, "127.0.0.1");
68                env.setProperty(ParameterQueue.RABBIT_PORT, "5672");
69                env.setProperty(ParameterQueue.DURABLE_QUEUE, "false");
70                env.setProperty(ParameterQueue.ENABLE_COMPRESSION, "false");
71
72                // Set info about where the message will be sent
73                env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");
74                env.setProperty(ParameterQueue.RETRY_TIME_CONNECTION, "2000");
75
76                Broker broker = new Broker(env);
77                BrokerKillerImpl bki = new BrokerKillerImpl(broker);
78                broker.bind("bk", bki);
79        }
80
81        @After
82        public void stop() throws Exception {
83                broker.stopBroker();
84        }
85
86        @Test
87        public void stopBroker() throws Exception {
88                bk.killServerBroker();
89        }
90
91}
Note: See TracBrowser for help on using the repository browser.