Bump to odlparent-9.0.0/yangtools-7.0.1-SNAPSHOT
[mdsal.git] / dom / mdsal-dom-schema-osgi / src / test / java / org / opendaylight / mdsal / dom / schema / osgi / impl / OSGiModelRuntimeTest.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.mdsal.dom.schema.osgi.impl;
9
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;
14
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;
26
27 @RunWith(MockitoJUnitRunner.StrictStubs.class)
28 public class OSGiModelRuntimeTest {
29     @Mock
30     private YangParserFactory parserFactory;
31     @Mock
32     private ComponentFactory contextFactory;
33     @Mock
34     private BundleContext bundleContext;
35
36     private OSGiModelRuntime target;
37
38     @Before
39     public void before() {
40         target = new OSGiModelRuntime();
41         target.parserFactory = parserFactory;
42         target.contextFactory = contextFactory;
43         doReturn(null).when(bundleContext).getServiceReference(FeaturesService.class);
44     }
45
46     @After
47     public void after() {
48         verifyNoMoreInteractions(parserFactory);
49         verifyNoMoreInteractions(contextFactory);
50         verifyNoMoreInteractions(bundleContext);
51     }
52
53     @Test
54     public void testActivate() {
55         doReturn(new Bundle[0]).when(bundleContext).getBundles();
56         doNothing().when(bundleContext).addBundleListener(any());
57         target.activate(bundleContext);
58     }
59
60     @Test
61     public void testDeactivate() {
62         testActivate();
63         doNothing().when(bundleContext).removeBundleListener(any());
64         target.deactivate();
65     }
66 }