Introduce BGPTableType Registry
[bgpcep.git] / bgp / openconfig-spi / src / test / java / org / opendaylight / protocol / bgp / openconfig / spi / BGPTableTypeRegistryProviderActivatorTest.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.openconfig.spi;
10
11 import java.util.Collections;
12 import java.util.List;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
18 import org.opendaylight.yangtools.concepts.AbstractRegistration;
19
20 public class BGPTableTypeRegistryProviderActivatorTest {
21
22     @Test
23     public void testBGPTableTypeRegistryProviderActivator() {
24         final AbstractBGPTableTypeRegistryProviderActivator activator = new AbstractBGPTableTypeRegistryProviderActivator(){
25             @Override
26             protected List<AbstractRegistration> startBGPTableTypeRegistryProviderImpl(
27                     final BGPTableTypeRegistryProvider provider) {
28                 return Collections.singletonList(provider.registerBGPTableType(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, IPV4UNICAST.class));
29             }};
30
31         final SimpleBGPTableTypeRegistryProvider provider = new SimpleBGPTableTypeRegistryProvider();
32         activator.startBGPTableTypeRegistryProvider(provider);
33         Assert.assertTrue(provider.getTableType(IPV4UNICAST.class).isPresent());
34         activator.stopBGPTableTypeRegistryProvider();
35         Assert.assertFalse(provider.getTableType(IPV4UNICAST.class).isPresent());
36         activator.close();
37     }
38
39 }