2 * Copyright (c) 2016 Red Hat, Inc. 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.odlparent.bundles4test;
10 import static com.google.common.truth.Truth.assertThat;
12 import java.util.Arrays;
13 import org.junit.Test;
14 import org.osgi.framework.Bundle;
15 import org.osgi.framework.ServiceReference;
18 * Unit test for ServiceReferenceUtil.
20 * @author Michael Vorburger.ch
22 public class ServiceReferenceUtilTest {
25 public void testGetUsingBundleSymbolicNames() {
26 assertThat(new ServiceReferenceUtil().getUsingBundleSymbolicNames(getServiceReference())).isEmpty();
30 public void testGetProperties() {
31 assertThat(new ServiceReferenceUtil().getProperties(getServiceReference())).containsExactly(
32 "property1", "value1",
33 "property2", Arrays.asList(new String[] { "value2.1", "value2.2" }));
36 private ServiceReference<?> getServiceReference() {
37 return new ServiceReference<Object>() {
40 public Object getProperty(String key) {
41 if ("property1".equals(key)) {
43 } else if ("property2".equals(key)) {
44 return new String[] { "value2.1", "value2.2" };
51 public String[] getPropertyKeys() {
52 return new String[] { "property1", "property2"};
56 public Bundle getBundle() {
61 public Bundle[] getUsingBundles() {
66 public boolean isAssignableTo(Bundle bundle, String className) {
71 public int compareTo(Object reference) {