[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 | |
---|
[83] | 18 | /** |
---|
| 19 | * |
---|
| 20 | * @author Sergi Toda <sergi.toda@estudiants.urv.cat> |
---|
| 21 | * |
---|
| 22 | */ |
---|
[54] | 23 | @RunWith(value = Parameterized.class) |
---|
| 24 | public class StopBrokerTest { |
---|
| 25 | |
---|
| 26 | private static Broker broker; |
---|
| 27 | private static BrokerKiller bk; |
---|
| 28 | |
---|
| 29 | public StopBrokerTest(String type) throws Exception { |
---|
[44] | 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) |
---|
[77] | 35 | env.setProperty(ParameterQueue.RABBIT_HOST, "127.0.0.1"); |
---|
| 36 | env.setProperty(ParameterQueue.RABBIT_PORT, "5672"); |
---|
[84] | 37 | env.setProperty(ParameterQueue.DURABLE_QUEUE, "false"); |
---|
[77] | 38 | env.setProperty(ParameterQueue.PROXY_SERIALIZER, type); |
---|
| 39 | env.setProperty(ParameterQueue.ENABLE_COMPRESSION, "false"); |
---|
[44] | 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 | |
---|
[54] | 50 | broker = new Broker(env); |
---|
| 51 | bk = broker.lookup("bk", BrokerKiller.class); |
---|
| 52 | } |
---|
[44] | 53 | |
---|
[54] | 54 | @Parameters |
---|
| 55 | public static Collection<Object[]> data() { |
---|
[62] | 56 | Object[][] data = new Object[][] { { Serializer.JAVA }, { Serializer.GSON }, { Serializer.KRYO } }; |
---|
[54] | 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) |
---|
[77] | 67 | env.setProperty(ParameterQueue.RABBIT_HOST, "127.0.0.1"); |
---|
| 68 | env.setProperty(ParameterQueue.RABBIT_PORT, "5672"); |
---|
[84] | 69 | env.setProperty(ParameterQueue.DURABLE_QUEUE, "false"); |
---|
[77] | 70 | env.setProperty(ParameterQueue.ENABLE_COMPRESSION, "false"); |
---|
[54] | 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 { |
---|
[44] | 88 | bk.killServerBroker(); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | } |
---|