--- /dev/null
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.yang.bmp.impl;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.contains;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import org.junit.Before;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Abstract base class for bmp module tests.
+ *
+ * @author Thomas Pantelis
+ */
+public class AbstractBmpModuleTest extends AbstractConfigTest {
+ @Before
+ public void setUp() throws Exception {
+ doAnswer(new Answer<Filter>() {
+ @Override
+ public Filter answer(final InvocationOnMock invocation) {
+ final String str = invocation.getArgumentAt(0, String.class);
+ final Filter mockFilter = mock(Filter.class);
+ doReturn(str).when(mockFilter).toString();
+ return mockFilter;
+ }
+ }).when(mockedContext).createFilter(anyString());
+
+ Mockito.doNothing().when(this.mockedContext).addServiceListener(any(ServiceListener.class), Mockito.anyString());
+ Mockito.doNothing().when(this.mockedContext).removeServiceListener(any(ServiceListener.class));
+
+ BGPExtensionProviderContext mockContext = mock(BGPExtensionProviderContext.class);
+ doReturn(mock(AddressFamilyRegistry.class)).when(mockContext).getAddressFamilyRegistry();
+ doReturn(mock(MessageRegistry.class)).when(mockContext).getMessageRegistry();
+ doReturn(mock(SubsequentAddressFamilyRegistry.class)).when(mockContext).getSubsequentAddressFamilyRegistry();
+ setupMockService(BGPExtensionProviderContext.class, mockContext);
+ }
+
+ void setupMockService(final Class<?> serviceInterface, final Object instance) throws Exception {
+ final ServiceReference<?> mockServiceRef = mock(ServiceReference.class);
+ doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
+ getServiceReferences(anyString(), contains(serviceInterface.getName()));
+ doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
+ getServiceReferences(serviceInterface.getName(), null);
+ doReturn(instance).when(mockedContext).getService(mockServiceRef);
+ }
+}
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleFactory;
import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleMXBean;
-public class BaseBmpParserModuleTest extends AbstractConfigTest {
+public class BaseBmpParserModuleTest extends AbstractBmpModuleTest {
private static final String INSTANCE_NAME = "parser-instance-bmp";
private static final String FACTORY_NAME = BaseBmpParserModuleFactory.NAME;
private static final String BGP_EXTENSION_INSTANCE_NAME = "extension-impl-bgp";
+ @Override
@Before
public void setUp() throws Exception {
+ super.setUp();
super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new BaseBmpParserModuleFactory(), new SimpleBGPExtensionProviderContextModuleFactory()));
}
*/
package org.opendaylight.controller.config.yang.bmp.impl;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.contains;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import javax.management.ObjectName;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.bmp.spi.SimpleBmpExtensionProviderContextModuleFactory;
import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleMXBean;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-public class BmpDispatcherImplModuleTest extends AbstractConfigTest {
+public class BmpDispatcherImplModuleTest extends AbstractBmpModuleTest {
private static final String INSTANCE_NAME = "bmp-message-fct";
private static final String FACTORY_NAME = BmpDispatcherImplModuleFactory.NAME;
private static final String BOSS_TG_INSTANCE_NAME = "boss-threadgroup-impl";
private static final String WORKER_TG_INSTANCE_NAME = "worker-threadgroup-impl";
+ @Override
@Before
public void setUp() throws Exception {
+ super.setUp();
super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext,
new BmpDispatcherImplModuleFactory(),
new NettyThreadgroupModuleFactory(),
new GlobalEventExecutorModuleFactory(),
new SimpleBmpExtensionProviderContextModuleFactory()));
- doAnswer(new Answer<Filter>() {
- @Override
- public Filter answer(InvocationOnMock invocation) {
- String str = invocation.getArgumentAt(0, String.class);
- Filter mockFilter = mock(Filter.class);
- doReturn(str).when(mockFilter).toString();
- return mockFilter;
- }
- }).when(mockedContext).createFilter(anyString());
- doNothing().when(mockedContext).addServiceListener(any(ServiceListener.class), anyString());
-
- setupMockService(EventLoopGroup.class);
- setupMockService(Timer.class);
- setupMockService(EventExecutor.class);
- }
-
- private void setupMockService(Class<?> serviceInterface) throws Exception {
- ServiceReference<?> mockServiceRef = mock(ServiceReference.class);
- doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
- getServiceReferences(anyString(), contains(serviceInterface.getName()));
- doReturn(mock(serviceInterface)).when(mockedContext).getService(mockServiceRef);
+ setupMockService(EventLoopGroup.class, mock(EventLoopGroup.class));
+ setupMockService(Timer.class, mock(Timer.class));
+ setupMockService(EventExecutor.class, mock(EventExecutor.class));
}
@Test
package org.opendaylight.controller.config.yang.bmp.impl;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.contains;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleFactory;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleListener;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
-public class BmpMonitorImplModuleTest extends AbstractConfigTest {
+public class BmpMonitorImplModuleTest extends AbstractBmpModuleTest {
private static final String FACTORY_NAME = BmpMonitorImplModuleFactory.NAME;
private static final String INSTANCE_NAME = "bmp-monitor-impl-instance";
@Mock private CheckedFuture<Void, TransactionCommitFailedException> mockedFuture;
@Mock private RpcResult<TransactionStatus> mockedResult;
+ @Override
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
+ super.setUp();
super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext,
new BmpMonitorImplModuleFactory(),
new RIBExtensionsImplModuleFactory(),
new GlobalEventExecutorModuleFactory(),
new SchemaServiceImplSingletonModuleFactory()));
- doAnswer(new Answer<Filter>() {
- @Override
- public Filter answer(final InvocationOnMock invocation) {
- final String str = invocation.getArgumentAt(0, String.class);
- final Filter mockFilter = mock(Filter.class);
- doReturn(str).when(mockFilter).toString();
- return mockFilter;
- }
- }).when(mockedContext).createFilter(anyString());
-
final ServiceReference<?> emptyServiceReference = mock(ServiceReference.class, "Empty");
final ServiceReference<?> classLoadingStrategySR = mock(ServiceReference.class, "ClassLoadingStrategy");
final ServiceReference<?> dataProviderServiceReference = mock(ServiceReference.class, "Data Provider");
final ServiceReference<?> schemaServiceReference = mock(ServiceReference.class, "schemaServiceReference");
- Mockito.doNothing().when(this.mockedContext).addServiceListener(any(ServiceListener.class), Mockito.anyString());
- Mockito.doNothing().when(this.mockedContext).removeServiceListener(any(ServiceListener.class));
-
Mockito.doNothing().when(this.mockedContext).addBundleListener(any(BundleListener.class));
Mockito.doNothing().when(this.mockedContext).removeBundleListener(any(BundleListener.class));
setupMockService(EventExecutor.class, AutoCloseableEventExecutor.CloseableEventExecutorMixin.globalEventExecutor());
}
- private void setupMockService(final Class<?> serviceInterface, final Object instance) throws Exception {
- final ServiceReference<?> mockServiceRef = mock(ServiceReference.class);
- doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
- getServiceReferences(anyString(), contains(serviceInterface.getName()));
- doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
- getServiceReferences(serviceInterface.getName(), null);
- doReturn(instance).when(mockedContext).getService(mockServiceRef);
- }
-
private static SchemaContext parseYangStreams(final Collection<ByteSource> streams) {
final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
try {
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">prefix:bgp-extensions-impl</type>
<name>global-bgp-extensions</name>
- <extension>
- <type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extension</type>
- <name>base-bgp-parser</name>
- </extension>
- <extension>
- <type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extension</type>
- <name>bgp-linkstate</name>
- </extension>
- <extension>
- <type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extension</type>
- <name>bgp-flowspec</name>
- </extension>
- <extension>
- <type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extension</type>
- <name>bgp-labeled-unicast</name>
- </extension>
- <extension>
- <type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extension</type>
- <name>bgp-vpn-ipv4</name>
- </extension>
- <extension>
- <type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extension</type>
- <name>bgp-vpn-ipv6</name>
- </extension>
- <extension>
- <type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extension</type>
- <name>bgp-evpn</name>
- </extension>
- </module>
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:base-bgp-parser</type>
- <name>base-bgp-parser</name>
</module>
+
<!-- Global bgp peer registry that should contain all configured bgp peers -->
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl">prefix:strict-bgp-peer-registry</type>
</service>
<service>
<type xmlns:bgpspi="urn:opendaylight:params:xml:ns:yang:controller:bgp:parser:spi">bgpspi:extension</type>
- <instance>
- <name>base-bgp-parser</name>
- <provider>/modules/module[type='base-bgp-parser'][name='base-bgp-parser']</provider>
- </instance>
<instance>
<name>bgp-linkstate</name>
<provider>/modules/module[type='bgp-linkstate'][name='bgp-linkstate']</provider>
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.bgp.evpn;
-
-import com.google.common.collect.Lists;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleTest;
-import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleTest;
-
-public final class EvpnModuleTest extends AbstractConfigTest {
- private static final String FACTORY_NAME = EvpnModuleFactory.NAME;
- private static final String INSTANCE_NAME = "bgp-evpn-impl";
-
- @Before
- public void setUp() {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new EvpnModuleFactory(),
- new SimpleBGPExtensionProviderContextModuleFactory(), new RIBExtensionsImplModuleFactory()));
- }
-
- @Test
- public void testLSTypeDefaultValue() throws Exception {
- final CommitStatus status = createEvpnModuleInstance();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 3, 0, 0);
- }
-
- @Test
- public void testCreateBean() throws Exception {
- final CommitStatus status = createEvpnModuleInstance();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 3, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws Exception {
- createEvpnModuleInstance();
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 3);
- }
-
- @Test
- public void testReconfigureInstance() throws Exception {
- createEvpnModuleInstance();
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 3);
- }
-
- private CommitStatus createEvpnModuleInstance() throws Exception {
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- final ObjectName evpnON = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-
- SimpleBGPExtensionProviderContextModuleTest.createBGPExtensionsModuleInstance(transaction, Lists.newArrayList(evpnON));
- RIBExtensionsImplModuleTest.createRIBExtensionsModuleInstance(transaction, Lists.newArrayList(evpnON));
- return transaction.commit();
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.bgp.flowspec;
-
-import com.google.common.collect.Lists;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleTest;
-import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleTest;
-
-/**
- * Created by cgasparini on 18.6.2015.
- */
-public class FlowspecModuleTest extends AbstractConfigTest {
-
- private static final String FACTORY_NAME = FlowspecModuleFactory.NAME;
- private static final String INSTANCE_NAME = "bgp-flowspec-impl";
-
- @Before
- public void setUp() {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new FlowspecModuleFactory(),
- new SimpleBGPExtensionProviderContextModuleFactory(), new RIBExtensionsImplModuleFactory()));
- }
-
- @Test
- public void testLSTypeDefaultValue() throws Exception {
- final CommitStatus status = createFlowspecModuleInstance();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 3, 0, 0);
- }
-
- @Test
- public void testCreateBean() throws Exception {
- final CommitStatus status = createFlowspecModuleInstance();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 3, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws Exception {
- createFlowspecModuleInstance();
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 3);
- }
-
- @Test
- public void testReconfigureInstance() throws Exception {
- createFlowspecModuleInstance();
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 3);
- }
-
- private CommitStatus createFlowspecModuleInstance() throws Exception {
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- final ObjectName flowspecON = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-
- SimpleBGPExtensionProviderContextModuleTest.createBGPExtensionsModuleInstance(transaction, Lists.newArrayList(flowspecON));
- RIBExtensionsImplModuleTest.createRIBExtensionsModuleInstance(transaction, Lists.newArrayList(flowspecON));
- return transaction.commit();
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.bgp.labeled.unicast;
-
-import com.google.common.collect.Lists;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleTest;
-import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleTest;
-
-public class LabeledUnicastModuleTest extends AbstractConfigTest {
-
- private static final String FACTORY_NAME = LabeledUnicastModuleFactory.NAME;
- private static final String INSTANCE_NAME = "bgp-labeled-unicast-impl";
-
- @Before
- public void setUp() {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new LabeledUnicastModuleFactory(),
- new SimpleBGPExtensionProviderContextModuleFactory(), new RIBExtensionsImplModuleFactory()));
- }
-
- @Test
- public void testLSTypeDefaultValue() throws Exception {
- final CommitStatus status = createLabeledUnicastModuleInstance();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 3, 0, 0);
- }
-
- @Test
- public void testCreateBean() throws Exception {
- final CommitStatus status = createLabeledUnicastModuleInstance();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 3, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws Exception {
- createLabeledUnicastModuleInstance();
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 3);
- }
-
- @Test
- public void testReconfigureInstance() throws Exception {
- createLabeledUnicastModuleInstance();
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 3);
- }
-
- private CommitStatus createLabeledUnicastModuleInstance() throws Exception {
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- final ObjectName LabeledUnicastON = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-
- SimpleBGPExtensionProviderContextModuleTest.createBGPExtensionsModuleInstance(transaction, Lists.newArrayList(LabeledUnicastON));
- RIBExtensionsImplModuleTest.createRIBExtensionsModuleInstance(transaction, Lists.newArrayList(LabeledUnicastON));
- return transaction.commit();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.config.yang.bgp.linkstate;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.contains;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleTest;
-import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleFactory;
-import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleTest;
-import org.opendaylight.controller.config.yang.rsvp.spi.SimpleRSVPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.rsvp.spi.SimpleRSVPExtensionProviderContextModuleMXBean;
-import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionProviderContext;
-import org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleRSVPExtensionProviderContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-
-public class LinkstateModuleTest extends AbstractConfigTest {
-
- private static final String FACTORY_NAME = LinkstateModuleFactory.NAME;
- private static final String INSTANCE_NAME = "bgp-linkstate-impl";
- private static final String RSVP_EXTENSION_INSTANCE_NAME = "extension-impl-rsvp";
- private ObjectName rspvInstance;
-
- @Before
- public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new
- LinkstateModuleFactory(), new SimpleBGPExtensionProviderContextModuleFactory(), new
- RIBExtensionsImplModuleFactory(), new SimpleRSVPExtensionProviderContextModuleFactory()));
-
- doAnswer(new Answer<Filter>() {
- @Override
- public Filter answer(final InvocationOnMock invocation) {
- final String str = invocation.getArgumentAt(0, String.class);
- final Filter mockFilter = mock(Filter.class);
- doReturn(str).when(mockFilter).toString();
- return mockFilter;
- }
- }).when(mockedContext).createFilter(anyString());
-
- Mockito.doNothing().when(this.mockedContext).addServiceListener(any(ServiceListener.class), Mockito.anyString());
- Mockito.doNothing().when(this.mockedContext).removeServiceListener(any(ServiceListener.class));
-
- setupMockService(RSVPExtensionProviderContext.class, new SimpleRSVPExtensionProviderContext());
- }
-
- private void setupMockService(final Class<?> serviceInterface, final Object instance) throws Exception {
- final ServiceReference<?> mockServiceRef = mock(ServiceReference.class);
- doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
- getServiceReferences(anyString(), contains(serviceInterface.getName()));
- doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
- getServiceReferences(serviceInterface.getName(), null);
- doReturn(instance).when(mockedContext).getService(mockServiceRef);
- }
-
- @Test
- public void testLSTypeDefaultValue() throws Exception {
- final CommitStatus status = createLinkstateModuleInstance(Optional.<Boolean>absent());
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 4, 0, 0);
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- final LinkstateModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), LinkstateModuleMXBean.class);
- assertTrue(mxBean.getIanaLinkstateAttributeType());
- }
-
- @Test
- public void testCreateBean() throws Exception {
- final CommitStatus status = createLinkstateModuleInstance(Optional.of(false));
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 4, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws Exception {
- createLinkstateModuleInstance(Optional.of(false));
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 4);
- }
-
- @Test
- public void testReconfigureInstance() throws Exception {
- createLinkstateModuleInstance(Optional.of(false));
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final LinkstateModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), LinkstateModuleMXBean.class);
- mxBean.setIanaLinkstateAttributeType(true);
- mxBean.setRsvpExtensions(rspvInstance);
- CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 3, 1);
- }
-
- private CommitStatus createLinkstateModuleInstance(final Optional<Boolean> ianaLSAttributeType) throws Exception {
- final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- final ObjectName linkstateON = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- final LinkstateModuleMXBean mxBean = transaction.newMXBeanProxy(linkstateON, LinkstateModuleMXBean.class);
- if(ianaLSAttributeType.isPresent()) {
- mxBean.setIanaLinkstateAttributeType(ianaLSAttributeType.get());
- }
- rspvInstance = createRsvpExtensionsInstance(transaction);
- mxBean.setRsvpExtensions(rspvInstance);
- SimpleBGPExtensionProviderContextModuleTest.createBGPExtensionsModuleInstance(transaction, Lists.newArrayList(linkstateON));
- RIBExtensionsImplModuleTest.createRIBExtensionsModuleInstance(transaction, Lists.newArrayList(linkstateON));
- return transaction.commit();
- }
-
- private ObjectName createRsvpExtensionsInstance(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
- final ObjectName nameCreated = transaction.createModule(SimpleRSVPExtensionProviderContextModuleFactory.NAME,
- RSVP_EXTENSION_INSTANCE_NAME);
- transaction.newMXBeanProxy(nameCreated, SimpleRSVPExtensionProviderContextModuleMXBean.class);
- return nameCreated;
- }
-}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+ <bean id="BGPActivator" class="org.opendaylight.protocol.bgp.parser.impl.BGPActivator"/>
+
+ <service ref="BGPActivator" interface="org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator"
+ odl:type="org.opendaylight.protocol.bgp.parser.impl.BGPActivator"/>
+</blueprint>
\ No newline at end of file
*/
package org.opendaylight.controller.config.yang.bgp.parser.spi;
-import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator;
-import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
+import org.osgi.framework.BundleContext;
/**
- *
+ * @deprecated Replaced by blueprint wiring
*/
+@Deprecated
public final class SimpleBGPExtensionProviderContextModule extends
org.opendaylight.controller.config.yang.bgp.parser.spi.AbstractSimpleBGPExtensionProviderContextModule {
+ private BundleContext bundleContext;
public SimpleBGPExtensionProviderContextModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
}
@Override
- public java.lang.AutoCloseable createInstance() {
- final class SimpleBGPExtensionProviderContextAutoCloseable extends SimpleBGPExtensionProviderContext implements AutoCloseable {
+ public AutoCloseable createInstance() {
+ final WaitingServiceTracker<BGPExtensionProviderContext> tracker =
+ WaitingServiceTracker.create(BGPExtensionProviderContext.class, bundleContext);
+ final BGPExtensionProviderContext service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+ return Reflection.newProxy(AutoCloseableBGPExtensionProviderContext.class, new AbstractInvocationHandler() {
@Override
- public void close() {
- for (final BGPExtensionProviderActivator e : getExtensionDependency()) {
- e.stop();
+ protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
+ if (method.getName().equals("close")) {
+ tracker.close();
+ return null;
+ } else {
+ return method.invoke(service, args);
}
}
- }
+ });
+ }
+
+ void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
- final SimpleBGPExtensionProviderContextAutoCloseable ret = new SimpleBGPExtensionProviderContextAutoCloseable();
- for (final BGPExtensionProviderActivator e : getExtensionDependency()) {
- e.start(ret);
- }
- return ret;
+ private static interface AutoCloseableBGPExtensionProviderContext extends BGPExtensionProviderContext, AutoCloseable {
}
}
*/
package org.opendaylight.controller.config.yang.bgp.parser.spi;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.osgi.framework.BundleContext;
+
/**
-*
-*/
-public class SimpleBGPExtensionProviderContextModuleFactory extends
- org.opendaylight.controller.config.yang.bgp.parser.spi.AbstractSimpleBGPExtensionProviderContextModuleFactory {
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class SimpleBGPExtensionProviderContextModuleFactory extends AbstractSimpleBGPExtensionProviderContextModuleFactory {
+ @Override
+ public SimpleBGPExtensionProviderContextModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+ SimpleBGPExtensionProviderContextModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
+ SimpleBGPExtensionProviderContextModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule,
+ oldInstance, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+ @Override
+ public SimpleBGPExtensionProviderContextModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ SimpleBGPExtensionProviderContextModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.parser.spi.pojo;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator;
+import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Starts and stops BGPExtensionProviderActivator instances for a BGPExtensionProviderContext.
+ *
+ * @author Thomas Pantelis
+ */
+public class SimpleBGPExtensionProviderContextActivator implements AutoCloseable {
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleBGPExtensionProviderContextActivator.class);
+
+ private final BGPExtensionProviderContext providerContext;
+ private final List<BGPExtensionProviderActivator> extensionActivators;
+
+ public SimpleBGPExtensionProviderContextActivator(final BGPExtensionProviderContext providerContext,
+ final List<BGPExtensionProviderActivator> extensionActivators) {
+ this.providerContext = Preconditions.checkNotNull(providerContext);
+ this.extensionActivators = Preconditions.checkNotNull(extensionActivators);
+ }
+
+ public void start() {
+ LOG.debug("Starting {} BGPExtensionProviderActivator instances", extensionActivators.size());
+
+ for(final BGPExtensionProviderActivator e : extensionActivators) {
+ e.start(providerContext);
+ }
+ }
+
+ @Override
+ public void close() {
+ LOG.debug("Stopping {} BGPExtensionProviderActivator instances", extensionActivators.size());
+
+ for(final BGPExtensionProviderActivator e : extensionActivators) {
+ e.stop();
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+ <!-- Obtains the specific list of BGPExtensionProviderActivator OSGi services announced via
+ META-INF/services/org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator resources.
+ -->
+ <odl:specific-reference-list id="extensionActivators" interface="org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator"/>
+
+ <bean id="extensionProviderContext" class="org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext"/>
+
+ <bean id="extensionProviderContextActivator" class="org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContextActivator"
+ init-method="start" destroy-method="close">
+ <argument ref="extensionProviderContext"/>
+ <argument ref="extensionActivators"/>
+ </bean>
+
+ <service ref="extensionProviderContext">
+ <interfaces>
+ <value>org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext</value>
+ <value>org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext</value>
+ </interfaces>
+ </service>
+</blueprint>
\ No newline at end of file
base "config:service-type";
config:java-class "org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator";
+ config:disable-osgi-service-registration;
}
identity bgp-extensions-impl {
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.bgp.parser.spi;
-
-import java.util.List;
-
-import javax.management.ObjectName;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-
-public class SimpleBGPExtensionProviderContextModuleTest extends AbstractConfigTest {
-
- private static final String FACTORY_NAME = SimpleBGPExtensionProviderContextModuleFactory.NAME;
- private static final String INSTANCE_NAME = "bgp-extensions-impl";
-
- @Before
- public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new SimpleBGPExtensionProviderContextModuleFactory()));
- }
-
- @Test
- public void testCreateBean() throws Exception {
- CommitStatus status = createInstance();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 1, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws Exception {
- createInstance();
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 1);
- }
-
- private CommitStatus createInstance() throws Exception {
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- return transaction.commit();
- }
-
- public static ObjectName createBGPExtensionsModuleInstance(final ConfigTransactionJMXClient transaction,
- final List<ObjectName> extensions) throws Exception {
- final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- SimpleBGPExtensionProviderContextModuleMXBean mxBean = transaction.newMXBeanProxy(objectName,
- SimpleBGPExtensionProviderContextModuleMXBean.class);
- mxBean.setExtension(extensions);
- return objectName;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-/**
- * Generated file
-
- * Generated from: yang module name: bgp-rib-impl yang module local name: base-bgp-parser
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Mon Nov 18 10:59:18 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-import org.opendaylight.protocol.bgp.parser.impl.BGPActivator;
-
-/**
- *
- */
-public final class BaseBGPParserModule extends org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBaseBGPParserModule {
-
- public BaseBGPParserModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public BaseBGPParserModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final BaseBGPParserModule oldModule,
- final java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- return new BGPActivator();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-/**
- * Generated file
-
- * Generated from: yang module name: bgp-rib-impl yang module local name: base-bgp-parser
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Mon Nov 18 10:59:18 CET 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-/**
-*
-*/
-public class BaseBGPParserModuleFactory extends org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBaseBGPParserModuleFactory {
-
-}
"Initial revision";
}
- identity base-bgp-parser {
- base config:module-type;
- config:java-name-prefix BaseBGPParser;
- config:provided-service bgpspi:extension;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case base-bgp-parser {
- when "/config:modules/config:module/config:type = 'base-bgp-parser'";
- }
- }
-
identity bgp-dispatcher {
description
"Service representing a BGP Dispatcher.";
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider;
+import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
+import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.RibId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId;
BindingToNormalizedNodeCodecFactory.getOrCreateInstance(
GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), mockedSchemaService);
+ BGPExtensionProviderContext mockContext = mock(BGPExtensionProviderContext.class);
+ doReturn(mock(MessageRegistry.class)).when(mockContext).getMessageRegistry();
+ setupMockService(BGPExtensionProviderContext.class, mockContext);
+
setupMockService(EventLoopGroup.class, NioEventLoopGroupCloseable.newInstance(0));
setupMockService(EventExecutor.class, AutoCloseableEventExecutor.CloseableEventExecutorMixin.globalEventExecutor());
setupMockService(DOMMountPointService.class, mock(DOMMountPointService.class));
}
- private void setupMockService(final Class<?> serviceInterface, final Object instance) throws Exception {
+ protected void setupMockService(final Class<?> serviceInterface, final Object instance) throws Exception {
final ServiceReference<?> mockServiceRef = mock(ServiceReference.class);
doReturn(new ServiceReference[]{mockServiceRef}).when(mockedContext).
getServiceReferences(anyString(), contains(serviceInterface.getName()));
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.config.yang.bgp.rib.impl;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-
-public class BaseBGPParserModuleTest extends AbstractConfigTest {
-
- private static final String INSTANCE_NAME = "bgp-parser-instance";
- private static final String FACTORY_NAME = BaseBGPParserModuleFactory.NAME;
-
- @Before
- public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new BaseBGPParserModuleFactory()));
- }
-
- @Test
- public void testCreateBean() throws Exception {
- final CommitStatus status = createInstance();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 1, 0, 0);
- }
-
- @Test
- public void testReusingOldInstance() throws Exception {
- createInstance();
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- assertBeanCount(1, FACTORY_NAME);
- final CommitStatus status = transaction.commit();
- assertBeanCount(1, FACTORY_NAME);
- assertStatus(status, 0, 0, 1);
- }
-
- private CommitStatus createInstance() throws Exception {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
- return transaction.commit();
- }
-}
base "config:service-type";
config:java-class "org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator";
+ config:disable-osgi-service-registration;
}
identity bgp-rib-extensions-impl {