Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2014-03-31 19:52:38 +0000
committerLars Vogel2014-03-31 21:09:51 +0000
commitc978c36702ee08bd1f4b5438f826b1c7af3cc5c3 (patch)
treeb148616a62f6ec402d27f18d5fa32d26f9b7d22e
parent556c9f7fd8dd53dac8c419cc460c81ac349ade27 (diff)
downloadeclipse.platform.ui-c978c36702ee08bd1f4b5438f826b1c7af3cc5c3.tar.gz
eclipse.platform.ui-c978c36702ee08bd1f4b5438f826b1c7af3cc5c3.tar.xz
eclipse.platform.ui-c978c36702ee08bd1f4b5438f826b1c7af3cc5c3.zip
Bug 431667 - [Tests] Context access in
org.eclipse.e4.core.commands.tests should be based on .class Change-Id: I6ae955a05a36330370b7a112ee7534fb30b65784 Signed-off-by: Lars Vogel <Lars.Vogel@gmail.com>
-rw-r--r--tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/DefineCommandsTest.java10
-rw-r--r--tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/HandlerTest.java61
-rw-r--r--tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/TestActivator.java7
3 files changed, 40 insertions, 38 deletions
diff --git a/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/DefineCommandsTest.java b/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/DefineCommandsTest.java
index d37853bc55f..34fabc2199a 100644
--- a/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/DefineCommandsTest.java
+++ b/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/DefineCommandsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+ * Copyright (c) 2013, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@gmail.com> - Bug 431667
*******************************************************************************/
package org.eclipse.e4.core.commands.tests;
@@ -26,8 +27,7 @@ public class DefineCommandsTest extends TestCase {
private static final String TEST_CAT1 = "test.cat1";
public void testCreateCommands() throws Exception {
- ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ ECommandService cs = workbenchContext.get(ECommandService.class);
assertNotNull(cs);
assertNotNull(cs.defineCategory(TEST_CAT1, "CAT1", null));
Category category = cs.getCategory(TEST_CAT1);
@@ -48,7 +48,7 @@ public class DefineCommandsTest extends TestCase {
public void testCreateWithSecondContexts() throws Exception {
IEclipseContext localContext = workbenchContext.createChild();
ECommandService cs = (ECommandService) localContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
assertNotNull(cs);
assertNotNull(cs.defineCategory(TEST_CAT1, "CAT1", null));
Category category = cs.getCategory(TEST_CAT1);
@@ -67,7 +67,7 @@ public class DefineCommandsTest extends TestCase {
public void testCreateWithTwoContexts() throws Exception {
IEclipseContext localContext = workbenchContext.createChild("Level1");
ECommandService cs = (ECommandService) localContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
assertNotNull(cs);
assertNotNull(cs.defineCategory(TEST_CAT1, "CAT1", null));
Category category = cs.getCategory(TEST_CAT1);
diff --git a/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/HandlerTest.java b/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/HandlerTest.java
index 16a4216b754..db81aaee631 100644
--- a/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/HandlerTest.java
+++ b/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/HandlerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@gmail.com> - Bug 431667
******************************************************************************/
package org.eclipse.e4.core.commands.tests;
@@ -61,13 +62,13 @@ public class HandlerTest extends TestCase {
public void testCallHandler() throws Exception {
EHandlerService hs = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
CallHandler handler = new CallHandler();
hs.activateHandler(TEST_ID1, handler);
assertFalse(handler.q1);
assertFalse(handler.q2);
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
assertTrue(hs.canExecute(cmd));
assertFalse(handler.q2);
@@ -78,13 +79,13 @@ public class HandlerTest extends TestCase {
public void testDeactivateHandler() throws Exception {
EHandlerService hs = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
CallHandler handler = new CallHandler();
hs.activateHandler(TEST_ID1, handler);
assertFalse(handler.q1);
assertFalse(handler.q2);
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
assertTrue(hs.canExecute(cmd));
assertFalse(handler.q2);
@@ -98,35 +99,35 @@ public class HandlerTest extends TestCase {
IEclipseContext c1 = workbenchContext.createChild("c1");
c1.activate();
EHandlerService h1 = (EHandlerService) c1.get(EHandlerService.class
- .getName());
+ );
CallHandler handler1 = new CallHandler();
h1.activateHandler(TEST_ID1, handler1);
ECommandService cs = (ECommandService) c1.get(ECommandService.class
- .getName());
+ );
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
assertTrue(h1.canExecute(cmd));
EHandlerService wHS = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
assertTrue(wHS.canExecute(cmd));
}
public void testQueryTwoHandlers() throws Exception {
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
EHandlerService wHS = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
IEclipseContext c1 = workbenchContext.createChild("c1");
c1.activate();
EHandlerService h1 = (EHandlerService) c1.get(EHandlerService.class
- .getName());
+ );
CallHandler handler1 = new CallHandler();
h1.activateHandler(TEST_ID1, handler1);
IEclipseContext c2 = workbenchContext.createChild("c2");
EHandlerService h2 = (EHandlerService) c2.get(EHandlerService.class
- .getName());
+ );
CallHandler handler2 = new CallHandler();
h2.activateHandler(TEST_ID1, handler2);
@@ -141,21 +142,21 @@ public class HandlerTest extends TestCase {
public void testExecuteTwoActiveHandlers() throws Exception {
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
EHandlerService wHS = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
IEclipseContext c1 = workbenchContext.createChild("c1");
c1.activate();
EHandlerService h1 = (EHandlerService) c1.get(EHandlerService.class
- .getName());
+ );
CallHandler handler1 = new CallHandler();
h1.activateHandler(TEST_ID1, handler1);
IEclipseContext c2 = workbenchContext.createChild("c2");
EHandlerService h2 = (EHandlerService) c2.get(EHandlerService.class
- .getName());
+ );
CallHandler handler2 = new CallHandler();
h2.activateHandler(TEST_ID1, handler2);
@@ -175,21 +176,21 @@ public class HandlerTest extends TestCase {
public void testSwitchActivationTwoHandlers() throws Exception {
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
EHandlerService wHS = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
IEclipseContext c1 = workbenchContext.createChild("c1");
c1.activate();
EHandlerService h1 = (EHandlerService) c1.get(EHandlerService.class
- .getName());
+ );
CallHandler handler1 = new CallHandler();
h1.activateHandler(TEST_ID1, handler1);
IEclipseContext c2 = workbenchContext.createChild("c2");
EHandlerService h2 = (EHandlerService) c2.get(EHandlerService.class
- .getName());
+ );
CallHandler handler2 = new CallHandler();
h2.activateHandler(TEST_ID1, handler2);
@@ -257,12 +258,12 @@ public class HandlerTest extends TestCase {
public void testMethodInfo() throws Exception {
Info helloInfo = new Info("Hello");
- workbenchContext.set(Info.class.getName(), helloInfo);
+ workbenchContext.set(Info.class, helloInfo);
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
EHandlerService wHS = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
HandlerWithInfo handler = new HandlerWithInfo();
wHS.activateHandler(TEST_ID1, handler);
@@ -272,17 +273,17 @@ public class HandlerTest extends TestCase {
public void testMethodWithAnnocation() throws Exception {
Info helloInfo = new Info("Hello");
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
ParameterizedCommand cmd = cs.createCommand(TEST_ID1, null);
EHandlerService wHS = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
HandlerWithAnnotations handler = new HandlerWithAnnotations();
wHS.activateHandler(TEST_ID1, handler);
- workbenchContext.set(Info.class.getName(), helloInfo);
+ workbenchContext.set(Info.class, helloInfo);
assertNull(wHS.executeHandler(cmd));
- workbenchContext.remove(Info.class.getName());
+ workbenchContext.remove(Info.class);
assertNull(wHS.executeHandler(cmd));
workbenchContext.set(ACTIVE_INFO_ID, helloInfo);
@@ -294,9 +295,9 @@ public class HandlerTest extends TestCase {
public void testBug314847() {
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
EHandlerService wHS = (EHandlerService) workbenchContext
- .get(EHandlerService.class.getName());
+ .get(EHandlerService.class);
ParameterizedCommand nonparameterizedCmd = cs.createCommand(TEST_ID3, null);
ParameterizedCommand parameterizedCmd = cs.createCommand(TEST_ID3,
@@ -331,7 +332,7 @@ public class HandlerTest extends TestCase {
private void defineCommands(IEclipseContext context) {
ECommandService cs = (ECommandService) workbenchContext
- .get(ECommandService.class.getName());
+ .get(ECommandService.class);
Category category = cs.defineCategory(TEST_CAT1, "CAT1", null);
cs.defineCommand(TEST_ID1, "ID1", null, category, null);
cs.defineCommand(TEST_ID2, "ID2", null, category, null);
diff --git a/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/TestActivator.java b/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/TestActivator.java
index 1e7c7d61eba..b81aba9a55b 100644
--- a/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/TestActivator.java
+++ b/tests/org.eclipse.e4.core.commands.tests/src/org/eclipse/e4/core/commands/tests/TestActivator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+ * Copyright (c) 2013, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <Lars.Vogel@gmail.com> - Bug 431667
*******************************************************************************/
package org.eclipse.e4.core.commands.tests;
@@ -37,7 +38,7 @@ public class TestActivator implements BundleActivator {
}
private void addLogService(IEclipseContext context) {
- context.set(LogService.class.getName(), new LogService() {
+ context.set(LogService.class, new LogService() {
public void log(int level, String message) {
System.out.println(level + ": " + message);
@@ -73,7 +74,7 @@ public class TestActivator implements BundleActivator {
}
public PackageAdmin getBundleAdmin() {
- return (PackageAdmin) serviceContext.get(PackageAdmin.class.getName());
+ return (PackageAdmin) serviceContext.get(PackageAdmin.class);
}
public Bundle getBundleForName(String bundleName) {

Back to the top