Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Ant UI tests to JUnit 4 #753

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.debug;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.eclipse.ant.internal.launching.debug.model.AntDebugTarget;
import org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint;
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
Expand Down Expand Up @@ -56,6 +60,10 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.IHyperlink;
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

/**
* Tests for launch configurations
Expand All @@ -65,18 +73,29 @@ public abstract class AbstractAntDebugTest extends AbstractAntUIBuildTest {

public static final int DEFAULT_TIMEOUT = 20000;

private static boolean wasAutomatedModeEnabled;
private static boolean wasIgnoreErrorEnabled;

/**
* The last relevant event set - for example, that caused a thread to suspend
*/
protected DebugEvent[] fEventSet;

public AbstractAntDebugTest(String name) {
super(name);
@BeforeClass
public static void setupClass() {
// set error dialog to non-blocking to avoid hanging the UI during test
wasAutomatedModeEnabled = ErrorDialog.AUTOMATED_MODE;
ErrorDialog.AUTOMATED_MODE = true;
wasIgnoreErrorEnabled = SafeRunnable.getIgnoreErrors();
SafeRunnable.setIgnoreErrors(true);
}

@AfterClass
public static void teardownClass() {
ErrorDialog.AUTOMATED_MODE = wasAutomatedModeEnabled;
SafeRunnable.setIgnoreErrors(wasIgnoreErrorEnabled);
}

/**
* Sets the last relevant event set
*
Expand Down Expand Up @@ -785,8 +804,8 @@ protected void setPreferences() {
debugUIPreferences.setValue(IDebugUIConstants.PREF_ACTIVATE_WORKBENCH, activate);
}

@Override
protected void tearDown() throws Exception {
@After
public void tearDown() throws Exception {
if (fEventSet != null) {
fEventSet = null;
}
Expand All @@ -796,11 +815,11 @@ protected void tearDown() throws Exception {
debugUIPreferences.setToDefault(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT);
debugUIPreferences.setToDefault(IInternalDebugUIConstants.PREF_ACTIVATE_DEBUG_VIEW);
debugUIPreferences.setToDefault(IDebugUIConstants.PREF_ACTIVATE_WORKBENCH);
super.tearDown();
}

@Before
@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
setPreferences();
DebugUIPlugin.getStandardDisplay().syncExec(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.debug;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -27,20 +31,19 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.ILineBreakpoint;
import org.junit.Test;

/**
* Tests Ant breakpoints.
*/
public class BreakpointTests extends AbstractAntDebugTest {

public BreakpointTests(String name) {
super(name);
}

@Test
public void testDeferredBreakpoints() throws Exception {
deferredBreakpoints(false);
}

@Test
public void testDeferredBreakpointsSepVM() throws Exception {
deferredBreakpoints(true);
}
Expand Down Expand Up @@ -80,10 +83,12 @@ private void deferredBreakpoints(boolean sepVM) throws Exception, CoreException,
}
}

@Test
public void testDisabledBreakpoint() throws Exception {
disabledBreakpoint(false);
}

@Test
public void testDisabledBreakpointSepVM() throws Exception {
disabledBreakpoint(true);
}
Expand All @@ -102,10 +107,12 @@ private void disabledBreakpoint(boolean separateVM) throws Exception, CoreExcept
}
}

@Test
public void testEnableDisableBreakpoint() throws Exception {
enableDisableBreapoint(false);
}

@Test
public void testEnableDisableBreakpointSepVM() throws Exception {
enableDisableBreapoint(true);
}
Expand Down Expand Up @@ -141,10 +148,12 @@ private synchronized void waitForTarget() throws InterruptedException {
wait(1000);
}

@Test
public void testSkipLineBreakpoint() throws Exception {
skipLineBreakpoint(false);
}

@Test
public void testSkipLineBreakpointSepVM() throws Exception {
skipLineBreakpoint(true);
}
Expand All @@ -170,26 +179,32 @@ private void skipLineBreakpoint(boolean sepVM) throws Exception {
}
}

@Test
public void testBreakpoint() throws Exception {
breakpoints(false, "default", 5, 15); //$NON-NLS-1$
}

@Test
public void testBreakpointSepVM() throws Exception {
breakpoints(true, "default", 5, 15); //$NON-NLS-1$
}

@Test
public void testTargetBreakpoint() throws Exception {
breakpoints(false, "entry2", 4, 24); //$NON-NLS-1$
}

