Skip to content

Package: ModelQuickFixRegistry_ITest

ModelQuickFixRegistry_ITest

nameinstructionbranchcomplexitylinemethod
ModelQuickFixRegistry_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%
serviceProviderRegistryTest()
M: 0 C: 49
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 15
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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: * Alexandra Buzila - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ui.quickfix.test;
15:
16: import static org.junit.Assert.assertNotNull;
17: import static org.junit.Assert.assertTrue;
18:
19: import java.util.List;
20:
21: import org.eclipse.emf.ecp.quickfix.ModelQuickFix;
22: import org.eclipse.emf.ecp.quickfix.ModelQuickFixRegistry;
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.framework.ServiceRegistration;
28:
29: /**
30: * @author Alexandra Buzila
31: *
32: */
33: public class ModelQuickFixRegistry_ITest {
34:
35:         @Test
36:         public void serviceProviderRegistryTest() {
37:                 final BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
38:                 // Register a QuickFix
39:                 final DummyModelQuickFix quickFix = new DummyModelQuickFix("");
40:                 quickFix.setPriority(1);
41:                 final ServiceRegistration<ModelQuickFix> serviceRegistration = bundleContext.registerService(
42:                         ModelQuickFix.class, quickFix, null);
43:                 final ServiceReference<ModelQuickFixRegistry> serviceReference = bundleContext.getServiceReference(
44:                         ModelQuickFixRegistry.class);
45:                 assertNotNull("ModelQuickFixRegistry service reference was not found", serviceReference); //$NON-NLS-1$
46:                 final ModelQuickFixRegistry registry = bundleContext.getService(serviceReference);
47:                 assertNotNull("ModelQuickFixRegistry was not found", registry); //$NON-NLS-1$
48:
49:                 final List<ModelQuickFix> quickFixes = registry.getAllModelQuickFixes();
50:                 assertTrue("ModelQuickFix service not found in the registry", quickFixes.contains(quickFix)); //$NON-NLS-1$
51:                 serviceRegistration.unregister();
52:                 bundleContext.ungetService(serviceReference);
53:         }
54:
55: }