Changeset 47 for trunk/src/test/java
- Timestamp:
- 06/18/13 16:51:22 (11 years ago)
- Location:
- trunk/src/test/java/omq/test
- Files:
-
- 3 added
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/test/java/omq/test/calculator/Calculator.java
r46 r47 23 23 public void asyncDivideByZero() throws IOException, SerializerException; 24 24 25 @SyncMethod 25 @SyncMethod(timeout = 1500) 26 26 public int divideByZero(); 27 27 -
trunk/src/test/java/omq/test/calculator/ClientJava.java
r46 r47 9 9 import omq.common.util.Serializer; 10 10 11 import org.junit.AfterClass; 11 12 import org.junit.BeforeClass; 12 13 import org.junit.Test; 13 14 14 public class Client Test{15 public class ClientJava { 15 16 private static Calculator remoteCalc; 16 17 private static Calculator remoteCalc2; … … 41 42 remoteCalc = (Calculator) Broker.lookup("calculator1", Calculator.class); 42 43 remoteCalc2 = (Calculator) Broker.lookup("calculator2", Calculator.class); 44 } 45 46 @AfterClass 47 public static void stop() throws Exception { 48 Broker.stopBroker(); 49 Thread.sleep(1000); 43 50 } 44 51 -
trunk/src/test/java/omq/test/calculator/ClientTest.java
r46 r47 1 1 package omq.test.calculator; 2 2 3 import static org.junit.Assert.assertEquals; 3 import org.junit.runner.RunWith; 4 import org.junit.runners.Suite; 4 5 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 11 import org.junit.BeforeClass; 12 import org.junit.Test; 13 6 @RunWith(Suite.class) 7 @Suite.SuiteClasses({ ClientJava.class, ClientGson.class, ClientKryo.class }) 14 8 public class ClientTest { 15 private static Calculator remoteCalc;16 private static Calculator remoteCalc2;17 18 @BeforeClass19 public static void startClient() throws Exception {20 Properties env = new Properties();21 env.setProperty(ParameterQueue.USER_NAME, "guest");22 env.setProperty(ParameterQueue.USER_PASS, "guest");23 24 // Set host info of rabbimq (where it is)25 env.setProperty(ParameterQueue.SERVER_HOST, "127.0.0.1");26 env.setProperty(ParameterQueue.SERVER_PORT, "5672");27 env.setProperty(ParameterQueue.DURABLE_QUEUES, "false");28 env.setProperty(ParameterQueue.SERIALIZER_NAME, Serializer.java);29 env.setProperty(ParameterQueue.ENABLECOMPRESSION, "false");30 31 // Set info about where the message will be sent32 env.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_exchange");33 // env.setProperty(ParameterQueue.DEBUGFILE, "c:\\middlewareDebug");34 35 // Set info about the queue & the exchange where the ResponseListener36 // will listen to.37 env.setProperty(ParameterQueue.RPC_REPLY_QUEUE, "reply_queue");38 env.setProperty(ParameterQueue.EVENT_REPLY_QUEUE, "event_queue");39 40 Broker.initBroker(env);41 remoteCalc = (Calculator) Broker.lookup("calculator1", Calculator.class);42 remoteCalc2 = (Calculator) Broker.lookup("calculator2", Calculator.class);43 }44 45 @Test46 public void add() throws Exception {47 int x = 10;48 int y = 20;49 50 int sync = remoteCalc.add(x, y);51 int sum = x + y;52 53 assertEquals(sum, sync);54 }55 56 @Test57 public void add2() throws Exception {58 int x = 10;59 int y = 20;60 61 int sync = remoteCalc2.add(x, y);62 int sum = x + y;63 64 assertEquals(sum, sync);65 }66 67 @Test68 public void mult() throws Exception {69 int x = 5;70 int y = 15;71 72 remoteCalc.mult(x, y);73 Thread.sleep(200);74 }75 76 @Test77 public void notifyEvent() throws Exception {78 ZeroListener zL = new ZeroListener("zero-event");79 80 remoteCalc.addListener(zL);81 82 remoteCalc.asyncDivideByZero();83 84 Thread.sleep(200);85 }86 87 @Test88 public void sendMessage() throws Exception {89 Message m = new Message(2334, "Hello objectmq");90 remoteCalc.sendMessage(m);91 }92 93 @Test(expected = ArithmeticException.class)94 public void divideByZero() {95 remoteCalc.divideByZero();96 }97 9 } -
trunk/src/test/java/omq/test/calculator/ServerTest.java
r46 r47 2 2 3 3 import java.util.Properties; 4 5 import org.junit.Test; 4 6 5 7 import omq.common.broker.Broker; … … 8 10 9 11 public class ServerTest { 10 private static CalculatorImpl calc;11 private static CalculatorImpl calc2;12 12 13 public static void main(String[] args) throws Exception { 13 private CalculatorImpl calc; 14 private CalculatorImpl calc2; 15 16 @Test 17 public void serverTest() throws Exception { 14 18 Properties env = new Properties(); 15 19 env.setProperty(ParameterQueue.USER_NAME, "guest"); … … 35 39 36 40 System.out.println("Server started"); 41 42 Thread.sleep(60 * 60 * 1000); 37 43 } 38 44 } -
trunk/src/test/java/omq/test/exception/ClientTest.java
r46 r47 4 4 5 5 import java.lang.reflect.UndeclaredThrowableException; 6 import java.util.Arrays; 7 import java.util.Collection; 6 8 import java.util.Properties; 7 9 … … 10 12 import omq.common.util.Serializer; 11 13 12 import org.junit. BeforeClass;14 import org.junit.After; 13 15 import org.junit.Test; 16 import org.junit.runner.RunWith; 17 import org.junit.runners.Parameterized; 18 import org.junit.runners.Parameterized.Parameters; 14 19 20 @RunWith(value = Parameterized.class) 15 21 public class ClientTest { 16 private staticClientInterface client;22 private ClientInterface client; 17 23 18 @BeforeClass 19 public static void startClient() throws Exception { 24 public ClientTest(String type) throws Exception { 20 25 Properties env = new Properties(); 21 26 env.setProperty(ParameterQueue.USER_NAME, "guest"); … … 26 31 env.setProperty(ParameterQueue.SERVER_PORT, "5672"); 27 32 env.setProperty(ParameterQueue.DURABLE_QUEUES, "false"); 28 env.setProperty(ParameterQueue.SERIALIZER_NAME, Serializer.kryo);33 env.setProperty(ParameterQueue.SERIALIZER_NAME, type); 29 34 env.setProperty(ParameterQueue.ENABLECOMPRESSION, "false"); 30 35 … … 39 44 Broker.initBroker(env); 40 45 client = (ClientInterface) Broker.lookup("server", ClientInterface.class); 46 } 47 48 @Parameters 49 public static Collection<Object[]> data() { 50 Object[][] data = new Object[][] { { Serializer.java }, { Serializer.gson }, { Serializer.kryo } }; 51 return Arrays.asList(data); 52 } 53 54 @After 55 public void stop() throws Exception { 56 Broker.stopBroker(); 41 57 } 42 58 -
trunk/src/test/java/omq/test/exception/ServerTest.java
r46 r47 5 5 import omq.common.broker.Broker; 6 6 import omq.common.util.ParameterQueue; 7 import omq.common.util.Serializer; 7 8 import org.junit.Test; 8 9 9 10 public class ServerTest { 10 11 11 public static void main(String[] args) throws Exception { 12 @Test 13 public void test() throws Exception { 12 14 Properties env = new Properties(); 13 15 env.setProperty(ParameterQueue.USER_NAME, "guest"); … … 18 20 env.setProperty(ParameterQueue.SERVER_PORT, "5672"); 19 21 env.setProperty(ParameterQueue.DURABLE_QUEUES, "false"); 20 env.setProperty(ParameterQueue.SERIALIZER_NAME, Serializer.kryo);21 22 env.setProperty(ParameterQueue.ENABLECOMPRESSION, "false"); 22 23 … … 29 30 Broker.initBroker(env); 30 31 Broker.bind("server", server); 32 33 Thread.sleep(60 * 60 * 1000); 31 34 } 32 35 } -
trunk/src/test/java/omq/test/faultTolerance/ServerTest.java
r46 r47 2 2 3 3 import java.util.Properties; 4 5 import org.junit.Test; 4 6 5 7 import omq.common.broker.Broker; … … 11 13 private static CalculatorImpl calc; 12 14 13 public static void main(String[] args) throws Exception { 15 @Test 16 public void test() throws Exception { 14 17 Properties env = new Properties(); 15 18 env.setProperty(ParameterQueue.USER_NAME, "guest"); … … 33 36 34 37 System.out.println("Server started"); 38 39 Thread.sleep(60 * 1000); 35 40 } 36 41 }
Note: See TracChangeset
for help on using the changeset viewer.