2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.mdsal.dom.schema.osgi.impl;
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.doNothing;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.verifyNoMoreInteractions;
15 import org.apache.karaf.features.FeaturesService;
16 import org.junit.After;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.mockito.Mock;
21 import org.mockito.junit.MockitoJUnitRunner;
22 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
23 import org.osgi.framework.Bundle;
24 import org.osgi.framework.BundleContext;
25 import org.osgi.service.component.ComponentFactory;
27 @RunWith(MockitoJUnitRunner.StrictStubs.class)
28 public class OSGiModelRuntimeTest {
30 private YangParserFactory parserFactory;
32 private ComponentFactory<OSGiModuleInfoSnapshotImpl> contextFactory;
34 private BundleContext bundleContext;
36 private OSGiModelRuntime target;
39 public void before() {
40 doReturn(new Bundle[0]).when(bundleContext).getBundles();
41 doNothing().when(bundleContext).addBundleListener(any());
42 doReturn(null).when(bundleContext).getServiceReference(FeaturesService.class);
43 target = new OSGiModelRuntime(parserFactory, contextFactory, bundleContext);
48 verifyNoMoreInteractions(parserFactory);
49 verifyNoMoreInteractions(contextFactory);
50 verifyNoMoreInteractions(bundleContext);
54 public void testActivate() {
55 // Before does all we need
59 public void testDeactivate() {
60 doNothing().when(bundleContext).removeBundleListener(any());