@Test
public void testTaskOutOfTargetBreakpoint() throws Exception {
breakpoints(false, "entry2", 36, 5); //$NON-NLS-1$
}

@Test
public void testTaskOutOfTargetBreakpointSepVm() throws Exception {
breakpoints(true, "entry2", 36, 5); //$NON-NLS-1$
}

@Test
public void testTargetBreakpointSepVM() throws Exception {
breakpoints(true, "entry2", 4, 24); //$NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.debug;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.eclipse.ant.internal.launching.debug.model.AntProperty;
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
import org.eclipse.ant.internal.launching.debug.model.AntThread;
Expand All @@ -25,6 +29,7 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.debug.core.model.IVariable;
import org.junit.Test;
import org.osgi.framework.Version;

public class PropertyTests extends AbstractAntDebugTest {
Expand All @@ -37,14 +42,12 @@ public class PropertyTests extends AbstractAntDebugTest {
+ antVersion.getMicro();
}

public PropertyTests(String name) {
super(name);
}

@Test
public void testSystemProperties() throws Exception {
systemProperties(false);
}

@Test
public void testSystemPropertiesSepVM() throws Exception {
systemProperties(true);
}
Expand Down Expand Up @@ -75,10 +78,12 @@ private void systemProperties(boolean sepVM) throws Exception, CoreException {
}
}

@Test
public void testUserProperties() throws Exception {
userProperties(false);
}

@Test
public void testUserPropertiesSepVM() throws Exception {
userProperties(true);
}
Expand Down Expand Up @@ -110,6 +115,7 @@ private void userProperties(boolean sepVM) throws Exception {
}
}

@Test
public void testRuntimeProperties() throws Exception {
runtimeProperties(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ant.tests.ui.debug;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint;
import org.eclipse.ant.internal.launching.debug.model.AntThread;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -35,17 +38,14 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.junit.Test;

/**
* Tests run to line debug functionality
*/
@SuppressWarnings("restriction")
public class RunToLineTests extends AbstractAntDebugTest {

public RunToLineTests(String name) {
super(name);
}

private final Object fLock = new Object();
private IEditorPart fEditor = null;

Expand Down Expand Up @@ -79,6 +79,7 @@ public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor persp
*
* @throws Exception
*/
@Test
public void testRunToLine() throws Exception {
runToLine(14, 14, true, false);
}
Expand All @@ -88,6 +89,7 @@ public void testRunToLine() throws Exception {
*
* @throws Exception
*/
@Test
public void testRunToLineSepVM() throws Exception {
runToLine(14, 14, true, true);
}
Expand All @@ -97,6 +99,7 @@ public void testRunToLineSepVM() throws Exception {
*
* @throws Exception
*/
@Test
public void testRunToLineSkipBreakpoint() throws Exception {
createLineBreakpoint(6, "breakpoints.xml"); //$NON-NLS-1$
runToLine(14, 14, true, false);
Expand All @@ -108,6 +111,7 @@ public void testRunToLineSkipBreakpoint() throws Exception {
*
* @throws Exception
*/
@Test
public void testRunToLineSkipBreakpointSepVM() throws Exception {
createLineBreakpoint(6, "breakpoints.xml"); //$NON-NLS-1$
runToLine(14, 14, true, true);
Expand All @@ -118,6 +122,7 @@ public void testRunToLineSkipBreakpointSepVM() throws Exception {
*
* @throws Exception
*/
@Test
public void testRunToLineHitBreakpoint() throws Exception {
createLineBreakpoint(6, "breakpoints.xml"); //$NON-NLS-1$
runToLine(14, 6, false, false);
Expand All @@ -128,6 +133,7 @@ public void testRunToLineHitBreakpoint() throws Exception {
*
* @throws Exception
*/
@Test
public void testRunToLineHitBreakpointSepVM() throws Exception {
createLineBreakpoint(6, "breakpoints.xml"); //$NON-NLS-1$
runToLine(14, 6, false, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.debug;

import static org.junit.Assert.assertTrue;

import org.eclipse.ant.internal.launching.debug.model.AntThread;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.debug.core.model.IStackFrame;
import org.junit.Test;

public class StackTests extends AbstractAntDebugTest {

public StackTests(String name) {
super(name);
}

@Test
public void testStackForAntCall() throws Exception {
antCallStack(false);
}

@Test
public void testStackForAntCallVM() throws Exception {
antCallStack(true);
}
Expand Down
Loading
Loading