Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 96600 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI Tests/org/eclipse/ui/tests/dynamicplugins/DynamicPluginsTestSuite.java (+8 lines)
Lines 29-37 Link Here
29
	 * Construct the test suite.
29
	 * Construct the test suite.
30
	 */
30
	 */
31
	public DynamicPluginsTestSuite() {
31
	public DynamicPluginsTestSuite() {
32
		addTest(new TestSuite(
33
				AcceleratorConfigurationsExtensionDynamicTest.class));
34
		addTest(new TestSuite(AcceleratorScopesExtensionDynamicTest.class));
35
		addTest(new TestSuite(ActionDefinitionsExtensionDynamicTest.class));
32
	    addTest(new TestSuite(ActionSetTests.class));
36
	    addTest(new TestSuite(ActionSetTests.class));
33
		addTest(new TestSuite(ActivitySupportTests.class));
37
		addTest(new TestSuite(ActivitySupportTests.class));
38
		addTest(new TestSuite(BindingsExtensionDynamicTest.class));
34
		addTest(new TestSuite(BrowserTests.class));
39
		addTest(new TestSuite(BrowserTests.class));
40
		addTest(new TestSuite(CommandsExtensionDynamicTest.class));
41
		addTest(new TestSuite(ContextsExtensionDynamicTest.class));
42
		addTest(new TestSuite(HandlersExtensionDynamicTest.class));
35
		addTest(new TestSuite(PreferencePageTests.class));
43
		addTest(new TestSuite(PreferencePageTests.class));
36
		addTest(new TestSuite(KeywordTests.class));
44
		addTest(new TestSuite(KeywordTests.class));
37
		addTest(new TestSuite(PropertyPageTests.class));
45
		addTest(new TestSuite(PropertyPageTests.class));
(-)Eclipse (+104 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.dynamicplugins;
12
13
import org.eclipse.core.commands.common.NamedHandleObject;
14
import org.eclipse.core.commands.common.NotDefinedException;
15
import org.eclipse.ui.internal.IWorkbenchConstants;
16
import org.eclipse.ui.keys.IBindingService;
17
18
/**
19
 * Tests whether the "org.eclipse.ui.acceleratorConfigurations" extension point
20
 * can be added and removed dynamically.
21
 * 
22
 * @since 3.1.1
23
 */
24
public final class AcceleratorConfigurationsExtensionDynamicTest extends
25
		DynamicTestCase {
26
27
	/**
28
	 * Constructs a new instance of
29
	 * <code>AcceleratorConfigurationsExtensionDynamicTest</code>.
30
	 * 
31
	 * @param testName
32
	 *            The name of the test; may be <code>null</code>.
33
	 */
34
	public AcceleratorConfigurationsExtensionDynamicTest(final String testName) {
35
		super(testName);
36
	}
37
38
	/**
39
	 * Returns the full-qualified identifier of the extension to be tested.
40
	 * 
41
	 * @return The extension identifier; never <code>null</code>.
42
	 */
43
	protected final String getExtensionId() {
44
		return "acceleratorConfigurationsExtensionDynamicTest.testDynamicAcceleratorConfigurationAddition";
45
	}
46
47
	/**
48
	 * Returns the unqualified identifier of the extension point to be tested.
49
	 * 
50
	 * @return The extension point identifier; never <code>null</code>.
51
	 */
52
	protected final String getExtensionPoint() {
53
		return IWorkbenchConstants.PL_ACCELERATOR_CONFIGURATIONS;
54
	}
55
56
	/**
57
	 * Returns the relative location of the folder on disk containing the
58
	 * plugin.xml file.
59
	 * 
60
	 * @return The relative install location; never <code>null</code>.
61
	 */
62
	protected final String getInstallLocation() {
63
		return "data/org.eclipse.acceleratorConfigurationsExtensionDynamicTest";
64
	}
65
66
	/**
67
	 * Tests whether the items defined in the extension point can be added and
68
	 * removed dynamically. It tests that the data doesn't exist, and then loads
69
	 * the extension. It tests that the data then exists, and unloads the
70
	 * extension. It tests that the data then doesn't exist.
71
	 */
72
	public final void testAcceleratorConfigurations() {
73
		final IBindingService service = (IBindingService) getWorkbench()
74
				.getAdapter(IBindingService.class);
75
		NamedHandleObject namedHandleObject;
76
77
		namedHandleObject = service.getScheme("monkey");
78
		try {
79
			namedHandleObject.getName();
80
			fail();
81
		} catch (final NotDefinedException e) {
82
			assertTrue(true);
83
		}
84
85
		getBundle();
86
87
		namedHandleObject = service.getScheme("monkey");
88
		try {
89
			assertTrue("Monkey".equals(namedHandleObject.getName()));
90
		} catch (final NotDefinedException e) {
91
			fail();
92
		}
93
94
		removeBundle();
95
96
		namedHandleObject = service.getScheme("monkey");
97
		try {
98
			namedHandleObject.getName();
99
			fail();
100
		} catch (final NotDefinedException e) {
101
			assertTrue(true);
102
		}
103
	}
104
}
(-)Eclipse (+104 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.dynamicplugins;
12
13
import org.eclipse.core.commands.common.NamedHandleObject;
14
import org.eclipse.core.commands.common.NotDefinedException;
15
import org.eclipse.ui.contexts.IContextService;
16
import org.eclipse.ui.internal.IWorkbenchConstants;
17
18
/**
19
 * Tests whether the "org.eclipse.ui.acceleratorScopes" extension point can be
20
 * added and removed dynamically.
21
 * 
22
 * @since 3.1.1
23
 */
24
public final class AcceleratorScopesExtensionDynamicTest extends
25
		DynamicTestCase {
26
27
	/**
28
	 * Constructs a new instance of
29
	 * <code>AcceleratorScopesExtensionDynamicTest</code>.
30
	 * 
31
	 * @param testName
32
	 *            The name of the test; may be <code>null</code>.
33
	 */
34
	public AcceleratorScopesExtensionDynamicTest(final String testName) {
35
		super(testName);
36
	}
37
38
	/**
39
	 * Returns the full-qualified identifier of the extension to be tested.
40
	 * 
41
	 * @return The extension identifier; never <code>null</code>.
42
	 */
43
	protected final String getExtensionId() {
44
		return "acceleratorScopesExtensionDynamicTest.testDynamicAcceleratorScopeAddition";
45
	}
46
47
	/**
48
	 * Returns the unqualified identifier of the extension point to be tested.
49
	 * 
50
	 * @return The extension point identifier; never <code>null</code>.
51
	 */
52
	protected final String getExtensionPoint() {
53
		return IWorkbenchConstants.PL_ACCELERATOR_SCOPES;
54
	}
55
56
	/**
57
	 * Returns the relative location of the folder on disk containing the
58
	 * plugin.xml file.
59
	 * 
60
	 * @return The relative install location; never <code>null</code>.
61
	 */
62
	protected final String getInstallLocation() {
63
		return "data/org.eclipse.acceleratorScopesExtensionDynamicTest";
64
	}
65
66
	/**
67
	 * Tests whether the items defined in the extension point can be added and
68
	 * removed dynamically. It tests that the data doesn't exist, and then loads
69
	 * the extension. It tests that the data then exists, and unloads the
70
	 * extension. It tests that the data then doesn't exist.
71
	 */
72
	public final void testAcceleratorScopes() {
73
		final IContextService service = (IContextService) getWorkbench()
74
				.getAdapter(IContextService.class);
75
		NamedHandleObject namedHandleObject;
76
77
		namedHandleObject = service.getContext("monkey");
78
		try {
79
			namedHandleObject.getName();
80
			fail();
81
		} catch (final NotDefinedException e) {
82
			assertTrue(true);
83
		}
84
85
		getBundle();
86
87
		namedHandleObject = service.getContext("monkey");
88
		try {
89
			assertTrue("Monkey".equals(namedHandleObject.getName()));
90
		} catch (final NotDefinedException e) {
91
			fail();
92
		}
93
94
		removeBundle();
95
96
		namedHandleObject = service.getContext("monkey");
97
		try {
98
			namedHandleObject.getName();
99
			fail();
100
		} catch (final NotDefinedException e) {
101
			assertTrue(true);
102
		}
103
	}
104
}
(-)Eclipse (+104 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.dynamicplugins;
12
13
import org.eclipse.core.commands.common.NamedHandleObject;
14
import org.eclipse.core.commands.common.NotDefinedException;
15
import org.eclipse.ui.commands.ICommandService;
16
import org.eclipse.ui.internal.IWorkbenchConstants;
17
18
/**
19
 * Tests whether the "org.eclipse.ui.actionDefinitions" extension point can be
20
 * added and removed dynamically.
21
 * 
22
 * @since 3.1.1
23
 */
24
public final class ActionDefinitionsExtensionDynamicTest extends
25
		DynamicTestCase {
26
27
	/**
28
	 * Constructs a new instance of
29
	 * <code>ActionDefinitionsExtensionDynamicTest</code>.
30
	 * 
31
	 * @param testName
32
	 *            The name of the test; may be <code>null</code>.
33
	 */
34
	public ActionDefinitionsExtensionDynamicTest(final String testName) {
35
		super(testName);
36
	}
37
38
	/**
39
	 * Returns the full-qualified identifier of the extension to be tested.
40
	 * 
41
	 * @return The extension identifier; never <code>null</code>.
42
	 */
43
	protected final String getExtensionId() {
44
		return "actionDefinitionsExtensionDynamicTest.testDynamicActionDefinitionAddition";
45
	}
46
47
	/**
48
	 * Returns the unqualified identifier of the extension point to be tested.
49
	 * 
50
	 * @return The extension point identifier; never <code>null</code>.
51
	 */
52
	protected final String getExtensionPoint() {
53
		return IWorkbenchConstants.PL_ACTION_DEFINITIONS;
54
	}
55
56
	/**
57
	 * Returns the relative location of the folder on disk containing the
58
	 * plugin.xml file.
59
	 * 
60
	 * @return The relative install location; never <code>null</code>.
61
	 */
62
	protected final String getInstallLocation() {
63
		return "data/org.eclipse.actionDefinitionsExtensionDynamicTest";
64
	}
65
66
	/**
67
	 * Tests whether the items defined in the extension point can be added and
68
	 * removed dynamically. It tests that the data doesn't exist, and then loads
69
	 * the extension. It tests that the data then exists, and unloads the
70
	 * extension. It tests that the data then doesn't exist.
71
	 */
72
	public final void testActionDefinitions() {
73
		final ICommandService service = (ICommandService) getWorkbench()
74
				.getAdapter(ICommandService.class);
75
		NamedHandleObject namedHandleObject;
76
77
		namedHandleObject = service.getCommand("monkey");
78
		try {
79
			namedHandleObject.getName();
80
			fail();
81
		} catch (final NotDefinedException e) {
82
			assertTrue(true);
83
		}
84
85
		getBundle();
86
87
		namedHandleObject = service.getCommand("monkey");
88
		try {
89
			assertTrue("Monkey".equals(namedHandleObject.getName()));
90
		} catch (final NotDefinedException e) {
91
			fail();
92
		}
93
94
		removeBundle();
95
96
		namedHandleObject = service.getCommand("monkey");
97
		try {
98
			namedHandleObject.getName();
99
			fail();
100
		} catch (final NotDefinedException e) {
101
			assertTrue(true);
102
		}
103
	}
104
}
(-)Eclipse (+182 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.dynamicplugins;
12
13
import org.eclipse.core.commands.common.NotDefinedException;
14
import org.eclipse.jface.bindings.Binding;
15
import org.eclipse.jface.bindings.Scheme;
16
import org.eclipse.jface.bindings.TriggerSequence;
17
import org.eclipse.jface.bindings.keys.KeySequence;
18
import org.eclipse.jface.bindings.keys.ParseException;
19
import org.eclipse.jface.contexts.IContextIds;
20
import org.eclipse.ui.internal.IWorkbenchConstants;
21
import org.eclipse.ui.keys.IBindingService;
22
23
/**
24
 * Tests whether the "org.eclipse.ui.bindings" extension point can be added and
25
 * removed dynamically.
26
 * 
27
 * @since 3.1.1
28
 */
29
public final class BindingsExtensionDynamicTest extends DynamicTestCase {
30
31
	/**
32
	 * Constructs a new instance of <code>BindingsExtensionDynamicTest</code>.
33
	 * 
34
	 * @param testName
35
	 *            The name of the test; may be <code>null</code>.
36
	 */
37
	public BindingsExtensionDynamicTest(final String testName) {
38
		super(testName);
39
	}
40
41
	/**
42
	 * Returns the full-qualified identifier of the extension to be tested.
43
	 * 
44
	 * @return The extension identifier; never <code>null</code>.
45
	 */
46
	protected final String getExtensionId() {
47
		return "bindingsExtensionDynamicTest.testDynamicBindingAddition";
48
	}
49
50
	/**
51
	 * Returns the unqualified identifier of the extension point to be tested.
52
	 * 
53
	 * @return The extension point identifier; never <code>null</code>.
54
	 */
55
	protected final String getExtensionPoint() {
56
		return IWorkbenchConstants.PL_BINDINGS;
57
	}
58
59
	/**
60
	 * Returns the relative location of the folder on disk containing the
61
	 * plugin.xml file.
62
	 * 
63
	 * @return The relative install location; never <code>null</code>.
64
	 */
65
	protected final String getInstallLocation() {
66
		return "data/org.eclipse.bindingsExtensionDynamicTest";
67
	}
68
69
	/**
70
	 * Tests whether the items defined in the extension point can be added and
71
	 * removed dynamically. It tests that the data doesn't exist, and then loads
72
	 * the extension. It tests that the data then exists, and unloads the
73
	 * extension. It tests that the data then doesn't exist.
74
	 * 
75
	 * @throws ParseException
76
	 *             If "M1+W" can't be parsed by the extension point.
77
	 */
78
	public void testBindings() throws ParseException {
79
		final IBindingService bindingService = (IBindingService) getWorkbench()
80
				.getAdapter(IBindingService.class);
81
		final TriggerSequence triggerSequence = KeySequence.getInstance("M1+W");
82
		Binding[] bindings;
83
		Scheme scheme;
84
		boolean found;
85
86
		found = false;
87
		bindings = bindingService.getBindings();
88
		if (bindings != null) {
89
			for (int i = 0; i < bindings.length; i++) {
90
				final Binding binding = bindings[i];
91
				if ("monkey".equals(binding.getSchemeId())
92
						&& IContextIds.CONTEXT_ID_WINDOW.equals(binding
93
								.getContextId())
94
						&& "org.eclipse.ui.views.showView".equals(binding
95
								.getParameterizedCommand().getId())
96
						&& binding.getParameterizedCommand().getParameterMap()
97
								.containsKey(
98
										"org.eclipse.ui.views.showView.viewId")
99
						&& binding.getPlatform() == null
100
						&& binding.getLocale() == null
101
						&& binding.getType() == Binding.SYSTEM
102
						&& triggerSequence.equals(binding.getTriggerSequence())) {
103
					found = true;
104
105
				}
106
			}
107
		}
108
		assertTrue(!found);
109
		scheme = bindingService.getScheme("monkey");
110
		try {
111
			scheme.getName();
112
			fail();
113
		} catch (final NotDefinedException e) {
114
			assertTrue(true);
115
		}
116
117
		getBundle();
118
119
		found = false;
120
		bindings = bindingService.getBindings();
121
		if (bindings != null) {
122
			for (int i = 0; i < bindings.length; i++) {
123
				final Binding binding = bindings[i];
124
				if ("monkey".equals(binding.getSchemeId())
125
						&& IContextIds.CONTEXT_ID_WINDOW.equals(binding
126
								.getContextId())
127
						&& "org.eclipse.ui.views.showView".equals(binding
128
								.getParameterizedCommand().getId())
129
						&& binding.getParameterizedCommand().getParameterMap()
130
								.containsKey(
131
										"org.eclipse.ui.views.showView.viewId")
132
						&& binding.getPlatform() == null
133
						&& binding.getLocale() == null
134
						&& binding.getType() == Binding.SYSTEM
135
						&& triggerSequence.equals(binding.getTriggerSequence())) {
136
					found = true;
137
138
				}
139
			}
140
		}
141
		assertTrue(found);
142
		scheme = bindingService.getScheme("monkey");
143
		try {
144
			assertTrue("Monkey".equals(scheme.getName()));
145
		} catch (final NotDefinedException e) {
146
			fail();
147
		}
148
149
		removeBundle();
150
151
		found = false;
152
		bindings = bindingService.getBindings();
153
		if (bindings != null) {
154
			for (int i = 0; i < bindings.length; i++) {
155
				final Binding binding = bindings[i];
156
				if ("monkey".equals(binding.getSchemeId())
157
						&& IContextIds.CONTEXT_ID_WINDOW.equals(binding
158
								.getContextId())
159
						&& "org.eclipse.ui.views.showView".equals(binding
160
								.getParameterizedCommand().getId())
161
						&& binding.getParameterizedCommand().getParameterMap()
162
								.containsKey(
163
										"org.eclipse.ui.views.showView.viewId")
164
						&& binding.getPlatform() == null
165
						&& binding.getLocale() == null
166
						&& binding.getType() == Binding.SYSTEM
167
						&& triggerSequence.equals(binding.getTriggerSequence())) {
168
					found = true;
169
170
				}
171
			}
172
		}
173
		assertTrue(!found);
174
		scheme = bindingService.getScheme("monkey");
175
		try {
176
			scheme.getName();
177
			fail();
178
		} catch (final NotDefinedException e) {
179
			assertTrue(true);
180
		}
181
	}
182
}
(-)Eclipse (+292 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.dynamicplugins;
12
13
import java.util.Collections;
14
15
import org.eclipse.core.commands.Command;
16
import org.eclipse.core.commands.ExecutionEvent;
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.commands.NotHandledException;
19
import org.eclipse.core.commands.common.NamedHandleObject;
20
import org.eclipse.core.commands.common.NotDefinedException;
21
import org.eclipse.jface.bindings.Binding;
22
import org.eclipse.jface.bindings.TriggerSequence;
23
import org.eclipse.jface.bindings.keys.KeySequence;
24
import org.eclipse.jface.bindings.keys.ParseException;
25
import org.eclipse.jface.contexts.IContextIds;
26
import org.eclipse.ui.commands.ICommandService;
27
import org.eclipse.ui.contexts.IContextService;
28
import org.eclipse.ui.internal.IWorkbenchConstants;
29
import org.eclipse.ui.keys.IBindingService;
30
31
/**
32
 * Tests whether the "org.eclipse.ui.commands" extension point can be added and
33
 * removed dynamically.
34
 * 
35
 * @since 3.1.1
36
 */
37
public final class CommandsExtensionDynamicTest extends DynamicTestCase {
38
39
	/**
40
	 * Constructs a new instance of <code>CommandsExtensionDynamicTest</code>.
41
	 * 
42
	 * @param testName
43
	 *            The name of the test; may be <code>null</code>.
44
	 */
45
	public CommandsExtensionDynamicTest(final String testName) {
46
		super(testName);
47
	}
48
49
	/**
50
	 * Returns the full-qualified identifier of the extension to be tested.
51
	 * 
52
	 * @return The extension identifier; never <code>null</code>.
53
	 */
54
	protected final String getExtensionId() {
55
		return "commandsExtensionDynamicTest.testDynamicCommandAddition";
56
	}
57
58
	/**
59
	 * Returns the unqualified identifier of the extension point to be tested.
60
	 * 
61
	 * @return The extension point identifier; never <code>null</code>.
62
	 */
63
	protected final String getExtensionPoint() {
64
		return IWorkbenchConstants.PL_COMMANDS;
65
	}
66
67
	/**
68
	 * Returns the relative location of the folder on disk containing the
69
	 * plugin.xml file.
70
	 * 
71
	 * @return The relative install location; never <code>null</code>.
72
	 */
73
	protected final String getInstallLocation() {
74
		return "data/org.eclipse.commandsExtensionDynamicTest";
75
	}
76
77
	/**
78
	 * Tests whether the items defined in the extension point can be added and
79
	 * removed dynamically. It tests that the data doesn't exist, and then loads
80
	 * the extension. It tests that the data then exists, and unloads the
81
	 * extension. It tests that the data then doesn't exist.
82
	 * 
83
	 * @throws ParseException
84
	 *             If "M1+W" can't be parsed by the extension point.
85
	 */
86
	public final void testCommands() throws ParseException {
87
		final IBindingService bindingService = (IBindingService) getWorkbench()
88
				.getAdapter(IBindingService.class);
89
		final ICommandService commandService = (ICommandService) getWorkbench()
90
				.getAdapter(ICommandService.class);
91
		final IContextService contextService = (IContextService) getWorkbench()
92
				.getAdapter(IContextService.class);
93
		final TriggerSequence triggerSequence = KeySequence.getInstance("M1+W");
94
		NamedHandleObject namedHandleObject;
95
		Binding[] bindings;
96
		Command command;
97
		boolean found;
98
99
		assertTrue(!"monkey".equals(bindingService.getActiveScheme().getId()));
100
		found = false;
101
		bindings = bindingService.getBindings();
102
		if (bindings != null) {
103
			for (int i = 0; i < bindings.length; i++) {
104
				final Binding binding = bindings[i];
105
				if ("monkey".equals(binding.getSchemeId())
106
						&& IContextIds.CONTEXT_ID_WINDOW.equals(binding
107
								.getContextId())
108
						&& "monkey".equals(binding.getParameterizedCommand()
109
								.getId()) && binding.getPlatform() == null
110
						&& binding.getLocale() == null
111
						&& binding.getType() == Binding.SYSTEM
112
						&& triggerSequence.equals(binding.getTriggerSequence())) {
113
					found = true;
114
115
				}
116
			}
117
		}
118
		assertTrue(!found);
119
		namedHandleObject = bindingService.getScheme("monkey");
120
		try {
121
			namedHandleObject.getName();
122
			fail();
123
		} catch (final NotDefinedException e) {
124
			assertTrue(true);
125
		}
126
		namedHandleObject = commandService.getCategory("monkey");
127
		try {
128
			namedHandleObject.getName();
129
			fail();
130
		} catch (final NotDefinedException e) {
131
			assertTrue(true);
132
		}
133
		command = commandService.getCommand("monkey");
134
		try {
135
			command.execute(new ExecutionEvent(Collections.EMPTY_MAP, null,
136
					null));
137
			fail();
138
		} catch (final ExecutionException e) {
139
			fail();
140
		} catch (final NotHandledException e) {
141
			assertTrue(true);
142
		}
143
		try {
144
			command.getName();
145
			fail();
146
		} catch (final NotDefinedException e) {
147
			assertTrue(true);
148
		}
149
		namedHandleObject = contextService.getContext("context");
150
		try {
151
			namedHandleObject.getName();
152
			fail();
153
		} catch (final NotDefinedException e) {
154
			assertTrue(true);
155
		}
156
		namedHandleObject = contextService.getContext("scope");
157
		try {
158
			namedHandleObject.getName();
159
			fail();
160
		} catch (final NotDefinedException e) {
161
			assertTrue(true);
162
		}
163
164
		getBundle();
165
166
		assertTrue("monkey".equals(bindingService.getActiveScheme().getId()));
167
		found = false;
168
		bindings = bindingService.getBindings();
169
		if (bindings != null) {
170
			for (int i = 0; i < bindings.length; i++) {
171
				final Binding binding = bindings[i];
172
				if ("monkey".equals(binding.getSchemeId())
173
						&& IContextIds.CONTEXT_ID_WINDOW.equals(binding
174
								.getContextId())
175
						&& "monkey".equals(binding.getParameterizedCommand()
176
								.getId()) && binding.getPlatform() == null
177
						&& binding.getLocale() == null
178
						&& binding.getType() == Binding.SYSTEM
179
						&& triggerSequence.equals(binding.getTriggerSequence())) {
180
					found = true;
181
182
				}
183
			}
184
		}
185
		assertTrue(found);
186
		namedHandleObject = bindingService.getScheme("monkey");
187
		try {
188
			assertTrue("Monkey".equals(namedHandleObject.getName()));
189
		} catch (final NotDefinedException e) {
190
			fail();
191
		}
192
		command = commandService.getCommand("monkey");
193
		try {
194
			command.execute(new ExecutionEvent(Collections.EMPTY_MAP, null,
195
					null));
196
		} catch (final ExecutionException e) {
197
			fail();
198
		} catch (final NotHandledException e) {
199
			fail();
200
		}
201
		try {
202
			assertEquals("Monkey", command.getName());
203
		} catch (final NotDefinedException e) {
204
			fail();
205
		}
206
		namedHandleObject = commandService.getCommand("monkey");
207
		try {
208
			assertTrue("Monkey".equals(namedHandleObject.getName()));
209
		} catch (final NotDefinedException e) {
210
			fail();
211
		}
212
		namedHandleObject = contextService.getContext("context");
213
		try {
214
			assertTrue("Monkey".equals(namedHandleObject.getName()));
215
		} catch (final NotDefinedException e) {
216
			fail();
217
		}
218
		namedHandleObject = contextService.getContext("scope");
219
		try {
220
			assertTrue("Monkey".equals(namedHandleObject.getName()));
221
		} catch (final NotDefinedException e) {
222
			fail();
223
		}
224
225
		removeBundle();
226
227
		assertTrue(!"monkey".equals(bindingService.getActiveScheme().getId()));
228
		found = false;
229
		bindings = bindingService.getBindings();
230
		if (bindings != null) {
231
			for (int i = 0; i < bindings.length; i++) {
232
				final Binding binding = bindings[i];
233
				if ("monkey".equals(binding.getSchemeId())
234
						&& IContextIds.CONTEXT_ID_WINDOW.equals(binding
235
								.getContextId())
236
						&& "monkey".equals(binding.getParameterizedCommand()
237
								.getId()) && binding.getPlatform() == null
238
						&& binding.getLocale() == null
239
						&& binding.getType() == Binding.SYSTEM
240
						&& triggerSequence.equals(binding.getTriggerSequence())) {
241
					found = true;
242
243
				}
244
			}
245
		}
246
		assertTrue(!found);
247
		namedHandleObject = bindingService.getScheme("monkey");
248
		try {
249
			namedHandleObject.getName();
250
			fail();
251
		} catch (final NotDefinedException e) {
252
			assertTrue(true);
253
		}
254
		namedHandleObject = commandService.getCategory("monkey");
255
		try {
256
			namedHandleObject.getName();
257
			fail();
258
		} catch (final NotDefinedException e) {
259
			assertTrue(true);
260
		}
261
		command = commandService.getCommand("monkey");
262
		try {
263
			command.execute(new ExecutionEvent(Collections.EMPTY_MAP, null,
264
					null));
265
			fail();
266
		} catch (final ExecutionException e) {
267
			fail();
268
		} catch (final NotHandledException e) {
269
			assertTrue(true);
270
		}
271
		try {
272
			command.getName();
273
			fail();
274
		} catch (final NotDefinedException e) {
275
			assertTrue(true);
276
		}
277
		namedHandleObject = contextService.getContext("context");
278
		try {
279
			namedHandleObject.getName();
280
			fail();
281
		} catch (final NotDefinedException e) {
282
			assertTrue(true);
283
		}
284
		namedHandleObject = contextService.getContext("scope");
285
		try {
286
			namedHandleObject.getName();
287
			fail();
288
		} catch (final NotDefinedException e) {
289
			assertTrue(true);
290
		}
291
	}
292
}
(-)Eclipse (+102 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.dynamicplugins;
12
13
import org.eclipse.core.commands.common.NamedHandleObject;
14
import org.eclipse.core.commands.common.NotDefinedException;
15
import org.eclipse.ui.contexts.IContextService;
16
import org.eclipse.ui.internal.IWorkbenchConstants;
17
18
/**
19
 * Tests whether the "org.eclipse.ui.contexts" extension point can be added and
20
 * removed dynamically.
21
 * 
22
 * @since 3.1.1
23
 */
24
public final class ContextsExtensionDynamicTest extends DynamicTestCase {
25
26
	/**
27
	 * Constructs a new instance of <code>ContextsExtensionDynamicTest</code>.
28
	 * 
29
	 * @param testName
30
	 *            The name of the test; may be <code>null</code>.
31
	 */
32
	public ContextsExtensionDynamicTest(final String testName) {
33
		super(testName);
34
	}
35
36
	/**
37
	 * Returns the full-qualified identifier of the extension to be tested.
38
	 * 
39
	 * @return The extension identifier; never <code>null</code>.
40
	 */
41
	protected final String getExtensionId() {
42
		return "contextsExtensionDynamicTest.testDynamicContextAddition";
43
	}
44
45
	/**
46
	 * Returns the unqualified identifier of the extension point to be tested.
47
	 * 
48
	 * @return The extension point identifier; never <code>null</code>.
49
	 */
50
	protected final String getExtensionPoint() {
51
		return IWorkbenchConstants.PL_CONTEXTS;
52
	}
53
54
	/**
55
	 * Returns the relative location of the folder on disk containing the
56
	 * plugin.xml file.
57
	 * 
58
	 * @return The relative install location; never <code>null</code>.
59
	 */
60
	protected final String getInstallLocation() {
61
		return "data/org.eclipse.contextsExtensionDynamicTest";
62
	}
63
64
	/**
65
	 * Tests whether the items defined in the extension point can be added and
66
	 * removed dynamically. It tests that the data doesn't exist, and then loads
67
	 * the extension. It tests that the data then exists, and unloads the
68
	 * extension. It tests that the data then doesn't exist.
69
	 */
70
	public final void testContexts() {
71
		final IContextService service = (IContextService) getWorkbench()
72
				.getAdapter(IContextService.class);
73
		NamedHandleObject namedHandleObject;
74
75
		namedHandleObject = service.getContext("monkey");
76
		try {
77
			namedHandleObject.getName();
78
			fail();
79
		} catch (final NotDefinedException e) {
80
			assertTrue(true);
81
		}
82
83
		getBundle();
84
85
		namedHandleObject = service.getContext("monkey");
86
		try {
87
			assertTrue("Monkey".equals(namedHandleObject.getName()));
88
		} catch (final NotDefinedException e) {
89
			fail();
90
		}
91
92
		removeBundle();
93
94
		namedHandleObject = service.getContext("monkey");
95
		try {
96
			namedHandleObject.getName();
97
			fail();
98
		} catch (final NotDefinedException e) {
99
			assertTrue(true);
100
		}
101
	}
102
}
(-)Eclipse (+115 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.dynamicplugins;
12
13
import java.util.Collections;
14
15
import org.eclipse.core.commands.Command;
16
import org.eclipse.core.commands.ExecutionEvent;
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.core.commands.NotHandledException;
19
import org.eclipse.ui.commands.ICommandService;
20
import org.eclipse.ui.internal.IWorkbenchConstants;
21
22
/**
23
 * Tests whether the "org.eclipse.ui.handlers" extension point can be added and
24
 * removed dynamically.
25
 * 
26
 * @since 3.1.1
27
 */
28
public final class HandlersExtensionDynamicTest extends DynamicTestCase {
29
30
	/**
31
	 * Constructs a new instance of <code>HandlersExtensionDynamicTest</code>.
32
	 * 
33
	 * @param testName
34
	 *            The name of the test; may be <code>null</code>.
35
	 */
36
	public HandlersExtensionDynamicTest(final String testName) {
37
		super(testName);
38
	}
39
40
	/**
41
	 * Returns the full-qualified identifier of the extension to be tested.
42
	 * 
43
	 * @return The extension identifier; never <code>null</code>.
44
	 */
45
	protected final String getExtensionId() {
46
		return "handlersExtensionDynamicTest.testDynamicHandlerAddition";
47
	}
48
49
	/**
50
	 * Returns the unqualified identifier of the extension point to be tested.
51
	 * 
52
	 * @return The extension point identifier; never <code>null</code>.
53
	 */
54
	protected final String getExtensionPoint() {
55
		return IWorkbenchConstants.PL_HANDLERS;
56
	}
57
58
	/**
59
	 * Returns the relative location of the folder on disk containing the
60
	 * plugin.xml file.
61
	 * 
62
	 * @return The relative install location; never <code>null</code>.
63
	 */
64
	protected final String getInstallLocation() {
65
		return "data/org.eclipse.handlersExtensionDynamicTest";
66
	}
67
68
	/**
69
	 * Tests whether the items defined in the extension point can be added and
70
	 * removed dynamically. It tests that the data doesn't exist, and then loads
71
	 * the extension. It tests that the data then exists, and unloads the
72
	 * extension. It tests that the data then doesn't exist.
73
	 */
74
	public final void testHandlers() {
75
		final ICommandService commandService = (ICommandService) getWorkbench()
76
				.getAdapter(ICommandService.class);
77
		Command command;
78
79
		command = commandService.getCommand("monkey");
80
		try {
81
			command.execute(new ExecutionEvent(Collections.EMPTY_MAP, null,
82
					null));
83
			fail();
84
		} catch (final ExecutionException e) {
85
			fail();
86
		} catch (final NotHandledException e) {
87
			assertTrue(true);
88
		}
89
90
		getBundle();
91
92
		command = commandService.getCommand("monkey");
93
		try {
94
			command.execute(new ExecutionEvent(Collections.EMPTY_MAP, null,
95
					null));
96
		} catch (final ExecutionException e) {
97
			fail();
98
		} catch (final NotHandledException e) {
99
			fail();
100
		}
101
102
		removeBundle();
103
104
		command = commandService.getCommand("monkey");
105
		try {
106
			command.execute(new ExecutionEvent(Collections.EMPTY_MAP, null,
107
					null));
108
			fail();
109
		} catch (final ExecutionException e) {
110
			fail();
111
		} catch (final NotHandledException e) {
112
			assertTrue(true);
113
		}
114
	}
115
}
(-)data/org.eclipse.acceleratorConfigurationsExtensionDynamicTest/plugin.xml (+20 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin
4
   id="acceleratorConfigurationsExtensionDynamicTest"
5
   name="Accelerator Configurations Extension Dynamic Test Plug-in"
6
   version="1.0.0">
7
   
8
   <requires>
9
      <import plugin="org.eclipse.ui"/>
10
   </requires>
11
12
   <extension
13
         id="testDynamicAcceleratorConfigurationAddition"
14
         point="org.eclipse.ui.acceleratorConfigurations">
15
      <acceleratorConfiguration
16
            id="monkey"
17
            name="Monkey" />
18
   </extension> 
19
20
</plugin>
(-)data/org.eclipse.acceleratorScopesExtensionDynamicTest/plugin.xml (+20 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin
4
   id="acceleratorScopesExtensionDynamicTest"
5
   name="Accelerator Scopes Extension Dynamic Test Plug-in"
6
   version="1.0.0">
7
   
8
   <requires>
9
      <import plugin="org.eclipse.ui"/>
10
   </requires>
11
12
   <extension
13
         id="testDynamicAcceleratorScopeAddition"
14
         point="org.eclipse.ui.acceleratorScopes">
15
      <acceleratorScope
16
            id="monkey"
17
            name="Monkey" />
18
   </extension> 
19
20
</plugin>
(-)data/org.eclipse.actionDefinitionsExtensionDynamicTest/plugin.xml (+20 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin
4
   id="actionDefinitionsExtensionDynamicTest"
5
   name="Action Definitions Extension Dynamic Test Plug-in"
6
   version="1.0.0">
7
   
8
   <requires>
9
      <import plugin="org.eclipse.ui"/>
10
   </requires>
11
12
   <extension
13
         id="testDynamicActionDefinitionAddition"
14
         point="org.eclipse.ui.actionDefinitions">
15
      <actionDefinition
16
            id="monkey"
17
            name="Monkey" />
18
   </extension> 
19
20
</plugin>
(-)data/org.eclipse.bindingsExtensionDynamicTest/plugin.xml (+28 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin
4
   id="bindingsExtensionDynamicTest"
5
   name="Bindings Extension Dynamic Test Plug-in"
6
   version="1.0.0">
7
   
8
   <requires>
9
      <import plugin="org.eclipse.ui"/>
10
   </requires>
11
12
   <extension
13
         id="testDynamicBindingAddition"
14
         point="org.eclipse.ui.bindings">
15
      <key
16
      		commandId="org.eclipse.ui.views.showView"
17
            sequence="M1+W"
18
            schemeId="monkey">
19
            <parameter
20
            	id="org.eclipse.ui.views.showView.viewId"
21
            	value="monkey" />
22
      </key>
23
      <scheme
24
            id="monkey"
25
            name="Monkey" />
26
   </extension> 
27
28
</plugin>
(-)data/org.eclipse.commandsExtensionDynamicTest/commands.jar (+19 lines)
Added Link Here
1
PK
2
]w3	META-INF/??PK
3
\w3???^jMETA-INF/MANIFEST.MF?M??LK-.?
4
K-*????R0?3??r?Cq,HL?HU?%??Ly???RKRSt?*A?M??
5
Lt?L4?K?|3????+?KRs?<???4y?x?PK
6
7w3org/PK
7
7w3org/eclipse/PK
8
7w3org/eclipse/ui/PK
9
7w3org/eclipse/ui/dynamic/PK
10
7w3 org/eclipse/ui/dynamic/commands/PK
11
7w3?m?	/(4org/eclipse/ui/dynamic/commands/DynamicHandler.class?P?J1=?k??V[??.???D+.](?g?PSf2???+]	.??J???A??>???&o?/?F?Pa?v????]?x?????DK.?$f???u???X?5??W?L??d?D??B????8?F?	C???1?N??j????h0tBm?e?D???(V?0?"?	?}\&k?Vg???3?^??Q?I??}?i??????q?A?+?ca?*Z*??U]????}??in?:????????~?T??_!P?	a}??????$?(?[t???@?M??6:?????5????](???R??????"?}PK
12
]w3	?AMETA-INF/??PK
13
\w3???^j??+META-INF/MANIFEST.MFPK
14
7w3?A?org/PK
15
7w3?A?org/eclipse/PK
16
7w3?Aorg/eclipse/ui/PK
17
7w3?A4org/eclipse/ui/dynamic/PK
18
7w3 ?Aiorg/eclipse/ui/dynamic/commands/PK
19
7w3?m?	/(4???org/eclipse/ui/dynamic/commands/DynamicHandler.classPK(
(-)data/org.eclipse.commandsExtensionDynamicTest/plugin.xml (+49 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin
4
   id="commandsExtensionDynamicTest"
5
   name="Commands Extension Dynamic Test Plug-in"
6
   version="1.0.0">
7
   
8
   <runtime>
9
      <library name="commands.jar">
10
         <export name="*"/>
11
      </library>
12
   </runtime>
13
   <requires>
14
      <import plugin="org.eclipse.ui"/>
15
   </requires>
16
17
	<extension
18
    		id="testDynamicCommandAddition"
19
			point="org.eclipse.ui.commands">
20
		<activeKeyConfiguration
21
			keyConfigurationId="monkey" />
22
		<category
23
			id="monkey"
24
			name="Monkey" />
25
		<command
26
			id="monkey"
27
			name="Monkey"
28
			categoryId="monkey"
29
			defaultHandler="org.eclipse.ui.dynamic.commands.DynamicHandler">
30
			<commandParameter
31
				id="monkey"
32
				name="Monkey" />
33
		</command>
34
		<keyBinding
35
			keySequence="M1+W"
36
			commandId="monkey"
37
			keyConfigurationId="monkey" />
38
		<keyConfiguration
39
			id="monkey"
40
			name="Monkey" />
41
		<context
42
			id="context"
43
			name="Monkey" />
44
		<scope
45
			id="scope"
46
			name="Monkey" />
47
	</extension> 
48
49
</plugin>
(-)data/org.eclipse.contextsExtensionDynamicTest/plugin.xml (+20 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin
4
   id="contextsExtensionDynamicTest"
5
   name="Contexts Extension Dynamic Test Plug-in"
6
   version="1.0.0">
7
   
8
   <requires>
9
      <import plugin="org.eclipse.ui"/>
10
   </requires>
11
12
   <extension
13
         id="testDynamicContextAddition"
14
         point="org.eclipse.ui.contexts">
15
      <context
16
            id="monkey"
17
            name="Monkey" />
18
   </extension> 
19
20
</plugin>
(-)data/org.eclipse.handlersExtensionDynamicTest/handlers.jar (+21 lines)
Added Link Here
1
PK
2
]w3	META-INF/??PK
3
\w3???^jMETA-INF/MANIFEST.MF?M??LK-.?
4
K-*????R0?3??r?Cq,HL?HU?%??Ly???RKRSt?*A?M??
5
Lt?L4?K?|3????+?KRs?<???4y?x?PK
6
7w3org/PK
7
7w3org/eclipse/PK
8
7w3org/eclipse/ui/PK
9
7w3org/eclipse/ui/dynamic/PK
10
7w3 org/eclipse/ui/dynamic/handlers/PK
11
7w3w??P0(4org/eclipse/ui/dynamic/handlers/DynamicHandler.class?P?J1=?kt????7?]4?qS)?V\?P????M??d2E?JW????off???	?s??{????7cx?1?S??JF?>S<?|???XK??"R&?e???=4?_525??12~f?i+:C?T'?N?????q?.??:??h???
12
t???8T?N??b???\??*??+?1?[w???%sK=?????gK??l?;k?<????k%-?j*Wc?????F?K???????
13
?1?w?N?<??E??6G/?z.?>?V????K?.?>:?V???????N?<,???y{?w{E??PK
14
]w3	?AMETA-INF/??PK
15
\w3???^j??+META-INF/MANIFEST.MFPK
16
7w3?A?org/PK
17
7w3?A?org/eclipse/PK
18
7w3?Aorg/eclipse/ui/PK
19
7w3?A4org/eclipse/ui/dynamic/PK
20
7w3 ?Aiorg/eclipse/ui/dynamic/handlers/PK
21
7w3w??P0(4???org/eclipse/ui/dynamic/handlers/DynamicHandler.classPK)
(-)data/org.eclipse.handlersExtensionDynamicTest/plugin.xml (+31 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.0"?>
3
<plugin
4
   id="handlersExtensionDynamicTest"
5
   name="Handlers Extension Dynamic Test Plug-in"
6
   version="1.0.0">
7
   
8
   <runtime>
9
      <library name="handlers.jar">
10
         <export name="*"/>
11
      </library>
12
   </runtime>
13
   <requires>
14
      <import plugin="org.eclipse.ui"/>
15
   </requires>
16
17
	<extension
18
			point="org.eclipse.ui.commands">
19
		<command
20
			id="monkey"
21
			name="Monkey" />
22
	</extension>
23
	<extension
24
    		id="testDynamicHandlerAddition"
25
			point="org.eclipse.ui.handlers">
26
		<handler
27
			commandId="monkey"
28
			class="org.eclipse.ui.dynamic.handlers.DynamicHandler" />
29
	</extension> 
30
31
</plugin>

Return to bug 96600