Initial framework migration to netty.
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / BGPImplTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.bgp.rib.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.Matchers.any;
12 import static org.mockito.Mockito.doReturn;
13
14 import java.io.IOException;
15 import java.util.Collections;
16
17 import org.junit.After;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.mockito.Mock;
21 import org.mockito.MockitoAnnotations;
22 import org.opendaylight.protocol.bgp.parser.BGPParameter;
23 import org.opendaylight.protocol.bgp.rib.impl.BGPImpl.BGPListenerRegistration;
24 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPConnection;
25 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
26 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
27 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal;
28 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
29
30 public class BGPImplTest {
31
32         @Mock
33         private BGPDispatcher disp;
34
35         @Mock
36         private BGPSessionProposal prop;
37
38         @Mock
39         private ProtocolMessageFactory parser;
40
41         private BGPImpl bgp;
42
43         @Before
44         public void setUp() throws IOException {
45                 MockitoAnnotations.initMocks(this);
46                 doReturn("").when(this.parser).toString();
47                 doReturn(null).when(this.disp).createClient(any(BGPConnection.class), any(ProtocolMessageFactory.class));
48         }
49
50         @Test
51         public void testBgpImpl() throws IOException {
52                 doReturn(new BGPSessionPreferences(null, 0, null, Collections.<BGPParameter> emptyList())).when(this.prop).getProposal();
53                 this.bgp = new BGPImpl(this.disp, this.parser, null, this.prop, null);
54                 final BGPListenerRegistration reg = (BGPListenerRegistration) this.bgp.registerUpdateListener(new SimpleSessionListener());
55                 assertEquals(SimpleSessionListener.class, reg.getListener().getClass());
56         }
57
58         @After
59         public void tearDown() {
60                 this.bgp.close();
61         }
62 }