add test case
[vfc/nfvo/driver/ems.git] / ems / boco / src / test / java / org / onap / vfc / nfvo / emsdriver / messagemgr / MessageChannelTest.java
1 /**
2  * Copyright 2017 BOCO Corporation.  CMCC Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.vfc.nfvo.emsdriver.messagemgr;
17
18 import static org.junit.Assert.*;
19
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.onap.vfc.nfvo.emsdriver.messagemgr.MessageChannel;
23
24 public class MessageChannelTest {
25
26         private MessageChannel messageChannel;
27         @Before
28     public void setUp() {
29                 messageChannel = new MessageChannel();
30         }
31         
32         @Test
33         public void MessageChannel(){
34                 MessageChannel messageChannel = new MessageChannel(10);
35                 assertNotNull(messageChannel.getQueue());
36                 MessageChannel messageChannel1 = new MessageChannel(0);
37                 assertNotNull(messageChannel1.getQueue());
38         }
39         
40         @Test
41         public void put() throws Exception{
42                 Object obj = new Object();
43                 messageChannel.put(obj);
44                 
45                 assertEquals(1, messageChannel.size());
46         }
47         
48         @Test
49         public void get() throws Exception{
50                 Object obj = new Object();
51                 messageChannel.put(obj);
52                 Object objr = messageChannel.get();
53                 assertNotNull(objr);
54         }
55         
56         @Test
57         public void poll() throws Exception{
58                 Object obj = new Object();
59                 messageChannel.put(obj);
60                 Object objr = messageChannel.poll();
61                 assertNotNull(objr);
62         }
63         
64         @Test
65         public void clear() throws Exception{
66                 Object obj = new Object();
67                 messageChannel.put(obj);
68                 messageChannel.clear();
69                 assertEquals(0, messageChannel.size());
70         }
71         
72 }