Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: eb8662469ff7d63466ff8bf485f9d6869b45eda7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*******************************************************************************
 *  Copyright (c) 2006, 2018 IBM Corporation and others.
 *
 *  This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License 2.0
 *  which accompanies this distribution, and is available at
 *  https://www.eclipse.org/legal/epl-2.0/
 *
 *  SPDX-License-Identifier: EPL-2.0
 *
 *  Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.common.tests.registry.simple;

import org.eclipse.core.runtime.*;

/**
 * Tests merging static and dynamic contributions.
 *
 * @since 3.2
 */
public class MergeContributionTest extends BaseExtensionRegistryRun {

	public MergeContributionTest() {
		super();
	}

	public MergeContributionTest(String name) {
		super(name);
	}

	public void testMergeStaticDynamic() {
		// Test with non-bundle contributor
		IContributor nonBundleContributor = ContributorFactorySimple.createContributor("ABC"); //$NON-NLS-1$
		String namespace = nonBundleContributor.getName();

		fillRegistryStatic(nonBundleContributor);
		checkRegistry(namespace, 3);
		fillRegistryDynamic(nonBundleContributor);
		checkRegistry(namespace, 6);

		stopRegistry();
		simpleRegistry = startRegistry();

		checkRegistry(namespace, 3);
		fillRegistryDynamic(nonBundleContributor);
		checkRegistry(namespace, 6);
	}

	private void fillRegistryStatic(IContributor contributor) {
		processXMLContribution(contributor, getXML("MergeStatic.xml"), true); //$NON-NLS-1$
	}

	private void fillRegistryDynamic(IContributor contributor) {
		processXMLContribution(contributor, getXML("MergeDynamic.xml"), false); //$NON-NLS-1$
	}

	private void checkRegistry(String namespace, int expectedExtensions) {
		IExtensionPoint extensionPoint = simpleRegistry.getExtensionPoint(qualifiedName(namespace, "MergeStatic")); //$NON-NLS-1$
		assertNotNull(extensionPoint);
		IExtension[] extensions = simpleRegistry.getExtensions(namespace);
		assertNotNull(extensions);
		assertEquals(expectedExtensions, extensions.length);
	}
}

Back to the top