MVPN RFC6514 Extendend communities
[bgpcep.git] / bgp / l3vpn / src / test / java / org / opendaylight / protocol / bgp / l3vpn / TableTypeActivatorTest.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.l3vpn;
10
11 import java.util.Optional;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider;
15 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
16 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
17 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.L3VPNIPV4UNICAST;
18 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.L3VPNIPV6UNICAST;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.MplsLabeledVpnSubsequentAddressFamily;
23
24 public class TableTypeActivatorTest {
25
26     private static final BgpTableType IPV4 = new BgpTableTypeImpl(Ipv4AddressFamily.class,
27             MplsLabeledVpnSubsequentAddressFamily.class);
28     private static final BgpTableType IPV6 = new BgpTableTypeImpl(Ipv6AddressFamily.class,
29             MplsLabeledVpnSubsequentAddressFamily.class);
30
31     @Test
32     public void testActivator() {
33         final TableTypeActivator tableTypeActivator = new TableTypeActivator();
34         final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
35         tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
36
37         final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(IPV4);
38         Assert.assertEquals(L3VPNIPV4UNICAST.class, afiSafiType.get());
39         final Optional<Class<? extends AfiSafiType>> afiSafiType2 = registry.getAfiSafiType(IPV6);
40         Assert.assertEquals(L3VPNIPV6UNICAST.class, afiSafiType2.get());
41
42         final Optional<BgpTableType> tableType = registry.getTableType(L3VPNIPV4UNICAST.class);
43         Assert.assertEquals(IPV4, tableType.get());
44         final Optional<BgpTableType> tableType2 = registry.getTableType(L3VPNIPV6UNICAST.class);
45         Assert.assertEquals(IPV6, tableType2.get());
46
47         tableTypeActivator.stopBGPTableTypeRegistryProvider();
48         tableTypeActivator.close();
49     }
50
51 }