2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.protocol.bgp.rib.impl.config;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
13 import static org.mockito.internal.verification.VerificationModeFactory.times;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.mockito.Mockito;
18 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder;
19 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
20 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.Config2;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev171207.Config2Builder;
26 public class AppPeerTest extends AbstractConfig {
27 private static final AppPeer APP_PEER = new AppPeer();
28 private final Neighbor neighbor = new NeighborBuilder()
29 .setConfig(new ConfigBuilder().addAugmentation(Config2.class,
30 new Config2Builder().setPeerGroup(OpenConfigMappingUtil.APPLICATION_PEER_GROUP_NAME)
32 .setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build();
36 public void setUp() throws Exception {
41 public void testAppPeer() {
42 APP_PEER.start(this.rib, this.neighbor, this.tableTypeRegistry);
43 Mockito.verify(this.rib).getYangRibId();
44 Mockito.verify(this.rib).getService();
45 Mockito.verify(this.rib, times(1)).getLocalTablesKeys();
47 APP_PEER.instantiateServiceInstance();
48 Mockito.verify(this.rib, times(2)).getYangRibId();
49 Mockito.verify(this.rib, times(2)).getRibSupportContext();
50 Mockito.verify(this.rib, times(2)).getLocalTablesKeys();
51 Mockito.verify(this.domTx).newWriteOnlyTransaction();
53 APP_PEER.closeServiceInstance();
56 APP_PEER.restart(this.rib, this.tableTypeRegistry);
57 APP_PEER.instantiateServiceInstance();
58 Mockito.verify(this.rib, times(4)).getYangRibId();
59 Mockito.verify(this.rib, times(2)).getService();
60 Mockito.verify(this.listener).close();
62 assertTrue(APP_PEER.containsEqualConfiguration(this.neighbor));
63 assertFalse(APP_PEER.containsEqualConfiguration(new NeighborBuilder()
64 .setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
65 APP_PEER.closeServiceInstance();