63e55ce77fa95c1eab58d4a77c5ab1aa8fbf56fb
[bgpcep.git] / bgp / bmp-spi / src / test / java / org / opendaylight / protocol / bmp / spi / registry / AbstractBmpExtensionProviderActivatorTest.java
1 /*
2  * Copyright (c) 2015 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.bmp.spi.registry;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.junit.Test;
13 import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
14
15 public class AbstractBmpExtensionProviderActivatorTest {
16
17     private final SimpleAbstractBmpExtensionProviderActivator activator = new SimpleAbstractBmpExtensionProviderActivator();
18     private static final SimpleBmpExtensionProviderContext context = new SimpleBmpExtensionProviderContext();
19
20
21     @Test
22     public void testStartActivator() throws BmpDeserializationException {
23         this.activator.start(context);
24         this.activator.close();
25     }
26
27     @Test(expected=IllegalStateException.class)
28     public void testStopActivator() {
29         this.activator.close();
30     }
31
32     private static class SimpleAbstractBmpExtensionProviderActivator extends AbstractBmpExtensionProviderActivator {
33         @Override
34         protected List<AutoCloseable> startImpl(final BmpExtensionProviderContext context) {
35             final List<AutoCloseable> reg = new ArrayList<AutoCloseable>();
36             reg.add(context.registerBmpMessageParser(1, new SimpleBmpMessageRegistry()));
37             return reg;
38         }
39     }
40
41 }