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
8 package org.opendaylight.protocol.bgp.openconfig.spi;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertNull;
13 import static org.junit.Assert.assertThrows;
15 import org.junit.Test;
16 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
17 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
18 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily;
22 import org.opendaylight.yangtools.concepts.Registration;
24 public class SimpleBGPTableTypeRegistryProviderTest {
25 private final BGPTableTypeRegistryProvider provider = new SimpleBGPTableTypeRegistryProvider();
26 private final Registration registration = provider.registerBGPTableType(
27 Ipv4AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE, IPV4UNICAST.VALUE);
30 public void testBGPTableTypeRegistryProvider() {
31 assertEquals(IPV4UNICAST.VALUE, provider.getAfiSafiType(
32 new BgpTableTypeImpl(Ipv4AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE)));
33 assertNull(provider.getAfiSafiType(
34 new BgpTableTypeImpl(Ipv6AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE)));
36 assertNotNull(provider.getTableType(IPV4UNICAST.VALUE));
37 assertNull(provider.getTableType(IPV6UNICAST.VALUE));
40 assertNull(provider.getTableType(IPV4UNICAST.VALUE));
44 public void testDuplicatedRegistration() {
45 assertThrows(IllegalStateException.class, () -> provider.registerBGPTableType(Ipv4AddressFamily.VALUE,
46 UnicastSubsequentAddressFamily.VALUE, IPV4UNICAST.VALUE));