2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Ericsson
6 * =============================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.appc.oam.util;
24 import static org.junit.Assert.assertEquals;
25 import org.junit.Test;
26 import org.mockito.Mockito;
27 import org.osgi.framework.Bundle;
29 public class BundleFilterTest {
32 public void testBundleFilter() {
33 Bundle mockBundle1 = Mockito.mock(Bundle.class);
34 Bundle mockBundle2 = Mockito.mock(Bundle.class);
35 Mockito.doReturn("Bundle-regex1").when(mockBundle1).getSymbolicName();
36 Mockito.doReturn("Bundle-regex2").when(mockBundle2).getSymbolicName();
37 Bundle[] bundles = {mockBundle1, mockBundle2};
38 String[] stopRegex = {"Bundle-regex1"};
39 String[] exceptRegex = {"NOT_MATCHING_REGEX"};
40 BundleFilter mockBundleFilter = Mockito.spy(new BundleFilter(stopRegex, exceptRegex, bundles));
41 assertEquals(1, mockBundleFilter.getBundlesToStop().size());
42 assertEquals(1, mockBundleFilter.getBundlesToNotStop().size());