diff options
68 files changed, 976 insertions, 866 deletions
diff --git a/org.eclipse.debug.tests/Platform Debug Test Suite.launch b/org.eclipse.debug.tests/Platform Debug Test Suite.launch index 4372b9637..f0d9ba813 100644 --- a/org.eclipse.debug.tests/Platform Debug Test Suite.launch +++ b/org.eclipse.debug.tests/Platform Debug Test Suite.launch @@ -1,41 +1,41 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig"> -<booleanAttribute key="append.args" value="true"/> -<booleanAttribute key="askclear" value="false"/> -<booleanAttribute key="automaticAdd" value="true"/> -<booleanAttribute key="automaticValidate" value="false"/> -<stringAttribute key="bootstrap" value=""/> -<stringAttribute key="checked" value="[NONE]"/> -<booleanAttribute key="clearConfig" value="true"/> -<booleanAttribute key="clearws" value="true"/> -<booleanAttribute key="clearwslog" value="false"/> -<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> -<booleanAttribute key="default" value="true"/> -<booleanAttribute key="includeOptional" value="true"/> -<stringAttribute key="location" value="${workspace_loc}/../debug-junit-workspace"/> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> -<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> -<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> -<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/> -<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.debug.tests.AutomatedSuite"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.debug.tests"/> -<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx384m"/> -<stringAttribute key="pde.version" value="3.3"/> -<stringAttribute key="product" value="org.eclipse.sdk.ide"/> -<booleanAttribute key="run_in_ui_thread" value="true"/> -<booleanAttribute key="show_selected_only" value="false"/> -<booleanAttribute key="tracing" value="false"/> -<booleanAttribute key="useCustomFeatures" value="false"/> -<booleanAttribute key="useDefaultConfig" value="true"/> -<booleanAttribute key="useDefaultConfigArea" value="false"/> -<booleanAttribute key="useProduct" value="true"/> + <booleanAttribute key="append.args" value="true"/> + <booleanAttribute key="askclear" value="false"/> + <booleanAttribute key="automaticAdd" value="true"/> + <booleanAttribute key="automaticValidate" value="false"/> + <stringAttribute key="bootstrap" value=""/> + <stringAttribute key="checked" value="[NONE]"/> + <booleanAttribute key="clearConfig" value="true"/> + <booleanAttribute key="clearws" value="true"/> + <booleanAttribute key="clearwslog" value="false"/> + <stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/> + <booleanAttribute key="default" value="true"/> + <booleanAttribute key="includeOptional" value="true"/> + <stringAttribute key="location" value="${workspace_loc}/../debug-junit-workspace"/> + <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> + <listEntry value="/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java"/> + </listAttribute> + <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> + <listEntry value="1"/> + </listAttribute> + <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> + <booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> + <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> + <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> + <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.debug.tests.AutomatedSuite"/> + <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/> + <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.debug.tests"/> + <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> + <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx384m"/> + <stringAttribute key="pde.version" value="3.3"/> + <stringAttribute key="product" value="org.eclipse.sdk.ide"/> + <booleanAttribute key="run_in_ui_thread" value="true"/> + <booleanAttribute key="show_selected_only" value="false"/> + <booleanAttribute key="tracing" value="false"/> + <booleanAttribute key="useCustomFeatures" value="false"/> + <booleanAttribute key="useDefaultConfig" value="true"/> + <booleanAttribute key="useDefaultConfigArea" value="false"/> + <booleanAttribute key="useProduct" value="true"/> </launchConfiguration> diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java index 1d6399254..8110b2464 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AbstractDebugTest.java @@ -28,10 +28,12 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.intro.IIntroManager; import org.eclipse.ui.intro.IIntroPart; import org.eclipse.ui.progress.UIJob; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.rules.TestName; -import junit.framework.TestCase; - -public class AbstractDebugTest extends TestCase { +public class AbstractDebugTest { private static boolean welcomeClosed; @@ -45,27 +47,21 @@ public class AbstractDebugTest extends TestCase { */ private final PreferenceMemento prefMemento = new PreferenceMemento(); - public AbstractDebugTest() { - super(); - } + @Rule + public TestName name = new TestName(); - public AbstractDebugTest(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { - super.setUp(); - TestUtil.log(IStatus.INFO, getName(), "setUp"); + @Before + public void setUp() throws Exception { + TestUtil.log(IStatus.INFO, name.getMethodName(), "setUp"); assertWelcomeScreenClosed(); } - @Override - protected void tearDown() throws Exception { - TestUtil.log(IStatus.INFO, getName(), "tearDown"); - TestUtil.cleanUp(getName()); + @After + public void tearDown() throws Exception { + TestUtil.log(IStatus.INFO, name.getMethodName(), "tearDown"); + TestUtil.cleanUp(name.getMethodName()); prefMemento.resetPreferences(); - super.tearDown(); } /** diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java index 32e1ed3c0..ed53aad4a 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java @@ -49,84 +49,33 @@ import org.eclipse.debug.tests.viewer.model.VirtualViewerLazyModeTests; import org.eclipse.debug.tests.viewer.model.VirtualViewerSelectionTests; import org.eclipse.debug.tests.viewer.model.VirtualViewerStateTests; import org.eclipse.debug.tests.viewer.model.VirtualViewerUpdateTests; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * Tests for integration and nightly builds. * * @since 3.6 */ -public class AutomatedSuite extends TestSuite { - - /** - * Returns the suite. This is required to use the JUnit Launcher. - * - * @return the test suite - */ - public static Test suite() { - return new AutomatedSuite(); - } - - /** - * Constructs the automated test suite. Adds all tests. - */ - public AutomatedSuite() { - // Source lookup tests - addTest(new TestSuite(SourceLookupFacilityTests.class)); - // BP tests - addTest(new TestSuite(BreakpointOrderingTests.class)); - // Note: jface viewer tests were moved out of nightly tests - // due to frequent problems on nightly build machines. - // (Bug 343308). - - // Virtual viewer tests - addTest(new TestSuite(VirtualViewerDeltaTests.class)); - addTest(new TestSuite(VirtualViewerContentTests.class)); - addTest(new TestSuite(VirtualViewerLazyModeTests.class)); - addTest(new TestSuite(VirtualViewerSelectionTests.class)); - addTest(new TestSuite(VirtualViewerStateTests.class)); - addTest(new TestSuite(VirtualViewerUpdateTests.class)); - addTest(new TestSuite(VirtualViewerFilterTests.class)); - - // Viewer neutral tests - addTest(new TestSuite(FilterTransformTests.class)); - addTest(new TestSuite(ChildrenUpdateTests.class)); - addTest(new TestSuite(PresentationContextTests.class)); - - // Memory view - addTest(new TestSuite(MemoryRenderingTests.class)); - - // Launch framework - addTest(new TestSuite(LaunchConfigurationTests.class)); - addTest(new TestSuite(AcceleratorSubstitutionTests.class)); - addTest(new TestSuite(LaunchHistoryTests.class)); - addTest(new TestSuite(LaunchFavoriteTests.class)); - addTest(new TestSuite(LaunchManagerTests.class)); - addTest(new TestSuite(RefreshTabTests.class)); - addTest(new TestSuite(ArgumentParsingTests.class)); - addTest(new TestSuite(LaunchTests.class)); - - // Status handlers - addTest(new TestSuite(StatusHandlerTests.class)); - - // Step filters - addTest(new TestSuite(StepFiltersTests.class)); - - // Console view - addTest(new TestSuite(ConsoleDocumentAdapterTests.class)); - addTest(new TestSuite(ConsoleManagerTests.class)); - addTest(new TestSuite(ConsoleTests.class)); - addTest(new TestSuite(IOConsoleTests.class)); - addTest(new TestSuite(IOConsoleFixedWidthTests.class)); - addTest(new TestSuite(ProcessConsoleManagerTests.class)); - addTest(new TestSuite(ProcessConsoleTests.class)); - addTest(new TestSuite(StreamsProxyTests.class)); - addTest(new TestSuite(TextConsoleViewerTest.class)); - addTest(new TestSuite(RuntimeProcessTests.class)); - - // Launch Groups - addTest(new TestSuite(LaunchGroupTests.class)); - } +@RunWith(Suite.class) +@Suite.SuiteClasses({ + SourceLookupFacilityTests.class, BreakpointOrderingTests.class, + VirtualViewerDeltaTests.class, VirtualViewerContentTests.class, + VirtualViewerLazyModeTests.class, VirtualViewerSelectionTests.class, + VirtualViewerStateTests.class, VirtualViewerUpdateTests.class, + VirtualViewerFilterTests.class, FilterTransformTests.class, + ChildrenUpdateTests.class, PresentationContextTests.class, + MemoryRenderingTests.class, LaunchConfigurationTests.class, + AcceleratorSubstitutionTests.class, LaunchHistoryTests.class, + LaunchFavoriteTests.class, LaunchManagerTests.class, + RefreshTabTests.class, ArgumentParsingTests.class, LaunchTests.class, + StatusHandlerTests.class, + StepFiltersTests.class, + ConsoleDocumentAdapterTests.class, ConsoleManagerTests.class, + ConsoleTests.class, IOConsoleTests.class, + IOConsoleFixedWidthTests.class, ProcessConsoleManagerTests.class, + ProcessConsoleTests.class, StreamsProxyTests.class, + TextConsoleViewerTest.class, RuntimeProcessTests.class, + LaunchGroupTests.class }) +public class AutomatedSuite { } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java index 58ef4f76a..b9f2c9e83 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java @@ -13,9 +13,6 @@ *******************************************************************************/ package org.eclipse.debug.tests; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.eclipse.debug.tests.viewer.model.ColumnPresentationTests; import org.eclipse.debug.tests.viewer.model.JFaceViewerCheckTests; import org.eclipse.debug.tests.viewer.model.JFaceViewerContentTests; @@ -26,6 +23,8 @@ import org.eclipse.debug.tests.viewer.model.JFaceViewerSelectionTests; import org.eclipse.debug.tests.viewer.model.JFaceViewerStateTests; import org.eclipse.debug.tests.viewer.model.JFaceViewerTopIndexTests; import org.eclipse.debug.tests.viewer.model.JFaceViewerUpdateTests; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * Tests to run locally. They require a user terminal to execute correctly @@ -33,31 +32,14 @@ import org.eclipse.debug.tests.viewer.model.JFaceViewerUpdateTests; * * @since 3.7 */ -public class LocalSuite extends TestSuite { - - /** - * Returns the suite. This is required to use the JUnit Launcher. - * - * @return the test suite - */ - public static Test suite() { - return new LocalSuite(); - } +@RunWith(Suite.class) +@Suite.SuiteClasses({ + JFaceViewerCheckTests.class, JFaceViewerContentTests.class, + JFaceViewerDeltaTests.class, JFaceViewerSelectionTests.class, + JFaceViewerStateTests.class, JFaceViewerUpdateTests.class, + JFaceViewerLazyTests.class, JFaceViewerTopIndexTests.class, + JFaceViewerFilterTests.class, ColumnPresentationTests.class +}) +public class LocalSuite { - /** - * Constructs the automated test suite. Adds all tests. - */ - public LocalSuite() { - // JFace viewer tests - addTest(new TestSuite(JFaceViewerCheckTests.class)); - addTest(new TestSuite(JFaceViewerContentTests.class)); - addTest(new TestSuite(JFaceViewerDeltaTests.class)); - addTest(new TestSuite(JFaceViewerSelectionTests.class)); - addTest(new TestSuite(JFaceViewerStateTests.class)); - addTest(new TestSuite(JFaceViewerUpdateTests.class)); - addTest(new TestSuite(JFaceViewerLazyTests.class)); - addTest(new TestSuite(JFaceViewerTopIndexTests.class)); - addTest(new TestSuite(JFaceViewerFilterTests.class)); - addTest(new TestSuite(ColumnPresentationTests.class)); - } } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java index 4d44939fd..74eee6e9b 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java @@ -13,37 +13,19 @@ *******************************************************************************/ package org.eclipse.debug.tests; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.eclipse.debug.tests.viewer.model.JFaceViewerPerformanceTests; import org.eclipse.debug.tests.viewer.model.VirtualViewerPerformanceTests; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * Tests for release builds. * * @since 3.6 */ -public class PerformanceSuite extends TestSuite { - - /** - * Returns the suite. This is required to use the JUnit Launcher. - * - * @return the test suite - */ - public static Test suite() { - return new PerformanceSuite(); - } - - /** - * Constructs the automated test suite. Adds all tests. - */ - public PerformanceSuite() { - // JFace viewer tests - addTest(new TestSuite(JFaceViewerPerformanceTests.class)); - - // Virtual viewer tests - addTest(new TestSuite(VirtualViewerPerformanceTests.class)); - } - +@RunWith(Suite.class) +@Suite.SuiteClasses({ + JFaceViewerPerformanceTests.class, + VirtualViewerPerformanceTests.class }) +public class PerformanceSuite { } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java index 3ad0c414e..99f2a2645 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.debug.tests; +import static org.junit.Assert.fail; + import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.util.ArrayList; @@ -28,8 +30,6 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Display; import org.junit.Assert; -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; public class TestUtil { @@ -129,7 +129,7 @@ public class TestUtil { } Boolean stillTrue = condition.apply(context); if (stillTrue) { - TestCase.fail(errorMessage.apply(context)); + fail(errorMessage.apply(context)); } } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java index 2b764fbdc..c70242f79 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.breakpoint; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.List; import org.eclipse.core.resources.IMarker; @@ -38,6 +42,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Widget; import org.eclipse.ui.IEditorInput; +import org.junit.Test; /** * Test the ordering used in the breakpoints view. @@ -46,10 +51,6 @@ import org.eclipse.ui.IEditorInput; */ public class BreakpointOrderingTests extends AbstractDebugTest { - public BreakpointOrderingTests(String name) { - super(name); - } - /** * Test only implementation of IBreakpoint. */ @@ -366,15 +367,22 @@ public class BreakpointOrderingTests extends AbstractDebugTest { return fTestBps; } + @Test public void testBreakpointOrdering0() throws CoreException { executeTest(createTestBreakpoints0()); } + + @Test public void testBreakpointOrdering1() throws CoreException { executeTest(createTestBreakpoints1()); } + + @Test public void testBreakpointOrdering2() throws CoreException { executeTest(createTestBreakpoints2()); } + + @Test public void testBreakpointOrdering3() throws CoreException { executeTest(createTestBreakpoints3()); } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleDocumentAdapterTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleDocumentAdapterTests.java index ffcd759c8..f2b58e55d 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleDocumentAdapterTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleDocumentAdapterTests.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +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.Collections; import java.util.LinkedList; @@ -32,6 +38,7 @@ import org.eclipse.swt.custom.TextChangeListener; import org.eclipse.swt.custom.TextChangedEvent; import org.eclipse.swt.custom.TextChangingEvent; import org.eclipse.ui.internal.console.ConsoleDocumentAdapter; +import org.junit.Test; /** * Tests {@link ConsoleDocumentAdapter}. @@ -42,17 +49,10 @@ import org.eclipse.ui.internal.console.ConsoleDocumentAdapter; @SuppressWarnings("restriction") public class ConsoleDocumentAdapterTests extends AbstractDebugTest { - public ConsoleDocumentAdapterTests() { - super(ConsoleDocumentAdapterTests.class.getSimpleName()); - } - - public ConsoleDocumentAdapterTests(String name) { - super(name); - } - /** * Test {@link ConsoleDocumentAdapter#setText(String)}. */ + @Test public void testSetText() { final ExpectingTextChangeListener eventListener = new ExpectingTextChangeListener(true, null); final IDocumentAdapter docAdapter = new ConsoleDocumentAdapter(-1); @@ -77,6 +77,7 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { /** * Test fixed width line wrap. (mostly with changes affecting a single line) */ + @Test public void testLineWrap() { final Random rand = new Random(4); final int wrapWidth = 10; @@ -406,6 +407,7 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { /** * Test inserting text containing line delimiters. */ + @Test public void testMultilineInserts() { final Random rand = new Random(4); final int wrapWidth = 10; @@ -577,6 +579,7 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { /** * Test text remove affecting than one line. */ + @Test public void testMultilineRemove() { final Random rand = new Random(4); final int wrapWidth = 10; @@ -701,6 +704,7 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { /** * Test text change affecting and inserting more than one line. */ + @Test public void testMultilineReplace() { final Random rand = new Random(4); final int wrapWidth = 10; @@ -797,6 +801,7 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { /** * Test line wrapping is correctly updated if fixed width changed. */ + @Test public void testSetWidth() { final Random rand = new Random(7); final ConsoleDocumentAdapter docAdapter = new ConsoleDocumentAdapter(-1); @@ -863,6 +868,7 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { * Some test cases derived from JavaDoc examples of {@link IDocumentAdapter} * (and its super interfaces). */ + @Test public void testInterfaceContract() { final ConsoleDocumentAdapter docAdapter = new ConsoleDocumentAdapter(-1); docAdapter.setDocument(new Document()); @@ -909,6 +915,7 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { * {@link IDocumentAdapter#setDocument(org.eclipse.jface.text.IDocument)} * and ensure old document is indeed disconnected and not notified anymore. */ + @Test public void testChangeDocument() { final IDocumentAdapter docAdapter = new ConsoleDocumentAdapter(-1); final IDocument doc1 = new Document(); @@ -1027,6 +1034,7 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { /** * Test adapter with a larger number of lines. (especially tests array grow) */ + @Test public void testManyLines() { final ConsoleDocumentAdapter docAdapter = new ConsoleDocumentAdapter(80); docAdapter.setDocument(new Document()); @@ -1251,10 +1259,6 @@ public class ConsoleDocumentAdapterTests extends AbstractDebugTest { return null; } assertNotNull("Unexpected event.", expectation); - if (expectation == null) { - // prevents wrong compiler warning 'expectation may be null' - return null; - } if (expectation.type != eventType && allowUnexpectedEvents) { return null; } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleManagerTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleManagerTests.java index 4e7639ab8..52e59cd9f 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleManagerTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleManagerTests.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -35,6 +39,9 @@ import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.IConsoleView; import org.eclipse.ui.part.IPageBookViewPage; import org.eclipse.ui.part.MessagePage; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * Tests console manager @@ -49,7 +56,8 @@ public class ConsoleManagerTests extends AbstractDebugTest { ConsoleMock firstConsole; @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); assertNotNull("Must run in UI thread, but was in: " + Thread.currentThread().getName(), //$NON-NLS-1$ Display.getCurrent()); @@ -77,13 +85,13 @@ public class ConsoleManagerTests extends AbstractDebugTest { firstConsole = new ConsoleMock(0); manager.addConsoles(new ConsoleMock[] { firstConsole }); manager.showConsoleView(firstConsole); - TestUtil.waitForJobs(getName(), 200, 5000); + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); TestUtil.processUIEvents(100); ConsoleMock.allShownConsoles.set(0); } - @Override - protected void tearDown() throws Exception { + @Override @After + public void tearDown() throws Exception { executorService.shutdownNow(); manager.removeConsoles(consoles); manager.removeConsoles(new ConsoleMock[] { firstConsole }); @@ -100,6 +108,7 @@ public class ConsoleManagerTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testShowAllConsoles() throws Exception { // Create a number of threads which will start and wait for the last one // created to call ConsoleManager.show. @@ -111,7 +120,7 @@ public class ConsoleManagerTests extends AbstractDebugTest { // Console manager starts a job with delay, let wait for him a bit System.out.println("Waiting on jobs now..."); //$NON-NLS-1$ - TestUtil.waitForJobs(getName(), 200, 5000); + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); // Give UI a chance to proceed pending console manager jobs System.out.println("Done with jobs, processing UI events again..."); //$NON-NLS-1$ @@ -154,7 +163,7 @@ public class ConsoleManagerTests extends AbstractDebugTest { latch.await(1, TimeUnit.MINUTES); System.out.println("Requesting to show: " + console); //$NON-NLS-1$ manager.showConsoleView(console); - TestUtil.waitForJobs(getName(), 200, 5000); + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); } catch (InterruptedException e) { e.printStackTrace(); Thread.interrupted(); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java index a291dcb18..289efb785 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleTests.java @@ -14,6 +14,10 @@ package org.eclipse.debug.tests.console; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; @@ -34,69 +38,64 @@ import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.IOConsole; import org.eclipse.ui.console.IOConsoleOutputStream; import org.eclipse.ui.console.MessageConsole; +import org.junit.Test; -import junit.framework.TestCase; public class ConsoleTests extends AbstractDebugTest { - public ConsoleTests() { - super("ConsoleTests"); //$NON-NLS-1$ - } - - public ConsoleTests(String name) { - super(name); - } - + @Test public void testConsoleOutputStreamEncoding() throws IOException { String testString = "abc\u00e4\u00f6\u00fcdef"; //$NON-NLS-1$ // abcdef need 1 byte in UTF-8 each // äöü (\u00e4\u00f6\u00fc) need 2 bytes each byte[] testStringBuffer = testString.getBytes(StandardCharsets.UTF_8); - TestCase.assertEquals("Test string \"" + testString + "\" should consist of 12 UTF-8 bytes", 12, testStringBuffer.length); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Test string \"" + testString + "\" should consist of 12 UTF-8 bytes", 12, testStringBuffer.length); //$NON-NLS-1$ //$NON-NLS-2$ MessageConsole console = new MessageConsole("Test Console", //$NON-NLS-1$ IConsoleConstants.MESSAGE_CONSOLE_TYPE, null, StandardCharsets.UTF_8.name(), true); IDocument document = console.getDocument(); - TestUtil.waitForJobs(getName(), 200, 5000); - TestCase.assertEquals("Document should be empty", "", document.get()); //$NON-NLS-1$ //$NON-NLS-2$ + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); + assertEquals("Document should be empty", "", document.get()); //$NON-NLS-1$ //$NON-NLS-2$ try (IOConsoleOutputStream outStream = console.newOutputStream()) { outStream.write(testStringBuffer, 0, 6); // half of ö (\u00f6) is written so we don't expect this char in // output but all previous chars can be decoded - TestUtil.waitForJobs(getName(), 200, 5000); - TestCase.assertEquals("First 4 chars should be written", testString.substring(0, 4), document.get()); //$NON-NLS-1$ + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); + assertEquals("First 4 chars should be written", testString.substring(0, 4), document.get()); //$NON-NLS-1$ outStream.write(testStringBuffer, 6, 6); // all remaining bytes are written so we expect the whole string // including the ö (\u00f6) which was at buffer boundary - TestUtil.waitForJobs(getName(), 200, 5000); - TestCase.assertEquals("whole test string should be written", testString, document.get()); //$NON-NLS-1$ + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); + assertEquals("whole test string should be written", testString, document.get()); //$NON-NLS-1$ } - TestUtil.waitForJobs(getName(), 200, 5000); + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); // after closing the stream, the document content should still be the // same - TestCase.assertEquals("closing the stream should not alter the document", testString, document.get()); //$NON-NLS-1$ + assertEquals("closing the stream should not alter the document", testString, document.get()); //$NON-NLS-1$ } + @Test public void testConsoleOutputStreamLastR() throws IOException { String testString = "a\r"; //$NON-NLS-1$ byte[] testStringBuffer = testString.getBytes(StandardCharsets.UTF_8); - TestCase.assertEquals("Test string \"" + testString + "\" should consist of 2 UTF-8 bytes", 2, testStringBuffer.length); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Test string \"" + testString + "\" should consist of 2 UTF-8 bytes", 2, testStringBuffer.length); //$NON-NLS-1$ //$NON-NLS-2$ MessageConsole console = new MessageConsole("Test Console 2", //$NON-NLS-1$ IConsoleConstants.MESSAGE_CONSOLE_TYPE, null, StandardCharsets.UTF_8.name(), true); IDocument document = console.getDocument(); - TestUtil.waitForJobs(getName(), 200, 5000); - TestCase.assertEquals("Document should be empty", "", document.get()); //$NON-NLS-1$ //$NON-NLS-2$ + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); + assertEquals("Document should be empty", "", document.get()); //$NON-NLS-1$ //$NON-NLS-2$ try (IOConsoleOutputStream outStream = console.newOutputStream()) { outStream.write(testStringBuffer); // everything but pending \r should be written - TestUtil.waitForJobs(getName(), 200, 5000); - TestCase.assertEquals("First char should be written", testString.substring(0, 1), document.get()); //$NON-NLS-1$ + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); + assertEquals("First char should be written", testString.substring(0, 1), document.get()); //$NON-NLS-1$ } - TestUtil.waitForJobs(getName(), 200, 5000); + TestUtil.waitForJobs(name.getMethodName(), 200, 5000); // after closing the stream, the document content should still be the // same - TestCase.assertEquals("closing the stream should write the pending \\r", testString, document.get()); //$NON-NLS-1$ + assertEquals("closing the stream should write the pending \\r", testString, document.get()); //$NON-NLS-1$ } + @Test public void testConsoleOutputStreamDocumentClosed() throws IOException { MessageConsole console = new MessageConsole("Test Console 3", //$NON-NLS-1$ IConsoleConstants.MESSAGE_CONSOLE_TYPE, null, StandardCharsets.UTF_8.name(), true); @@ -106,13 +105,14 @@ public class ConsoleTests extends AbstractDebugTest { document.getDocumentPartitioner().disconnect(); try { outStream.write("write2"); //$NON-NLS-1$ - TestCase.fail("IOException with message \"Document is closed\" expected"); //$NON-NLS-1$ + fail("IOException with message \"Document is closed\" expected"); //$NON-NLS-1$ } catch (IOException ioe) { - TestCase.assertEquals("Document is closed", ioe.getMessage()); //$NON-NLS-1$ + assertEquals("Document is closed", ioe.getMessage()); //$NON-NLS-1$ } } } + @Test public void testConsoleOutputStreamClosed() throws IOException { MessageConsole console = new MessageConsole("Test Console 4", //$NON-NLS-1$ IConsoleConstants.MESSAGE_CONSOLE_TYPE, null, StandardCharsets.UTF_8.name(), true); @@ -121,13 +121,14 @@ public class ConsoleTests extends AbstractDebugTest { outStream.close(); try { outStream.write("test2".getBytes(StandardCharsets.UTF_8)); //$NON-NLS-1$ - TestCase.fail("IOException with message \"Output Stream is closed\" expected"); //$NON-NLS-1$ + fail("IOException with message \"Output Stream is closed\" expected"); //$NON-NLS-1$ } catch (IOException ioe) { - TestCase.assertEquals("Output Stream is closed", ioe.getMessage()); //$NON-NLS-1$ + assertEquals("Output Stream is closed", ioe.getMessage()); //$NON-NLS-1$ } } } + @Test public void testConsoleOutputStreamDocumentStreamClosed() throws IOException { MessageConsole console = new MessageConsole("Test Console 5", //$NON-NLS-1$ IConsoleConstants.MESSAGE_CONSOLE_TYPE, null, StandardCharsets.UTF_8.name(), true); @@ -137,19 +138,20 @@ public class ConsoleTests extends AbstractDebugTest { document.getDocumentPartitioner().disconnect(); try { outStream.write("write2"); //$NON-NLS-1$ - TestCase.fail("IOException with message \"Document is closed\" expected"); //$NON-NLS-1$ + fail("IOException with message \"Document is closed\" expected"); //$NON-NLS-1$ } catch (IOException ioe) { - TestCase.assertEquals("Document is closed", ioe.getMessage()); //$NON-NLS-1$ + assertEquals("Document is closed", ioe.getMessage()); //$NON-NLS-1$ } try { outStream.write("write3"); //$NON-NLS-1$ - TestCase.fail("IOException with message \"Output Stream is closed\" expected"); //$NON-NLS-1$ + fail("IOException with message \"Output Stream is closed\" expected"); //$NON-NLS-1$ } catch (IOException ioe) { - TestCase.assertEquals("Output Stream is closed", ioe.getMessage()); //$NON-NLS-1$ + assertEquals("Output Stream is closed", ioe.getMessage()); //$NON-NLS-1$ } } } + @Test public void testSetNullEncoding() throws IOException { MessageConsole console = new MessageConsole("Test Console 6", null); //$NON-NLS-1$ try (IOConsoleOutputStream outStream = console.newOutputStream()) { @@ -164,6 +166,7 @@ public class ConsoleTests extends AbstractDebugTest { * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=268608">bug * 268608</a> */ + @Test public void testFindReplaceIsEnabledOnConsoleOpen() throws Exception { IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart consoleView = activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW); @@ -177,11 +180,11 @@ public class ConsoleTests extends AbstractDebugTest { try { consoleManager.addConsoles(consoles); consoleManager.showConsoleView(console); - TestUtil.waitForJobs(getName(), 100, 3000); + TestUtil.waitForJobs(name.getMethodName(), 100, 3000); ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE); - TestCase.assertTrue("expected FindReplace command to be enabled after opening console", command.isEnabled()); + assertTrue("expected FindReplace command to be enabled after opening console", command.isEnabled()); } finally { consoleManager.removeConsoles(consoles); activePage.hideView(consoleView); @@ -193,6 +196,7 @@ public class ConsoleTests extends AbstractDebugTest { * * @throws Exception if test fails */ + @Test public void testIOConsoleAvailable() throws Exception { IOConsole console = new IOConsole("", null); try (InputStream consoleInput = console.getInputStream()) { diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleFixedWidthTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleFixedWidthTests.java index dba2f11cc..d0c2b5f72 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleFixedWidthTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleFixedWidthTests.java @@ -20,14 +20,6 @@ import org.eclipse.debug.tests.TestUtil; */ public class IOConsoleFixedWidthTests extends IOConsoleTests { - public IOConsoleFixedWidthTests() { - super(IOConsoleFixedWidthTests.class.getSimpleName()); - } - - public IOConsoleFixedWidthTests(String name) { - super(name); - } - @Override protected IOConsoleTestUtil getTestUtil(String title) { final IOConsoleTestUtil c = super.getTestUtil(title); @@ -37,7 +29,7 @@ public class IOConsoleFixedWidthTests extends IOConsoleTests { c.getConsole().setConsoleWidth(3); c.setIgnoreFixedConsole(true); // console width is applied asynchronous - TestUtil.waitForJobs(getName(), 50, 1000); + TestUtil.waitForJobs(name.getMethodName(), 50, 1000); return c; } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java index 831f810b7..056e8402a 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTestUtil.java @@ -13,6 +13,13 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +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.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -35,8 +42,6 @@ import org.eclipse.ui.console.IConsoleDocumentPartitioner; import org.eclipse.ui.console.IOConsole; import org.eclipse.ui.console.IOConsoleOutputStream; -import junit.framework.TestCase; - /** * Utility to help testing input and output in {@link IOConsole}. */ @@ -89,11 +94,11 @@ public final class IOConsoleTestUtil { */ public IOConsoleTestUtil(IOConsole console, StyledText textPanel, String name) { this.console = console; - TestCase.assertNotNull(this.console); + assertNotNull(this.console); this.doc = console.getDocument(); - TestCase.assertNotNull(this.doc); + assertNotNull(this.doc); final Class<?> expectedInterface = IConsoleDocumentPartitioner.class; - TestCase.assertTrue("Expected partitioner implements " + expectedInterface.getName() + // + assertTrue("Expected partitioner implements " + expectedInterface.getName() + // ". Found: " + this.doc.getDocumentPartitioner().getClass(), // expectedInterface.isAssignableFrom(this.doc.getDocumentPartitioner().getClass())); this.partitioner = (IConsoleDocumentPartitioner) this.doc.getDocumentPartitioner(); @@ -110,7 +115,7 @@ public final class IOConsoleTestUtil { public IOConsoleTestUtil clear() throws Exception { console.clearConsole(); flush(); - TestCase.assertEquals("Console is not cleared.", 0, doc.getLength()); + assertEquals("Console is not cleared.", 0, doc.getLength()); return this; } @@ -202,7 +207,7 @@ public final class IOConsoleTestUtil { public IOConsoleTestUtil writeAndVerify(final String s, IOConsoleOutputStream out) throws Exception { final int oldLength = doc.getLength(); write(s, out); - TestCase.assertEquals("Console content length not as expected.", oldLength + s.length(), doc.getLength()); + assertEquals("Console content length not as expected.", oldLength + s.length(), doc.getLength()); verifyContentByOffset(s, oldLength); verifyOutputPartitions(oldLength, s.length()); return this; @@ -256,8 +261,8 @@ public final class IOConsoleTestUtil { final int oldSelectionLength = textPanel.getSelectionCount(); final int oldOffset = getCaretOffset() - oldSelectionLength; insert(content); - TestCase.assertEquals("Console content length not as expected.", oldLength + content.length() - oldSelectionLength, doc.getLength()); - TestCase.assertEquals("Caret not at expected position.", oldOffset + content.length(), getCaretOffset()); + assertEquals("Console content length not as expected.", oldLength + content.length() - oldSelectionLength, doc.getLength()); + assertEquals("Caret not at expected position.", oldOffset + content.length(), getCaretOffset()); verifyContentByOffset(content, oldOffset); verifyInputPartitions(oldOffset, content.length()); return this; @@ -306,8 +311,8 @@ public final class IOConsoleTestUtil { final int oldSelectionLength = textPanel.getSelectionCount(); final int oldOffset = getCaretOffset() - oldSelectionLength; insertTyping(content); - TestCase.assertEquals("Console content length not as expected.", oldLength + content.length() - oldSelectionLength, doc.getLength()); - TestCase.assertEquals("Caret not at expected position.", oldOffset + content.length(), getCaretOffset()); + assertEquals("Console content length not as expected.", oldLength + content.length() - oldSelectionLength, doc.getLength()); + assertEquals("Caret not at expected position.", oldOffset + content.length(), getCaretOffset()); verifyContentByOffset(content, oldOffset); verifyInputPartitions(oldOffset, content.length()); return this; @@ -525,7 +530,7 @@ public final class IOConsoleTestUtil { */ public IOConsoleTestUtil verifyContent(String expectedContent) { verifyContentByOffset(expectedContent, 0); - TestCase.assertEquals("More or less content in console as expected.", expectedContent.length(), doc.getLength()); + assertEquals("More or less content in console as expected.", expectedContent.length(), doc.getLength()); return this; } @@ -543,9 +548,9 @@ public final class IOConsoleTestUtil { try { final IRegion line = doc.getLineInformation(l); verifyContentByOffset(expectedContent, line.getOffset()); - TestCase.assertEquals("Line " + l + " has wrong length.", expectedContent.length(), line.getLength()); + assertEquals("Line " + l + " has wrong length.", expectedContent.length(), line.getLength()); } catch (BadLocationException e) { - TestCase.fail("Expected line " + lineNum + " not found in console document. Bad location!"); + fail("Expected line " + lineNum + " not found in console document. Bad location!"); } return this; } @@ -562,9 +567,9 @@ public final class IOConsoleTestUtil { try { final int o = offset < 0 ? doc.getLength() + offset : offset; final int len = Math.min(doc.getLength() - o, expectedContent.length()); - TestCase.assertEquals("Expected string not found in console document.", expectedContent, doc.get(o, len)); + assertEquals("Expected string not found in console document.", expectedContent, doc.get(o, len)); } catch (BadLocationException ex) { - TestCase.fail("Expected string '" + expectedContent + "' not found in console document. Bad location!"); + fail("Expected string '" + expectedContent + "' not found in console document. Bad location!"); } return this; } @@ -630,8 +635,8 @@ public final class IOConsoleTestUtil { public IOConsoleTestUtil verifyPartitions(final int offset, final int length, final String expectedType, final boolean allowMixedTypes, final boolean allowGaps, int minPartitionNumber) { { final ITypedRegion[] partitions = getPartitioner().computePartitioning(offset, length); - TestCase.assertNotNull("Got no partitions.", partitions); - TestCase.assertTrue("Got less partitions than expected.", partitions.length >= minPartitionNumber); + assertNotNull("Got no partitions.", partitions); + assertTrue("Got less partitions than expected.", partitions.length >= minPartitionNumber); // points to offset after last partition range aka. expected start // of next partition @@ -639,13 +644,13 @@ public final class IOConsoleTestUtil { ITypedRegion lastPartition = null; String partitionType = expectedType; for (ITypedRegion partition : partitions) { - TestCase.assertNotSame("Got same partition twice.", lastPartition, partition); - TestCase.assertTrue("Partition overlapping. (or not sorted as expected)", partition.getOffset() >= lastEnd); + assertNotSame("Got same partition twice.", lastPartition, partition); + assertTrue("Partition overlapping. (or not sorted as expected)", partition.getOffset() >= lastEnd); if (!allowGaps && lastEnd != -1) { - TestCase.assertTrue("Partitioning gap.", partition.getOffset() == lastEnd); + assertTrue("Partitioning gap.", partition.getOffset() == lastEnd); } - TestCase.assertTrue("Not a valid partition type.", validPartionTypes.contains(partition.getType())); - TestCase.assertTrue("Wrong partition type.", partitionType == null || partitionType.equals(partition.getType()) || allowMixedTypes); + assertTrue("Not a valid partition type.", validPartionTypes.contains(partition.getType())); + assertTrue("Wrong partition type.", partitionType == null || partitionType.equals(partition.getType()) || allowMixedTypes); if (partitionType == null && !allowMixedTypes) { partitionType = partition.getType(); } @@ -660,17 +665,17 @@ public final class IOConsoleTestUtil { while (pos < end) { final ITypedRegion partition = getPartitioner().getPartition(pos); if (partition == null) { - TestCase.assertTrue("Did not expect 'null' partition.", allowGaps); + assertTrue("Did not expect 'null' partition.", allowGaps); pos++; continue; } - TestCase.assertNotSame("Got same partition again.", lastPartition, partition); - TestCase.assertFalse("Did not expected and cannot handle empty partition.", partition.getLength() == 0); - TestCase.assertTrue("Got not the requested partition.", partition.getOffset() <= pos && partition.getOffset() + partition.getLength() > pos); - TestCase.assertTrue("Not a valid partition type.", validPartionTypes.contains(partition.getType())); + assertNotSame("Got same partition again.", lastPartition, partition); + assertFalse("Did not expected and cannot handle empty partition.", partition.getLength() == 0); + assertTrue("Got not the requested partition.", partition.getOffset() <= pos && partition.getOffset() + partition.getLength() > pos); + assertTrue("Not a valid partition type.", validPartionTypes.contains(partition.getType())); lastPartition = partition; if (partitionType != null && !partitionType.equals(partition.getType())) { - TestCase.assertTrue("Wrong partition type.", allowMixedTypes); + assertTrue("Wrong partition type.", allowMixedTypes); pos += partition.getLength(); end += partition.getLength(); continue; @@ -725,7 +730,7 @@ public final class IOConsoleTestUtil { try { defaultOut.close(); } catch (IOException e) { - TestCase.fail("Failed to close output stream."); + fail("Failed to close output stream."); } } } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java index 5ec28c675..a90cad29a 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/IOConsoleTests.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +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.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -51,6 +56,9 @@ import org.eclipse.ui.console.IConsoleDocumentPartitionerExtension; import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.IOConsole; import org.eclipse.ui.console.IOConsoleOutputStream; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * Tests the {@link IOConsole}. Especially the partitioner and viewer parts. @@ -79,16 +87,9 @@ public class IOConsoleTests extends AbstractDebugTest { } }; - public IOConsoleTests() { - super(IOConsoleTests.class.getSimpleName()); - } - - public IOConsoleTests(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); // create or activate console view @@ -111,7 +112,8 @@ public class IOConsoleTests extends AbstractDebugTest { } @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { Platform.removeLogListener(errorLogListener); super.tearDown(); @@ -134,12 +136,12 @@ public class IOConsoleTests extends AbstractDebugTest { }); final IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); consoleManager.addConsoles(new IConsole[] { console }); - TestUtil.waitForJobs(getName(), 25, 10000); + TestUtil.waitForJobs(name.getMethodName(), 25, 10000); consoleManager.showConsoleView(console); @SuppressWarnings("restriction") final org.eclipse.ui.internal.console.IOConsolePage page = (org.eclipse.ui.internal.console.IOConsolePage) consoleView.getCurrentPage(); final StyledText textPanel = (StyledText) page.getControl(); - return new IOConsoleTestUtil(console, textPanel, getName()); + return new IOConsoleTestUtil(console, textPanel, name.getMethodName()); } /** @@ -190,6 +192,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test console clear. */ + @Test public void testConsoleClear() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test clear"); @@ -234,6 +237,7 @@ public class IOConsoleTests extends AbstractDebugTest { * Test multiple writes, i.e. {@link IOConsole} receives content from * connected {@link IOConsoleOutputStream}. */ + @Test public void testWrites() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test writes"); final String[] strings = new String[] { @@ -254,6 +258,7 @@ public class IOConsoleTests extends AbstractDebugTest { * Test {@link IOConsole} input stream, i.e. simulate user typing or pasting * input in console. */ + @Test public void testUserInput() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test input"); final List<String> expectedInput = new ArrayList<>(); @@ -290,6 +295,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test {@link IOConsole} with file as input source. */ + @Test public void testInputFile() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test input file"); // open default output stream to match usual behavior where two output @@ -309,6 +315,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test mixes of outputs and user inputs in various variants. */ + @Test public void testMixedWriteAndInput() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test input output mix"); final List<String> expectedInput = new ArrayList<>(); @@ -406,6 +413,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test enabling/disabling control character interpretation. */ + @Test public void testControlCharacterSettings() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test options"); @@ -434,6 +442,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test handling of <code>\b</code>. */ + @Test public void testBackspaceControlCharacter() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test \\b"); c.getConsole().setCarriageReturnAsControlCharacter(false); @@ -515,6 +524,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test handling of <code>\r</code>. */ + @Test public void testCarriageReturnControlCharacter() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test \\r"); c.getConsole().setCarriageReturnAsControlCharacter(true); @@ -560,6 +570,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test handling of <code>\f</code>. */ + @Test public void testFormFeedControlCharacter() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test \\f"); c.getConsole().setHandleControlCharacters(true); @@ -603,6 +614,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test larger number of partitions with pseudo random console content. */ + @Test public void testManyPartitions() throws IOException { final IOConsoleTestUtil c = getTestUtil("Test many partitions"); final List<String> expectedInput = new ArrayList<>(); @@ -644,6 +656,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Test console trimming. */ + @Test public void testTrim() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test trim"); try (IOConsoleOutputStream defaultOut = c.getDefaultOutputStream()) { @@ -668,6 +681,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Some extra tests for IOConsolePartitioner. */ + @Test public void testIOPartitioner() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test partitioner"); @@ -694,6 +708,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Tests for the {@link IConsoleDocumentPartitioner} interface. */ + @Test public void testIConsoleDocumentPartitioner() throws Exception { final IOConsoleTestUtil c = getTestUtil("Test IConsoleDocumentPartitioner"); try (IOConsoleOutputStream otherOut = c.getConsole().newOutputStream()) { @@ -815,6 +830,7 @@ public class IOConsoleTests extends AbstractDebugTest { /** * Regression test for deadlock in stream processing. */ + @Test public void testBug421303_StreamProcessingDeadlock() throws Exception { // Test situation is that UI thread and another thread both write a // large amount of output into same IOConsoleOutputStream at same time diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleManagerTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleManagerTests.java index 7c662d31f..7b9b878eb 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleManagerTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleManagerTests.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.DebugPlugin; @@ -30,6 +34,7 @@ import org.eclipse.debug.tests.TestUtil; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsoleManager; +import org.junit.Test; /** * Tests the ProcessConsoleManager. @@ -37,19 +42,12 @@ import org.eclipse.ui.console.IConsoleManager; @SuppressWarnings("restriction") public class ProcessConsoleManagerTests extends AbstractDebugTest { - public ProcessConsoleManagerTests() { - super(ProcessConsoleManagerTests.class.getSimpleName()); - } - - public ProcessConsoleManagerTests(String name) { - super(name); - } - /** * Test addition and removal of a ProcessConsole. It also kind of tests * {@link LaunchManager} because the ProcessConsoleManager primary works * through an {@link ILaunchListener} which is honored by this test. */ + @Test public void testProcessConsoleLifecycle() throws Exception { // ensure debug UI plugin is started before adding first launch DebugUIPlugin.getDefault(); @@ -59,7 +57,7 @@ public class ProcessConsoleManagerTests extends AbstractDebugTest { if (existingNumConsoles > 0) { // existing consoles must not harm this test but it may be // interesting in case the test fails - TestUtil.log(IStatus.INFO, getName(), "Found " + existingNumConsoles + " existing consoles on test start."); + TestUtil.log(IStatus.INFO, name.getMethodName(), "Found " + existingNumConsoles + " existing consoles on test start."); } ILaunch launch = null; @@ -69,7 +67,7 @@ public class ProcessConsoleManagerTests extends AbstractDebugTest { launch = process.getLaunch(); launchManager.addLaunch(launch); // do not wait on input read job - TestUtil.waitForJobs(getName(), 0, 10000, ProcessConsole.class); + TestUtil.waitForJobs(name.getMethodName(), 0, 10000, ProcessConsole.class); assertEquals("No console was added.", 1, consoleManager.getConsoles().length); } finally { mockProcess.destroy(); @@ -77,7 +75,7 @@ public class ProcessConsoleManagerTests extends AbstractDebugTest { if (launch != null) { launchManager.removeLaunch(launch); - TestUtil.waitForJobs(getName(), 0, 10000); + TestUtil.waitForJobs(name.getMethodName(), 0, 10000); assertEquals("Console is not removed.", 0, consoleManager.getConsoles().length); } } @@ -86,6 +84,7 @@ public class ProcessConsoleManagerTests extends AbstractDebugTest { * Test problematic scenario where launch is already removed before console * is created. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=546710#c13 */ + @Test public void testBug546710_ConsoleCreationRaceCondition() throws Exception { final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); for (ILaunch existingLaunch : launchManager.getLaunches()) { @@ -109,7 +108,7 @@ public class ProcessConsoleManagerTests extends AbstractDebugTest { } ProcessConsoleManager processConsoleManager = DebugUIPlugin.getDefault().getProcessConsoleManager(); - TestUtil.waitForJobs(getName(), 0, 10000); + TestUtil.waitForJobs(name.getMethodName(), 0, 10000); int openConsoles = 0; if (processConsoleManager.getConsole(process1) != null) { openConsoles++; @@ -122,7 +121,7 @@ public class ProcessConsoleManagerTests extends AbstractDebugTest { final ConsoleRemoveAllTerminatedAction removeAction = new ConsoleRemoveAllTerminatedAction(); assertTrue("Remove terminated action should be enabled.", removeAction.isEnabled() || launchManager.getLaunches().length == 0); removeAction.run(); - TestUtil.waitForJobs(getName(), 0, 10000); + TestUtil.waitForJobs(name.getMethodName(), 0, 10000); assertNull("First console not removed.", processConsoleManager.getConsole(process1)); assertNull("Second console not removed.", processConsoleManager.getConsole(process1)); } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java index 3f7eb9f5c..37e3737a6 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.nio.charset.StandardCharsets; import java.util.Collections; @@ -38,13 +41,14 @@ import org.eclipse.debug.tests.TestUtil; import org.eclipse.debug.tests.launching.LaunchConfigurationTests; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.console.ConsoleColorProvider; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.IConsoleConstants; import org.eclipse.ui.console.IConsoleManager; import org.eclipse.ui.console.IOConsoleInputStream; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * Tests the ProcessConsole. @@ -57,32 +61,23 @@ public class ProcessConsoleTests extends AbstractDebugTest { private final AtomicInteger loggedErrors = new AtomicInteger(0); /** Listener to count error messages in {@link ConsolePlugin} log. */ - private final ILogListener errorLogListener = new ILogListener() { - @Override - public void logging(IStatus status, String plugin) { - if (status.matches(IStatus.ERROR)) { - loggedErrors.incrementAndGet(); - } + private final ILogListener errorLogListener = (status, plugin) -> { + if (status.matches(IStatus.ERROR)) { + loggedErrors.incrementAndGet(); } }; - public ProcessConsoleTests() { - super(ProcessConsoleTests.class.getSimpleName()); - } - - public ProcessConsoleTests(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); loggedErrors.set(0); Platform.addLogListener(errorLogListener); } @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { Platform.removeLogListener(errorLogListener); super.tearDown(); @@ -96,6 +91,7 @@ public class ProcessConsoleTests extends AbstractDebugTest { * This test starts every two byte character on an even byte offset. * </p> */ + @Test public void testUTF8InputEven() throws Exception { // 5000 characters result in 10000 bytes which should be more than most // common buffer sizes. @@ -109,6 +105,7 @@ public class ProcessConsoleTests extends AbstractDebugTest { * This test starts every two byte character on an odd byte offset. * </p> */ + @Test public void testUTF8InputOdd() throws Exception { // 5000 characters result in 10000 bytes which should be more than most // common buffer sizes. @@ -162,6 +159,7 @@ public class ProcessConsoleTests extends AbstractDebugTest { * <code>ProcessConsole.class</code> family. * </p> */ + @Test public void testInputReadJobCancel() throws Exception { final MockProcess mockProcess = new MockProcess(MockProcess.RUN_FOREVER); try { @@ -174,7 +172,7 @@ public class ProcessConsoleTests extends AbstractDebugTest { final Class<?> jobFamily = org.eclipse.debug.internal.ui.views.console.ProcessConsole.class; assertTrue("Input read job not started.", Job.getJobManager().find(jobFamily).length > 0); Job.getJobManager().cancel(jobFamily); - TestUtil.waitForJobs(getName(), 0, 1000); + TestUtil.waitForJobs(name.getMethodName(), 0, 1000); assertEquals("Input read job not canceled.", 0, Job.getJobManager().find(jobFamily).length); } finally { console.destroy(); @@ -187,10 +185,11 @@ public class ProcessConsoleTests extends AbstractDebugTest { /** * Test console finished notification with standard process console. */ + @Test public void testProcessTerminationNotification() throws Exception { - TestUtil.log(IStatus.INFO, getName(), "Process terminates after Console is initialized."); + TestUtil.log(IStatus.INFO, name.getMethodName(), "Process terminates after Console is initialized."); processTerminationTest(null, false); - TestUtil.log(IStatus.INFO, getName(), "Process terminates before Console is initialized."); + TestUtil.log(IStatus.INFO, name.getMethodName(), "Process terminates before Console is initialized."); processTerminationTest(null, true); } @@ -198,6 +197,7 @@ public class ProcessConsoleTests extends AbstractDebugTest { * Test console finished notification if process standard input is feed from * file. */ + @Test public void testProcessTerminationNotificationWithInputFile() throws Exception { File inFile = DebugUIPlugin.getDefault().getStateLocation().addTrailingSeparator().append("testStdin.txt").toFile(); boolean fileCreated = inFile.createNewFile(); @@ -206,9 +206,9 @@ public class ProcessConsoleTests extends AbstractDebugTest { ILaunchConfigurationType launchType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(LaunchConfigurationTests.ID_TEST_LAUNCH_TYPE); ILaunchConfigurationWorkingCopy launchConfiguration = launchType.newInstance(null, "testProcessTerminationNotificationWithInputFromFile"); launchConfiguration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, inFile.getAbsolutePath()); - TestUtil.log(IStatus.INFO, getName(), "Process terminates after Console is initialized."); + TestUtil.log(IStatus.INFO, name.getMethodName(), "Process terminates after Console is initialized."); processTerminationTest(launchConfiguration, false); - TestUtil.log(IStatus.INFO, getName(), "Process terminates before Console is initialized."); + TestUtil.log(IStatus.INFO, name.getMethodName(), "Process terminates before Console is initialized."); processTerminationTest(launchConfiguration, true); } finally { inFile.delete(); @@ -230,12 +230,9 @@ public class ProcessConsoleTests extends AbstractDebugTest { final IProcess process = DebugPlugin.newProcess(new Launch(launchConfig, ILaunchManager.RUN_MODE, null), mockProcess, "testProcessTerminationNotification"); @SuppressWarnings("restriction") final org.eclipse.debug.internal.ui.views.console.ProcessConsole console = new org.eclipse.debug.internal.ui.views.console.ProcessConsole(process, new ConsoleColorProvider()); - console.addPropertyChangeListener(new IPropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent event) { - if (event.getSource() == console && IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE.equals(event.getProperty())) { - terminationSignaled.set(true); - } + console.addPropertyChangeListener(event -> { + if (event.getSource() == console && IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE.equals(event.getProperty())) { + terminationSignaled.set(true); } }); final IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); @@ -244,11 +241,11 @@ public class ProcessConsoleTests extends AbstractDebugTest { if (mockProcess.isAlive()) { mockProcess.destroy(); } - TestUtil.waitForJobs(getName(), 50, 10000); + TestUtil.waitForJobs(name.getMethodName(), 50, 10000); assertTrue("No console complete notification received.", terminationSignaled.get()); } finally { consoleManager.removeConsoles(new IConsole[] { console }); - TestUtil.waitForJobs(getName(), 0, 10000); + TestUtil.waitForJobs(name.getMethodName(), 0, 10000); } } } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/RuntimeProcessTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/RuntimeProcessTests.java index c3d631b10..0134dc349 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/RuntimeProcessTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/RuntimeProcessTests.java @@ -13,38 +13,32 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.concurrent.atomic.AtomicInteger; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IDebugEventSetListener; import org.eclipse.debug.core.model.RuntimeProcess; import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.debug.tests.TestUtil; +import org.junit.Test; public class RuntimeProcessTests extends AbstractDebugTest { - public RuntimeProcessTests() { - super(RuntimeProcessTests.class.getSimpleName()); - } - - public RuntimeProcessTests(String name) { - super(name); - } - /** * Test behavior of {@link RuntimeProcess} if the wrapped process * terminates. */ + @Test public void testProcessTerminated() throws Exception { AtomicInteger processTerminateEvents = new AtomicInteger(); - DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() { - @Override - public void handleDebugEvents(DebugEvent[] events) { - for (DebugEvent event : events) { - if (event.getKind() == DebugEvent.TERMINATE) { - processTerminateEvents.incrementAndGet(); - } + DebugPlugin.getDefault().addDebugEventListener(events -> { + for (DebugEvent event : events) { + if (event.getKind() == DebugEvent.TERMINATE) { + processTerminateEvents.incrementAndGet(); } } }); @@ -59,21 +53,19 @@ public class RuntimeProcessTests extends AbstractDebugTest { mockProcess.destroy(); TestUtil.waitWhile(p -> !p.isTerminated(), runtimeProcess, 1000, p -> "RuntimePocess not terminated."); - TestUtil.waitForJobs(getName(), 25, 500); + TestUtil.waitForJobs(name.getMethodName(), 25, 500); assertEquals("Wrong number of terminate events.", 1, processTerminateEvents.get()); assertEquals("RuntimeProcess reported wrong exit code.", 1, runtimeProcess.getExitValue()); } /** Test {@link RuntimeProcess} terminating the wrapped process. */ + @Test public void testTerminateProcess() throws Exception { AtomicInteger processTerminateEvents = new AtomicInteger(); - DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() { - @Override - public void handleDebugEvents(DebugEvent[] events) { - for (DebugEvent event : events) { - if (event.getKind() == DebugEvent.TERMINATE) { - processTerminateEvents.incrementAndGet(); - } + DebugPlugin.getDefault().addDebugEventListener(events -> { + for (DebugEvent event : events) { + if (event.getKind() == DebugEvent.TERMINATE) { + processTerminateEvents.incrementAndGet(); } } }); @@ -89,7 +81,7 @@ public class RuntimeProcessTests extends AbstractDebugTest { assertFalse("RuntimeProcess failed to terminated wrapped process.", mockProcess.isAlive()); TestUtil.waitWhile(p -> !p.isTerminated(), runtimeProcess, 1000, p -> "RuntimePocess not terminated."); - TestUtil.waitForJobs(getName(), 25, 500); + TestUtil.waitForJobs(name.getMethodName(), 25, 500); assertEquals("Wrong number of terminate events.", 1, processTerminateEvents.get()); assertEquals("RuntimeProcess reported wrong exit code.", 1, runtimeProcess.getExitValue()); } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/StreamsProxyTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/StreamsProxyTests.java index 6f0b2af78..71569147a 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/StreamsProxyTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/StreamsProxyTests.java @@ -13,30 +13,26 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +import static org.junit.Assert.assertEquals; + import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.util.Collections; import org.eclipse.debug.internal.core.StreamsProxy; import org.eclipse.debug.tests.AbstractDebugTest; +import org.junit.Test; /** * Tests the {@link StreamsProxy}. */ public class StreamsProxyTests extends AbstractDebugTest { - public StreamsProxyTests() { - super(StreamsProxyTests.class.getSimpleName()); - } - - public StreamsProxyTests(String name) { - super(name); - } - /** * Test console receiving UTF-8 output from process where two-byte UTF-8 * characters start at even offsets. */ + @Test public void testReceiveUTF8Even() throws Exception { // 4500 characters results in 9000 byte of output which should be more // than most common buffer sizes. @@ -47,6 +43,7 @@ public class StreamsProxyTests extends AbstractDebugTest { * Test console receiving UTF-8 output from process where two-byte UTF-8 * characters start at odd offsets. */ + @Test public void testReceiveUTF8Odd() throws Exception { // 4500 characters results in 9000 byte of output which should be more // than most common buffer sizes. diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/TextConsoleViewerTest.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/TextConsoleViewerTest.java index ed260ba48..2f775f33a 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/TextConsoleViewerTest.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/TextConsoleViewerTest.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.debug.tests.console; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -23,6 +26,7 @@ import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.graphics.Color; import org.eclipse.ui.console.TextConsoleViewer; +import org.junit.Test; /** * Not really a test for {@link TextConsoleViewer} yet since it only test one @@ -30,18 +34,11 @@ import org.eclipse.ui.console.TextConsoleViewer; */ public class TextConsoleViewerTest extends AbstractDebugTest { - public TextConsoleViewerTest() { - super(TextConsoleViewerTest.class.getSimpleName()); - } - - public TextConsoleViewerTest(String name) { - super(name); - } - /** * Test override of existing styles with a new style. Typically used to * apply link styling on already styled console document. */ + @Test public void testStyleOverride() throws Throwable { Color colorR = null; Color colorG = null; diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/expressions/ExpressionManagerTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/expressions/ExpressionManagerTests.java index 24434287e..616325342 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/expressions/ExpressionManagerTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/expressions/ExpressionManagerTests.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.debug.tests.expressions; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -26,6 +29,8 @@ import org.eclipse.debug.core.model.IWatchExpression; import org.eclipse.debug.internal.core.ExpressionManager; import org.eclipse.debug.internal.core.IExpressionsListener2; import org.eclipse.debug.tests.AbstractDebugTest; +import org.junit.After; +import org.junit.Test; /** * Tests expression manager and listener call backs @@ -124,7 +129,8 @@ public class ExpressionManagerTests extends AbstractDebugTest { } @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { // remove all expressions from the manager getManager().removeExpressions(getManager().getExpressions()); super.tearDown(); @@ -149,6 +155,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { /** * Add expressions and ensure proper call backs are received. */ + @Test public void testAddExpressions() { IExpressionManager manager = getManager(); SinlgeListener single = new SinlgeListener(); @@ -184,6 +191,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { /** * Remove expressions and ensure proper call backs are received. */ + @Test public void testRemoveExpressions() { IExpressionManager manager = getManager(); SinlgeListener single = new SinlgeListener(); @@ -224,6 +232,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { /** * Change expressions and ensure proper call backs are received. */ + @Test public void testChangeExpressions() { IExpressionManager manager = getManager(); SinlgeListener single = new SinlgeListener(); @@ -265,6 +274,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { /** * Insert expressions and ensure proper call backs are received. */ + @Test public void testInsertBeforeExpressions() { ExpressionManager manager = (ExpressionManager) getManager(); SinlgeListener single = new SinlgeListener(); @@ -322,6 +332,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { /** * Insert expressions and ensure proper call backs are received. */ + @Test public void testInsertAfterExpressions() { ExpressionManager manager = (ExpressionManager) getManager(); SinlgeListener single = new SinlgeListener(); @@ -379,6 +390,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { /** * Move expressions and ensure proper call backs are received. */ + @Test public void testMoveBeforeExpressions() { ExpressionManager manager = (ExpressionManager) getManager(); SinlgeListener single = new SinlgeListener(); @@ -429,6 +441,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { /** * Move expressions and ensure proper call backs are received. */ + @Test public void testMoveAfterExpressions() { ExpressionManager manager = (ExpressionManager) getManager(); SinlgeListener single = new SinlgeListener(); @@ -479,6 +492,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { /** * Test persist and restore of expressions */ + @Test public void testPersistExpressions() { ExpressionManager manager = (ExpressionManager) getManager(); IWatchExpression exp1 = manager.newWatchExpression("exp1"); //$NON-NLS-1$ @@ -505,6 +519,7 @@ public class ExpressionManagerTests extends AbstractDebugTest { * * @throws InterruptedException */ + @Test public void testConcurrentAccess() throws InterruptedException { final boolean[] done = new boolean[]{false}; final Exception[] ex = new Exception[]{null}; diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java index c892767c5..5b11e558c 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java @@ -29,15 +29,6 @@ import org.eclipse.debug.tests.AbstractDebugTest; public abstract class AbstractLaunchTest extends AbstractDebugTest { /** - * Constructs a test with the given name. - * - * @param name - */ - public AbstractLaunchTest(String name) { - super(name); - } - - /** * Returns the launch manager. * * @return launch manager diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AcceleratorSubstitutionTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AcceleratorSubstitutionTests.java index 2df5a7ee9..04f1c9459 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AcceleratorSubstitutionTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AcceleratorSubstitutionTests.java @@ -13,8 +13,11 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +import static org.junit.Assert.assertEquals; + import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.tests.AbstractDebugTest; +import org.junit.Test; /** * Tests accelerator adjustments for DBCS languages. @@ -24,17 +27,11 @@ import org.eclipse.debug.tests.AbstractDebugTest; */ public class AcceleratorSubstitutionTests extends AbstractDebugTest { - /** - * Constructor - * @param name the name of the test - */ - public AcceleratorSubstitutionTests(String name) { - super(name); - } /** * tests a string with "..." */ + @Test public void testWithEllipses() { assertEquals("incorrect DBCS accelerator substitution", //$NON-NLS-1$ "Open Run Dialog(&R)...", //$NON-NLS-1$ @@ -44,6 +41,7 @@ public class AcceleratorSubstitutionTests extends AbstractDebugTest { /** * tests a string without "..." */ + @Test public void testWithoutEllipses() { assertEquals("incorrect DBCS accelerator substitution", //$NON-NLS-1$ "Open Run Dialog(&R)", //$NON-NLS-1$ @@ -53,6 +51,7 @@ public class AcceleratorSubstitutionTests extends AbstractDebugTest { /** * tests a string that should not change (no DBCS style accelerator). */ + @Test public void testWithoutDBCSAcclerator() { assertEquals("incorrect DBCS accelerator substitution", //$NON-NLS-1$ "Open &Run Dialog...", //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/ArgumentParsingTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/ArgumentParsingTests.java index e9cbbeccb..19e0c9f77 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/ArgumentParsingTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/ArgumentParsingTests.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +import static org.junit.Assert.assertEquals; + import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -30,6 +32,7 @@ import org.eclipse.core.runtime.URIUtil; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.osgi.service.environment.Constants; +import org.junit.Test; /** * Tests {@link org.eclipse.debug.core.DebugPlugin#parseArguments(String)} and @@ -164,19 +167,22 @@ public class ArgumentParsingTests extends AbstractDebugTest { } // -- tests: - + @Test public void testEmpty() throws Exception { execute("", new String[0]); //$NON-NLS-1$ } + @Test public void test1arg() throws Exception { execute("a", new String[] { "a" }); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void test2arg() throws Exception { execute("a b", new String[] { "a", "b" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + @Test public void test100arg() throws Exception { StringBuilder buf = new StringBuilder(); for (int i = 0; i < 100; i++) { @@ -188,6 +194,7 @@ public class ArgumentParsingTests extends AbstractDebugTest { execute(buf.toString(), args, buf.toString().trim()); } + @Test public void testEscape() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("\\1"); //$NON-NLS-1$ @@ -196,22 +203,27 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testEscapeDoubleQuote1() throws Exception { execute1Arg("\\\"", "\"", "\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + @Test public void testEscapeDoubleQuote2() throws Exception { execute1Arg("arg=\\\"bla\\\"", "arg=\"bla\"", "arg=\\\"bla\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + @Test public void testDoubleQuoted1() throws Exception { execute1Arg("\"1 2\"", "1 2"); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testDoubleQuoted2() throws Exception { execute1Arg("\"1\"", "1", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + @Test public void testDoubleQuoted3() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { // execute1Arg("\"\"", "", "\"\""); // would be correct, but ProcessImpl is buggy on Windows JDKs @@ -221,6 +233,7 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testDoubleQuoted4() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("\"\"\"\"", "\"", "\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -229,10 +242,12 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testDoubleQuoted5() throws Exception { execute1Arg("ab\"cd\"ef\"gh\"", "abcdefgh", "abcdefgh"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + @Test public void testDoubleQuotedWithSpace1() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("\"\"\"1\"\" 2\"", "\"1\" 2", "\"\\\"1\\\" 2\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -241,10 +256,12 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testDoubleQuotedWithSpace2() throws Exception { execute1Arg("\"\\\"1\\\" 2\"", "\"1\" 2"); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testSingleQuoted1() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("'1 2'", new String[] { "'1", "2'" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -253,6 +270,7 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testSingleQuoted2() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute1Arg("'1'", "'1'", "'1'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -261,10 +279,12 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testWindows1() throws Exception { execute("\"a b c\" d e", new String[] { "a b c", "d", "e" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } + @Test public void testWindows2() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("\"ab\\\"c\" \"\\\\\" d", new String[] { "ab\"c", "\\", "d" }, "ab\\\"c \\ d"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ @@ -273,6 +293,7 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testWindows3() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("a\\\\\\b d\"e f\"g h", new String[] { "a\\\\\\b", "de fg", "h" }, "a\\\\\\b \"de fg\" h"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ @@ -281,10 +302,12 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testWindows4() throws Exception { execute("a\\\\\\\"b c d", new String[] { "a\\\"b", "c", "d" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } + @Test public void testWindows5() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("a\\\\\\\\\"b c\" d e", new String[] { "a\\\\b c", "d", "e" }, "\"a\\\\b c\" d e"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ @@ -293,6 +316,7 @@ public class ArgumentParsingTests extends AbstractDebugTest { } } + @Test public void testAllInOne() throws Exception { if (Platform.getOS().equals(Constants.OS_WIN32)) { execute("1 \"\" 2 \" \" 3 \\\" 4 \"a b\" 5 \\\"bla\\\" 6 \"ab\"cd 7 ef\"gh\" 8 i\"\"j 9 \"x\\\"y\\\\\" 10 z\\\\z 11 \"two-quotes:\"\"\"\"\" 12 \"g\"\"h\" 13 \"\"\"a\"\" b\"", //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java index 837e0ef94..5447884d9 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java @@ -14,6 +14,13 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +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.io.File; import java.io.FileFilter; import java.io.IOException; @@ -66,6 +73,7 @@ import org.eclipse.debug.ui.DebugUITools; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import org.junit.Test; import org.osgi.framework.Bundle; /** @@ -207,14 +215,6 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Constructor - * @param name - */ - public LaunchConfigurationTests(String name) { - super(name); - } - - /** * Returns a scratch project for launch configurations * * @return @@ -301,11 +301,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a local working copy configuration, sets some attributes, - * and saves the working copy, and retrieves the attributes. + * Creates a local working copy configuration, sets some attributes, and + * saves the working copy, and retrieves the attributes. * * @throws CoreException */ + @Test public void testCreateLocalConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$ IPath location = wc.getLocation(); @@ -333,6 +334,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testLocalName() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "localName"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); @@ -349,6 +351,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Creates a shared working copy configuration and tests is name. */ + @Test public void testSharedName() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "sharedName"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); @@ -364,8 +367,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Ensures that a launch configuration returns a complete attribute map + * * @throws CoreException */ + @Test public void testGetAttributes() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$ IPath location = wc.getLocation(); @@ -387,8 +392,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Ensures that set attributes works + * * @throws CoreException */ + @Test public void testSetAttributes() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$ Map<String, Object> map = new HashMap<>(); @@ -413,8 +420,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Ensures that set attributes to <code>null</code> works + * * @throws CoreException */ + @Test public void testSetNullAttributes() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$ wc.setAttributes(null); @@ -431,11 +440,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a local working copy configuration, sets some attributes, - * and saves the working copy, and retrieves the attributes. - * Copy the configuration and ensure the original still exists. + * Creates a local working copy configuration, sets some attributes, and + * saves the working copy, and retrieves the attributes. Copy the + * configuration and ensure the original still exists. + * * @throws CoreException */ + @Test public void testLocalCopy() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "configToCopy"); //$NON-NLS-1$ IPath location = wc.getLocation(); @@ -473,10 +484,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Create a config and save it twice, ensuring it only - * ends up in the index once. + * Create a config and save it twice, ensuring it only ends up in the index + * once. + * * @throws CoreException */ + @Test public void testDoubleSave() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "configDoubleSave"); //$NON-NLS-1$ IPath location = wc.getLocation(); @@ -510,11 +523,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a local working copy configuration, sets some attributes, - * and saves the working copy, and retrieves the attributes. Deletes - * the configuration and ensures it no longer exists. + * Creates a local working copy configuration, sets some attributes, and + * saves the working copy, and retrieves the attributes. Deletes the + * configuration and ensures it no longer exists. + * * @throws CoreException */ + @Test public void testDeleteLocalConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2delete"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); @@ -537,12 +552,14 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a local working copy configuration, sets some attributes, - * and saves the working copy, and retrieves the attributes. Renames - * the configuration and ensures it's old config no longer exists, - * and that attributes are retrievable from the new (renamed) config. + * Creates a local working copy configuration, sets some attributes, and + * saves the working copy, and retrieves the attributes. Renames the + * configuration and ensures it's old config no longer exists, and that + * attributes are retrievable from the new (renamed) config. + * * @throws CoreException */ + @Test public void testRenameLocalConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2rename"); //$NON-NLS-1$ IPath location = wc.getLocation(); @@ -584,8 +601,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Moves a local configuration to a shared location + * * @throws CoreException */ + @Test public void testMoveLocalToSharedConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2share"); //$NON-NLS-1$ IPath location = wc.getLocation(); @@ -627,8 +646,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Moves a local configuration to a shared location + * * @throws CoreException */ + @Test public void testMoveSharedToLocalConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2local"); //$NON-NLS-1$ IPath location = wc.getLocation(); @@ -669,10 +690,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a shared working copy configuration, sets some attributes, - * and saves the working copy, and retrieves the attributes. + * Creates a shared working copy configuration, sets some attributes, and + * saves the working copy, and retrieves the attributes. + * * @throws CoreException */ + @Test public void testCreateSharedConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); @@ -694,11 +717,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a shared working copy configuration, sets some attributes, - * and saves the working copy, and retrieves the attributes. - * Copies the configuration and ensures the original still exists. + * Creates a shared working copy configuration, sets some attributes, and + * saves the working copy, and retrieves the attributes. Copies the + * configuration and ensures the original still exists. + * * @throws CoreException */ + @Test public void testSharedCopy() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2Copy"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); @@ -735,11 +760,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** - * Creates a shared working copy configuration, sets some attributes, - * and saves the working copy, and retrieves the attributes. Deletes - * the configuration and ensures it no longer exists. + * Creates a shared working copy configuration, sets some attributes, and + * saves the working copy, and retrieves the attributes. Deletes the + * configuration and ensures it no longer exists. + * * @throws CoreException */ + @Test public void testDeleteSharedConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2delete"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); @@ -761,12 +788,14 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a shared working copy configuration, sets some attributes, - * and saves the working copy, and retrieves the attributes. Renames - * the configuration and ensures it's old config no longer exists, - * and that attributes are retrievable from the new (renamed) config. + * Creates a shared working copy configuration, sets some attributes, and + * saves the working copy, and retrieves the attributes. Renames the + * configuration and ensures it's old config no longer exists, and that + * attributes are retrievable from the new (renamed) config. + * * @throws CoreException */ + @Test public void testRenameSharedConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2rename"); //$NON-NLS-1$ ILaunchConfiguration handle = wc.doSave(); @@ -813,10 +842,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a few configs, closes the project and re-opens the - * project to ensure the config index is persisted properly + * Creates a few configs, closes the project and re-opens the project to + * ensure the config index is persisted properly + * * @throws CoreException */ + @Test public void testPersistIndex() throws CoreException { // close all editors before closing project: @see bug 204023 closeAllEditors(); @@ -896,11 +927,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Ensures that a removal notification is sent for a shared config in a project - * that is deleted. + * Ensures that a removal notification is sent for a shared config in a + * project that is deleted. * * @throws Exception */ + @Test public void testDeleteProjectWithSharedConfig() throws Exception { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("DeleteSharedConfig"); //$NON-NLS-1$ try { @@ -936,6 +968,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testNestedWorkingCopyLocalConfiguration() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config123"); //$NON-NLS-1$ IPath location = wc.getLocation(); @@ -987,11 +1020,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a configuration in an EFS linked folder. Deletes configuration directly. + * Creates a configuration in an EFS linked folder. Deletes configuration + * directly. * * @throws CoreException * @throws URISyntaxException */ + @Test public void testCreateDeleteEFS() throws CoreException, URISyntaxException { IFileSystem fileSystem = EFS.getFileSystem("debug"); //$NON-NLS-1$ assertNotNull("Missing debug EFS", fileSystem); //$NON-NLS-1$ @@ -1020,12 +1055,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Creates a configuration in an EFS linked folder. Deletes the folder to ensure the - * configuration is also deleted. + * Creates a configuration in an EFS linked folder. Deletes the folder to + * ensure the configuration is also deleted. * * @throws CoreException * @throws URISyntaxException */ + @Test public void testCreateDeleteEFSLink() throws CoreException, URISyntaxException { IFileSystem fileSystem = EFS.getFileSystem("debug"); //$NON-NLS-1$ assertNotNull("Missing debug EFS", fileSystem); //$NON-NLS-1$ @@ -1056,6 +1092,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws Exception */ + @Test public void testEFSProjectRename() throws Exception { // create test project IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject("RenameEFS"); //$NON-NLS-1$ @@ -1119,6 +1156,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws Exception */ + @Test public void testImport() throws Exception { // create a shared configuration "Import4" in the workspace to be overwritten on import ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "Import4"); //$NON-NLS-1$ @@ -1134,14 +1172,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau getLaunchManager().addLaunchConfigurationListener(listener); // import manager.importConfigurations(dir.listFiles( - new FileFilter() { - @Override - public boolean accept(File file) { - return file.isFile() && - file.getName().endsWith( - ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION); - } - }), + (FileFilter) file -> file.isFile() && file.getName().endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION)), null); // should be one removed @@ -1179,6 +1210,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testWorkingCopyGetLocation() throws CoreException { ILaunchConfigurationWorkingCopy workingCopy = newConfiguration(null, "test-get-location"); //$NON-NLS-1$ IPath location = workingCopy.getLocation(); @@ -1188,6 +1220,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Tests that the framework adds launch time stamps to launch objects. */ + @Test public void testLaunchTimeStamp() throws CoreException { ILaunchConfigurationWorkingCopy workingCopy = newConfiguration(null, "test-time-stamp"); //$NON-NLS-1$ ILaunch launch = workingCopy.launch(ILaunchManager.DEBUG_MODE, null); @@ -1207,6 +1240,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * Tests that the framework adds terminate time stamps to launch and process * objects. */ + @Test public void testTerminateTimeStamp() throws Exception { ILaunchConfigurationWorkingCopy workingCopy = newConfiguration(null, "test-time-stamp"); //$NON-NLS-1$ ILaunch launch = workingCopy.launch(ILaunchManager.DEBUG_MODE, null); @@ -1254,10 +1288,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Tests that attributes in a nested map are persisted in alphabetical order. + * Tests that attributes in a nested map are persisted in alphabetical + * order. * * @throws CoreException */ + @Test public void testMapAttributePersistence() throws CoreException, IOException { ILaunchConfigurationWorkingCopy c1 = newEmptyConfiguration(getProject(), "testMapAttributes1"); //$NON-NLS-1$ HashMap<String, String> map = new HashMap<>(); @@ -1335,10 +1371,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Tests that attributes in a nested set are persisted in alphabetical order. + * Tests that attributes in a nested set are persisted in alphabetical + * order. * * @throws CoreException */ + @Test public void testSetAttributePersistence() throws CoreException, IOException { ILaunchConfigurationWorkingCopy c1 = newEmptyConfiguration(getProject(), "testSetAttributes1"); //$NON-NLS-1$ Set<String> set = new HashSet<>(); @@ -1416,11 +1454,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Ensures that client does not attempt to nest configurations in a sub directory when - * using local metadata location. See bug 275741. + * Ensures that client does not attempt to nest configurations in a sub + * directory when using local metadata location. See bug 275741. * * @throws CoreException */ + @Test public void testIllegalFileSepCharName() { try { newConfiguration(null, new Path("some").append("nested").append("config").toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -1432,12 +1471,13 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Ensures that client can nest configurations in a sub directory when - * using a workspace location. See bug 275741. For behavior compatibility - * a client should be able to use a slash in the configuration name. + * Ensures that client can nest configurations in a sub directory when using + * a workspace location. See bug 275741. For behavior compatibility a client + * should be able to use a slash in the configuration name. * * @throws CoreException */ + @Test public void testLegalFileSepCharName() { try { newConfiguration(getProject(), new Path("some").append("nested").append("config").toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -1451,6 +1491,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testIllegalCharName() { try { newConfiguration(getProject(), "<config>"); //$NON-NLS-1$ @@ -1462,10 +1503,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Test that moving and renaming a shared configuration at the same time works. + * Test that moving and renaming a shared configuration at the same time + * works. * * @throws CoreException */ + @Test public void testRenameAndMoveShared() throws CoreException { IProject project = getProject(); IFolder f1 = project.getFolder("f1"); //$NON-NLS-1$ @@ -1486,11 +1529,15 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Test support for a URL in the 'icon' part of the launchConfigurationTypeImages extension point + * Test support for a URL in the 'icon' part of the + * launchConfigurationTypeImages extension point + * + * Bug 381175 - [patch] launchConfigurationTypeImage to support platform: + * style icons * - * Bug 381175 - [patch] launchConfigurationTypeImage to support platform: style icons * @throws Exception */ + @Test public void testGetTypeImageFromURI() throws Exception { ImageDescriptor descriptor = DebugUITools.getImageDescriptor("org.eclipse.debug.tests.launch.type1"); //$NON-NLS-1$ assertNotNull("The image descriptior type.image.1 must exist", descriptor); //$NON-NLS-1$ @@ -1499,8 +1546,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau /** * Test support for a declared launch configuration type image + * * @throws Exception */ + @Test public void testGetTyeImage() throws Exception { ImageDescriptor descriptor = DebugUITools.getImageDescriptor("org.eclipse.debug.tests.launch.type"); //$NON-NLS-1$ assertNotNull("The image descriptior type.image.2 must exist", descriptor); //$NON-NLS-1$ @@ -1514,6 +1563,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * @throws Exception * @since 3.9.0 */ + @Test public void testGetProjectMappedResource1() throws Exception { ILaunchConfiguration lc = newConfiguration(null, "test.project.resource.mapping"); //$NON-NLS-1$ try { @@ -1536,6 +1586,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * @throws Exception * @since 3.9.0 */ + @Test public void testGetProjectMappedResource2() throws Exception { ILaunchConfiguration lc = newConfiguration(null, "test.project.resource.mapping"); //$NON-NLS-1$ try { @@ -1557,6 +1608,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * @throws Exception * @since 3.9.0 */ + @Test public void testGetProjectMappedResource3() throws Exception { ILaunchConfiguration lc = newConfiguration(null, "test.project.resource.mapping"); //$NON-NLS-1$ try { @@ -1583,6 +1635,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * @throws Exception * @since 3.9.0 */ + @Test public void testGetProjectMappedResource4() throws Exception { ILaunchConfiguration lc = newConfiguration(null, "test.project.resource.mapping"); //$NON-NLS-1$ try { @@ -1605,6 +1658,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * @throws Exception * @since 3.9.0 */ + @Test public void testNullLaunchConfigurationInLaunch() throws Exception { Launch l = new Launch(null, ILaunchManager.RUN_MODE, null); LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager(); @@ -1645,6 +1699,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testCopyAttributes() throws CoreException { ILaunchConfigurationWorkingCopy source = newPrototype(null, "test-copy-attributes-source"); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy dest = newEmptyConfiguration(null, "test-copy-attributes-dest"); //$NON-NLS-1$ @@ -1660,6 +1715,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testCreationFromPrototype() throws CoreException { ILaunchConfigurationWorkingCopy temp = newPrototype(null, "test-creation-from-prototype"); //$NON-NLS-1$ temp.setAttribute("TEMPLATE", "TEMPLATE"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1677,6 +1733,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testIsPrototype() throws CoreException { ILaunchConfigurationWorkingCopy wc = newPrototype(null, "test-is-prototype"); //$NON-NLS-1$ ILaunchConfiguration prototype = wc.doSave(); @@ -1693,6 +1750,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testPrototypeChildren() throws CoreException { ILaunchConfigurationWorkingCopy wc = newPrototype(null, "test-references"); //$NON-NLS-1$ ILaunchConfiguration prototype = wc.doSave(); @@ -1722,6 +1780,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testPrototypeRemoveBehavior() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "test-remove"); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy t1 = newEmptyPrototype(null, "prototype-1"); //$NON-NLS-1$ @@ -1741,11 +1800,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau } /** - * Tests that setting a configuration's prototype to null cleans its prototype - * association. + * Tests that setting a configuration's prototype to null cleans its + * prototype association. * * @throws CoreException */ + @Test public void testUnPrototype() throws CoreException { ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "test-un-prototype"); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy t1 = newEmptyPrototype(null, "prototype-un"); //$NON-NLS-1$ @@ -1769,6 +1829,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testNestedPrototypes() throws CoreException { ILaunchConfigurationWorkingCopy t1 = newPrototype(null, "test-nest-root"); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy t2 = newPrototype(null, "prototype-nested"); //$NON-NLS-1$ @@ -1786,6 +1847,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testIllegalPrototype() throws CoreException { ILaunchConfigurationWorkingCopy c1 = newConfiguration(null, "test-config"); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy t1 = newConfiguration(null, "test-not-a-prototype"); //$NON-NLS-1$ @@ -1804,6 +1866,7 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau * * @throws CoreException */ + @Test public void testCopyPrototype() throws CoreException { ILaunchConfigurationWorkingCopy t1 = newEmptyPrototype(null, "prototype-to-duplicate"); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy t2 = t1.copy("duplicate-prototype"); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java index aec5de711..328a94734 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +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.ArrayList; import java.util.List; @@ -21,6 +26,9 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory; import org.eclipse.debug.ui.IDebugUIConstants; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * Test the launch history favorites get updated properly as configurations as @@ -37,15 +45,8 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { private ILaunchConfiguration fConfig; /** - * Constructor - * @param name - */ - public LaunchFavoriteTests(String name) { - super(name); - } - - /** * Returns the run launch history + * * @return */ private LaunchHistory getRunLaunchHistory() { @@ -61,16 +62,18 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { } @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); // clear the favorites getRunLaunchHistory().setFavorites(new ILaunchConfiguration[0]); getDebugLaunchHistory().setFavorites(new ILaunchConfiguration[0]); - fConfig = getLaunchConfiguration(getName()); + fConfig = getLaunchConfiguration(name.getMethodName()); } @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { // delete the configuration used during this test ILaunchConfiguration configuration = getLaunchConfiguration(); if (configuration.exists()) { @@ -170,6 +173,7 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { * * @throws CoreException */ + @Test public void testBecomeFavorite() throws CoreException { ILaunchConfigurationWorkingCopy wc = addFavorite(getLaunchConfiguration(), IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP); addFavorite(wc, IDebugUIConstants.ID_RUN_LAUNCH_GROUP); @@ -179,10 +183,12 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { } /** - * Tests that a when a favorite is no longer a favorite, it gets removed from the favorites. + * Tests that a when a favorite is no longer a favorite, it gets removed + * from the favorites. * * @throws CoreException */ + @Test public void testUnFavorite() throws CoreException { testBecomeFavorite(); // create favorite in two histories ILaunchConfigurationWorkingCopy wc = removeFavorite(getLaunchConfiguration(), IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP); @@ -197,6 +203,7 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { * * @throws CoreException */ + @Test public void testDeleteConfiguration() throws CoreException { testBecomeFavorite(); // create a favorite in two histories ILaunchConfiguration configuration = getLaunchConfiguration(); @@ -206,10 +213,12 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { } /** - * When a favorite is renamed, it should still be in the list, with the new name. + * When a favorite is renamed, it should still be in the list, with the new + * name. * * @throws CoreException */ + @Test public void testRenameFavorite() throws CoreException { testBecomeFavorite(); ILaunchConfiguration original = getLaunchConfiguration(); @@ -222,10 +231,12 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { } /** - * Renaming a configuration and making it a favorite at the same time - should appear in the list. + * Renaming a configuration and making it a favorite at the same time - + * should appear in the list. * * @throws CoreException */ + @Test public void testRenameBecomeFavorite() throws CoreException { ILaunchConfiguration original = getLaunchConfiguration(); ILaunchConfigurationWorkingCopy copy = original.getWorkingCopy(); @@ -239,10 +250,12 @@ public class LaunchFavoriteTests extends AbstractLaunchTest { } /** - * Renaming a configuration and removing its favorite status should remove it from the list. + * Renaming a configuration and removing its favorite status should remove + * it from the list. * * @throws CoreException */ + @Test public void testRenameUnFavorite() throws CoreException { testBecomeFavorite(); ILaunchConfiguration original = getLaunchConfiguration(); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java index 0b64fda8b..74ed4a95f 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -48,6 +51,9 @@ import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory; import org.eclipse.debug.tests.TestUtil; import org.eclipse.debug.ui.IDebugUIConstants; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; public class LaunchGroupTests extends AbstractLaunchTest { @@ -73,12 +79,9 @@ public class LaunchGroupTests extends AbstractLaunchTest { } }; - public LaunchGroupTests() { - super("Launch Groups Test"); //$NON-NLS-1$ - } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); // reset count @@ -86,7 +89,8 @@ public class LaunchGroupTests extends AbstractLaunchTest { } @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { // make sure listener is removed getLaunchManager().removeLaunchListener(lcListener); ILaunch[] launches = getLaunchManager().getLaunches(); @@ -100,7 +104,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { launch.terminate(); } } catch (Exception e) { - TestUtil.log(IStatus.ERROR, getName(), "Error terminating launch: " + launch, e); + TestUtil.log(IStatus.ERROR, name.getMethodName(), "Error terminating launch: " + launch, e); } } super.tearDown(); @@ -137,6 +141,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { return h; } + @Test public void testNone() throws Exception { ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$ ILaunchConfiguration t2 = getLaunchConfiguration("Test2"); //$NON-NLS-1$ @@ -153,6 +158,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { assertTrue("history[2] should be Test1", history[2].contentsEqual(t1)); //$NON-NLS-1$ } + @Test public void testDelay() throws Exception { ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$ ILaunchConfiguration t2 = getLaunchConfiguration("Test2"); //$NON-NLS-1$ @@ -172,6 +178,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { assertTrue("history[2] should be Test1", history[2].contentsEqual(t1)); //$NON-NLS-1$ } + @Test public void testTerminated() throws Exception { final ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$ final ILaunchConfiguration t2 = getLaunchConfiguration("Test2"); //$NON-NLS-1$ @@ -217,6 +224,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { assertTrue("history[2] should be Test1", history[2].contentsEqual(t1)); //$NON-NLS-1$ } + @Test public void testAdopt() throws Exception { final ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$ final ILaunchConfiguration grp = createLaunchGroup(DEF_GRP_NAME, createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, false), createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, true)); @@ -235,6 +243,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { assertEquals("Test1 should be launched only once", 1, launchCount.get()); //$NON-NLS-1$ } + @Test public void testAdoptComplex() throws Exception { final ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$ @@ -265,6 +274,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { assertEquals("Test1 should be launched only once", 1, launchCount.get()); //$NON-NLS-1$ } + @Test public void testWaitForOutput() throws Exception { String testOutput = "TestOutput"; //$NON-NLS-1$ @@ -318,6 +328,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { assertTrue("history[2] should be Test1", history[2].contentsEqual(t1)); //$NON-NLS-1$ } + @Test public void testRename() throws Exception { ILaunchConfiguration t1 = getLaunchConfiguration("Test1"); //$NON-NLS-1$ ILaunchConfiguration t2 = getLaunchConfiguration("Test2"); //$NON-NLS-1$ @@ -337,8 +348,10 @@ public class LaunchGroupTests extends AbstractLaunchTest { } /** - * Test for Bug 529651. Build before launch was not invoked for launches started as part of group launch. + * Test for Bug 529651. Build before launch was not invoked for launches + * started as part of group launch. */ + @Test public void testBuildBeforeLaunch() throws CoreException { final AtomicInteger launched = new AtomicInteger(0); final AtomicInteger buildRequested = new AtomicInteger(0); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java index 1393539ba..7e3321e84 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.debug.core.ILaunchConfiguration; @@ -21,6 +25,7 @@ import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory; import org.eclipse.debug.ui.IDebugUIConstants; +import org.junit.Test; /** * Test the utilization of launch histories: sizing, ordering, completeness and correctness @@ -35,14 +40,6 @@ import org.eclipse.debug.ui.IDebugUIConstants; public class LaunchHistoryTests extends AbstractLaunchTest { /** - * Constructor - * @param name - */ - public LaunchHistoryTests(String name) { - super(name); - } - - /** * Returns the run launch history * @return */ @@ -75,9 +72,10 @@ public class LaunchHistoryTests extends AbstractLaunchTest { } /** - * This method tests that an item added to the history is added to the head of - * history. + * This method tests that an item added to the history is added to the head + * of history. */ + @Test public void testHistoryAddition() throws CoreException { LaunchHistory runhistory = getRunLaunchHistory(); assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$ @@ -89,10 +87,11 @@ public class LaunchHistoryTests extends AbstractLaunchTest { } /** - * As both the run and the debug launch histories will accept a java application - * launch config, both launch histories should contain the test launch configuration - * and it should be the recent launch for both of them + * As both the run and the debug launch histories will accept a java + * application launch config, both launch histories should contain the test + * launch configuration and it should be the recent launch for both of them */ + @Test public void testHistoriesInSync() throws CoreException { LaunchHistory runhistory = getRunLaunchHistory(); assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$ @@ -108,8 +107,10 @@ public class LaunchHistoryTests extends AbstractLaunchTest { } /** - * If we launch config A, then config B, and then config A again, A should be the most recent launch + * If we launch config A, then config B, and then config A again, A should + * be the most recent launch */ + @Test public void testHistoryReodering() throws CoreException { LaunchHistory runhistory = getRunLaunchHistory(); assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$ @@ -131,9 +132,10 @@ public class LaunchHistoryTests extends AbstractLaunchTest { } /** - * If we rename a launch configuration it should not effect the launch history if the renamed configuration - * is present in the history. + * If we rename a launch configuration it should not effect the launch + * history if the renamed configuration is present in the history. */ + @Test public void testRenameConfigHistoryUpdate() throws CoreException { LaunchHistory runhistory = getRunLaunchHistory(); assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$ @@ -154,9 +156,11 @@ public class LaunchHistoryTests extends AbstractLaunchTest { } /** - * If we delete a launch configuration and the configuration is present in the launch history, it should be removed - * from the history and the history should be shifted up one place. + * If we delete a launch configuration and the configuration is present in + * the launch history, it should be removed from the history and the history + * should be shifted up one place. */ + @Test public void testDeleteLaunchConfigurationHistoryUpdate() throws CoreException { LaunchHistory runhistory = getRunLaunchHistory(); assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$ @@ -176,9 +180,10 @@ public class LaunchHistoryTests extends AbstractLaunchTest { } /** - * Tests that setting the size of the launch history appropriately changes what will be returned - * when the history is queried for it contents + * Tests that setting the size of the launch history appropriately changes + * what will be returned when the history is queried for it contents */ + @Test public void testLaunchHistorySize() throws CoreException { LaunchHistory runhistory = getRunLaunchHistory(); assertNotNull("The run launch history should not be null", runhistory); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java index 6a5a7d6bd..3f6160db8 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +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 org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; @@ -23,6 +29,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.internal.core.LaunchManager; import org.eclipse.debug.tests.launching.CancellingLaunchDelegate.CancellingLaunch; +import org.junit.Test; /** * @@ -33,17 +40,11 @@ import org.eclipse.debug.tests.launching.CancellingLaunchDelegate.CancellingLaun @SuppressWarnings("deprecation") public class LaunchManagerTests extends AbstractLaunchTest { - /** - * Constructor - * @param name - */ - public LaunchManagerTests(String name) { - super(name); - } /** * Tests generating a valid launch configuration name */ + @Test public void testGenereateConfigName() { String configname = "launch_configuration"; //$NON-NLS-1$ String name = getLaunchManager().generateLaunchConfigurationName(configname); @@ -51,9 +52,10 @@ public class LaunchManagerTests extends AbstractLaunchTest { } /** - * Tests generating a launch configuration name with an unsupported char using - * the deprecated method + * Tests generating a launch configuration name with an unsupported char + * using the deprecated method */ + @Test public void testGenereateConfigNameBadChar() { String configname = "config:name"; //$NON-NLS-1$ String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname); @@ -63,6 +65,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { /** * Tests that a valid name is accepted as is. */ + @Test public void testGenerateValidName() { String configname = "thisisavalidname"; //$NON-NLS-1$ String name = getLaunchManager().generateLaunchConfigurationName(configname); @@ -70,9 +73,10 @@ public class LaunchManagerTests extends AbstractLaunchTest { } /** - * Tests generating a launch configuration name using a name that is an OS reserved - * name. Win 32 test only. + * Tests generating a launch configuration name using a name that is an OS + * reserved name. Win 32 test only. */ + @Test public void testGenerateConfigNameReservedName() { if(Platform.OS_WIN32.equals(Platform.getOS())) { String configname = "aux"; //$NON-NLS-1$ @@ -84,6 +88,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { /** * Tests generating a configuration name that contains an invalid character */ + @Test public void testGenerateBadConfigName() { String configname = "config:name"; //$NON-NLS-1$ String name = getLaunchManager().generateLaunchConfigurationName(configname); @@ -91,9 +96,10 @@ public class LaunchManagerTests extends AbstractLaunchTest { } /** - * Tests generating a name that conflicts with an OS reserved name. This test is for windows only as there - * are no reserved names on other OS's. + * Tests generating a name that conflicts with an OS reserved name. This + * test is for windows only as there are no reserved names on other OS's. */ + @Test public void testGenerateConflictingName() { if(Platform.OS_WIN32.equals(Platform.getOS())) { String configname = "aux"; //$NON-NLS-1$ @@ -103,9 +109,10 @@ public class LaunchManagerTests extends AbstractLaunchTest { } /** - * Tests generating a configuration name that contains an invalid character and where there - * is another config with the replaced name already + * Tests generating a configuration name that contains an invalid character + * and where there is another config with the replaced name already */ + @Test public void testGenerateBadCharConflict() throws Exception { String configname = "config:name"; //$NON-NLS-1$ String name = getLaunchManager().generateLaunchConfigurationName(configname); @@ -119,9 +126,10 @@ public class LaunchManagerTests extends AbstractLaunchTest { /** * Tests generating a name that conflicts with an OS reserved name and that - * there is a config with the replaced name already. This test is for windows only as there - * are no reserved names on other OS's. + * there is a config with the replaced name already. This test is for + * windows only as there are no reserved names on other OS's. */ + @Test public void testGenerateBadNameConflict() throws Exception { if(Platform.OS_WIN32.equals(Platform.getOS())) { String configname = "com2"; //$NON-NLS-1$ @@ -136,8 +144,11 @@ public class LaunchManagerTests extends AbstractLaunchTest { } /** - * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness + * Tests the + * {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} + * method for correctness */ + @Test public void testValidateConfigGoodName() { String configname = "configname"; //$NON-NLS-1$ try { @@ -149,8 +160,11 @@ public class LaunchManagerTests extends AbstractLaunchTest { } /** - * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness + * Tests the + * {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} + * method for correctness */ + @Test public void testValidateConfigBadCharName() { String configname = "config:name"; //$NON-NLS-1$ try { @@ -163,8 +177,11 @@ public class LaunchManagerTests extends AbstractLaunchTest { } /** - * Tests the {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} method for correctness + * Tests the + * {@link org.eclipse.debug.core.ILaunchManager#isValidLaunchConfigurationName(String)} + * method for correctness */ + @Test public void testValidateConfigBadName() { if(Platform.OS_WIN32.equals(Platform.getOS())) { String configname = "com1"; //$NON-NLS-1$ @@ -179,9 +196,11 @@ public class LaunchManagerTests extends AbstractLaunchTest { } /** - * Tests that generating a configuration name when there exists a configuration with that name - * already properly updates a '(N)' counter at the end + * Tests that generating a configuration name when there exists a + * configuration with that name already properly updates a '(N)' counter at + * the end */ + @Test public void testGenerateNameExistingConfig() throws Exception { String configname = "x.y.z.configname"; //$NON-NLS-1$ getLaunchConfiguration(configname); @@ -203,6 +222,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { /** * Tests that removing an accelerator properly removes it without affecting the base string (readable) value */ + @Test public void testRemoveAcc() { String text = "&Remove"; //$NON-NLS-1$ String label = LaunchManager.removeAccelerators(text); @@ -259,6 +279,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=437122 * @since 3.9.100 */ + @Test public void testCancelledPreLaunchCheck() throws Exception { ILaunchConfiguration config = getCancellingConfiguration(true, false, false); assertNotNull("The cancelling config should have been created", config); //$NON-NLS-1$ @@ -283,6 +304,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=437122 * @since 3.9.100 */ + @Test public void testCancelledFinalLaunchCheck() throws Exception { ILaunchConfiguration config = getCancellingConfiguration(false, true, false); assertNotNull("The cancelling config should have been created", config); //$NON-NLS-1$ @@ -307,6 +329,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=437122 * @since 3.9.100 */ + @Test public void testCancelledBuildForLaunch() throws Exception { ILaunchConfiguration config = getCancellingConfiguration(false, false, true); assertNotNull("The cancelling config should have been created", config); //$NON-NLS-1$ @@ -333,6 +356,7 @@ public class LaunchManagerTests extends AbstractLaunchTest { * the NPE in the unpatched code, increase the size of config. However, * increasing the number increases the runtime of the test substantially. */ + @Test public void testNPE_Bug484882() throws Exception { // In this thread continuously creates configs so that // org.eclipse.debug.internal.core.LaunchManager.clearConfigNameCache() diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java index dde7976cc..415344383 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; import java.util.ConcurrentModificationException; @@ -28,6 +31,8 @@ import org.eclipse.debug.core.Launch; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IDisconnect; import org.eclipse.debug.core.model.IProcess; +import org.junit.Before; +import org.junit.Test; /** * Tests for the {@link Launch} class @@ -42,16 +47,9 @@ public class LaunchTests extends AbstractLaunchTest { private Runnable writeProcessesTask; private Runnable writeDebugTargetsTask; - /** - * Constructor - * @param name - */ - public LaunchTests(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); final Launch launch = new Launch(null, ILaunchManager.RUN_MODE, null); @@ -94,19 +92,16 @@ public class LaunchTests extends AbstractLaunchTest { }; } - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - /** * Modifies debug targets and checks if this causes * {@link ConcurrentModificationException} in the another thread */ + @Test public void testTerminatedAndWriteTargets() throws Exception { assertTrue(testExecution(readIsTerminatedTask, writeDebugTargetsTask)); } + @Test public void testDisconnectedAndWriteTargets() throws Exception { assertTrue(testExecution(readIsDisconnectedTask, writeDebugTargetsTask)); } @@ -115,6 +110,7 @@ public class LaunchTests extends AbstractLaunchTest { * Modifies processes and checks if this causes * {@link ConcurrentModificationException} in the another thread */ + @Test public void testTerminatedAndWriteProcesses() throws Exception { assertTrue(testExecution(readIsTerminatedTask, writeProcessesTask)); } @@ -123,6 +119,7 @@ public class LaunchTests extends AbstractLaunchTest { * Modifies processes and checks if this causes * {@link ConcurrentModificationException} in the another thread */ + @Test public void testDisconnectedAndWriteProcesses() throws Exception { assertTrue(testExecution(readIsDisconnectedTask, writeProcessesTask)); } @@ -175,7 +172,7 @@ public class LaunchTests extends AbstractLaunchTest { } } } finally { - System.out.println(getName() + " runs: " + runs); //$NON-NLS-1$ + System.out.println(name.getMethodName() + " runs: " + runs); //$NON-NLS-1$ job.cancel(); } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java index 05fd4b2d8..0c2c14286 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.io.ByteArrayInputStream; import org.eclipse.core.resources.IFile; @@ -33,6 +36,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import org.junit.Test; /** * Tests the refresh tab. @@ -40,14 +44,6 @@ import org.eclipse.ui.PlatformUI; public class RefreshTabTests extends AbstractLaunchTest { /** - * Constructor - * @param name - */ - public RefreshTabTests(String name) { - super(name); - } - - /** * Sets the selected resource in the navigator view. * * @param resource resource to select @@ -70,8 +66,10 @@ public class RefreshTabTests extends AbstractLaunchTest { /** * Tests a refresh scope of the selected resource + * * @throws CoreException */ + @Test public void testSelectedResource() throws CoreException { String scope = "${resource}"; //$NON-NLS-1$ IResource resource = getProject().getFolder("src"); //$NON-NLS-1$ @@ -84,8 +82,10 @@ public class RefreshTabTests extends AbstractLaunchTest { /** * Tests a refresh scope of the selected resource's container + * * @throws CoreException */ + @Test public void testSelectionsFolder() throws CoreException { String scope = "${container}"; //$NON-NLS-1$ IResource resource = getProject().getFolder("src"); //$NON-NLS-1$ @@ -98,8 +98,10 @@ public class RefreshTabTests extends AbstractLaunchTest { /** * Tests a refresh scope of the selected resource's project + * * @throws CoreException */ + @Test public void testSelectionsProject() throws CoreException { String scope = "${project}"; //$NON-NLS-1$ IResource resource = getProject().getFolder("src"); //$NON-NLS-1$ @@ -112,8 +114,10 @@ public class RefreshTabTests extends AbstractLaunchTest { /** * Tests a refresh scope of the selected resource's project + * * @throws CoreException */ + @Test public void testWorkspaceScope() throws CoreException { String scope = "${workspace}"; //$NON-NLS-1$ IResource[] result = RefreshTab.getRefreshResources(scope); @@ -124,8 +128,10 @@ public class RefreshTabTests extends AbstractLaunchTest { /** * Tests a refresh scope for a specific resource (old format) + * * @throws CoreException */ + @Test public void testSpecificResource() throws CoreException { String scope = "${resource:/RefreshTabTests/some.file}"; //$NON-NLS-1$ IResource resource = getProject().getFile("some.file"); //$NON-NLS-1$ @@ -137,8 +143,10 @@ public class RefreshTabTests extends AbstractLaunchTest { /** * Tests a refresh scope for a working set + * * @throws CoreException */ + @Test public void testWorkingSet() throws CoreException { String scope= "${working_set:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<launchConfigurationWorkingSet factoryID=\"org.eclipse.ui.internal.WorkingSetFactory\" name=\"workingSet\" editPageId=\"org.eclipse.ui.resourceWorkingSetPage\">\n<item factoryID=\"org.eclipse.ui.internal.model.ResourceFactory\" path=\"/RefreshTabTests/some.file\" type=\"1\"/>\n</launchConfigurationWorkingSet>}"; //$NON-NLS-1$ IResource resource = getProject().getFile("some.file"); //$NON-NLS-1$ @@ -167,11 +175,12 @@ public class RefreshTabTests extends AbstractLaunchTest { } /** - * Tests the launch configuration attribute comparator extension for comparing - * old/new attribute styles. + * Tests the launch configuration attribute comparator extension for + * comparing old/new attribute styles. * * @throws CoreException */ + @Test public void testRefreshScopeComparator() throws CoreException { String oldStyle = "${working_set:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<launchConfigurationWorkingSet factoryID=\"org.eclipse.ui.internal.WorkingSetFactory\" name=\"workingSet\" editPageId=\"org.eclipse.ui.resourceWorkingSetPage\">\n<item factoryID=\"org.eclipse.ui.internal.model.ResourceFactory\" path=\"/RefreshTabTests/some.file\" type=\"1\"/>\n</launchConfigurationWorkingSet>}"; //$NON-NLS-1$ String newStyle = "${working_set:<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<resources>\n<item path=\"/RefreshTabTests/some.file\" type=\"1\"/>\n</resources>}"; //$NON-NLS-1$ @@ -183,6 +192,7 @@ public class RefreshTabTests extends AbstractLaunchTest { * * @throws CoreException */ + @Test public void testResourceMemento() throws CoreException { IResource[] resources = new IResource[] { getProject(), getProject().getFile("not.exist"), getProject().getFile("some.file") }; //$NON-NLS-1$ //$NON-NLS-2$ String memento = RefreshUtil.toMemento(resources); @@ -198,6 +208,7 @@ public class RefreshTabTests extends AbstractLaunchTest { * * @throws CoreException */ + @Test public void testEmptyResourceSet() throws CoreException { String memento = RefreshUtil.toMemento(new IResource[]{}); IResource[] resources = RefreshUtil.toResources(memento); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/SourceLookupFacilityTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/SourceLookupFacilityTests.java index ca6b50c4e..fd963297b 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/SourceLookupFacilityTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/SourceLookupFacilityTests.java @@ -13,6 +13,13 @@ *******************************************************************************/ package org.eclipse.debug.tests.sourcelookup; +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.lang.reflect.Field; import java.util.HashMap; import java.util.LinkedHashMap; @@ -22,6 +29,7 @@ import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility; import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupResult; import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult; +import org.junit.Test; /** * Tests {@link SourceLookupFacility} @@ -44,19 +52,13 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { TestSourceLocator fTestLocator = new TestSourceLocator(); /** - * @param name - */ - public SourceLookupFacilityTests(String name) { - super(name); - } - - /** * Tests calling * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} * with simple type, no locator and no forcing * * @throws Exception */ + @Test public void testLookupStringNoLocatorNoForce() throws Exception { try { String artifact = "Empty"; //$NON-NLS-1$ @@ -75,6 +77,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStringNoForce() throws Exception { try { String artifact = "One"; //$NON-NLS-1$ @@ -100,6 +103,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStringForce() throws Exception { try { String artifact = "Two"; //$NON-NLS-1$ @@ -125,6 +129,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStringLocatorNoForce() throws Exception { try { String artifact = "Three"; //$NON-NLS-1$ @@ -143,6 +148,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStackframeNoForce() throws Exception { try { ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestDirector, false); @@ -167,6 +173,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStackframeForce() throws Exception { try { ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestDirector, true); @@ -191,6 +198,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStackframeWithDebugElement1() throws Exception { try { ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(new TestStackFrame(null), null, false); @@ -208,6 +216,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStackframeWithDebugElement2() throws Exception { try { ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, null, false); @@ -232,6 +241,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStackframeWithDebugElement3() throws Exception { try { ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, null, true); @@ -256,6 +266,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStackframeWithDebugElement4() throws Exception { try { ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestLocator, false); @@ -280,6 +291,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { * * @throws Exception */ + @Test public void testLookupStackframeWithDebugElement5() throws Exception { try { ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestLocator, true); @@ -297,6 +309,7 @@ public class SourceLookupFacilityTests extends AbstractDebugTest { } } + @Test public void testLRU() throws Exception { try { final int MAX_LRU_SIZE = 10; diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandlerTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandlerTests.java index b1411fe90..9e138b5f8 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandlerTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/statushandlers/StatusHandlerTests.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.statushandlers; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.preferences.InstanceScope; @@ -22,6 +26,7 @@ import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; import org.eclipse.debug.internal.core.Preferences; import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.debug.tests.TestsPlugin; +import org.junit.Test; /** * Tests status handlers @@ -36,6 +41,7 @@ public class StatusHandlerTests extends AbstractDebugTest { /** * Tests that a status handler extension exists */ + @Test public void testStatusHandlerExtension() { IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(STATUS); assertNotNull("missing status handler extension", handler); //$NON-NLS-1$ @@ -45,6 +51,7 @@ public class StatusHandlerTests extends AbstractDebugTest { /** * Tests that status handlers are not returned when preference is disabled */ + @Test public void testDisableStatusHandlers() { try { Preferences.setBoolean(DebugPlugin.getUniqueIdentifier(), IInternalDebugCoreConstants.PREF_ENABLE_STATUS_HANDLERS, false, InstanceScope.INSTANCE); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/StepFiltersTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/StepFiltersTests.java index 768fbe55e..2ae5002b0 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/StepFiltersTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/stepfilters/StepFiltersTests.java @@ -10,21 +10,28 @@ *******************************************************************************/ package org.eclipse.debug.tests.stepfilters; +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 org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IStepFilter; import org.eclipse.debug.tests.AbstractDebugTest; +import org.junit.Test; /** * Tests step filters */ public class StepFiltersTests extends AbstractDebugTest { - + @Test public void testStepFitlersExtension_01() { IStepFilter[] stepFilters = DebugPlugin.getStepFilters("com.example.lalala.model"); //$NON-NLS-1$ assertNotNull(stepFilters); assertEquals(0, stepFilters.length); } + @Test public void testStepFitlersExtension_02() { IStepFilter[] stepFilters = DebugPlugin.getStepFilters("com.example.debug.model"); //$NON-NLS-1$ assertNotNull(stepFilters); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java index 0fe5c99f6..7fcdeebad 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java @@ -13,22 +13,25 @@ *******************************************************************************/ package org.eclipse.debug.tests.view.memory; +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 org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.memory.IMemoryRenderingBindingsListener; import org.eclipse.debug.ui.memory.IMemoryRenderingManager; import org.eclipse.debug.ui.memory.IMemoryRenderingType; +import org.junit.Test; /** * Tests memory rendering manager */ public class MemoryRenderingTests extends AbstractDebugTest { - public MemoryRenderingTests(String name) { - super(name); - } - + @Test public void testRenderingTypes() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryRenderingType[] types = manager.getRenderingTypes(); @@ -42,6 +45,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertTrue("Missing type", indexOf(manager.getRenderingType("org.eclipse.debug.ui.rendering.unsignedint"), types) >= 0); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testRenderingTypeNames() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryRenderingType type = manager.getRenderingType("rendering_type_1"); //$NON-NLS-1$ @@ -50,6 +54,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertEquals("Wrong name", "Rendering Two", type.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testSingleBinding() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryBlock block = new MemoryBlockOne(); @@ -58,6 +63,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertEquals("Wrong binding", "rendering_type_1", types[0].getId()); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testDoubleBinding() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryBlock block = new MemoryBlockTwo(); @@ -67,6 +73,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertTrue("Missing binding", indexOf(manager.getRenderingType("rendering_type_2"), types) >= 0); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testDefaultBinding() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryBlock block = new MemoryBlockOne(); @@ -75,6 +82,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertEquals("Wrong binding", "rendering_type_1", types[0].getId()); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testNoDefaultBinding() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryBlock block = new MemoryBlockTwo(); @@ -82,6 +90,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertEquals("Wrong number of bindings", 0, types.length); //$NON-NLS-1$ } + @Test public void testPrimaryBinding() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryBlock block = new MemoryBlockOne(); @@ -89,6 +98,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertEquals("Wrong binding", "rendering_type_1", type.getId()); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testNoPrimaryBinding() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryBlock block = new MemoryBlockTwo(); @@ -96,6 +106,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertNull("Wrong binding", type); //$NON-NLS-1$ } + @Test public void testDefaultWithoutPrimaryBinding() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryBlock block = new MemoryBlockThree(); @@ -104,6 +115,7 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertEquals("Wrong binding", "rendering_type_3", types[0].getId()); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testDynamicBinding() { IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); IMemoryBlock block = new MemoryBlockDynamic(); @@ -117,14 +129,10 @@ public class MemoryRenderingTests extends AbstractDebugTest { assertEquals("Wrong bindings", manager.getRenderingType("rendering_type_1"), type); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testBindingChangeNotification() { final boolean[] changed = new boolean[1]; - IMemoryRenderingBindingsListener listener = new IMemoryRenderingBindingsListener() { - @Override - public void memoryRenderingBindingsChanged() { - changed[0] = true; - } - }; + IMemoryRenderingBindingsListener listener = () -> changed[0] = true; IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager(); // bug 374447 - Need to make sure that DynamicRenderingBindings singleton diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/AbstractViewerModelTest.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/AbstractViewerModelTest.java index 62c5693ad..74545efbb 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/AbstractViewerModelTest.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/AbstractViewerModelTest.java @@ -15,7 +15,6 @@ package org.eclipse.debug.tests.viewer.model; import java.util.function.Function; -import org.eclipse.core.commands.ExecutionException; import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.debug.tests.TestUtil; @@ -23,6 +22,8 @@ import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; +import org.junit.After; +import org.junit.Before; public abstract class AbstractViewerModelTest extends AbstractDebugTest { @@ -31,12 +32,9 @@ public abstract class AbstractViewerModelTest extends AbstractDebugTest { IInternalTreeModelViewer fViewer; TestModelUpdatesListener fListener; - public AbstractViewerModelTest(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); fDisplay = PlatformUI.getWorkbench().getDisplay(); fShell = new Shell(fDisplay); @@ -49,7 +47,8 @@ public abstract class AbstractViewerModelTest extends AbstractDebugTest { } @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { fListener.dispose(); fViewer.getPresentationContext().dispose(); @@ -59,15 +58,6 @@ public abstract class AbstractViewerModelTest extends AbstractDebugTest { super.tearDown(); } - @Override - protected void runTest() throws Throwable { - try { - super.runTest(); - } catch (Throwable t) { - throw new ExecutionException("Test failed: " + t.getMessage() + "\n fListener = " + fListener, t); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - abstract protected IInternalTreeModelViewer createViewer(Display display, Shell shell); abstract protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java index 287a72393..bcffbb942 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java @@ -18,6 +18,7 @@ import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.debug.tests.viewer.model.TestModel.TestElement; import org.eclipse.jface.viewers.TreePath; +import org.junit.Test; /** * Tests which verify the check box support. This test is very similar to the @@ -29,15 +30,12 @@ import org.eclipse.jface.viewers.TreePath; */ abstract public class CheckTests extends AbstractViewerModelTest { - public CheckTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, false, false); } + @Test public void testSimpleSingleLevel() throws Exception { // Create the model with test data TestModel model = TestModel.simpleSingleLevel(); @@ -60,6 +58,7 @@ abstract public class CheckTests extends AbstractViewerModelTest { model.validateData(fViewer, TreePath.EMPTY); } + @Test public void testSimpleMultiLevel() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -104,7 +103,7 @@ abstract public class CheckTests extends AbstractViewerModelTest { // // Assert.assertTrue(element.getChecked() != initialCheckState); // } - + @Test public void testUpdateCheck() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java index fb293ebfa..a39ceebe2 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.viewers.model.ChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; @@ -34,6 +38,7 @@ import org.eclipse.jface.viewers.ViewerLabel; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; +import org.junit.Test; /** * Tests coalescing of children update requests. @@ -229,13 +234,6 @@ public class ChildrenUpdateTests extends AbstractDebugTest { } } - /** - * @param name - */ - public ChildrenUpdateTests(String name) { - super(name); - } - protected TreeModelContentProvider getContentProvider() { return new BogusModelContentProvider(); } @@ -243,6 +241,7 @@ public class ChildrenUpdateTests extends AbstractDebugTest { /** * Tests coalescing of requests */ + @Test public void testCoalesce () { Object element = new Object(); TreeModelContentProvider cp = getContentProvider(); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java index 92d3c131b..7654bf633 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; import java.util.function.Function; @@ -38,6 +40,9 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.XMLMemento; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * Tests to verify that the viewer properly handles initial columns width. @@ -49,18 +54,16 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM private TestModelUpdatesListener fListener; private boolean fResized = false; - public ColumnPresentationTests(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); createViewer(); } @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { destroyViewer(); super.tearDown(); } @@ -258,9 +261,10 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM * implementation without requiring the presentation being * IColumnPresentation2 (i.e. ensure we do not break backward compatibility * of interface). Also, we verify that the initial columns width is the - * average of tree width / number of visible columns, which is the logic - * in InternalTreeModelViewer. + * average of tree width / number of visible columns, which is the logic in + * InternalTreeModelViewer. */ + @Test public void testInitialColumnAverageWidth() throws Exception { fResized = false; @@ -290,6 +294,7 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM * Also, we verify that the initial columns width is the width computed by * the IColumnPresentation2 implementation. */ + @Test public void testInitialColumnWidth() throws Exception { fResized = false; @@ -317,6 +322,7 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM * is not used when there are user settings inside the viewer which are * created from user resizing columns. */ + @Test public void testRespectUserSettings() throws Exception { MyColumnPresentation2 colPre = new MyColumnPresentation2(); makeModel(colPre, "m2"); //$NON-NLS-1$ @@ -361,6 +367,7 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM * is not used when there are user settings inside the viewer which are * restored from memento, e.g., restoring workspace, etc. */ + @Test public void testRespectMemento() throws Exception { MyColumnPresentation2 colPre = new MyColumnPresentation2(); makeModel(colPre, "m2"); //$NON-NLS-1$ @@ -392,9 +399,10 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM } /** - * In this test: verify that tree viewer can handle the column presentation changing - * its available column IDs between runs (bug 360015). + * In this test: verify that tree viewer can handle the column presentation + * changing its available column IDs between runs (bug 360015). */ + @Test public void testChangedColumnIds() throws Exception { MyColumnPresentation colPre = new MyColumnPresentation(); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java index 64a38b7fa..0c844d458 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -31,6 +33,7 @@ import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.debug.tests.TestUtil; import org.eclipse.debug.tests.viewer.model.TestModel.TestElement; import org.eclipse.jface.viewers.TreePath; +import org.junit.Test; /** * Tests that verify that the viewer property retrieves all the content @@ -40,15 +43,12 @@ import org.eclipse.jface.viewers.TreePath; */ abstract public class ContentTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public ContentTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, true, true); } + @Test public void testSimpleSingleLevel() throws Exception { // Create the model with test data TestModel model = TestModel.simpleSingleLevel(); @@ -73,6 +73,7 @@ abstract public class ContentTests extends AbstractViewerModelTest implements IT assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) ); } + @Test public void testSimpleMultiLevel() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -143,6 +144,7 @@ abstract public class ContentTests extends AbstractViewerModelTest implements IT * use data from stale updates to populate the viewer.<br> * See bug 210027 */ + @Test public void testLabelUpdatesCompletedOutOfSequence1() throws Exception { TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates(); model.fCaptureLabelUpdates = true; @@ -155,7 +157,7 @@ abstract public class ContentTests extends AbstractViewerModelTest implements IT // Set input into the view to update it, but block children updates. // Wait for view to start retrieving content. fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> model.fCapturedUpdates.size() < model.getRootElement().fChildren.length, createModelErrorMessage(model)); List<IViewerUpdate> firstUpdates = model.fCapturedUpdates; @@ -194,10 +196,11 @@ abstract public class ContentTests extends AbstractViewerModelTest implements IT * Test to make sure that label provider cancels stale updates and doesn't * use data from stale updates to populate the viewer.<br> * This version of the test changes the elements in the view, and not just - * the elements' labels. In this case, the view should still cancel stale + * the elements' labels. In this case, the view should still cancel stale * updates.<br> * See bug 210027 */ + @Test public void testLabelUpdatesCompletedOutOfSequence2() throws Exception { TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates(); model.fCaptureLabelUpdates = true; @@ -210,7 +213,7 @@ abstract public class ContentTests extends AbstractViewerModelTest implements IT // Set input into the view to update it, but block children updates. // Wait for view to start retrieving content. fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> model.fCapturedUpdates.size() < model.getRootElement().fChildren.length, createModelErrorMessage(model)); List<IViewerUpdate> firstUpdates = model.fCapturedUpdates; model.fCapturedUpdates = Collections.synchronizedList(new ArrayList<IViewerUpdate>(2)); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java index e6c25d01e..49c67557c 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java @@ -14,6 +14,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Arrays; import java.util.List; import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; @@ -24,6 +28,7 @@ import org.eclipse.debug.tests.viewer.model.TestModel.TestElement; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ITreeSelection; import org.eclipse.jface.viewers.TreePath; +import org.junit.Test; /** * Tests to verify that the viewer property retrieves and processes the @@ -31,15 +36,12 @@ import org.eclipse.jface.viewers.TreePath; */ abstract public class DeltaTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public DeltaTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, false, false); } + @Test public void testUpdateLabel() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -65,6 +67,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes model.validateData(fViewer, TreePath.EMPTY); } + @Test public void testRefreshStruct() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -95,6 +98,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes model.validateData(fViewer, TreePath.EMPTY); } + @Test public void testRefreshStruct2() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -144,6 +148,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes model.validateData(fViewer, TreePath.EMPTY); } + @Test public void testRefreshCoalesceStruct() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -174,7 +179,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) ); } - + @Test public void testInsert() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -210,9 +215,10 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes } /** - * This test checks that insert and select delta flags are processed in correct order: - * insert then select. + * This test checks that insert and select delta flags are processed in + * correct order: insert then select. */ + @Test public void testInsertAndSelect() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -258,9 +264,10 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes } /** - * This test checks that insert and remove deltas are processed in correct order: - * remove deltas are processed first then insert deltas. + * This test checks that insert and remove deltas are processed in correct + * order: remove deltas are processed first then insert deltas. */ + @Test public void testInsertAndRemove() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -301,7 +308,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes model.validateData(fViewer, TreePath.EMPTY); } - + @Test public void testAddElement() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -425,7 +432,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes model.validateData(fViewer, parentPath, true); } - + @Test public void testRemove() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -451,6 +458,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes model.validateData(fViewer, TreePath.EMPTY); } + @Test public void testExpandAndSelect() throws Exception { TestModel model = TestModel.simpleMultiLevel(); @@ -533,6 +541,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes /** * This test verifies that expand and select updates are being ignored. */ + @Test public void testExpandAndSelect_simple() throws Exception { TestModel model = TestModel.simpleMultiLevel(); @@ -581,6 +590,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes } } + @Test public void testCompositeModelRefreshStruct() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -614,6 +624,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes model.validateData(fViewer, TreePath.EMPTY); } + @Test public void testCompositeModelAddElement() throws Exception { TestModel model = TestModel.compositeMultiLevel(); fViewer.setAutoExpandLevel(-1); @@ -644,6 +655,7 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes model.validateData(fViewer, TreePath.EMPTY); } + @Test public void testBug292322() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java index fb958178a..1f003ab74 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertTrue; + import java.util.regex.Pattern; import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; @@ -28,6 +30,7 @@ import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.TreeSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; +import org.junit.Test; /** * Tests that verify that the viewer property retrieves all the content @@ -37,10 +40,6 @@ import org.eclipse.jface.viewers.ViewerFilter; */ abstract public class FilterTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public FilterTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, true, true); @@ -97,31 +96,37 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe } } + @Test public void testSimpleSingleLevel() throws Exception { TestModel model = TestModel.simpleSingleLevel(); doTestSimpleLevel(model, new ViewerFilter[] { new TestViewerFilter("2") }); //$NON-NLS-1$ } + @Test public void testSimpleSingleLevelWithTMVFilter() throws Exception { TestModel model = TestModel.simpleSingleLevel(); doTestSimpleLevel(model, new ViewerFilter[] { new TestTMVFilter("2", model.getRootElement()) }); //$NON-NLS-1$ } + @Test public void testSimpleSingleLevelWithMixedFilters() throws Exception { TestModel model = TestModel.simpleSingleLevel(); doTestSimpleLevel(model, new ViewerFilter[] { new TestTMVFilter("2", model.getRootElement()), new TestViewerFilter("1") }); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testSimpleMultiLevel() throws Exception { TestModel model = TestModel.simpleMultiLevel(); doTestSimpleLevel(model, new ViewerFilter[] { new TestViewerFilter(".1"), new TestViewerFilter(".2") }); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testSimpleMultiLevelWithTMVFilter() throws Exception { TestModel model = TestModel.simpleMultiLevel(); doTestSimpleLevel(model, new ViewerFilter[] { new TestTMVFilter(".1", null), new TestTMVFilter(".2", null) }); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testSimpleMultiLevelWithMixedFilters() throws Exception { TestModel model = TestModel.simpleMultiLevel(); doTestSimpleLevel(model, new ViewerFilter[] { new TestViewerFilter(".1"), new TestTMVFilter(".2", null) }); //$NON-NLS-1$ //$NON-NLS-2$ @@ -147,10 +152,12 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe model.validateData(fViewer, TreePath.EMPTY, false, filters); } + @Test public void testLargeSingleLevel() throws Exception { doTestLargeSingleLevel(new ViewerFilter[] { new TestViewerFilter("2") }); //$NON-NLS-1$ } + @Test public void testLargeSingleLevelWithTMVFilter() throws Exception { doTestLargeSingleLevel(new ViewerFilter[] { new TestTMVFilter("2", null) }); //$NON-NLS-1$ } @@ -174,18 +181,20 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe /** - * Replace an element that is not visible but filtered out. With an element that is NOT filtered out. - * Fire REPLACE delta. + * Replace an element that is not visible but filtered out. With an element + * that is NOT filtered out. Fire REPLACE delta. */ + @Test public void testReplacedUnrealizedFilteredElement() throws Exception { doTestReplacedUnrealizedFilteredElement(new ViewerFilter[] { new TestViewerFilter("2") }); //$NON-NLS-1$ } /** - * Replace an element that is not visible but filtered out. With an element that is NOT filtered out. - * Fire REPLACE delta. + * Replace an element that is not visible but filtered out. With an element + * that is NOT filtered out. Fire REPLACE delta. */ + @Test public void testReplacedUnrealizedFilteredElementWithTMVFilter() throws Exception { doTestReplacedUnrealizedFilteredElement(new ViewerFilter[] { new TestTMVFilter("2", null) }); //$NON-NLS-1$ } @@ -204,7 +213,7 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe // Populate the view (all elements containing a "2" will be filtered out. fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage()); @@ -226,11 +235,12 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe assertTrue(replacedElementPaths.length != 0); } - + @Test public void testRefreshUnrealizedFilteredElement() throws Exception { doTestRefreshUnrealizedFilteredElement(new ViewerFilter[] { new TestViewerFilter("2") }); //$NON-NLS-1$ } + @Test public void testRefreshUnrealizedFilteredElementWithTMVFilter() throws Exception { doTestRefreshUnrealizedFilteredElement(new ViewerFilter[] { new TestTMVFilter("2", null) }); //$NON-NLS-1$ } @@ -252,7 +262,7 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe // Populate the view (all elements containing a "2" will be filtered out. fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage()); @@ -274,14 +284,17 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe assertTrue(replacedElementPaths.length != 0); } + @Test public void testRefreshToUnfilterElements() throws Exception { doTestRefreshToUnfilterElements(new ViewerFilter[] { new TestViewerFilter(".1"), new TestViewerFilter(".2") }); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testRefreshToUnfilterElementsWithTMVFilter() throws Exception { doTestRefreshToUnfilterElements(new ViewerFilter[] { new TestTMVFilter(".1", null), new TestTMVFilter(".2", null) }); //$NON-NLS-1$ //$NON-NLS-2$ } + @Test public void testRefreshToUnfilterElementsWithMixedFilters() throws Exception { doTestRefreshToUnfilterElements(new ViewerFilter[] { new TestViewerFilter(".1"), new TestTMVFilter(".2", null) }); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -305,7 +318,7 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe // Populate the view (all elements containing a "2" will be filtered out. fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage()); @@ -320,6 +333,7 @@ abstract public class FilterTests extends AbstractViewerModelTest implements ITe model.validateData(fViewer, TreePath.EMPTY, false, filters1); } + @Test public void testPreserveExpandedOnMultLevelContent() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = StateTests.alternatingSubsreesModel(6); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTransformTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTransformTests.java index 6a4db089d..96357fdea 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTransformTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTransformTests.java @@ -13,9 +13,17 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertArrayEquals; +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 org.eclipse.debug.internal.ui.viewers.model.FilterTransform; import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.jface.viewers.TreePath; +import org.junit.Before; +import org.junit.Test; /** * Tests the virtual viewer's filter transform @@ -36,19 +44,13 @@ public class FilterTransformTests extends AbstractDebugTest { public FilterTransform transform; /** - * @param name - */ - public FilterTransformTests(String name) { - super(name); - } - - /** * Builds a filter transform. Model has 8 elements, * and elements 0, 2, 3, 6, 7 are filtered. Elements * 1, 4, 5 are visible. */ @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); transform = new FilterTransform(); root = new Object(); @@ -67,70 +69,73 @@ public class FilterTransformTests extends AbstractDebugTest { assertTrue(transform.addFilteredIndex(TreePath.EMPTY, 7, element7)); } - protected boolean equals(int[] a, int[] b) { - if (a.length == b.length) { - for (int i = 0; i < b.length; i++) { - if (a[i] != b[i]) { - return false; - } - } - return true; - } - return false; - } - + @Test public void testRemoveMiddleElementFromFilters() { assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 3)); //$NON-NLS-1$ transform.removeElementFromFilters(TreePath.EMPTY, element3); assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 3)); //$NON-NLS-1$ - assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[] { 0, 2, 5, 6 })); //$NON-NLS-1$ + assertArrayEquals("Wrong filter state", transform.getFilteredChildren(TreePath.EMPTY), new int[] { //$NON-NLS-1$ + 0, 2, 5, 6 }); } + @Test public void testRemoveFirstElementFromFilters() { assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 0)); //$NON-NLS-1$ transform.removeElementFromFilters(TreePath.EMPTY, element0); assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 0)); //$NON-NLS-1$ - assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[] { 1, 2, 5, 6 })); //$NON-NLS-1$ + assertArrayEquals("Wrong filter state", transform.getFilteredChildren(TreePath.EMPTY), new int[] { //$NON-NLS-1$ + 1, 2, 5, 6 }); } + @Test public void testRemoveLastFromFilters() { assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 7)); //$NON-NLS-1$ transform.removeElementFromFilters(TreePath.EMPTY, element7); assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 7)); //$NON-NLS-1$ - assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[] { 0, 2, 3, 6 })); //$NON-NLS-1$ + assertArrayEquals("Wrong filter state", transform.getFilteredChildren(TreePath.EMPTY), new int[] { //$NON-NLS-1$ + 0, 2, 3, 6 }); } + @Test public void testClearMiddleElementFromFilters() { assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 3)); //$NON-NLS-1$ transform.clear(TreePath.EMPTY, 3); assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 3)); //$NON-NLS-1$ - assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[] { 0, 2, 6, 7 })); //$NON-NLS-1$ + assertArrayEquals("Wrong filter state", transform.getFilteredChildren(TreePath.EMPTY), new int[] { //$NON-NLS-1$ + 0, 2, 6, 7 }); } + @Test public void testClearFirstElementFromFilters() { assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 0)); //$NON-NLS-1$ transform.clear(TreePath.EMPTY, 0); assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 0)); //$NON-NLS-1$ - assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[] { 2, 3, 6, 7 })); //$NON-NLS-1$ + assertArrayEquals("Wrong filter state", transform.getFilteredChildren(TreePath.EMPTY), new int[] { //$NON-NLS-1$ + 2, 3, 6, 7 }); } + @Test public void testClearLastFromFilters() { assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 7)); //$NON-NLS-1$ transform.clear(TreePath.EMPTY, 7); assertFalse("Element should be unfiltered", transform.isFiltered(TreePath.EMPTY, 7)); //$NON-NLS-1$ - assertTrue("Wrong filter state", equals(transform.getFilteredChildren(TreePath.EMPTY), new int[] { 0, 2, 3, 6 })); //$NON-NLS-1$ + assertArrayEquals("Wrong filter state", transform.getFilteredChildren(TreePath.EMPTY), new int[] { //$NON-NLS-1$ + 0, 2, 3, 6 }); } + @Test public void testViewToModelCount() { assertEquals("Wrong model count", 8, transform.viewToModelCount(TreePath.EMPTY, 3)); //$NON-NLS-1$ } + @Test public void testViewToModelIndex() { assertEquals("Wrong model index", 1, transform.viewToModelIndex(TreePath.EMPTY, 0)); //$NON-NLS-1$ assertEquals("Wrong model index", 4, transform.viewToModelIndex(TreePath.EMPTY, 1)); //$NON-NLS-1$ assertEquals("Wrong model index", 5, transform.viewToModelIndex(TreePath.EMPTY, 2)); //$NON-NLS-1$ } + @Test public void testAddAlreadyFiltered() { assertTrue("Element should be filtered", transform.isFiltered(TreePath.EMPTY, 0)); //$NON-NLS-1$ boolean added = transform.addFilteredIndex(TreePath.EMPTY, 0, element0); @@ -139,9 +144,10 @@ public class FilterTransformTests extends AbstractDebugTest { /** - * Test to make sure that setModelChildCount() updates internal arrays appropriately. - * See bug 200325. + * Test to make sure that setModelChildCount() updates internal arrays + * appropriately. See bug 200325. */ + @Test public void testRegression200325() { transform.setModelChildCount(TreePath.EMPTY, 2); try { diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java index 21e849d19..f62128a5b 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerCheckTests extends CheckTests { - public JFaceViewerCheckTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.CHECK, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java index 53feebda2..abc288c77 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerContentTests extends ContentTests { - public JFaceViewerContentTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java index 5bfa72a37..6e131c8ae 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java @@ -20,16 +20,13 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.junit.Test; /** * @since 3.6 */ public class JFaceViewerDeltaTests extends DeltaTests { - public JFaceViewerDeltaTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ @@ -39,6 +36,7 @@ public class JFaceViewerDeltaTests extends DeltaTests { * TODO: remove this method when bug 292322 gets fixed in TreeViewer */ @Override + @Test public void testBug292322() { } } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java index e120aa4c9..2b8010e86 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerFilterTests extends FilterTests { - public JFaceViewerFilterTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.MULTI, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java index 9d042f74b..a2883d7f7 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java @@ -25,10 +25,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerLazyTests extends LazyTests { - public JFaceViewerLazyTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java index ed4b6815f..70cd1425d 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java @@ -25,10 +25,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerPerformanceTests extends PerformanceTests { - public JFaceViewerPerformanceTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java index eda0e22a3..657efe5e0 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerPopupTests extends PopupTests { - public JFaceViewerPopupTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell, int style) { return new TreeModelViewer(fShell, SWT.VIRTUAL | style, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java index b520b9b31..38da36ece 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerSelectionTests extends SelectionTests { - public JFaceViewerSelectionTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java index ef8b08746..96ab6ee18 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerStateTests extends StateTests { - public JFaceViewerStateTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.MULTI, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java index d0ffc8645..171e8198c 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java @@ -16,10 +16,12 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.eclipse.core.runtime.Platform; import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDeltaVisitor; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext; import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer; @@ -29,16 +31,13 @@ import org.eclipse.jface.viewers.TreePath; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.junit.Test; /** * @since 3.6 */ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public JFaceViewerTopIndexTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, false, false); @@ -62,6 +61,7 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements * Restore REVEAL on simple model with elements without children. * */ + @Test public void testRestoreTopIndex() throws Exception { TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer()); @@ -122,11 +122,12 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements } /** - * Restore REVEAL when having also to restore an expanded element - * that is just above the REVEAL element. + * Restore REVEAL when having also to restore an expanded element that is + * just above the REVEAL element. * * See bug 324100 */ + @Test public void testRestoreTopAndExpand() throws Exception { TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer()); @@ -219,6 +220,7 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements * * See bug 324100 */ + @Test public void testRestoreTopTriggersExpand() throws Exception { TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer()); @@ -299,6 +301,7 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements * This test verifies that canceling a reveal pending state delta is * properly handled when a new reveal delta is received from the model. */ + @Test public void testRestoreRevealAfterRevealCancel() throws Exception { TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer()); TestModel model = TestModel.simpleMultiLevel(); @@ -362,6 +365,7 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements * This test verifies that canceling a reveal pending state delta is * properly handled when a new reveal delta is received from the model. */ + @Test public void testRestoreRevealAfterRevealCancel2() throws Exception { if (Platform.getOS().equals(Platform.OS_MACOSX)) { // skip this test on Mac - see bug 327557 @@ -409,13 +413,9 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements // Update the viewer with new selection delta to something new in the view TreePath pathToBeRevealed = model.findElement("2.1"); //$NON-NLS-1$ ModelDelta revealDelta = model.makeElementDelta(pathToBeRevealed, IModelDelta.REVEAL); - revealDelta.accept(new IModelDeltaVisitor() { - - @Override - public boolean visit(IModelDelta delta, int depth) { - ((ModelDelta)delta).setFlags(delta.getFlags() | IModelDelta.EXPAND); - return true; - } + revealDelta.accept((delta, depth) -> { + ((ModelDelta) delta).setFlags(delta.getFlags() | IModelDelta.EXPAND); + return true; }); // Wait for the second model delta to process @@ -432,11 +432,12 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements /** - * Restore REVEAL when having also to restore an expanded element - * that is just above the REVEAL element. + * Restore REVEAL when having also to restore an expanded element that is + * just above the REVEAL element. * * See bug 324100 */ + @Test public void testRestoreDeepTreeAndReveal() throws Exception { TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer()); @@ -490,6 +491,7 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements * This test verifies that a revealed node does not get scrolled away due to * structural updates. */ + @Test public void testRevealWithContentChanges() throws Exception { @SuppressWarnings("unused") TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer()); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java index 4a1d39f9e..ba25f064f 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class JFaceViewerUpdateTests extends UpdateTests { - public JFaceViewerUpdateTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java index 2819182c2..2ed7193b8 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertEquals; + import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; @@ -21,6 +23,7 @@ import org.eclipse.debug.tests.viewer.model.TestModel.TestElement; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.TreeSelection; +import org.junit.Test; /** * Tests that verify that the viewer property retrieves all the content @@ -30,10 +33,6 @@ import org.eclipse.jface.viewers.TreeSelection; */ abstract public class LazyTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public LazyTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, true, true); @@ -63,10 +62,10 @@ abstract public class LazyTests extends AbstractViewerModelTest implements ITest } /** - * Test to make sure that if an element is expanded its children are - * not automatically materialized. - * (bug 305739 and bug 304277) + * Test to make sure that if an element is expanded its children are not + * automatically materialized. (bug 305739 and bug 304277) */ + @Test public void testExpandLargeSubTree() throws Exception { // Create test model with lots of children. TestModel model = largeSubtreeModel(1000); @@ -103,10 +102,11 @@ abstract public class LazyTests extends AbstractViewerModelTest implements ITest } /** - * Test to make sure that if an element that is previously selected, is - * then selected and replaced, that no extra elements are retrieved. - * (bug 304277 comment #24, and bug 305739 comment #9). + * Test to make sure that if an element that is previously selected, is then + * selected and replaced, that no extra elements are retrieved. (bug 304277 + * comment #24, and bug 305739 comment #9). */ + @Test public void testReplaceAndSelectInSubTreeTree() throws Exception { // Create test model with lots of children. TestModel model = largeSubtreeModel(1000); @@ -154,8 +154,7 @@ abstract public class LazyTests extends AbstractViewerModelTest implements ITest assertEquals(((IStructuredSelection)fViewer.getSelection()).getFirstElement(), _1_0_newElement); } - /** - */ + @Test public void testContentRefresh() throws Exception { // Create test model with lots of children. TestModel model = largeSubtreeModel(1000); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java index 148291e7e..0d1a91255 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java @@ -24,6 +24,8 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.test.performance.Performance; import org.eclipse.test.performance.PerformanceMeter; +import org.junit.Before; +import org.junit.Test; /** * Tests to measure the performance of the viewer updates. @@ -32,8 +34,8 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement protected VisibleVirtualItemValidator fVirtualItemValidator; - public PerformanceTests(String name) { - super(name); + public String getDefaultScenarioId() { + return this.getClass().getName() + '#' + name.getMethodName() + "()"; //$NON-NLS-1$ } @Override @@ -42,7 +44,8 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement } @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); fVirtualItemValidator = new VisibleVirtualItemValidator(0, Integer.MAX_VALUE); } @@ -54,7 +57,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement */ abstract protected int getTestModelDepth(); - + @Test public void testRefreshStruct() throws Exception { TestModel model = new TestModel(); model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$ @@ -71,7 +74,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement model.validateData(fViewer, TreePath.EMPTY); Performance perf = Performance.getDefault(); - PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this)); + PerformanceMeter meter = perf.createPerformanceMeter(getDefaultScenarioId()); try { for (int i = 0; i < 10; i++) { // Update the model @@ -94,6 +97,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement } } + @Test public void testRefreshStruct2() throws Exception { TestModel model = new TestModel(); model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$ @@ -111,7 +115,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement fVirtualItemValidator.setVisibleRange(0, 50); Performance perf = Performance.getDefault(); - PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this)); + PerformanceMeter meter = perf.createPerformanceMeter(getDefaultScenarioId()); try { for (int i = 0; i < 100; i++) { // Update the model @@ -137,7 +141,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement } } - + @Test public void testRefreshStructReplaceElements() throws Exception { TestModel model = new TestModel(); model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$ @@ -154,7 +158,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement model.validateData(fViewer, TreePath.EMPTY); Performance perf = Performance.getDefault(); - PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this)); + PerformanceMeter meter = perf.createPerformanceMeter(getDefaultScenarioId()); try { for (int i = 0; i < 100; i++) { // Update the model @@ -177,7 +181,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement } } - + @Test public void testRefreshList() throws Exception { TestModel model = new TestModel(); model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$ @@ -195,7 +199,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement model.validateData(fViewer, TreePath.EMPTY); Performance perf = Performance.getDefault(); - PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this)); + PerformanceMeter meter = perf.createPerformanceMeter(getDefaultScenarioId()); try { for (int i = 0; i < 100; i++) { // Update the model @@ -218,6 +222,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement } } + @Test public void testSaveAndRestore() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); @@ -240,7 +245,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement fViewer.setAutoExpandLevel(-1); Performance perf = Performance.getDefault(); - PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this)); + PerformanceMeter meter = perf.createPerformanceMeter(getDefaultScenarioId()); try { for (int i = 0; i < 100; i++) { // Update the model @@ -272,6 +277,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement } + @Test public void testRefreshListFiltered() throws Exception { TestModel model = new TestModel(); model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$ @@ -305,7 +311,7 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement model.validateData(fViewer, TreePath.EMPTY); Performance perf = Performance.getDefault(); - PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this)); + PerformanceMeter meter = perf.createPerformanceMeter(getDefaultScenarioId()); try { for (int i = 0; i < 100; i++) { // Update the model diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java index d37b2f8b3..7c59c6e17 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java @@ -14,6 +14,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -31,6 +35,7 @@ import org.eclipse.jface.viewers.TreeSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.junit.Test; /** * Tests to verify that the viewer property updates when created @@ -40,10 +45,6 @@ import org.eclipse.swt.widgets.Shell; */ abstract public class PopupTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public PopupTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, false, false); @@ -63,6 +64,7 @@ abstract public class PopupTests extends AbstractViewerModelTest implements ITes /** * This test verifies that content updates are still being performed. */ + @Test public void testRefreshStruct() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -96,6 +98,7 @@ abstract public class PopupTests extends AbstractViewerModelTest implements ITes /** * This test verifies that expand and select updates are being ignored. */ + @Test public void testExpandAndSelect() throws Exception { TestModel model = TestModel.simpleMultiLevel(); @@ -147,6 +150,7 @@ abstract public class PopupTests extends AbstractViewerModelTest implements ITes } } + @Test public void testPreserveExpandedOnSubTreeContent() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java index 901d62105..13c3a04c7 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java @@ -14,11 +14,14 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertEquals; + import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext; import org.eclipse.debug.tests.AbstractDebugTest; import org.eclipse.ui.IPersistableElement; import org.eclipse.ui.XMLMemento; +import org.junit.Test; /** * Test the serialization of presentation context properties. @@ -27,13 +30,10 @@ import org.eclipse.ui.XMLMemento; */ public class PresentationContextTests extends AbstractDebugTest { - public PresentationContextTests(String name) { - super(name); - } - /** * Tests saving and restoring presentation context properties. */ + @Test public void testSaveRestore () { PresentationContext context = new PresentationContext("test"); //$NON-NLS-1$ context.setProperty("string", "string"); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java index e73e9c96f..0a2de1761 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java @@ -14,6 +14,9 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.List; @@ -27,16 +30,13 @@ import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.TreeSelection; +import org.junit.Test; /** * Tests to verify that the viewer properly handles selection changes. */ abstract public class SelectionTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public SelectionTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, false, false); @@ -62,11 +62,11 @@ abstract public class SelectionTests extends AbstractViewerModelTest implements } /** - * In this test: - * - set selection to an element deep in the model - * - verify that selection chagned listener is called - * - verify that the selection is in the viewer is correct + * In this test: - set selection to an element deep in the model - verify + * that selection chagned listener is called - verify that the selection is + * in the viewer is correct */ + @Test public void testSimpleSetSelection() throws Exception { // Create the model and populate the view. TestModel model = makeMultiLevelModel(); @@ -86,10 +86,10 @@ abstract public class SelectionTests extends AbstractViewerModelTest implements } /** - * In this test verify that selection policy can prevent selection - * from being set and verify that a FORCE flag can override the selection - * policy. + * In this test verify that selection policy can prevent selection from + * being set and verify that a FORCE flag can override the selection policy. */ + @Test public void testSelectionPolicy() throws Exception { // Create the model and populate the view. final TestModel model = makeMultiLevelModel(); @@ -151,12 +151,11 @@ abstract public class SelectionTests extends AbstractViewerModelTest implements /** - * In this test: - * - set a seleciton to an element - * - then remove that element - * - update the view with remove delta - * -> The selection should be re-set to empty. + * In this test: - set a seleciton to an element - then remove that element + * - update the view with remove delta -> The selection should be re-set to + * empty. */ + @Test public void testSelectRemove() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -196,12 +195,10 @@ abstract public class SelectionTests extends AbstractViewerModelTest implements /** - * In this test: - * - set a selection to an element - * - then remove that element - * - then refresh the view. - * -> The selection should be re-set to empty. + * In this test: - set a selection to an element - then remove that element + * - then refresh the view. -> The selection should be re-set to empty. */ + @Test public void testSelectRemoveRefreshStruct() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java index 1883dfcb9..b1db2a55a 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java @@ -14,6 +14,10 @@ *******************************************************************************/ package org.eclipse.debug.tests.viewer.model; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -27,6 +31,7 @@ import org.eclipse.debug.tests.viewer.model.TestModel.TestElement; import org.eclipse.jface.viewers.ITreeSelection; import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.TreeSelection; +import org.junit.Test; /** * Tests to verify that the viewer can save and restore correctly the expansion @@ -36,10 +41,6 @@ import org.eclipse.jface.viewers.TreeSelection; */ abstract public class StateTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public StateTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, false, false); @@ -49,6 +50,7 @@ abstract public class StateTests extends AbstractViewerModelTest implements ITes return fViewer; } + @Test public void testUpdateViewer() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -270,6 +272,7 @@ abstract public class StateTests extends AbstractViewerModelTest implements ITes TestUtil.waitWhile(t -> !listener.isFinished(CONTENT_SEQUENCE_COMPLETE | MODEL_CHANGED_COMPLETE), null, 30000, t -> "Listener not finished: " + listener); } + @Test public void testPreserveExpandedOnRemove() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); @@ -310,6 +313,7 @@ abstract public class StateTests extends AbstractViewerModelTest implements ITes assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); } + @Test public void testPreserveExpandedOnInsert() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); @@ -355,6 +359,7 @@ abstract public class StateTests extends AbstractViewerModelTest implements ITes assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); } + @Test public void testPreserveExpandedOnMultLevelContent() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); @@ -410,6 +415,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 5) ); } + @Test public void testKeepCollapsedAfterRemovingAndReaddingChildrenInExpandedTree() throws Exception { boolean showChildren[] = new boolean[] { true }; int size = 3; @@ -535,6 +541,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } + @Test public void testPreserveExpandedOnSubTreeContent() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); @@ -585,6 +592,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); } + @Test public void testPreserveExpandedOnContentStress() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); @@ -653,6 +661,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } + @Test public void testPreserveLargeModelOnContent() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(100); @@ -664,7 +673,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage()); expandAlternateElements(fListener, model, false); @@ -712,10 +721,11 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } /** - * This test verifies that if the model selects a new element - * following a content refresh, the state restore logic will - * not override the selection requested by the model. + * This test verifies that if the model selects a new element following a + * content refresh, the state restore logic will not override the selection + * requested by the model. */ + @Test public void testPreserveSelectionDeltaAfterContent() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); @@ -758,6 +768,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertEquals(new TreeSelection(model.findElement("2.1")), fViewer.getSelection()); //$NON-NLS-1$ } + @Test public void testPreserveCollapseDeltaAfterContent() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); @@ -813,6 +824,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == false); //$NON-NLS-1$ } + @Test public void testPreserveExpandDeltaAfterContent() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); @@ -851,7 +863,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$ } - + @Test public void testSaveAndRestore1() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); @@ -899,6 +911,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } + @Test public void testSaveAndRestore2() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); @@ -949,6 +962,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } + @Test public void testSaveAndRestoreInputInstance() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); @@ -991,6 +1005,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } + @Test public void testSaveAndRestoreInputInstanceEquals() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(6); @@ -1036,7 +1051,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } } - + @Test public void testSaveAndRestoreLarge() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(100); @@ -1048,7 +1063,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage()); expandAlternateElements(fListener, model, false); @@ -1067,7 +1082,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL); fViewer.setInput(null); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE | STATE_UPDATES), createListenerErrorMessage()); // Set the viewer input back to the model. When view updates are complete @@ -1075,7 +1090,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(); fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage()); // Validate data (only select visible elements). @@ -1092,10 +1107,11 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } /** - * This test saves state of a large tree. Then the tree is modified - * to contain much fewer elements. The restore logic should discard the - * rest of the saved state delta once all the elements are visible. + * This test saves state of a large tree. Then the tree is modified to + * contain much fewer elements. The restore logic should discard the rest of + * the saved state delta once all the elements are visible. */ + @Test public void testSaveAndRestorePartialStateLarge() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = alternatingSubsreesModel(100); @@ -1107,7 +1123,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Set the input into the view and update the view. fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage()); expandAlternateElements(fListener, model, false); @@ -1126,7 +1142,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL); fViewer.setInput(null); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE | STATE_UPDATES), createListenerErrorMessage()); @@ -1140,7 +1156,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle // Note: disable redundant updates because the reveal delta triggers one. fListener.reset(); fViewer.setInput(model.getRootElement()); - TestUtil.waitForJobs(getName(), 300, 5000); + TestUtil.waitForJobs(name.getMethodName(), 300, 5000); // MONITOR FOR THE STATE RESTORE TO COMPLETE waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage()); @@ -1158,6 +1174,7 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) ); } + @Test public void testPreserveCollapseAndSelectDeltaAfterSaveAndRestore() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); @@ -1223,8 +1240,10 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle /** * Test for bug 359859.<br> - * This test verifies that RESTORE state is handled after SAVE previous state was completed + * This test verifies that RESTORE state is handled after SAVE previous + * state was completed */ + @Test public void testSaveRestoreOrder() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); TestModel model = TestModel.simpleMultiLevel(); @@ -1253,9 +1272,10 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle } /** - * This test tries to restore a viewer state while input == null. - * See: Bug 380288 - NPE switching to the Breakpoints View + * This test tries to restore a viewer state while input == null. See: Bug + * 380288 - NPE switching to the Breakpoints View */ + @Test public void testUpdateWithNullInput() throws Exception { TestModel model = TestModel.simpleMultiLevel(); fViewer.setAutoExpandLevel(-1); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java index bba5dec82..38c01584d 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java @@ -23,13 +23,13 @@ import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; -import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDeltaVisitor; import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.debug.tests.TestUtil; import org.eclipse.debug.tests.viewer.model.TestModel.TestElement; import org.eclipse.jface.viewers.TreePath; import org.junit.Assert; +import org.junit.Test; /** * Tests to verify that the viewer property updates following changes in the @@ -39,21 +39,16 @@ import org.junit.Assert; */ abstract public class UpdateTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants { - public UpdateTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, false, false); } /** - * This test: - * - creates a simple model - * - replaces the list of elements with a shorter list of elements - * - refreshes the viewer + * This test: - creates a simple model - replaces the list of elements with + * a shorter list of elements - refreshes the viewer */ + @Test public void testRemoveElements() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -88,11 +83,10 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe } /** - * This test: - * - creates a simple model - * - sets a list of children to one of the elements - * - refreshes the viewer + * This test: - creates a simple model - sets a list of children to one of + * the elements - refreshes the viewer */ + @Test public void testAddNewChildren() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -175,6 +169,7 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe } } + @Test public void testRepeatedAddRemoveElement() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); @@ -201,10 +196,11 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe } /** - * This test verifies that when the viewer processes a delta that causes viewer - * updates it initiates the model update sequence before it finishes processing - * the delta. + * This test verifies that when the viewer processes a delta that causes + * viewer updates it initiates the model update sequence before it finishes + * processing the delta. */ + @Test public void testNotifyUpdatesTartedOnModelChanged() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -229,11 +225,12 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe /** - * This test case attempts to create a race condition between processing - * of the content updates and processing of add/remove model deltas. - * <br> - * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a> + * This test case attempts to create a race condition between processing of + * the content updates and processing of add/remove model deltas. <br> + * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug + * 304066</a> */ + @Test public void testContentPlusAddRemoveUpdateRaceConditionsElement() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -287,11 +284,12 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe /** - * This test case attempts to create a race condition between processing - * of the content updates and processing of add/remove model deltas. - * <br> - * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a> + * This test case attempts to create a race condition between processing of + * the content updates and processing of add/remove model deltas. <br> + * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug + * 304066</a> */ + @Test public void testInsertAtInvalidIndex() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -308,16 +306,12 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe final int insertIndex = model.getRootElement().getChildren().length; ModelDelta delta = model.insertElementChild(TreePath.EMPTY, insertIndex, new TestElement(model, "last - invalid index", new TestElement[0])); //$NON-NLS-1$ // Change insert index to out of range - delta.accept(new IModelDeltaVisitor() { - - @Override - public boolean visit(IModelDelta visitorDelta, int depth) { - if ((visitorDelta.getFlags() & IModelDelta.INSERTED) != 0) { - ((ModelDelta)visitorDelta).setIndex(insertIndex + 1); - return false; - } - return true; + delta.accept((visitorDelta, depth) -> { + if ((visitorDelta.getFlags() & IModelDelta.INSERTED) != 0) { + ((ModelDelta) visitorDelta).setIndex(insertIndex + 1); + return false; } + return true; }); // Remove delta should generate no new updates, but we still need to wait for the event to @@ -330,10 +324,12 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe } /** - * This test forces the viewer to reschedule pending content updates - * due to a remove event from the model. + * This test forces the viewer to reschedule pending content updates due to + * a remove event from the model. + * * @see org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider#rescheduleUpdates */ + @Test public void testRescheduleUpdates() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -369,6 +365,7 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe * - Process queued updates in order.<br> * </p> */ + @Test public void testCanceledUpdates1() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -406,6 +403,7 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe * - Process queued updates in REVERSE order.<br> * </p> */ + @Test public void testCanceledUpdates2() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -448,6 +446,7 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe * - Process queued updates in order.<br> * </p> */ + @Test public void testCanceledUpdates3() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -490,6 +489,7 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe * - Process queued updates in REVERSE order.<br> * </p> */ + @Test public void testCanceledUpdates4() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -533,12 +533,14 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe /** * This test removes an element while there are updates running on its - * sub-tree. With a precise timing this operation caused Bug 373790. + * sub-tree. With a precise timing this operation caused Bug 373790. * <p> * See Bug 373790 - Debug view stays busy after Resume * </p> + * * @see org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider#rescheduleUpdates */ + @Test public void testCancelUpdatesOnRemoveElementWhileUpdatingSubTree() throws Exception { TestModel model = TestModel.simpleMultiLevel(); fViewer.setAutoExpandLevel(-1); @@ -575,6 +577,7 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe * - Process queued updates in order.<br> * </p> */ + @Test public void testCanceledUpdatesOnSetInput() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); @@ -612,6 +615,7 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe * - Process queued updates in order.<br> * </p> */ + @Test public void testCanceledUpdatesOnSetNullInput() throws Exception { TestModel model = TestModel.simpleSingleLevel(); fViewer.setAutoExpandLevel(-1); diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java index af1434896..396eaa0ae 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java @@ -25,10 +25,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerContentTests extends ContentTests { - public VirtualViewerContentTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java index 2c68368f0..4b50bffec 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java @@ -25,10 +25,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerDeltaTests extends DeltaTests { - public VirtualViewerDeltaTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java index f0aff25a4..4c7d9c2de 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerFilterTests extends FilterTests { - public VirtualViewerFilterTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, SWT.VIRTUAL, new PresentationContext("TestViewer"), new VisibleVirtualItemValidator(0, 100)); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java index 8c95b7fba..fdc8acbaa 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java @@ -20,6 +20,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelV import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.junit.Test; /** * Tests which verify the operation of the virtual viewer in the lazy mode. @@ -30,10 +31,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerLazyModeTests extends AbstractViewerModelTest { - public VirtualViewerLazyModeTests(String name) { - super(name); - } - @Override protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) { return new TestModelUpdatesListener(viewer, false, false); @@ -44,6 +41,7 @@ public class VirtualViewerLazyModeTests extends AbstractViewerModelTest { return new VirtualTreeModelViewer(display, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$ } + @Test public void test() { // TODO } diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java index 6143a3184..ba308d9f4 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java @@ -26,10 +26,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerPerformanceTests extends PerformanceTests { - public VirtualViewerPerformanceTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, SWT.VIRTUAL, new PresentationContext("TestViewer"), fVirtualItemValidator); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java index fd07796f4..3834c93d4 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java @@ -25,10 +25,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerPopupTests extends PopupTests { - public VirtualViewerPopupTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell, int style) { return new VirtualTreeModelViewer(fDisplay, style, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java index 68100fab3..21cabcd27 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java @@ -25,10 +25,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerSelectionTests extends SelectionTests { - public VirtualViewerSelectionTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java index 1c39f0bb1..4aca898d5 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java @@ -25,10 +25,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerStateTests extends StateTests { - public VirtualViewerStateTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java index 42a69e80c..3450569fa 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java @@ -25,10 +25,6 @@ import org.eclipse.swt.widgets.Shell; */ public class VirtualViewerUpdateTests extends UpdateTests { - public VirtualViewerUpdateTests(String name) { - super(name); - } - @Override protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ |