Skip to content

Package: MappingSegmentExpander_ITest

MappingSegmentExpander_ITest

nameinstructionbranchcomplexitylinemethod
MappingSegmentExpander_ITest()
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%
testServiceRegistrationAndType()
M: 4 C: 45
92%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 1 C: 15
94%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2018 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: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.core.services.segments.mapping;
15:
16: import static org.junit.Assert.assertNotNull;
17:
18: import java.util.Collection;
19:
20: import org.eclipse.emfforms.spi.core.services.domainexpander.EMFFormsDMRSegmentExpander;
21: import org.junit.Test;
22: import org.osgi.framework.BundleContext;
23: import org.osgi.framework.FrameworkUtil;
24: import org.osgi.framework.InvalidSyntaxException;
25: import org.osgi.framework.ServiceReference;
26:
27: /**
28: * @author Lucas Koehler
29: *
30: */
31: public class MappingSegmentExpander_ITest {
32:
33:         @Test
34:         public void testServiceRegistrationAndType() throws InvalidSyntaxException {
35:                 final BundleContext bundleContext = FrameworkUtil.getBundle(MappingSegmentExpander_ITest.class)
36:                         .getBundleContext();
37:
38:                 final Collection<ServiceReference<EMFFormsDMRSegmentExpander>> serviceReferences = bundleContext
39:                         .getServiceReferences(EMFFormsDMRSegmentExpander.class, null);
40:                 EMFFormsDMRSegmentExpander mappingExpander = null;
41:                 ServiceReference<EMFFormsDMRSegmentExpander> serviceReference = null;
42:•                for (final ServiceReference<EMFFormsDMRSegmentExpander> curRef : serviceReferences) {
43:                         final EMFFormsDMRSegmentExpander curService = bundleContext.getService(curRef);
44:•                        if (MappingSegmentExpander.class.isInstance(curService)) {
45:                                 mappingExpander = curService;
46:                                 serviceReference = curRef;
47:                                 break;
48:                         }
49:                         bundleContext.ungetService(curRef);
50:                 }
51:
52:                 assertNotNull(mappingExpander);
53:                 bundleContext.ungetService(serviceReference);
54:         }
55:
56: }