Skip to content

Package: NoImmediateServices_PTest

NoImmediateServices_PTest

nameinstructionbranchcomplexitylinemethod
NoImmediateServices_PTest()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
test()
M: 18 C: 49
73%
M: 2 C: 6
75%
M: 2 C: 3
60%
M: 3 C: 11
79%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2021 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.sdk.integration.test;
15:
16: import static org.junit.Assert.fail;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.List;
21: import java.util.stream.Collectors;
22:
23: import org.junit.Test;
24: import org.osgi.framework.BundleContext;
25: import org.osgi.framework.FrameworkUtil;
26: import org.osgi.framework.ServiceReference;
27: import org.osgi.service.component.runtime.ServiceComponentRuntime;
28: import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
29:
30: public class NoImmediateServices_PTest {
31:
32:         @Test
33:         public void test() {
34:                 final BundleContext bundleContext = FrameworkUtil.getBundle(NoImmediateServices_PTest.class).getBundleContext();
35:                 final ServiceReference<ServiceComponentRuntime> serviceReference = bundleContext
36:                         .getServiceReference(ServiceComponentRuntime.class);
37:                 final ServiceComponentRuntime service = bundleContext.getService(serviceReference);
38:                 final Collection<ComponentDescriptionDTO> components = service.getComponentDescriptionDTOs();
39:                 final List<String> immediateComponents = new ArrayList<String>();
40:•                for (final ComponentDescriptionDTO component : components) {
41:•                        if (component.immediate && component.implementationClass.contains("emf")) { //$NON-NLS-1$
42:                                 immediateComponents.add(component.implementationClass);
43:                         }
44:                 }
45:                 bundleContext.ungetService(serviceReference);
46:•                if (immediateComponents.size() > 0) {
47:                         fail(String.format("There are immediate Services! %1$s", //$NON-NLS-1$
48:                                 immediateComponents.stream().collect(Collectors.joining(",")))); //$NON-NLS-1$
49:                 }
50:         }
51:
52: }