[46] | 1 | package omq.test.stopBroker; |
---|
[44] | 2 | |
---|
[54] | 3 | import java.util.Arrays; |
---|
| 4 | import java.util.Collection; |
---|
[44] | 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 | |
---|
[54] | 11 | import org.junit.After; |
---|
| 12 | import org.junit.BeforeClass; |
---|
| 13 | import org.junit.Test; |
---|
| 14 | import org.junit.runner.RunWith; |
---|
| 15 | import org.junit.runners.Parameterized; |
---|
| 16 | import org.junit.runners.Parameterized.Parameters; |
---|
[44] | 17 | |
---|
[54] | 18 | @RunWith(value = Parameterized.class) |
---|
| 19 | public class StopBrokerTest { |
---|
| 20 | |
---|
| 21 | private static Broker broker; |
---|
| 22 | private static BrokerKiller bk; |
---|
| 23 | |
---|
| 24 | public StopBrokerTest(String type) throws Exception { |
---|
[44] | 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"); |
---|
[54] | 33 | env.setProperty(ParameterQueue.SERIALIZER_NAME, type); |
---|
[44] | 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 | |
---|
[54] | 46 | broker = new Broker(env); |
---|
| 47 | bk = broker.lookup("bk", BrokerKiller.class); |
---|
| 48 | } |
---|
[44] | 49 | |
---|
[54] | 50 | @Parameters |
---|
| 51 | public static Collection<Object[]> data() { |
---|
[62] | 52 | Object[][] data = new Object[][] { { Serializer.JAVA }, { Serializer.GSON }, { Serializer.KRYO } }; |
---|
[54] | 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 { |
---|
[44] | 84 | bk.killServerBroker(); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | } |
---|