- Timestamp:
- 05/20/13 19:45:19 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/objectmq/src/omq/ztest/calculator/CalculatorTest.java
r11 r15 12 12 13 13 public class CalculatorTest { 14 private static CalculatorImpl calc;15 14 private static Calculator remoteCalc; 16 17 @BeforeClass 18 public static void startServer() throws Exception { 19 Properties env = new Properties(); 20 env.setProperty(ParameterQueue.USER_NAME, "guest"); 21 env.setProperty(ParameterQueue.USER_PASS, "guest"); 22 23 // Get host info of rabbimq (where it is) 24 env.setProperty(ParameterQueue.SERVER_HOST, "10.30.239.228"); 25 env.setProperty(ParameterQueue.SERVER_PORT, "5672"); 26 env.setProperty(ParameterQueue.SERIALIZERNAME, "omq.common.util.Serializers.KryoImp"); 27 env.setProperty(ParameterQueue.ENABLECOMPRESSION, "true"); 28 29 // Get info about the queue & the exchange where the RemoteListener will 30 // listen to. 31 env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange"); 32 env.setProperty(ParameterQueue.RPC_QUEUE, "rpc_queue"); 33 env.setProperty(ParameterQueue.RPC_ROUTING_KEY, "rpc"); 34 35 calc = new CalculatorImpl(); 36 37 Broker.initBroker(env); 38 Broker.bind(Calculator.class.getSimpleName(), calc); 39 } 15 private static Calculator remoteCalc2; 40 16 41 17 @BeforeClass … … 46 22 47 23 // Set host info of rabbimq (where it is) 48 env.setProperty(ParameterQueue.SERVER_HOST, "1 0.30.239.228");24 env.setProperty(ParameterQueue.SERVER_HOST, "127.0.0.1"); 49 25 env.setProperty(ParameterQueue.SERVER_PORT, "5672"); 50 26 env.setProperty(ParameterQueue.SERIALIZERNAME, "omq.common.util.Serializers.KryoImp"); 51 env.setProperty(ParameterQueue.ENABLECOMPRESSION, " true");52 27 env.setProperty(ParameterQueue.ENABLECOMPRESSION, "false"); 28 53 29 // Set info about where the message will be sent 54 30 env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange"); 55 env.setProperty(ParameterQueue.RPC_ROUTING_KEY, "rpc");56 31 57 32 // Set info about the queue & the exchange where the ResponseListener … … 61 36 62 37 Broker.initBroker(env); 63 remoteCalc = (Calculator) Broker.lookup(Calculator.class.getSimpleName(), Calculator.class); 38 remoteCalc = (Calculator) Broker.lookup("calculator1", Calculator.class); 39 remoteCalc2 = (Calculator) Broker.lookup("calculator2", Calculator.class); 64 40 } 65 41 … … 76 52 77 53 @Test 54 public void add2() throws Exception { 55 int x = 10; 56 int y = 20; 57 58 int sync = remoteCalc2.add(x, y); 59 int sum = x + y; 60 61 assertEquals(sum, sync); 62 } 63 64 @Test 78 65 public void mult() throws Exception { 79 66 int x = 5; … … 82 69 remoteCalc.mult(x, y); 83 70 Thread.sleep(200); 84 85 int mult = x * y;86 87 assertEquals(mult, calc.getMult());88 71 } 89 72 }
Note: See TracChangeset
for help on using the changeset viewer.