diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java index 6a7a56662b8..562d8df97eb 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/ActionDelegateProxyTest.java @@ -16,12 +16,12 @@ import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow; import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents; -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.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -37,18 +37,16 @@ import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.tests.api.workbenchpart.MenuContributionHarness; -import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule; +import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension; import org.eclipse.ui.tests.harness.util.FileUtil; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -@Ignore("broke during e4 transition and still need adjustments") +@Disabled("broke during e4 transition and still need adjustments") +@ExtendWith(CloseTestWindowsExtension.class) public class ActionDelegateProxyTest { - @Rule - public CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule(); - private static final String DELEGATE_ACTION_SET_ID = "org.eclipse.ui.tests.delegateActionSet"; private static final String INC_COMMAND = "org.eclipse.ui.tests.incMenuHarness"; private static final String VIEW_ID = "org.eclipse.ui.tests.api.MenuTestHarness"; 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 b4199ef5932..a5e8233e10a 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 @@ -16,8 +16,8 @@ package org.eclipse.ui.tests.commands; import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.HashMap; import java.util.Map; @@ -41,20 +41,18 @@ 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.CloseTestWindowsRule; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * @since 3.3 */ +@ExtendWith(CloseTestWindowsExtension.class) public class CommandCallbackTest { - @Rule - public final CloseTestWindowsRule closeTestWindowsRule = new CloseTestWindowsRule(); - private static final String HOST_PARAM_ID = "host"; private static final String PROT_PARAM_ID = "protocol"; private static final String PREFIX = "tests.commands.CCT."; @@ -71,7 +69,7 @@ public class CommandCallbackTest { private CallbackHandler cmd1Handler; private CallbackHandler cmd2Handler; - @Before + @BeforeEach public final void setUp() throws Exception { workbench = PlatformUI.getWorkbench(); commandService = workbench.getService(ICommandService.class); @@ -84,7 +82,7 @@ public final void setUp() throws Exception { cmd2Activation = handlerService.activateHandler(CMD2_ID, cmd2Handler); } - @After + @AfterEach public final void tearDown() throws Exception { if (cmd1Activation != null) { handlerService.deactivateHandler(cmd1Activation); diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java index a3f6c2b0b7c..66de85b5c05 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/commands/CommandEnablementTest.java @@ -15,11 +15,11 @@ package org.eclipse.ui.tests.commands; import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow; -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 static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Field; import java.util.Map; @@ -68,22 +68,20 @@ import org.eclipse.ui.menus.UIElement; import org.eclipse.ui.services.IEvaluationService; import org.eclipse.ui.services.ISourceProviderService; -import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * @since 3.3 */ -@Ignore("broke during e4 transition and still need adjustments") +@Disabled("broke during e4 transition and still need adjustments") +@ExtendWith(CloseTestWindowsExtension.class) public class CommandEnablementTest { - @Rule - public CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule(); - private static final String CONTEXT_TEST2 = "org.eclipse.ui.command.contexts.enablement_test2"; private static final String CONTEXT_TEST1 = "org.eclipse.ui.command.contexts.enablement_test1"; private static final String PREFIX = "tests.commands.CCT."; @@ -110,7 +108,7 @@ public class CommandEnablementTest { private IContextActivation contextActivation2; private IWorkbench fWorkbench; - @Before + @BeforeEach public void doSetUp() throws Exception { fWorkbench = PlatformUI.getWorkbench(); commandService = fWorkbench.getService(ICommandService.class); @@ -128,7 +126,7 @@ public void doSetUp() throws Exception { contextHandler = new CheckContextHandler(); } - @After + @AfterEach public void doTearDown() throws Exception { if (activation1 != null) { handlerService.deactivateHandler(activation1); 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 a496383c19c..0a3a0d82b6e 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 @@ -15,10 +15,10 @@ package org.eclipse.ui.tests.commands; import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow; -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.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.HashMap; import java.util.Map; @@ -48,23 +48,21 @@ import org.eclipse.ui.handlers.IHandlerActivation; import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.services.IServiceLocator; -import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule; +import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension; import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * Tests various aspects of command state. * * @since 3.2 */ +@ExtendWith(CloseTestWindowsExtension.class) public class HandlerActivationTest { - @Rule - public final CloseTestWindowsRule closeTestWindowsRule = new CloseTestWindowsRule(); - static class ActTestHandler extends AbstractHandler { public String contextId; @@ -174,8 +172,7 @@ private void assertHandlerIsExecuted(Command cmd, String handlerId) 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(count + 1, handler.executionCount, "The handler count should be incremented"); } private void createHandlerActivation(String contextId, String handlerId, @@ -185,7 +182,7 @@ private void createHandlerActivation(String contextId, String handlerId, makeHandler(handlerId, contextId, expression); } - @Before + @BeforeEach public final void setUp() throws Exception { for (final String[] contextInfo : CREATE_CONTEXTS) { final Context context = contextService.getContext(contextInfo[0]); @@ -203,7 +200,7 @@ public final void setUp() throws Exception { } - @After + @AfterEach public final void tearDown() throws Exception { handlerService.deactivateHandlers(testHandlerActivations.values()); testHandlerActivations.clear(); @@ -214,15 +211,15 @@ public final void tearDown() throws Exception { private void doTestForBreak() throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException { Command cmd = commandService.getCommand(CMD_ID); - assertTrue("Command should be defined", cmd.isDefined()); + assertTrue(cmd.isDefined(), "Command should be defined"); - assertFalse("Should not be handled yet", cmd.isHandled()); + assertFalse(cmd.isHandled(), "Should not be handled yet"); IContextActivation c1 = activateContext(C1_ID); IContextActivation c2 = activateContext(C2_ID); IContextActivation c3 = activateContext(C3_ID); - assertTrue("Should still be handled", cmd.isHandled()); + assertTrue(cmd.isHandled(), "Should still be handled"); assertHandlerIsExecuted(cmd, H3); @@ -260,22 +257,21 @@ public void testBasicHandler() throws Exception { new String[] { ISources.ACTIVE_CONTEXT_NAME }); Command cmd = commandService.getCommand(CMD_ID); - assertTrue("Command should be defined", cmd.isDefined()); + assertTrue(cmd.isDefined(), "Command should be defined"); - assertFalse("Should not be handled yet", cmd.isHandled()); + assertFalse(cmd.isHandled(), "Should not be handled yet"); IContextActivation activationC1 = activateContext(C1_ID); - assertTrue("Should definitely be handled", cmd.isHandled()); + assertTrue(cmd.isHandled(), "Should definitely be handled"); 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(count + 1, handler1.executionCount, "The handler count should be correct"); contextService.deactivateContext(activationC1); - assertFalse("Should not be handled", cmd.isHandled()); + assertFalse(cmd.isHandled(), "Should not be handled"); } @Test @@ -382,32 +378,29 @@ public void testTwoHandlers() throws Exception { ISources.ACTIVE_ACTION_SETS_NAME }); Command cmd = commandService.getCommand(CMD_ID); - assertTrue("Command should be defined", cmd.isDefined()); + assertTrue(cmd.isDefined(), "Command should be defined"); - assertFalse("Should not be handled yet", cmd.isHandled()); + assertFalse(cmd.isHandled(), "Should not be handled yet"); IContextActivation activationC1 = activateContext(C1_ID); - assertTrue("Should definitely be handled", cmd.isHandled()); + assertTrue(cmd.isHandled(), "Should definitely be handled"); 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(count1 + 1, handler1.executionCount, "The handler count should be incremented"); activateContext(C2_ID); - assertTrue("Should still be handled", cmd.isHandled()); + assertTrue(cmd.isHandled(), "Should still be handled"); ActTestHandler handler2 = (ActTestHandler) testHandlers.get(H2); 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(count1, handler1.executionCount, "The handler1 count should not be incremented"); + assertEquals(count2 + 1, handler2.executionCount, "The handler2 count should be incremented"); contextService.deactivateContext(activationC1); - assertTrue("Will still be handled", cmd.isHandled()); + assertTrue(cmd.isHandled(), "Will still be handled"); } @Test diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java index 2362513423c..59ad4ae60ed 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/contexts/Bug74990Test.java @@ -14,7 +14,7 @@ package org.eclipse.ui.tests.contexts; import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbench; @@ -24,20 +24,18 @@ import org.eclipse.ui.contexts.EnabledSubmission; import org.eclipse.ui.contexts.IContext; import org.eclipse.ui.contexts.IWorkbenchContextSupport; -import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule; -import org.junit.Rule; -import org.junit.Test; +import org.eclipse.ui.tests.harness.util.CloseTestWindowsExtension; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * A test for whether part identifiers work properly for EnabledSubmissions. * * @since 3.1 */ +@ExtendWith(CloseTestWindowsExtension.class) public final class Bug74990Test { - @Rule - public CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule(); - /** * Tests whether a part-specific context -- submitted via Java code -- is * matched properly. This is only using the part id. The test verifies that it @@ -62,7 +60,7 @@ public final void testPartIdSubmission() throws PartInitException { try { // Test to make sure the context is not currently enabled. - assertTrue("The MockViewPart context should not be enabled", !testContext.isEnabled()); + assertTrue(!testContext.isEnabled(), "The MockViewPart context should not be enabled"); /* * Open a window with the MockViewPart, and make sure it now enabled. @@ -72,13 +70,13 @@ public final void testPartIdSubmission() throws PartInitException { page.activate(openedView); while (fWorkbench.getDisplay().readAndDispatch()) { } - assertTrue("The MockViewPart context should be enabled", testContext.isEnabled()); + assertTrue(testContext.isEnabled(), "The MockViewPart context should be enabled"); // Hide the view, and test that is becomes disabled again. page.hideView(openedView); while (fWorkbench.getDisplay().readAndDispatch()) { } - assertTrue("The MockViewPart context should not be enabled", !testContext.isEnabled()); + assertTrue(!testContext.isEnabled(), "The MockViewPart context should not be enabled"); } finally { contextSupport.removeEnabledSubmission(testSubmission);