Implementation for enabling remote rpc calls between 2 instances of md-sal
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / implementation / src / test / java / org / opendaylight / controller / sal / connector / remoterpc / ClientTest.java
1 package org.opendaylight.controller.sal.connector.remoterpc;
2
3 import junit.framework.Assert;
4 import org.junit.Before;
5 import org.junit.Test;
6 import org.opendaylight.controller.sal.connector.remoterpc.dto.MessageWrapper;
7 import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
8
9 import java.util.concurrent.TimeoutException;
10
11 public class ClientTest {
12
13     Client client;
14     
15   @Before
16   public void setup(){
17       client = new Client();
18       client.getRequestQueue().clear();
19   }
20
21   @Test
22   public void testStop() throws Exception {
23
24   }
25
26   @Test
27   public void testPool() throws Exception {
28
29   }
30
31   @Test
32   public void process_AddAMessage_ShouldAddToQueue() throws Exception {
33     client.process(getEmptyMessageWrapper());
34     Assert.assertEquals(1, client.getRequestQueue().size());
35   }
36
37   /**
38    * Queue size is 100. Adding 101 message should time out in 2 sec
39    * if server does not process it
40    * @throws Exception
41    */
42   @Test(expected = TimeoutException.class)
43   public void process_Add101Message_ShouldThrow() throws Exception {
44     for (int i=0;i<101;i++){
45       client.process(getEmptyMessageWrapper());
46     }
47   }
48
49   @Test
50   public void testStart() throws Exception {
51   }
52
53   private MessageWrapper getEmptyMessageWrapper(){
54     return new MessageWrapper(new Message(), null);
55   }
56 }