Skip to content

Junit4 rule testutil migration #3031

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -20,6 +20,7 @@
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.swt.custom.StyledText;
Expand Down Expand Up @@ -58,6 +59,10 @@
import org.eclipse.ui.editors.tests.TestUtil;

public class CodeMiningTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private static String PROJECT_NAME = "test_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());

private static IProject project;
Expand All @@ -80,7 +85,6 @@ public void after() {
drainEventQueue();
CodeMiningTestProvider.provideContentMiningAtOffset = -1;
CodeMiningTestProvider.provideHeaderMiningAtLine = -1;
TestUtil.cleanUp();
}

private static void closeAllEditors() {
Expand Down Expand Up @@ -357,4 +361,4 @@ private final boolean waitForCondition(Display display, long timeout, Callable<B
} while (!cond && diff < timeout);
return cond;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.core.runtime.NullProgressMonitor;
Expand Down Expand Up @@ -50,6 +51,9 @@ public class CaseActionTest {
private static IFile file;
private AbstractTextEditor editor;

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

@BeforeClass
public static void setUpBeforeClass() throws Exception {
project = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
Expand All @@ -63,7 +67,6 @@ public static void setUpBeforeClass() throws Exception {
public static void tearDownAfterClass() throws Exception {
file.delete(true, new NullProgressMonitor());
project.delete(true, new NullProgressMonitor());
TestUtil.cleanUp();
}

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.jface.preference.IPreferenceStore;
Expand All @@ -31,6 +31,9 @@

public class ChainedPreferenceStoreTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private class PropertyChangeListener implements IPropertyChangeListener {

@Override
Expand All @@ -47,10 +50,6 @@ public void propertyChange(PropertyChangeEvent event) {
private static final String DEFAULT_VALUE= "4";
private static final String DEFAULT_DEFAULT_VALUE= "";

@After
public void tearDown() {
TestUtil.cleanUp();
}

/**
* [implementation] ChainedPreferenceStore
Expand Down Expand Up @@ -140,4 +139,4 @@ public void testChainedStore3() {
assertEquals(null, event.getOldValue());
assertEquals(DEFAULT_VALUE, event.getNewValue());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ public class DocumentProviderRegistryTest {
@Rule
public TemporaryFolder tmp = new TemporaryFolder();

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private IFile file;

@After
public void tearDown() throws Exception {
if (file != null) {
ResourceHelper.delete(file.getProject());
}
TestUtil.cleanUp();
}

@Test
Expand Down Expand Up @@ -81,4 +83,4 @@ public static class TestDocumentProvider extends TextFileDocumentProvider {
// found the right one.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.swt.custom.ScrolledComposite;
Expand Down Expand Up @@ -61,6 +62,9 @@
*/
public class EncodingChangeTests {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private static final String NON_DEFAULT_ENCODING= "US-ASCII".equals(ResourcesPlugin.getEncoding()) ? "ISO-8859-1" : "US-ASCII";
private static final String ORIGINAL_CONTENT= "line1\nline2\nline3";

Expand Down Expand Up @@ -94,7 +98,6 @@ public void tearDown() throws Exception {
fEditor= null;
fFile= null;
ResourceHelper.deleteProject("EncodingChangeTestProject");
TestUtil.cleanUp();
}

@Test
Expand Down Expand Up @@ -186,4 +189,4 @@ public void testAInvalidEncoding() {
fail();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -73,6 +74,9 @@
*/
public class FileDocumentProviderTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private File file;
private AtomicBoolean stoppedByTest;
private AtomicBoolean stopLockingFlag;
Expand Down Expand Up @@ -136,8 +140,6 @@ public void tearDown() throws Exception {
page.closeEditor(editor, false);
}
ResourceHelper.deleteProject(file.getProject().getName());
TestUtil.runEventLoop();
TestUtil.cleanUp();
}

@Test
Expand Down Expand Up @@ -432,4 +434,4 @@ public IStatus run2() {
}
return Status.OK_STATUS;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.osgi.framework.FrameworkUtil;

Expand Down Expand Up @@ -52,6 +53,10 @@
import org.eclipse.ui.texteditor.FindReplaceAction;

public class FindNextActionTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private static final String TEST_PROJECT_NAME = "TestProject";

private static final String BUNDLE_FOR_CONSTRUCTED_KEYS_NAME = "org.eclipse.ui.texteditor.ConstructedEditorMessages";//$NON-NLS-1$
Expand Down Expand Up @@ -103,7 +108,6 @@ public void tearDown() throws Exception {
editor = null;
project.delete(true, null);
project = null;
TestUtil.cleanUp();
}

private void resetInitialSearchSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.swt.custom.StyledText;
Expand Down Expand Up @@ -53,6 +54,9 @@
*/
public class GotoLineTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private static final String ORIGINAL_CONTENT= "line1\nline2\nline3";

private IFile fFile;
Expand All @@ -71,7 +75,6 @@ public void setUp() throws Exception {
public void tearDown() throws Exception {
ResourceHelper.deleteProject("GoToLineTestProject");
fFile= null;
TestUtil.cleanUp();
}

@Test
Expand Down Expand Up @@ -122,4 +125,4 @@ private void goToLine(int line, int expectedResult) {
fail();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -51,6 +52,9 @@
*/
public class LargeFileTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private IFile fLargeFile;

private IPreferenceStore preferenceStore;
Expand Down Expand Up @@ -84,7 +88,6 @@ public void tearDown() throws Exception {
ResourceHelper.deleteProject("LargeFileTestProject");
fLargeFile= null;
preferenceStore.setValue(AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED, initialWordWrap);
TestUtil.cleanUp();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.osgi.framework.Bundle;

Expand All @@ -46,6 +47,9 @@

public class MarkerAnnotationOrderTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

IContributor pointContributor= null;

Object masterToken= null;
Expand Down Expand Up @@ -81,7 +85,6 @@ public void tearDown() throws Exception {
registry.removeExtension(extension, masterToken);
}
}
TestUtil.cleanUp();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.swt.custom.StyledText;
Expand All @@ -44,6 +45,9 @@

public class SegmentedModeTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private static final String ORIGINAL_CONTENT= "this\nis\nthe\ncontent\nof\nthe\nfile";

private IFile fFile;
Expand All @@ -61,7 +65,6 @@ public void setUp() throws Exception {
@After
public void tearDown() throws Exception {
ResourceHelper.deleteProject("project");
TestUtil.cleanUp();
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.eclipse.swt.custom.CTabFolder;
Expand Down Expand Up @@ -51,6 +52,10 @@
import org.eclipse.ui.editors.text.TextEditor;

public class StatusEditorTest {

@Rule
public TestUtil.CleanupRule cleanup = new TestUtil.CleanupRule();

private IWorkbenchWindow window;
private Display display;
private IWorkbenchPage page;
Expand All @@ -67,8 +72,6 @@ public void before() throws WorkbenchException {
public void after() {
window.close();
page = null;
processEvents();
TestUtil.cleanUp();
}

/*
Expand Down
Loading
Loading