Skip to content

Commit 6ed2b3b

Browse files
committed
Replace UITestCase with test rule in remaining UI tests
1 parent 2a9d970 commit 6ed2b3b

38 files changed

+277
-363
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourcePathCopyTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
package org.eclipse.ui.tests.dialogs;
1616

1717
import static org.eclipse.ui.PlatformUI.getWorkbench;
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertNotNull;
21+
import static org.junit.Assert.assertTrue;
1822

1923
import java.awt.HeadlessException;
2024
import java.awt.Toolkit;
@@ -55,23 +59,20 @@
5559
import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage;
5660
import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage.ProjectRecord;
5761
import org.eclipse.ui.tests.TestPlugin;
62+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
5863
import org.eclipse.ui.tests.harness.util.DialogCheck;
5964
import org.eclipse.ui.tests.harness.util.EmptyPerspective;
6065
import org.eclipse.ui.tests.harness.util.FileUtil;
61-
import org.eclipse.ui.tests.harness.util.UITestCase;
66+
import org.junit.Rule;
6267
import org.junit.Test;
6368

64-
public class ResourcePathCopyTest extends UITestCase {
69+
public class ResourcePathCopyTest {
6570

6671
private static final String DATA_PATH_PREFIX = "data/org.eclipse.datatransferArchives/";
6772
private static final String ARCHIVE_JAVA_PROJECT = "helloworld";
6873

69-
/**
70-
* @param testName
71-
*/
72-
public ResourcePathCopyTest(String testName) {
73-
super(testName);
74-
}
74+
@Rule
75+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
7576

7677
@Test
7778
public void testPathCopy() throws CoreException, IOException, HeadlessException, UnsupportedFlavorException {

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIEditWorkingSetWizardAuto.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515

1616
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
1717
import static org.eclipse.ui.PlatformUI.getWorkbench;
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertNotNull;
21+
import static org.junit.Assert.assertNull;
22+
import static org.junit.Assert.assertSame;
23+
import static org.junit.Assert.assertTrue;
1824

1925
import java.util.List;
2026

@@ -37,22 +43,17 @@
3743
import org.eclipse.ui.internal.registry.WorkingSetRegistry;
3844
import org.eclipse.ui.tests.harness.util.ArrayUtil;
3945
import org.eclipse.ui.tests.harness.util.DialogCheck;
46+
import org.junit.After;
47+
import org.junit.Before;
4048
import org.junit.Test;
41-
import org.junit.runner.RunWith;
42-
import org.junit.runners.JUnit4;
4349

4450
/**
4551
* Tests the WorkingSetEditWizard
4652
* Tests input validation, presence of correct edit page and
4753
* wizard page texts.
4854
*/
49-
@RunWith(JUnit4.class)
5055
public class UIEditWorkingSetWizardAuto extends UIWorkingSetWizardsAuto<WorkingSetEditWizard> {
5156

52-
public UIEditWorkingSetWizardAuto() {
53-
super(UIEditWorkingSetWizardAuto.class.getSimpleName());
54-
}
55-
5657
@Override
5758
protected WorkingSetEditWizard createWizardToTest() {
5859
return new WorkingSetEditWizard(getDefaultEditPage());
@@ -149,15 +150,13 @@ public void testEditPage() throws Throwable {
149150
DialogCheck.assertDialogTexts(getWizardDialog());
150151
}
151152

152-
@Override
153-
public void doSetUp() throws Exception {
154-
super.doSetUp();
153+
@Before
154+
public final void disableAutoBuild() throws Exception {
155155
setAutoBuilding(false);
156156
}
157157

158-
@Override
159-
public void doTearDown() throws Exception {
160-
super.doTearDown();
158+
@After
159+
public final void restoreAutoBuild() throws Exception {
161160
ResourcesPlugin.getWorkspace().setDescription(Workspace.defaultWorkspaceDescription());
162161
}
163162

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UINewWorkingSetWizardAuto.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
package org.eclipse.ui.tests.dialogs;
1515

1616
import static org.eclipse.ui.PlatformUI.getWorkbench;
17+
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.assertFalse;
19+
import static org.junit.Assert.assertNotNull;
20+
import static org.junit.Assert.assertNull;
21+
import static org.junit.Assert.assertTrue;
1722

1823
import java.util.List;
1924

@@ -37,21 +42,14 @@
3742
import org.eclipse.ui.tests.harness.util.ArrayUtil;
3843
import org.eclipse.ui.tests.harness.util.DialogCheck;
3944
import org.junit.Test;
40-
import org.junit.runner.RunWith;
41-
import org.junit.runners.JUnit4;
4245

4346
/**
4447
* Tests the WorkingSetNewWizard.
4548
* Tests input validation, presence of type page and correct edit page
4649
* and wizard page texts.
4750
*/
48-
@RunWith(JUnit4.class)
4951
public class UINewWorkingSetWizardAuto extends UIWorkingSetWizardsAuto<IWorkingSetNewWizard> {
5052

51-
public UINewWorkingSetWizardAuto() {
52-
super(UINewWorkingSetWizardAuto.class.getSimpleName());
53-
}
54-
5553
@Override
5654
protected IWorkingSetNewWizard createWizardToTest() {
5755
return getWorkbench().getWorkingSetManager().createWorkingSetNewWizard(null);

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIWorkingSetWizardsAuto.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,17 @@
4545
import org.eclipse.ui.internal.registry.WorkingSetDescriptor;
4646
import org.eclipse.ui.internal.registry.WorkingSetRegistry;
4747
import org.eclipse.ui.tests.TestPlugin;
48+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
4849
import org.eclipse.ui.tests.harness.util.DialogCheck;
4950
import org.eclipse.ui.tests.harness.util.FileUtil;
50-
import org.eclipse.ui.tests.harness.util.UITestCase;
51+
import org.junit.After;
52+
import org.junit.Before;
53+
import org.junit.Rule;
5154

5255
/**
5356
* Abstract test class for the working set wizard tests.
5457
*/
55-
public abstract class UIWorkingSetWizardsAuto<W extends IWizard> extends UITestCase {
58+
public abstract class UIWorkingSetWizardsAuto<W extends IWizard> {
5659
protected static final String WORKING_SET_NAME_1 = "ws1";
5760

5861
protected static final String WORKING_SET_NAME_2 = "ws2";
@@ -61,6 +64,9 @@ public abstract class UIWorkingSetWizardsAuto<W extends IWizard> extends UITestC
6164

6265
private static final int SIZING_WIZARD_HEIGHT_2 = 500;
6366

67+
@Rule
68+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
69+
6470
private WizardDialog wizardDialog;
6571

6672
private W wizardToTest;
@@ -71,10 +77,6 @@ public abstract class UIWorkingSetWizardsAuto<W extends IWizard> extends UITestC
7177

7278
private IFile fileInProject2;
7379

74-
public UIWorkingSetWizardsAuto(String name) {
75-
super(name);
76-
}
77-
7880
protected WizardDialog getWizardDialog() {
7981
return wizardDialog;
8082
}
@@ -95,9 +97,8 @@ protected IFile getFileInProject2() {
9597
return fileInProject2;
9698
}
9799

98-
@Override
99-
protected void doSetUp() throws Exception {
100-
super.doSetUp();
100+
@Before
101+
public final void setUp() throws Exception {
101102
wizardToTest = createWizardToTest();
102103
wizardDialog = createWizardDialog();
103104
initializeTestResources();
@@ -122,12 +123,11 @@ private void initializeTestResources() throws CoreException {
122123
fileInProject2 = FileUtil.createFile("f2.txt", project2);
123124
}
124125

125-
@Override
126-
protected void doTearDown() throws Exception {
126+
@After
127+
public final void tearDown() throws Exception {
127128
removeAllWorkingSets();
128129
cleanupWorkspace();
129130
disposeWizardAndDialog();
130-
super.doTearDown();
131131
}
132132

133133
private void removeAllWorkingSets() {

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroTest.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
package org.eclipse.ui.tests.intro;
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
17+
import static org.junit.Assert.assertFalse;
18+
import static org.junit.Assert.assertNotNull;
19+
import static org.junit.Assert.assertNull;
20+
import static org.junit.Assert.assertTrue;
1721

1822
import org.eclipse.jface.preference.IPreferenceStore;
1923
import org.eclipse.ui.IPageLayout;
@@ -32,19 +36,21 @@
3236
import org.eclipse.ui.internal.util.PrefUtil;
3337
import org.eclipse.ui.intro.IIntroManager;
3438
import org.eclipse.ui.intro.IIntroPart;
39+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
3540
import org.eclipse.ui.tests.harness.util.EmptyPerspective;
3641
import org.eclipse.ui.tests.harness.util.PreferenceMementoRule;
37-
import org.eclipse.ui.tests.harness.util.UITestCase;
42+
import org.junit.After;
43+
import org.junit.Before;
3844
import org.junit.Rule;
3945
import org.junit.Test;
40-
import org.junit.runner.RunWith;
41-
import org.junit.runners.JUnit4;
4246

4347
/**
4448
* @since 3.0
4549
*/
46-
@RunWith(JUnit4.class)
47-
public class IntroTest extends UITestCase {
50+
public class IntroTest {
51+
52+
@Rule
53+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
4854

4955
@Rule
5056
public final PreferenceMementoRule preferenceMemento = new PreferenceMementoRule();
@@ -53,10 +59,6 @@ public class IntroTest extends UITestCase {
5359

5460
private IntroDescriptor oldDesc;
5561

56-
public IntroTest() {
57-
super(IntroTest.class.getSimpleName());
58-
}
59-
6062
@Test
6163
public void testCloseInEmptyPerspective() {
6264
testClose(EmptyPerspective.PERSP_ID);
@@ -241,10 +243,8 @@ public void testViewClosure() {
241243
assertNull(workbench.getIntroManager().getIntro());
242244
}
243245

244-
@Override
245-
protected void doSetUp() throws Exception {
246-
super.doSetUp();
247-
246+
@Before
247+
public final void setUp() throws Exception {
248248
// these tests rely on the 3.2 behavior for sticky views
249249
IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
250250
preferenceStore.putValue(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR, "true");
@@ -257,9 +257,8 @@ protected void doSetUp() throws Exception {
257257
window = openTestWindow();
258258
}
259259

260-
@Override
261-
protected void doTearDown() throws Exception {
262-
super.doTearDown();
260+
@After
261+
public final void tearDown() throws Exception {
263262
Workbench.getInstance().setIntroDescriptor(oldDesc);
264263
}
265264
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/intro/IntroTest2.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
package org.eclipse.ui.tests.intro;
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
17+
import static org.junit.Assert.assertNotNull;
18+
import static org.junit.Assert.assertNull;
1719

1820
import org.eclipse.jface.preference.IPreferenceStore;
1921
import org.eclipse.ui.IPerspectiveDescriptor;
@@ -28,25 +30,24 @@
2830
import org.eclipse.ui.internal.intro.IntroDescriptor;
2931
import org.eclipse.ui.internal.util.PrefUtil;
3032
import org.eclipse.ui.intro.IIntroPart;
31-
import org.eclipse.ui.tests.harness.util.UITestCase;
33+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
34+
import org.junit.After;
35+
import org.junit.Before;
36+
import org.junit.Rule;
3237
import org.junit.Test;
33-
import org.junit.runner.RunWith;
34-
import org.junit.runners.JUnit4;
3538

3639
/**
3740
* @since 3.0
3841
*/
39-
@RunWith(JUnit4.class)
40-
public class IntroTest2 extends UITestCase {
42+
public class IntroTest2 {
43+
44+
@Rule
45+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
4146

4247
IWorkbenchWindow window = null;
4348

4449
private IntroDescriptor oldDesc;
4550

46-
public IntroTest2() {
47-
super(IntroTest2.class.getSimpleName());
48-
}
49-
5051
/**
5152
* Open the intro, change perspective, close the intro
5253
* and ensure that the intro has been closed in the
@@ -80,10 +81,8 @@ public void testPerspectiveChangeWith33StickyBehavior() {
8081

8182
}
8283

83-
@Override
84-
protected void doSetUp() throws Exception {
85-
super.doSetUp();
86-
84+
@Before
85+
public final void setUp() throws Exception {
8786
// these tests rely on the 3.3 behavior for sticky views
8887
IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
8988
preferenceStore.putValue(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR, "false");
@@ -96,9 +95,8 @@ protected void doSetUp() throws Exception {
9695
window = openTestWindow();
9796
}
9897

99-
@Override
100-
protected void doTearDown() throws Exception {
101-
super.doTearDown();
98+
@After
99+
public final void tearDown() throws Exception {
102100
Workbench.getInstance().setIntroDescriptor(oldDesc);
103101
}
104102
}

0 commit comments

Comments
 (0)