diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java index 477a3b314c8..b977f1ad99d 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/activities/DynamicTest.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.ui.tests.activities; +import static org.eclipse.ui.PlatformUI.getWorkbench; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -28,8 +29,6 @@ import org.eclipse.core.runtime.ContributorFactoryOSGi; import org.eclipse.core.runtime.IContributor; import org.eclipse.core.runtime.RegistryFactory; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.activities.IActivity; import org.eclipse.ui.activities.IActivityPatternBinding; import org.eclipse.ui.activities.IActivityRequirementBinding; @@ -41,6 +40,7 @@ import org.eclipse.ui.activities.WorkbenchTriggerPointAdvisor; import org.eclipse.ui.internal.activities.MutableActivityManager; import org.eclipse.ui.tests.TestPlugin; +import org.eclipse.ui.tests.harness.util.DisplayHelper; import org.junit.Before; import org.junit.Test; @@ -425,8 +425,8 @@ public void testCategoryListener() { * Tests to ensure dynamism with regard to the extension registry. */ @Test - public void testDynamicRegistry() { - IWorkbenchActivitySupport was = PlatformUI.getWorkbench() + public void testDynamicRegistry() throws NotDefinedException { + IWorkbenchActivitySupport was = getWorkbench() .getActivitySupport(); IActivity activity = was.getActivityManager().getActivity( "dynamic.activity"); @@ -464,18 +464,8 @@ public void testDynamicRegistry() { // spin the event loop and ensure that the changes come down the pipe. // 20 seconds should be more than enough - long endTime = System.currentTimeMillis() + 20000; - while (!(registryChanged[0] && registryChanged[1]) - && System.currentTimeMillis() < endTime) { - - Display display = PlatformUI.getWorkbench().getDisplay(); - if (display != null && !display.isDisposed()) { - while (display.readAndDispatch()) { - } - } - display.sleep(); - - } + DisplayHelper.waitForCondition(getWorkbench().getDisplay(), 20000, + () -> registryChanged[0] == true && registryChanged[1]); assertTrue("Activity Listener not called", registryChanged[0]); assertTrue("Category Listener not called", registryChanged[1]); @@ -490,11 +480,7 @@ public void testDynamicRegistry() { .pattern()); assertEquals("dynamic.activity", patternBinding.getActivityId()); - try { - assertTrue(activity.isDefaultEnabled()); - } catch (NotDefinedException e) { - fail(e.getMessage()); - } + assertTrue(activity.isDefaultEnabled()); Set requirementBindings = activity.getActivityRequirementBindings(); assertEquals(1, requirementBindings.size()); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorPartTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorPartTest.java index 3ac368b2722..192ff86003b 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorPartTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorPartTest.java @@ -13,6 +13,13 @@ *******************************************************************************/ package org.eclipse.ui.tests.api; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -30,23 +37,13 @@ import org.eclipse.ui.tests.harness.util.CallHistory; import org.eclipse.ui.tests.harness.util.FileUtil; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * This is a test for IEditorPart. Since IEditorPart is an interface this test * verifies the IEditorPart lifecycle rather than the implementation. */ -@RunWith(JUnit4.class) public class IEditorPartTest extends IWorkbenchPartTest { - /** - * Constructor for IEditorPartTest - */ - public IEditorPartTest() { - super(IEditorPartTest.class.getSimpleName()); - } - /** * @see IWorkbenchPartTest#openPart(IWorkbenchPage) */ diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IViewPartTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IViewPartTest.java index 86d49773315..8533b55847e 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IViewPartTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IViewPartTest.java @@ -13,30 +13,23 @@ *******************************************************************************/ package org.eclipse.ui.tests.api; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.eclipse.ui.ISaveablePart; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.tests.harness.util.CallHistory; import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * This is a test for IViewPart. Since IViewPart is an * interface this test verifies the IViewPart lifecycle rather * than the implementation. */ -@RunWith(JUnit4.class) public class IViewPartTest extends IWorkbenchPartTest { - /** - * Constructor for IEditorPartTest - */ - public IViewPartTest() { - super(IViewPartTest.class.getSimpleName()); - } - /** * @see IWorkbenchPartTest#openPart(IWorkbenchPage) */ diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartTest.java index f909a2a72ea..4dfbcf198ba 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkbenchPartTest.java @@ -13,10 +13,13 @@ *******************************************************************************/ package org.eclipse.ui.tests.api; +import static org.junit.Assert.assertTrue; + import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.tests.harness.util.CallHistory; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.Before; import org.junit.Test; /** @@ -24,23 +27,15 @@ * interface this test verifies the IWorkbenchPart lifecycle rather * than the implementation. */ -public abstract class IWorkbenchPartTest extends UITestCase { +public abstract class IWorkbenchPartTest { protected IWorkbenchWindow fWindow; protected IWorkbenchPage fPage; - /** - * Constructor for IActionDelegateTest - */ - public IWorkbenchPartTest(String testName) { - super(testName); - } - - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - fWindow = openTestWindow(); + @Before + public void doSetUp() throws Exception { + fWindow = UITestCase.openTestWindow(); fPage = fWindow.getActivePage(); } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java index 5ca79a621e3..8d7fda78fba 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/Bug417762Test.java @@ -33,9 +33,6 @@ import org.eclipse.ui.handlers.IHandlerService; import org.junit.Test; -/** - * @since 3.5 - */ public class Bug417762Test { @Test diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandCallbackTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandCallbackTest.java index 86080c18388..26e82b5797a 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandCallbackTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandCallbackTest.java @@ -15,6 +15,11 @@ package org.eclipse.ui.tests.commands; +import static org.eclipse.ui.PlatformUI.getWorkbench; +import static org.eclipse.ui.tests.harness.util.UITestCase.openTestWindow; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import java.util.HashMap; import java.util.Map; @@ -35,22 +40,21 @@ import org.eclipse.ui.menus.UIElement; import org.eclipse.ui.services.IServiceLocator; import org.eclipse.ui.services.IServiceScopes; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -/** - * @since 3.3 - */ -@RunWith(JUnit4.class) -public class CommandCallbackTest extends UITestCase { +public class CommandCallbackTest { private static final String HOST_PARAM_ID = "host"; private static final String PROT_PARAM_ID = "protocol"; private static final String PREFIX = "tests.commands.CCT."; private static final String CMD1_ID = PREFIX + "cmd1"; private static final String CMD2_ID = PREFIX + "cmd2"; + @Rule + public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule(); private ICommandService commandService; private Command cmd1; @@ -61,18 +65,13 @@ public class CommandCallbackTest extends UITestCase { private CallbackHandler cmd1Handler; private CallbackHandler cmd2Handler; - public CommandCallbackTest() { - super(CommandCallbackTest.class.getSimpleName()); - } - - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - commandService = fWorkbench + @Before + public void doSetUp() throws Exception { + commandService = getWorkbench() .getService(ICommandService.class); cmd1 = commandService.getCommand(CMD1_ID); cmd2 = commandService.getCommand(CMD2_ID); - handlerService = fWorkbench + handlerService = getWorkbench() .getService(IHandlerService.class); cmd1Handler = new CallbackHandler(); cmd1Activation = handlerService.activateHandler(CMD1_ID, cmd1Handler); @@ -80,8 +79,8 @@ protected void doSetUp() throws Exception { cmd2Activation = handlerService.activateHandler(CMD2_ID, cmd2Handler); } - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { if (cmd1Activation != null) { handlerService.deactivateHandler(cmd1Activation); cmd1Activation = null; @@ -90,7 +89,6 @@ protected void doTearDown() throws Exception { handlerService.deactivateHandler(cmd2Activation); cmd2Activation = null; } - super.doTearDown(); } private static class CallbackHandler extends AbstractHandler implements @@ -180,9 +178,9 @@ public void testNoParametersWithCallbacks() throws Exception { ParameterizedCommand pc2 = new ParameterizedCommand(cmd1, null); IElementReference cr1 = commandService.registerElementForCommand(pc1, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); IElementReference cr2 = commandService.registerElementForCommand(pc2, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); try { assertEquals(2, cmd1Handler.callbacks); @@ -213,9 +211,9 @@ public void testParametersWithCallbacks() throws Exception { new Parameterization(parmProt, "http"), new Parameterization(parmHost, "download.eclipse.org") }); IElementReference cr1 = commandService.registerElementForCommand(pc1, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); IElementReference cr2 = commandService.registerElementForCommand(pc2, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); try { assertEquals(2, cmd2Handler.callbacks); @@ -261,11 +259,11 @@ public void testParmsToSameCommand() throws Exception { new Parameterization(parmProt, "http"), new Parameterization(parmHost, "download.eclipse.org") }); IElementReference cr1 = commandService.registerElementForCommand(pc1, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); IElementReference cr2 = commandService.registerElementForCommand(pc2, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); IElementReference cr3 = commandService.registerElementForCommand(pc3, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); try { assertEquals(3, cmd2Handler.callbacks); @@ -323,15 +321,15 @@ public void testParmsToDifferentProtocol() throws Exception { new Parameterization[] { new Parameterization(parmProt, "ftp"), new Parameterization(parmHost, "download.eclipse.org") }); IElementReference cr1 = commandService.registerElementForCommand(pc1, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); IElementReference cr2 = commandService.registerElementForCommand(pc2, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); IElementReference cr3 = commandService.registerElementForCommand(pc3, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); IElementReference cr4 = commandService.registerElementForCommand(pc4, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); IElementReference cr5 = commandService.registerElementForCommand(pc5, - new MyElement(fWorkbench)); + new MyElement(getWorkbench())); try { assertEquals(5, cmd2Handler.callbacks); Map filter = new HashMap<>(); @@ -420,7 +418,7 @@ public void testCallbackCleanup() throws Exception { try { assertEquals(2, cmd1Handler.callbacks); cmd1Handler.callbacks = 0; - closeAllTestWindows(); + closeTestWindows.closeAllTestWindows(); commandService.refreshElements(CMD1_ID, null); assertEquals(1, cmd1Handler.callbacks); } finally { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java index bc2576a2bf4..74d1e749855 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/HandlerActivationTest.java @@ -14,6 +14,12 @@ package org.eclipse.ui.tests.commands; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.HashMap; import java.util.Map; @@ -44,17 +50,16 @@ import org.eclipse.ui.services.IServiceLocator; import org.eclipse.ui.tests.harness.util.UITestCase; import org.eclipse.ui.views.contentoutline.ContentOutline; +import org.junit.After; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Tests various aspects of command state. * * @since 3.2 */ -@RunWith(JUnit4.class) -public class HandlerActivationTest extends UITestCase { +public class HandlerActivationTest { static class ActTestHandler extends AbstractHandler { public String contextId; @@ -78,16 +83,15 @@ static class OutlineOnlyHandler extends AbstractHandler { public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); if (!(part instanceof ContentOutline)) { - throw new ExecutionException("bogus part " - + part.getSite().getId()); + throw new ExecutionException("bogus part " + part.getSite().getId()); } return null; } @Override public void setEnabled(Object evaluationContext) { - IWorkbenchPart part = (IWorkbenchPart) HandlerUtil.getVariable( - evaluationContext, ISources.ACTIVE_PART_NAME); + IWorkbenchPart part = (IWorkbenchPart) HandlerUtil.getVariable(evaluationContext, + ISources.ACTIVE_PART_NAME); setBaseEnabled(part instanceof ContentOutline); } } @@ -96,13 +100,11 @@ public void setEnabled(Object evaluationContext) { public static final String C1_ID = C_PREFIX + ISources.ACTIVE_CONTEXT_NAME; - public static final String C2_ID = C_PREFIX - + ISources.ACTIVE_ACTION_SETS_NAME; + public static final String C2_ID = C_PREFIX + ISources.ACTIVE_ACTION_SETS_NAME; public static final String C3_ID = C_PREFIX + ISources.ACTIVE_SHELL_NAME; - public static final String C4_ID = C_PREFIX - + ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME; + public static final String C4_ID = C_PREFIX + ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME; private static final String CATEGORY_ID = "org.eclipse.ui.category.window"; @@ -110,13 +112,10 @@ public void setEnabled(Object evaluationContext) { private static final String[][] CREATE_CONTEXTS = { { C1_ID, "Active Contexts", null, IContextService.CONTEXT_ID_WINDOW }, - { C2_ID, "Active Action Sets", null, - IContextService.CONTEXT_ID_WINDOW }, + { C2_ID, "Active Action Sets", null, IContextService.CONTEXT_ID_WINDOW }, { C3_ID, "Active Shell", null, IContextService.CONTEXT_ID_WINDOW }, - { C4_ID, "Active Workbench Window Shell", null, - IContextService.CONTEXT_ID_WINDOW }, - { (C_PREFIX + ISources.ACTIVE_MENU_NAME), - "Active Workbench Window Shell", null, + { C4_ID, "Active Workbench Window Shell", null, IContextService.CONTEXT_ID_WINDOW }, + { (C_PREFIX + ISources.ACTIVE_MENU_NAME), "Active Workbench Window Shell", null, IContextService.CONTEXT_ID_WINDOW }, }; public static final String H1 = C_PREFIX + "h1"; @@ -143,14 +142,10 @@ public void setEnabled(Object evaluationContext) { * Constructor for HandlerActivationTest. */ public HandlerActivationTest() { - super(HandlerActivationTest.class.getSimpleName()); services = PlatformUI.getWorkbench(); - contextService = services - .getService(IContextService.class); - commandService = services - .getService(ICommandService.class); - handlerService = services - .getService(IHandlerService.class); + contextService = services.getService(IContextService.class); + commandService = services.getService(ICommandService.class); + handlerService = services.getService(IHandlerService.class); } private IContextActivation activateContext(String contextId) { @@ -160,24 +155,21 @@ private IContextActivation activateContext(String contextId) { } private void assertHandlerIsExecuted(Command cmd, String handlerId) - throws ExecutionException, NotDefinedException, - NotEnabledException, NotHandledException { + throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException { ActTestHandler handler = (ActTestHandler) testHandlers.get(handlerId); int count = handler.executionCount; cmd.executeWithChecks(handlerService.createExecutionEvent(cmd, null)); - assertEquals("The handler count should be incremented", count + 1, - handler.executionCount); + assertEquals("The handler count should be incremented", count + 1, handler.executionCount); } - private void createHandlerActivation(String contextId, String handlerId, - String[] expressionInfo) { + private void createHandlerActivation(String contextId, String handlerId, String[] expressionInfo) { ActiveContextExpression expression; expression = new ActiveContextExpression(contextId, expressionInfo); makeHandler(handlerId, contextId, expression); } - @Override - protected void doSetUp() throws Exception { + @Before + public void doSetUp() throws Exception { for (final String[] contextInfo : CREATE_CONTEXTS) { final Context context = contextService.getContext(contextInfo[0]); if (!context.isDefined()) { @@ -194,17 +186,16 @@ protected void doSetUp() throws Exception { } - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { handlerService.deactivateHandlers(testHandlerActivations.values()); testHandlerActivations.clear(); contextService.deactivateContexts(testContextActivations.values()); testContextActivations.clear(); - super.doTearDown(); } - private void doTestForBreak() throws ExecutionException, - NotDefinedException, NotEnabledException, NotHandledException { + private void doTestForBreak() + throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException { Command cmd = commandService.getCommand(CMD_ID); assertTrue("Command should be defined", cmd.isDefined()); @@ -223,8 +214,7 @@ private void doTestForBreak() throws ExecutionException, contextService.deactivateContext(c1); } - private void makeHandler(String handler, String context, - ActiveContextExpression expression) { + private void makeHandler(String handler, String context, ActiveContextExpression expression) { IHandler currentHandler = null; if (!testHandlers.containsKey(handler)) { currentHandler = new ActTestHandler(context); @@ -233,30 +223,19 @@ private void makeHandler(String handler, String context, currentHandler = testHandlers.get(handler); } - testHandlerActivations.put(handler, handlerService.activateHandler( - CMD_ID, currentHandler, expression)); + testHandlerActivations.put(handler, handlerService.activateHandler(CMD_ID, currentHandler, expression)); } - @Test - public void testExceptionThrowingHandler(){ - - try { - handlerService.executeCommand("org.eclipse.ui.tests.command.handlerException", null); - fail("An exception should be thrown for this handler"); - } catch (Exception e) { - if(!(e instanceof ExecutionException)) { - fail("Unexpected exception while executing command", e); - } - } + public void testExceptionThrowingHandler() { + assertThrows("An exception should be thrown for this handler", ExecutionException.class, + () -> handlerService.executeCommand("org.eclipse.ui.tests.command.handlerException", null)); } - @Test public void testBasicHandler() throws Exception { - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); Command cmd = commandService.getCommand(CMD_ID); assertTrue("Command should be defined", cmd.isDefined()); @@ -269,8 +248,7 @@ public void testBasicHandler() throws Exception { ActTestHandler handler1 = (ActTestHandler) testHandlers.get(H1); int count = handler1.executionCount; cmd.executeWithChecks(handlerService.createExecutionEvent(cmd, null)); - assertEquals("The handler count should be correct", count + 1, - handler1.executionCount); + assertEquals("The handler count should be correct", count + 1, handler1.executionCount); contextService.deactivateContext(activationC1); @@ -279,26 +257,20 @@ public void testBasicHandler() throws Exception { @Test public void testForBreak123() throws Exception { - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); createHandlerActivation(C2_ID, H2, - new String[] { ISources.ACTIVE_CONTEXT_NAME, - ISources.ACTIVE_ACTION_SETS_NAME }); - createHandlerActivation(C3_ID, H3, new String[] { - ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); + new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_ACTION_SETS_NAME }); + createHandlerActivation(C3_ID, H3, new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); doTestForBreak(); } @Test public void testForBreak132() throws Exception { - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); - createHandlerActivation(C3_ID, H3, new String[] { - ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); + createHandlerActivation(C3_ID, H3, new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); createHandlerActivation(C2_ID, H2, - new String[] { ISources.ACTIVE_CONTEXT_NAME, - ISources.ACTIVE_ACTION_SETS_NAME }); + new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_ACTION_SETS_NAME }); doTestForBreak(); } @@ -306,12 +278,9 @@ public void testForBreak132() throws Exception { @Test public void testForBreak213() throws Exception { createHandlerActivation(C2_ID, H2, - new String[] { ISources.ACTIVE_CONTEXT_NAME, - ISources.ACTIVE_ACTION_SETS_NAME }); - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); - createHandlerActivation(C3_ID, H3, new String[] { - ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); + new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_ACTION_SETS_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); + createHandlerActivation(C3_ID, H3, new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); doTestForBreak(); } @@ -319,38 +288,29 @@ public void testForBreak213() throws Exception { @Test public void testForBreak231() throws Exception { createHandlerActivation(C2_ID, H2, - new String[] { ISources.ACTIVE_CONTEXT_NAME, - ISources.ACTIVE_ACTION_SETS_NAME }); - createHandlerActivation(C3_ID, H3, new String[] { - ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); + new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_ACTION_SETS_NAME }); + createHandlerActivation(C3_ID, H3, new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); doTestForBreak(); } @Test public void testForBreak312() throws Exception { - createHandlerActivation(C3_ID, H3, new String[] { - ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); + createHandlerActivation(C3_ID, H3, new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); createHandlerActivation(C2_ID, H2, - new String[] { ISources.ACTIVE_CONTEXT_NAME, - ISources.ACTIVE_ACTION_SETS_NAME }); + new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_ACTION_SETS_NAME }); doTestForBreak(); } @Test public void testForBreak321() throws Exception { - createHandlerActivation(C3_ID, H3, new String[] { - ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); + createHandlerActivation(C3_ID, H3, new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_SHELL_NAME }); createHandlerActivation(C2_ID, H2, - new String[] { ISources.ACTIVE_CONTEXT_NAME, - ISources.ACTIVE_ACTION_SETS_NAME }); - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); + new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_ACTION_SETS_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); doTestForBreak(); } @@ -359,10 +319,8 @@ public void testForBreak321() throws Exception { public void testForNegativeNumber() throws Exception { String c5_id = C_PREFIX + ISources.ACTIVE_MENU_NAME; String h5 = C_PREFIX + "h5"; - createHandlerActivation(c5_id, h5, new String[] { - ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_MENU_NAME }); - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); + createHandlerActivation(c5_id, h5, new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_MENU_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); Command cmd = commandService.getCommand(CMD_ID); @@ -374,11 +332,9 @@ public void testForNegativeNumber() throws Exception { @Test public void testTwoHandlers() throws Exception { - createHandlerActivation(C1_ID, H1, - new String[] { ISources.ACTIVE_CONTEXT_NAME }); + createHandlerActivation(C1_ID, H1, new String[] { ISources.ACTIVE_CONTEXT_NAME }); createHandlerActivation(C2_ID, H2, - new String[] { ISources.ACTIVE_CONTEXT_NAME, - ISources.ACTIVE_ACTION_SETS_NAME }); + new String[] { ISources.ACTIVE_CONTEXT_NAME, ISources.ACTIVE_ACTION_SETS_NAME }); Command cmd = commandService.getCommand(CMD_ID); assertTrue("Command should be defined", cmd.isDefined()); @@ -390,8 +346,7 @@ public void testTwoHandlers() throws Exception { ActTestHandler handler1 = (ActTestHandler) testHandlers.get(H1); int count1 = handler1.executionCount; cmd.executeWithChecks(new ExecutionEvent()); - assertEquals("The handler count should be incremented", count1 + 1, - handler1.executionCount); + assertEquals("The handler count should be incremented", count1 + 1, handler1.executionCount); activateContext(C2_ID); assertTrue("Should still be handled", cmd.isHandled()); @@ -400,10 +355,8 @@ public void testTwoHandlers() throws Exception { int count2 = handler2.executionCount; count1 = handler1.executionCount; cmd.executeWithChecks(new ExecutionEvent()); - assertEquals("The handler1 count should not be incremented", count1, - handler1.executionCount); - assertEquals("The handler2 count should be incremented", count2 + 1, - handler2.executionCount); + assertEquals("The handler1 count should not be incremented", count1, handler1.executionCount); + assertEquals("The handler2 count should be incremented", count2 + 1, handler2.executionCount); contextService.deactivateContext(activationC1); assertTrue("Will still be handled", cmd.isHandled()); @@ -411,12 +364,10 @@ public void testTwoHandlers() throws Exception { @Test public void testLocalContext() throws Exception { - IWorkbenchWindow window = openTestWindow("org.eclipse.ui.resourcePerspective"); + IWorkbenchWindow window = UITestCase.openTestWindow("org.eclipse.ui.resourcePerspective"); OutlineOnlyHandler handler = new OutlineOnlyHandler(); - IEvaluationContext oldContext = handlerService - .createContextSnapshot(false); - testHandlerActivations.put(handler, handlerService.activateHandler( - CMD_ID, handler)); + IEvaluationContext oldContext = handlerService.createContextSnapshot(false); + testHandlerActivations.put(handler, handlerService.activateHandler(CMD_ID, handler)); Command cmd = commandService.getCommand(CMD_ID); ParameterizedCommand pcmd = new ParameterizedCommand(cmd, null); try { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java index 04bf1ac9abb..a612c7f1b59 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ToggleStateTest.java @@ -36,15 +36,8 @@ import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import org.junit.runners.MethodSorters; -/** - * @since 3.5 - * @author Prakash G.R. - */ -@RunWith(JUnit4.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ToggleStateTest { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingArchiveProjectFilterTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingArchiveProjectFilterTest.java index 5132ead15f5..7fcd9980fba 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingArchiveProjectFilterTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingArchiveProjectFilterTest.java @@ -14,6 +14,12 @@ package org.eclipse.ui.tests.datatransfer; +import static org.eclipse.ui.PlatformUI.getWorkbench; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.net.URL; import java.util.ArrayList; @@ -40,7 +46,6 @@ import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.internal.dialogs.ImportExportWizard; import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage; @@ -50,22 +55,16 @@ import org.eclipse.ui.tests.harness.util.EmptyPerspective; import org.eclipse.ui.tests.harness.util.FileUtil; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) -public class ImportExistingArchiveProjectFilterTest extends UITestCase { +public class ImportExistingArchiveProjectFilterTest { private static final String DATA_PATH_PREFIX = "data/org.eclipse.datatransferArchives/"; private static final String ARCHIVE_JAVA_PROJECT = "ExcludeFilter_Import"; - public ImportExistingArchiveProjectFilterTest() { - super(ImportExistingArchiveProjectFilterTest.class.getName()); - } - - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { if (dialog != null) { dialog.close(); dialog = null; @@ -75,7 +74,6 @@ protected void doTearDown() throws Exception { for (int i = projects.length - 1; i >= 0; i--) { FileUtil.deleteProject(projects[i]); } - super.doTearDown(); } // Testcase for Github Issue @@ -133,7 +131,7 @@ public void testFolderVisibilityPostZipProjectImport() // is applied to hide on import TreeViewer treeViewer = projectExplorer.getCommonViewer(); projectExplorer.getCommonViewer().expandToLevel(2); - processEvents(); + UITestCase.processEvents(); // Check Project explorer tree viewer if res folder is present @@ -193,6 +191,6 @@ public WizardProjectsImportPage getNewWizard() { } private Shell getShell() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + return getWorkbench().getActiveWorkbenchWindow().getShell(); } } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java index 80b17938d83..25f90a88ed0 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java @@ -17,8 +17,14 @@ package org.eclipse.ui.tests.datatransfer; import static org.eclipse.jface.dialogs.IMessageProvider.WARNING; +import static org.eclipse.ui.PlatformUI.getWorkbench; import static org.eclipse.ui.tests.datatransfer.ImportTestUtils.restoreWorkspaceConfiguration; import static org.eclipse.ui.tests.datatransfer.ImportTestUtils.setWorkspaceAutoBuild; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; @@ -48,7 +54,6 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.internal.dialogs.ImportExportWizard; import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages; @@ -57,8 +62,9 @@ import org.eclipse.ui.tests.TestPlugin; import org.eclipse.ui.tests.datatransfer.ImportTestUtils.TestBuilder; import org.eclipse.ui.tests.harness.util.FileUtil; -import org.eclipse.ui.tests.harness.util.UITestCase; import org.eclipse.ui.wizards.datatransfer.ExternalProjectImportWizard; +import org.junit.After; +import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; @@ -67,7 +73,7 @@ @RunWith(JUnit4.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ImportExistingProjectsWizardTest extends UITestCase { +public class ImportExistingProjectsWizardTest { private static final String DATA_PATH_PREFIX = "data/org.eclipse.datatransferArchives/"; private static final String WS_DATA_LOCATION = "importExistingFromDirTest"; @@ -89,17 +95,12 @@ public class ImportExistingProjectsWizardTest extends UITestCase { private boolean originalRefreshSetting; - public ImportExistingProjectsWizardTest() { - super(ImportExistingProjectsWizardTest.class.getName()); - } - private Shell getShell() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + return getWorkbench().getActiveWorkbenchWindow().getShell(); } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); + @Before + public void doSetUp() throws Exception { originalRefreshSetting = ResourcesPlugin.getPlugin() .getPluginPreferences().getBoolean( ResourcesPlugin.PREF_AUTO_REFRESH); @@ -108,8 +109,8 @@ protected void doSetUp() throws Exception { setWorkspaceAutoBuild(true); } - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { if (dialog != null) { dialog.close(); dialog = null; @@ -143,12 +144,11 @@ protected void doTearDown() throws Exception { ResourcesPlugin.getPlugin().getPluginPreferences().setValue( ResourcesPlugin.PREF_AUTO_REFRESH, originalRefreshSetting); restoreWorkspaceConfiguration(); - super.doTearDown(); } private void waitForRefresh() { try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile( + getWorkbench().getProgressService().busyCursorWhile( monitor -> Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, new NullProgressMonitor())); } catch (InvocationTargetException | InterruptedException e) { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExportWizardsCategoryTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExportWizardsCategoryTests.java index 3e982ae2123..4836f0ef93f 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExportWizardsCategoryTests.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExportWizardsCategoryTests.java @@ -13,18 +13,18 @@ *******************************************************************************/ package org.eclipse.ui.tests.datatransfer; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import org.eclipse.core.runtime.IPath; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.internal.registry.WizardsRegistryReader; -import org.eclipse.ui.tests.harness.util.UITestCase; import org.eclipse.ui.wizards.IWizardCategory; import org.eclipse.ui.wizards.IWizardDescriptor; +import org.junit.After; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) -public class ImportExportWizardsCategoryTests extends UITestCase { +public class ImportExportWizardsCategoryTests { private static String WIZARD_ID_IMPORT_NO_CATEGORY = "org.eclipse.ui.tests.import.NoCategory"; private static String WIZARD_ID_IMPORT_INVALID_CATEGORY = "org.eclipse.ui.tests.import.InvalidCategory"; @@ -48,7 +48,6 @@ public class ImportExportWizardsCategoryTests extends UITestCase { IWizardCategory importRoot; public ImportExportWizardsCategoryTests() { - super(ImportExportWizardsCategoryTests.class.getSimpleName()); exportRoot = WorkbenchPlugin.getDefault() .getExportWizardRegistry().getRootCategory(); importRoot = WorkbenchPlugin.getDefault() @@ -68,7 +67,7 @@ public void testImportNoCategoryProvided(){ wizardDesc != null); return; } - assertTrue("Could not find Other category", false); + fail("Could not find Other category"); } @Test @@ -83,7 +82,7 @@ public void testImportCategoryDoesNotExist(){ wizardDesc != null); return; } - assertTrue("Could not find Other category", false); + fail("Could not find Other category"); } @Test @@ -98,7 +97,7 @@ public void testImportAddToNewCategory(){ wizardDesc != null); return; } - assertTrue("Could not find category named " + WIZARD_IMPORT_NEW_CATEGORY, false); + fail("Could not find category named " + WIZARD_IMPORT_NEW_CATEGORY); } @Test @@ -113,7 +112,7 @@ public void testImportAddToParentedCategory(){ wizardDesc != null); return; } - assertTrue("Could not find category named " + WIZARD_IMPORT_NEW_PARENTED_CATEGORY, false); + fail("Could not find category named " + WIZARD_IMPORT_NEW_PARENTED_CATEGORY); } @Test @@ -128,7 +127,7 @@ public void testImportDuplicateCategory(){ wizardDesc != null); return; } - assertTrue("Could not find category named " + WIZARD_IMPORT_DUPLICATE_CATEGORY, false); + fail("Could not find category named " + WIZARD_IMPORT_DUPLICATE_CATEGORY); } @Test @@ -153,7 +152,7 @@ public void testExportNoCategoryProvided(){ wizardDesc != null); return; } - assertTrue("Could not find Other category", false); + fail("Could not find Other category"); } @Test @@ -168,7 +167,7 @@ public void testExportCategoryDoesNotExist(){ wizardDesc != null); return; } - assertTrue("Could not find Other category", false); + fail("Could not find Other category"); } @Test @@ -183,7 +182,7 @@ public void testExportAddToNewCategory(){ wizardDesc != null); return; } - assertTrue("Could not find category named " + WIZARD_EXPORT_NEW_CATEGORY, false); + fail("Could not find category named " + WIZARD_EXPORT_NEW_CATEGORY); } @Test @@ -198,7 +197,7 @@ public void testExportAddToParentedCategory(){ wizardDesc != null); return; } - assertTrue("Could not find category named " + WIZARD_EXPORT_NEW_PARENTED_CATEGORY, false); + fail("Could not find category named " + WIZARD_EXPORT_NEW_PARENTED_CATEGORY); } @Test @@ -213,7 +212,7 @@ public void testExportDuplicateCategory(){ wizardDesc != null); return; } - assertTrue("Could not find category named " + WIZARD_EXPORT_DUPLICATE_CATEGORY, false); + fail("Could not find category named " + WIZARD_EXPORT_DUPLICATE_CATEGORY); } @Test @@ -225,9 +224,8 @@ public void testExportUsingImportCategory(){ category == null); } - @Override - protected void doTearDown() throws Exception { - super.doTearDown(); + @After + public void doTearDown() throws Exception { importRoot = null; exportRoot = null; } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportOperationTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportOperationTest.java index 3ac0365d368..7d0e8942554 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportOperationTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportOperationTest.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.ui.tests.datatransfer; +import static org.eclipse.ui.tests.harness.util.UITestCase.openTestWindow; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -29,15 +34,16 @@ import org.eclipse.core.tests.harness.FileSystemHelper; import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.tests.harness.util.FileUtil; -import org.eclipse.ui.tests.harness.util.UITestCase; import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider; import org.eclipse.ui.wizards.datatransfer.ImportOperation; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public class ImportOperationTest extends UITestCase implements IOverwriteQuery { +public class ImportOperationTest implements IOverwriteQuery { private static final String[] directoryNames = { "dir1", "dir2" }; @@ -47,10 +53,6 @@ public class ImportOperationTest extends UITestCase implements IOverwriteQuery { private IProject project; - public ImportOperationTest() { - super(ImportOperationTest.class.getSimpleName()); - } - private void createSubDirectory(String parentName, String newDirName) throws IOException { String newDirPath = parentName + File.separatorChar + newDirName; @@ -75,9 +77,8 @@ public String queryOverwrite(String pathString) { return ""; } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); + @Before + public void doSetUp() throws Exception { Class testClass = Class .forName("org.eclipse.ui.tests.datatransfer.ImportOperationTest"); InputStream stream = testClass.getResourceAsStream("tests.ini"); @@ -104,9 +105,8 @@ private void setUpDirectory() throws IOException { * Tear down. Delete the project we created and all of the * files on the file system. */ - @Override - protected void doTearDown() throws Exception { - super.doTearDown(); + @After + public void doTearDown() throws Exception { try { project.delete(true, true, null); File topDirectory = new File(localDirectory); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/SmartImportTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/SmartImportTests.java index de57704c53c..68e9d693d0a 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/SmartImportTests.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/SmartImportTests.java @@ -16,6 +16,13 @@ import static org.eclipse.ui.tests.datatransfer.ImportTestUtils.restoreWorkspaceConfiguration; import static org.eclipse.ui.tests.datatransfer.ImportTestUtils.setWorkspaceAutoBuild; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEventsUntil; +import static org.eclipse.ui.tests.harness.util.UITestCase.waitForJobs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.CharArrayReader; import java.io.CharArrayWriter; @@ -68,7 +75,8 @@ import org.eclipse.ui.internal.wizards.datatransfer.SmartImportWizard; import org.eclipse.ui.tests.TestPlugin; import org.eclipse.ui.tests.datatransfer.contributions.ImportMeProjectConfigurator; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -77,31 +85,22 @@ * @since 3.12 */ @RunWith(JUnit4.class) -public class SmartImportTests extends UITestCase { +public class SmartImportTests { private WizardDialog dialog; - public SmartImportTests() { - super(SmartImportTests.class.getName()); - } - - @Override + @Before public void doSetUp() throws Exception { - super.doSetUp(); ImportMeProjectConfigurator.configuredProjects.clear(); clearAll(); setWorkspaceAutoBuild(true); } - @Override + @After public void doTearDown() throws Exception { ImportMeProjectConfigurator.configuredProjects.clear(); - try { - clearAll(); - restoreWorkspaceConfiguration(); - } finally { - super.doTearDown(); - } + clearAll(); + restoreWorkspaceConfiguration(); } private void clearAll() throws CoreException, IOException { @@ -144,7 +143,7 @@ private void proceedSmartImportWizard(SmartImportWizard wizard) throws Interrupt private void proceedSmartImportWizard(SmartImportWizard wizard, Consumer setSettings) throws InterruptedException { - WizardDialog dialog = new WizardDialog(getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); + WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); try { dialog.setBlockOnOpen(false); dialog.open(); @@ -231,7 +230,7 @@ public void testImportProjectWithExistingName() SmartImportWizard wizard = new SmartImportWizard(); wizard.setInitialImportSource(file); - this.dialog = new WizardDialog(getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); + this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.setBlockOnOpen(false); dialog.open(); processEvents(); @@ -351,7 +350,7 @@ public void testCancelWizardCancelsJob() { SmartImportWizard wizard = new SmartImportWizard(); wizard.setInitialImportSource(importRoot); - this.dialog = new WizardDialog(getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); + this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.setBlockOnOpen(false); dialog.open(); SmartImportRootWizardPage page = (SmartImportRootWizardPage) dialog.getCurrentPage(); @@ -425,7 +424,7 @@ public void testChangedWorkingSets() throws Exception { SmartImportWizard wizard = new SmartImportWizard(); wizard.setInitialImportSource(directoryToImport); wizard.setInitialWorkingSets(Collections.singleton(workingSet)); - this.dialog = new WizardDialog(getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); + this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.setBlockOnOpen(false); dialog.open(); processEvents(); @@ -484,7 +483,7 @@ public void testBug559600() throws Exception { wizard.setInitialImportSource(File.listRoots()[0]); wizard.getDialogSettings().put("SmartImportRootWizardPage.STORE_HIDE_ALREADY_OPEN", true); wizard.getDialogSettings().put("SmartImportRootWizardPage.STORE_NESTED_PROJECTS", false); - this.dialog = new WizardDialog(getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); + this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.setBlockOnOpen(false); dialog.open(); SmartImportRootWizardPage page = (SmartImportRootWizardPage) dialog.getCurrentPage(); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIEditWorkingSetWizardAuto.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIEditWorkingSetWizardAuto.java index dd42e31bc4c..263c7103fee 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIEditWorkingSetWizardAuto.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIEditWorkingSetWizardAuto.java @@ -14,8 +14,15 @@ package org.eclipse.ui.tests.dialogs; import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import java.util.List; + import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceDescription; @@ -29,6 +36,7 @@ import org.eclipse.swt.widgets.Widget; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSetManager; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.IWorkingSetPage; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.internal.dialogs.WorkingSetEditWizard; @@ -36,21 +44,14 @@ import org.eclipse.ui.tests.harness.util.ArrayUtil; import org.eclipse.ui.tests.harness.util.DialogCheck; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Tests the WorkingSetEditWizard * Tests input validation, presence of correct edit page and * wizard page texts. */ -@RunWith(JUnit4.class) public class UIEditWorkingSetWizardAuto extends UIWorkingSetWizardsAuto { - public UIEditWorkingSetWizardAuto() { - super(UIEditWorkingSetWizardAuto.class.getSimpleName()); - } - @Override protected WorkingSetEditWizard createWizardToTest() { return new WorkingSetEditWizard(getDefaultEditPage()); @@ -102,7 +103,7 @@ public void testEditPage() throws Throwable { /* * Test page state with preset page input */ - IWorkingSetManager workingSetManager = fWorkbench.getWorkingSetManager(); + IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); IWorkingSet workingSet = workingSetManager.createWorkingSet(WORKING_SET_NAME_1, new IAdaptable[] { getProject1(), getFileInProject2() }); getWizard().setSelection(workingSet); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UINewWorkingSetWizardAuto.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UINewWorkingSetWizardAuto.java index 569c5c40e4f..5c9b10c7035 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UINewWorkingSetWizardAuto.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UINewWorkingSetWizardAuto.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.ui.tests.dialogs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.List; import org.eclipse.core.runtime.IAdaptable; @@ -25,6 +31,7 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.Widget; import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.IWorkingSetNewWizard; import org.eclipse.ui.dialogs.IWorkingSetPage; import org.eclipse.ui.internal.WorkbenchPlugin; @@ -35,24 +42,17 @@ import org.eclipse.ui.tests.harness.util.ArrayUtil; import org.eclipse.ui.tests.harness.util.DialogCheck; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Tests the WorkingSetNewWizard. * Tests input validation, presence of type page and correct edit page * and wizard page texts. */ -@RunWith(JUnit4.class) public class UINewWorkingSetWizardAuto extends UIWorkingSetWizardsAuto { - public UINewWorkingSetWizardAuto() { - super(UINewWorkingSetWizardAuto.class.getSimpleName()); - } - @Override protected IWorkingSetNewWizard createWizardToTest() { - return getWorkbench().getWorkingSetManager().createWorkingSetNewWizard(null); + return PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetNewWizard(null); } @Test diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIWorkingSetWizardsAuto.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIWorkingSetWizardsAuto.java index 9fdef717853..e642d1e3007 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIWorkingSetWizardsAuto.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIWorkingSetWizardsAuto.java @@ -45,12 +45,13 @@ import org.eclipse.ui.tests.TestPlugin; import org.eclipse.ui.tests.harness.util.DialogCheck; import org.eclipse.ui.tests.harness.util.FileUtil; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; +import org.junit.Before; /** * Abstract test class for the working set wizard tests. */ -public abstract class UIWorkingSetWizardsAuto extends UITestCase { +public abstract class UIWorkingSetWizardsAuto { protected static final String WORKING_SET_NAME_1 = "ws1"; protected static final String WORKING_SET_NAME_2 = "ws2"; @@ -69,10 +70,6 @@ public abstract class UIWorkingSetWizardsAuto extends UITestC private IFile fileInProject2; - public UIWorkingSetWizardsAuto(String name) { - super(name); - } - protected WizardDialog getWizardDialog() { return wizardDialog; } @@ -93,9 +90,8 @@ protected IFile getFileInProject2() { return fileInProject2; } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); + @Before + public void doSetUp() throws Exception { wizardToTest = createWizardToTest(); wizardDialog = createWizardDialog(); initializeTestResources(); @@ -120,16 +116,15 @@ private void initializeTestResources() throws CoreException { fileInProject2 = FileUtil.createFile("f2.txt", project2); } - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { removeAllWorkingSets(); cleanupWorkspace(); disposeWizardAndDialog(); - super.doTearDown(); } private void removeAllWorkingSets() { - IWorkingSetManager workingSetManager = fWorkbench.getWorkingSetManager(); + IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); IWorkingSet[] workingSets = workingSetManager.getWorkingSets(); for (IWorkingSet workingSet : workingSets) { workingSetManager.removeWorkingSet(workingSet); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/EditorActionBarsTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/EditorActionBarsTest.java index 0854d8b8541..c5cec41d841 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/EditorActionBarsTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/EditorActionBarsTest.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.ui.tests.internal; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.jface.action.CoolBarManager; @@ -37,18 +41,16 @@ import org.eclipse.ui.tests.api.MockViewPart; import org.eclipse.ui.tests.harness.util.FileUtil; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * This class contains tests for the editor action bars * implementation. */ -@RunWith(JUnit4.class) @Ignore -public class EditorActionBarsTest extends UITestCase { +public class EditorActionBarsTest { protected IWorkbenchWindow fWindow; @@ -56,17 +58,9 @@ public class EditorActionBarsTest extends UITestCase { private final String EDITOR_ID = "org.eclipse.ui.tests.internal.EditorActionBarsTest"; - /** - * Constructor for IEditorPartTest - */ - public EditorActionBarsTest() { - super(EditorActionBarsTest.class.getSimpleName()); - } - - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - fWindow = openTestWindow(); + @Before + public void doSetUp() throws Exception { + fWindow = UITestCase.openTestWindow(); fPage = fWindow.getActivePage(); } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/FileEditorMappingTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/FileEditorMappingTest.java index 1890cc249fd..9e032d47132 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/FileEditorMappingTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/FileEditorMappingTest.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.ui.tests.internal; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.ArrayList; import java.util.List; @@ -20,7 +23,7 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.internal.registry.EditorDescriptor; import org.eclipse.ui.internal.registry.FileEditorMapping; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -28,19 +31,13 @@ @RunWith(JUnit4.class) @Ignore -public class FileEditorMappingTest extends UITestCase { +public class FileEditorMappingTest { private EditorDescriptor textEditor; private EditorDescriptor pdeEditor; - public FileEditorMappingTest() { - super(FileEditorMappingTest.class.getSimpleName()); - } - - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - + @Before + public void doSetUp() throws Exception { textEditor = (EditorDescriptor) IDE.getEditorDescriptor("test.txt"); pdeEditor = (EditorDescriptor) IDE.getEditorDescriptor("plugin.xml"); } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SWTBotWorkbenchResetTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SWTBotWorkbenchResetTest.java index b815684b370..d0011487f30 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SWTBotWorkbenchResetTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SWTBotWorkbenchResetTest.java @@ -14,6 +14,11 @@ package org.eclipse.ui.tests.internal; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; @@ -24,21 +29,11 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.tests.harness.util.UITestCase; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Test for Bug 511729 — Improve robustness to SWTBot.resetWorkbench() */ -@RunWith(JUnit4.class) -public class SWTBotWorkbenchResetTest extends UITestCase { - - /** - * Constructs a new instance of this test case. - */ - public SWTBotWorkbenchResetTest() { - super(SWTBotWorkbenchResetTest.class.getSimpleName()); - } +public class SWTBotWorkbenchResetTest { /** * Open a new window, switch to a different perspective such that parts are @@ -47,7 +42,7 @@ public SWTBotWorkbenchResetTest() { */ @Test public void testResetWorkbench() throws CoreException { - IWorkbenchWindow window = openTestWindow(IDE.RESOURCE_PERSPECTIVE_ID); + IWorkbenchWindow window = UITestCase.openTestWindow(IDE.RESOURCE_PERSPECTIVE_ID); window.getWorkbench().showPerspective("org.eclipse.ui.tests.api.ViewPerspective", window); processEvents(); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SaveablesListTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SaveablesListTest.java index 7ecf5a0c3d2..e6ce2166428 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SaveablesListTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/SaveablesListTest.java @@ -16,6 +16,10 @@ import static org.eclipse.ui.SaveablesLifecycleEvent.POST_CLOSE; import static org.eclipse.ui.SaveablesLifecycleEvent.POST_OPEN; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collection; @@ -36,16 +40,10 @@ import org.eclipse.ui.Saveable; import org.eclipse.ui.SaveablesLifecycleEvent; import org.eclipse.ui.internal.SaveablesList; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -/** - * @since 3.5 - */ -@RunWith(JUnit4.class) -public class SaveablesListTest extends UITestCase { +public class SaveablesListTest { static class GoodSaveable extends Saveable { @@ -181,12 +179,8 @@ protected Map getModelRefCounts() { private DummyPart part2; private DummyPart part3; - public SaveablesListTest() { - super(SaveablesListTest.class.getSimpleName()); - } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); + @Before + public void doSetUp() throws Exception { slist = new SaveablesListForTest(); source = new Object(); part1 = new DummyPart(); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/TextHandlerTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/TextHandlerTest.java index c0e289e3634..5011ca407ad 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/TextHandlerTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/TextHandlerTest.java @@ -14,6 +14,10 @@ package org.eclipse.ui.tests.internal; +import static org.eclipse.ui.tests.harness.util.UITestCase.openTestWindow; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeFalse; import org.eclipse.core.runtime.Platform; @@ -23,22 +27,14 @@ import org.eclipse.swt.dnd.URLTransfer; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.actions.TextActionHandler; -import org.eclipse.ui.tests.harness.util.UITestCase; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Test for {@link TextActionHandler}. * * @since 3.5 */ -@RunWith(JUnit4.class) -public class TextHandlerTest extends UITestCase { - - public TextHandlerTest() { - super(TextHandlerTest.class.getSimpleName()); - } +public class TextHandlerTest { @Test public void testEditableText() throws Exception { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchPageTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchPageTest.java index aed27fb7a46..c16c28f09cc 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchPageTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchPageTest.java @@ -13,25 +13,21 @@ *******************************************************************************/ package org.eclipse.ui.tests.internal; +import static org.junit.Assert.assertEquals; + import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.WorkbenchPage; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) @Ignore -public class WorkbenchPageTest extends UITestCase { - - public WorkbenchPageTest() { - super(WorkbenchPageTest.class.getSimpleName()); - } +public class WorkbenchPageTest { @Test public void test1() { @@ -88,12 +84,11 @@ private void assertOrderAfterPerformedShowIn(List expected, String... sh } private WorkbenchPage getWorkbenchPage() { - return (WorkbenchPage) fWorkbench.getActiveWorkbenchWindow().getActivePage(); + return (WorkbenchPage) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); } - @Override - protected void doTearDown() throws Exception { - super.doTearDown(); + @After + public void doTearDown() throws Exception { clearMruPartIds(); } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchSiteProgressServiceModelTagsTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchSiteProgressServiceModelTagsTest.java index 6fe19226832..ae46f8bc5c1 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchSiteProgressServiceModelTagsTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchSiteProgressServiceModelTagsTest.java @@ -14,6 +14,12 @@ package org.eclipse.ui.tests.internal; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.ui.internal.workbench.swt.CSSConstants; @@ -26,17 +32,13 @@ import org.eclipse.ui.internal.progress.WorkbenchSiteProgressService; import org.eclipse.ui.tests.api.workbenchpart.EmptyView; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; -/** - * @since 3.5 - */ -@RunWith(JUnit4.class) -public class WorkbenchSiteProgressServiceModelTagsTest extends UITestCase { +public class WorkbenchSiteProgressServiceModelTagsTest { private IWorkbenchWindow window; private IWorkbenchPage page; @@ -53,14 +55,9 @@ public class WorkbenchSiteProgressServiceModelTagsTest extends UITestCase { private WorkbenchSiteProgressServiceTestable progressService; - public WorkbenchSiteProgressServiceModelTagsTest() { - super(WorkbenchSiteProgressServiceModelTagsTest.class.getSimpleName()); - } - - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - window = openTestWindow(); + @Before + public void doSetUp() throws Exception { + window = UITestCase.openTestWindow(); page = window.getActivePage(); view = (EmptyView) page.showView(EmptyView.ID); @@ -79,12 +76,11 @@ protected void doSetUp() throws Exception { } - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { eventBroker.unsubscribe(eventHandler); eventBroker = null; page.hideView(view); - super.doTearDown(); } @Test diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchWindowSubordinateSourcesTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchWindowSubordinateSourcesTests.java index 46b5e3e7cfb..ba634856bd1 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchWindowSubordinateSourcesTests.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbenchWindowSubordinateSourcesTests.java @@ -14,6 +14,9 @@ package org.eclipse.ui.tests.internal; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.eclipse.core.expressions.EqualsExpression; import org.eclipse.core.expressions.EvaluationResult; import org.eclipse.core.expressions.IEvaluationContext; @@ -28,30 +31,24 @@ import org.eclipse.ui.internal.WorkbenchWindow; import org.eclipse.ui.services.IEvaluationService; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Tests various sources keyed off the workbench window. * * @since 3.3 */ -@RunWith(JUnit4.class) @Ignore("Disabled due 544032, see also 485167") -public class WorkbenchWindowSubordinateSourcesTests extends UITestCase { +public class WorkbenchWindowSubordinateSourcesTests { private WorkbenchWindow window; - public WorkbenchWindowSubordinateSourcesTests() { - super(WorkbenchWindowSubordinateSourcesTests.class.getSimpleName()); - } - - @Override - protected void doSetUp() throws Exception { - window = (WorkbenchWindow) openTestWindow(); - processEvents(); + @Before + public void doSetUp() throws Exception { + window = (WorkbenchWindow) UITestCase.openTestWindow(); + UITestCase.processEvents(); } @Test diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbookEditorsHandlerTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbookEditorsHandlerTest.java index 67b97b3b24b..9268b59f696 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbookEditorsHandlerTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/WorkbookEditorsHandlerTest.java @@ -14,6 +14,9 @@ package org.eclipse.ui.tests.internal; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.util.Arrays; import java.util.List; @@ -35,16 +38,15 @@ import org.eclipse.ui.ide.IDE; import org.eclipse.ui.internal.WorkbookEditorsHandler; import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule; import org.eclipse.ui.tests.harness.util.FileUtil; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; -public class WorkbookEditorsHandlerTest extends UITestCase { - +public class WorkbookEditorsHandlerTest { - public WorkbookEditorsHandlerTest(String testName) { - super(testName); - } private static final String PROJECT_NAME = "WorkbookEditorsHandlerTest"; private static final String PROJECT_NAME_1 = PROJECT_NAME + 1; @@ -54,7 +56,10 @@ public WorkbookEditorsHandlerTest(String testName) { private IProject project1; private IProject project2; - @Override + @Rule + public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule(); + + @Before public void doSetUp() throws CoreException { activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); activePage = activeWindow.getActivePage(); @@ -62,8 +67,9 @@ public void doSetUp() throws CoreException { project2 = FileUtil.createProject(PROJECT_NAME_2); } - @Override + @After public void doTearDown() throws Exception { + activePage.closeAllEditors(false); if (project1 != null) { project1.delete(true, true, null); project1 = null; @@ -72,7 +78,6 @@ public void doTearDown() throws Exception { project2.delete(true, true, null); project2 = null; } - activePage.closeAllEditors(false); } @Test diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroPartTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroPartTest.java index 784004d4274..4757be56402 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroPartTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroPartTest.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.ui.tests.intro; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import org.eclipse.jface.resource.ImageDescriptor; @@ -25,22 +28,14 @@ import org.eclipse.ui.tests.api.IWorkbenchPartTest; import org.eclipse.ui.tests.api.MockPart; import org.eclipse.ui.tests.harness.util.CallHistory; +import org.junit.After; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -/** - * @since 3.0 - */ -@RunWith(JUnit4.class) public class IntroPartTest extends IWorkbenchPartTest { private IntroDescriptor oldDesc; - public IntroPartTest() { - super(IntroPartTest.class.getSimpleName()); - } - @Override protected MockPart openPart(IWorkbenchPage page) throws Throwable { return (MockIntroPart) page.getWorkbenchWindow().getWorkbench() @@ -92,7 +87,8 @@ public void testImage() throws Throwable { } @Override - protected void doSetUp() throws Exception { + @Before + public void doSetUp() throws Exception { super.doSetUp(); oldDesc = Workbench.getInstance().getIntroDescriptor(); IntroDescriptor testDesc = getIntroDesc(); @@ -104,9 +100,8 @@ private IntroDescriptor getIntroDesc() { .getIntroRegistry().getIntro("org.eclipse.ui.testintro"); } - @Override + @After protected void doTearDown() throws Exception { - super.doTearDown(); Workbench.getInstance().setIntroDescriptor(oldDesc); } } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroTest2.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroTest2.java index 5575a04c49f..1917935fd2e 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroTest2.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroTest2.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.ui.tests.intro; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.IPerspectiveDescriptor; import org.eclipse.ui.IViewPart; @@ -27,24 +30,16 @@ import org.eclipse.ui.internal.util.PrefUtil; import org.eclipse.ui.intro.IIntroPart; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -/** - * @since 3.0 - */ -@RunWith(JUnit4.class) -public class IntroTest2 extends UITestCase { +public class IntroTest2 { IWorkbenchWindow window = null; private IntroDescriptor oldDesc; - public IntroTest2() { - super(IntroTest2.class.getSimpleName()); - } - /** * Open the intro, change perspective, close the intro * and ensure that the intro has been closed in the @@ -78,10 +73,8 @@ public void testPerspectiveChangeWith33StickyBehavior() { } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - + @Before + public void doSetUp() throws Exception { // these tests rely on the 3.3 behavior for sticky views IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); preferenceStore.putValue(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR, "false"); @@ -91,12 +84,11 @@ protected void doSetUp() throws Exception { .getDefault().getIntroRegistry().getIntro( "org.eclipse.ui.testintro"); Workbench.getInstance().setIntroDescriptor(testDesc); - window = openTestWindow(); + window = UITestCase.openTestWindow(); } - @Override - protected void doTearDown() throws Exception { - super.doTearDown(); + @After + public void doTearDown() throws Exception { Workbench.getInstance().setIntroDescriptor(oldDesc); } } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/NoIntroPartTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/NoIntroPartTest.java index 29de8fe8b4b..88e7383cad3 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/NoIntroPartTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/NoIntroPartTest.java @@ -13,28 +13,23 @@ *******************************************************************************/ package org.eclipse.ui.tests.intro; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.internal.Workbench; import org.eclipse.ui.internal.intro.IntroDescriptor; import org.eclipse.ui.intro.IIntroPart; import org.eclipse.ui.tests.api.IWorkbenchPartTest; import org.eclipse.ui.tests.api.MockPart; +import org.junit.After; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -/** - * @since 3.0 - */ -@RunWith(JUnit4.class) public class NoIntroPartTest extends IWorkbenchPartTest { private IntroDescriptor oldDesc; - public NoIntroPartTest() { - super(NoIntroPartTest.class.getSimpleName()); - } - @Override protected MockPart openPart(IWorkbenchPage page) throws Throwable { return (MockPart) page.getWorkbenchWindow().getWorkbench() @@ -58,15 +53,15 @@ public void testOpenAndClose() throws Throwable { } @Override - protected void doSetUp() throws Exception { + @Before + public void doSetUp() throws Exception { super.doSetUp(); oldDesc = Workbench.getInstance().getIntroDescriptor(); Workbench.getInstance().setIntroDescriptor(null); } - @Override - protected void doTearDown() throws Exception { - super.doTearDown(); + @After + public void doTearDown() throws Exception { Workbench.getInstance().setIntroDescriptor(oldDesc); } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuVisibilityTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuVisibilityTest.java index 61e84aea888..1b9efc6e876 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuVisibilityTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/MenuVisibilityTest.java @@ -14,6 +14,11 @@ package org.eclipse.ui.tests.menus; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.Collections; import org.eclipse.core.commands.ExecutionEvent; @@ -53,24 +58,19 @@ import org.eclipse.ui.tests.api.workbenchpart.MenuContributionHarness; import org.eclipse.ui.tests.commands.ActiveContextExpression; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * @since 3.3 */ -@RunWith(JUnit4.class) -public class MenuVisibilityTest extends UITestCase { +public class MenuVisibilityTest { private static final String EXTENSION_ID = "org.eclipse.ui.tests.menusX1"; private static final String LOCATION = "menu:foo"; private static final String COMMAND_ID = "org.eclipse.ui.tests.commandEnabledVisibility"; - public MenuVisibilityTest() { - super(MenuVisibilityTest.class.getSimpleName()); - } - private IContextService contextService; private IMenuService menuService; private IWorkbenchWindow window; @@ -412,11 +412,10 @@ public void createContributionItems(IServiceLocator menuService, IContributionRo parentMenuManager.dispose(); } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); + @Before + public void doSetUp() throws Exception { - window = openTestWindow(); + window = UITestCase.openTestWindow(); menuService = window.getService(IMenuService.class); contextService = window .getService(IContextService.class); @@ -428,8 +427,8 @@ protected void doSetUp() throws Exception { } } - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { if (activeContext != null) { contextService.deactivateContext(activeContext); activeContext = null; @@ -437,7 +436,5 @@ protected void doTearDown() throws Exception { menuService = null; contextService = null; window = null; - - super.doTearDown(); } } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ShowViewMenuTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ShowViewMenuTest.java index 68f40b4be4e..23b7da89945 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ShowViewMenuTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/menus/ShowViewMenuTest.java @@ -13,33 +13,25 @@ ******************************************************************************/ package org.eclipse.ui.tests.menus; +import static org.junit.Assert.assertEquals; + import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.internal.ShowViewMenu; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -/** - * @since 3.5 - */ -@RunWith(JUnit4.class) -public class ShowViewMenuTest extends UITestCase { +public class ShowViewMenuTest { private IWorkbenchWindow workbenchWindow; - public ShowViewMenuTest() { - super(ShowViewMenuTest.class.getSimpleName()); - } - - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); + @Before + public void doSetUp() throws Exception { // open a workbench window with the empty perspective, since it defines // no show view shortcuts, it is suitable for the two single show view // action tests - workbenchWindow = openTestWindow(); + workbenchWindow = UITestCase.openTestWindow(); } /*********************************** diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageEditorPartTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageEditorPartTest.java index 3140d1cfe6f..53bc5812bdb 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageEditorPartTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageEditorPartTest.java @@ -13,30 +13,26 @@ *******************************************************************************/ package org.eclipse.ui.tests.multipageeditor; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.ui.IEditorPart; import org.eclipse.ui.internal.ErrorEditorPart; import org.eclipse.ui.internal.part.NullEditorInput; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class MultiPageEditorPartTest extends UITestCase { - public MultiPageEditorPartTest() { - super(MultiPageEditorPartTest.class.getSimpleName()); - } +public class MultiPageEditorPartTest { - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { TestMultiPageEditorThrowingPartInitException.resetSpy(); - super.doTearDown(); } @Test public void testDisposalWithoutSuccessfulInitialization() throws Exception { - IEditorPart editor = openTestWindow().getActivePage().openEditor(new NullEditorInput(), + IEditorPart editor = UITestCase.openTestWindow().getActivePage().openEditor(new NullEditorInput(), "org.eclipse.ui.tests.multipageeditor.TestMultiPageEditorThrowingPartInitException"); //$NON-NLS-1$ assertTrue(editor instanceof ErrorEditorPart); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageKeyBindingTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageKeyBindingTest.java index 5686e65b3f6..3abb65469d7 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageKeyBindingTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiPageKeyBindingTest.java @@ -30,8 +30,6 @@ import org.eclipse.ui.tests.harness.util.UITestCase; import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Tests that key bindings are treated correctly in a multi-page editor. This @@ -41,16 +39,8 @@ * @since 3.0 */ @SuppressWarnings("removal") -@RunWith(JUnit4.class) @Ignore("Focus issues, see Commit c28efd634f53c9de7bb31b756ffc755b8faf0ffe") -public class MultiPageKeyBindingTest extends UITestCase { - - /** - * Constructs a new instance of MultiPageKeyBindingTest. - */ - public MultiPageKeyBindingTest() { - super(MultiPageKeyBindingTest.class.getSimpleName()); - } +public class MultiPageKeyBindingTest { /** * Tests that the key bindings are updated when the page is switched in a @@ -67,7 +57,7 @@ public void testSwitch() throws CoreException, ParseException { final String fileName = "A." + extension; //$NON-NLS-1$ // Open a new test window. - IWorkbenchWindow window = openTestWindow(); + IWorkbenchWindow window = UITestCase.openTestWindow(); // Create a blurb file. IWorkbenchPage page = window.getActivePage(); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiVariablePageTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiVariablePageTest.java index b71d3df0963..5c521ffe808 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiVariablePageTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/multipageeditor/MultiVariablePageTest.java @@ -13,6 +13,14 @@ *******************************************************************************/ package org.eclipse.ui.tests.multipageeditor; +import static org.eclipse.ui.PlatformUI.getWorkbench; +import static org.eclipse.ui.tests.harness.util.UITestCase.openTestWindow; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.util.Collection; @@ -37,10 +45,9 @@ import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.MultiPageEditorPart; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule; +import org.junit.Rule; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** *

@@ -54,8 +61,7 @@ * * @since 3.2 */ -@RunWith(JUnit4.class) -public class MultiVariablePageTest extends UITestCase { +public class MultiVariablePageTest { private static final String FILE_CONTENTS = "#section01\nsection 1\n#section02\nsection 2\nwith info\n#section03\nLast page\n"; @@ -67,9 +73,8 @@ public class MultiVariablePageTest extends UITestCase { private int fPostCalled; - public MultiVariablePageTest() { - super(MultiVariablePageTest.class.getSimpleName()); - } + @Rule + public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule(); /** * Make sure that setting the active page programmatically calls diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ViewerItemsLimitTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ViewerItemsLimitTest.java index fe45de90956..edbf81378d6 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ViewerItemsLimitTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ViewerItemsLimitTest.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.ui.tests.preferences; +import static org.eclipse.ui.PlatformUI.getWorkbench; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEvents; +import static org.eclipse.ui.tests.harness.util.UITestCase.processEventsUntil; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.util.HashMap; @@ -49,20 +55,18 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPreferenceConstants; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.internal.views.markers.MarkersTreeViewer; import org.eclipse.ui.intro.IIntroPart; import org.eclipse.ui.navigator.CommonViewer; import org.eclipse.ui.tests.harness.util.EmptyPerspective; import org.eclipse.ui.tests.harness.util.UITestCase; +import org.junit.After; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) -public class ViewerItemsLimitTest extends UITestCase { +public class ViewerItemsLimitTest { private IPreferenceStore preferenceStore; @@ -80,15 +84,11 @@ public class ViewerItemsLimitTest extends UITestCase { private IWorkbenchPage activePage; - public ViewerItemsLimitTest() { - super(ViewerItemsLimitTest.class.getSimpleName()); - } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - cleanUp(); + @Before + public void doSetUp() throws Exception { preferenceStore = WorkbenchPlugin.getDefault().getPreferenceStore(); + cleanUp(); int viewLimit = preferenceStore.getInt(IWorkbenchPreferenceConstants.LARGE_VIEW_LIMIT); assertEquals("Default viewer limit must be " + DEFAULT_VIEW_LIMIT, DEFAULT_VIEW_LIMIT, viewLimit); window = getActiveWindow(); @@ -98,15 +98,14 @@ protected void doSetUp() throws Exception { getWorkbench().showPerspective(EmptyPerspective.PERSP_ID, window); } - @Override - protected void doTearDown() throws Exception { + @After + public void doTearDown() throws Exception { cleanUp(); preferenceStore.setValue(IWorkbenchPreferenceConstants.LARGE_VIEW_LIMIT, DEFAULT_VIEW_LIMIT); activePage.closeAllPerspectives(false, false); if (defaultPerspective != null) { getWorkbench().showPerspective(defaultPerspective.getId(), window); } - super.doTearDown(); } /** @@ -189,14 +188,14 @@ public void testProjectExplorerLimitedProjects() throws CoreException { } private IWorkbenchWindow getActiveWindow() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow(); assertNotNull("Should get one window", window); return window; } private static void processBackgroundUpdates(int minWaitTime) { processEvents(); - waitForJobs(minWaitTime, 10_000); + UITestCase.waitForJobs(minWaitTime, 10_000); processEvents(); } @@ -224,7 +223,7 @@ private static void deleteAllProjects() throws CoreException { } private static IWorkbench closeIntro() { - IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbench workbench = getWorkbench(); IIntroPart introPart = workbench.getIntroManager().getIntro(); if (introPart != null) { workbench.getIntroManager().closeIntro(introPart); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java index 3e27cced754..76c266a91cf 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/propertysheet/PropertySheetAuto.java @@ -15,6 +15,10 @@ package org.eclipse.ui.tests.propertysheet; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Random; @@ -38,10 +42,9 @@ import org.eclipse.ui.views.properties.PropertySheetEntry; import org.eclipse.ui.views.properties.PropertySheetPage; import org.eclipse.ui.views.properties.TextPropertyDescriptor; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * The class implements a test for the workbench's default @@ -52,9 +55,7 @@ * properties and handles the transition to another set of * properties. */ - -@RunWith(JUnit4.class) -public class PropertySheetAuto extends UITestCase { +public class PropertySheetAuto { /** * This car serves as a simple porperty source. @@ -234,10 +235,6 @@ public String toString() { private static final String[] models = new String[] { "Thunderbird", "Deville", "Viper", "320i", "Camry", "Ultima", "Prelude", "V70" }; - public PropertySheetAuto() { - super(PropertySheetAuto.class.getSimpleName()); - } - /** * Creates a array of car objects */ @@ -278,10 +275,9 @@ private Car createCar() { return new Car(modelYear, color, manufacturer, model, engineSize); } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - workbenchWindow = openTestWindow(); + @Before + public void doSetUp() throws Exception { + workbenchWindow = UITestCase.openTestWindow(); activePage = workbenchWindow.getActivePage(); processUiEvents(); } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/JFaceThemeTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/JFaceThemeTest.java index f0ae0ee3203..6207ae26dfd 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/JFaceThemeTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/JFaceThemeTest.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.ui.tests.themes; +import static org.eclipse.ui.PlatformUI.getWorkbench; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.jface.resource.ColorDescriptor; import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.jface.resource.FontRegistry; @@ -23,21 +29,14 @@ import org.eclipse.ui.themes.ITheme; import org.eclipse.ui.themes.IThemeManager; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Tests the pushing down of current theme changes into JFace. * * @since 3.0 */ -@RunWith(JUnit4.class) public class JFaceThemeTest extends ThemeTest { - public JFaceThemeTest() { - super(JFaceThemeTest.class.getSimpleName()); - } - private void setAndTest(String themeId, IPropertyChangeListener listener) { JFaceResources.getFontRegistry().addListener(listener); JFaceResources.getColorRegistry().addListener(listener); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/ThemeAPITest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/ThemeAPITest.java index 15266e65323..61aa5c53567 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/ThemeAPITest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/ThemeAPITest.java @@ -14,6 +14,13 @@ *******************************************************************************/ package org.eclipse.ui.tests.themes; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.List; import java.util.Set; @@ -32,15 +39,12 @@ import org.eclipse.ui.themes.ITheme; import org.eclipse.ui.themes.IThemeManager; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; /** * Tests the theme API. * * @since 3.0 */ -@RunWith(JUnit4.class) public class ThemeAPITest extends ThemeTest { private static final String EXTENDED_THEME3 = "extendedTheme3"; @@ -72,10 +76,6 @@ public class ThemeAPITest extends ThemeTest { private static final String BAD_COLOR2 = "badColor2"; private static final String BAD_COLOR3 = "badColor3"; - public ThemeAPITest() { - super(ThemeAPITest.class.getSimpleName()); - } - private void checkEvents(ThemePropertyListener listener, Object source, Object oldObject, Object newObject) { boolean array = oldObject instanceof Object[]; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/ThemeTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/ThemeTest.java index 95e0bf3f5a2..0819db3e7de 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/ThemeTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/themes/ThemeTest.java @@ -14,17 +14,21 @@ *******************************************************************************/ package org.eclipse.ui.tests.themes; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + import java.util.Arrays; import org.eclipse.e4.ui.css.swt.theme.IThemeEngine; -import org.eclipse.ui.tests.harness.util.UITestCase; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.themes.ITheme; import org.eclipse.ui.themes.IThemeManager; +import org.junit.Before; /** * @since 3.0 */ -public abstract class ThemeTest extends UITestCase { +public abstract class ThemeTest { private static final String MOCK_CSS_THEME = "org.eclipse.e4.ui.css.theme.mock"; protected static final String BOGUSID = "BOGUSID"; @@ -57,22 +61,17 @@ protected static String formatArray(Object[] datas) { protected IThemeManager fManager; - public ThemeTest(String testName) { - super(testName); - // TODO Auto-generated constructor stub - } - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - fManager = fWorkbench.getThemeManager(); + @Before + public void doSetUp() throws Exception { + fManager = PlatformUI.getWorkbench().getThemeManager(); fManager.setCurrentTheme(IThemeManager.DEFAULT_THEME); mockCSSTheme(); } private void mockCSSTheme() { - IThemeEngine themeEngine = fWorkbench.getService(IThemeEngine.class); + IThemeEngine themeEngine = PlatformUI.getWorkbench().getService(IThemeEngine.class); org.eclipse.e4.ui.css.swt.theme.ITheme currentTheme = themeEngine.getActiveTheme(); if (currentTheme != null && !MOCK_CSS_THEME.equals(currentTheme.getId())) { themeEngine.setTheme(MOCK_CSS_THEME, false);