Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2016-02-03 17:16:02 +0000
committerSopot Cela2016-02-03 17:16:02 +0000
commit79782e1b3df69cff447cb2c40093172cd769117b (patch)
tree8fc1f9b001e8c7817d80ecebd7ad7f8b9322a7ab /org.eclipse.ui.editors.tests/src
parent805de570454ef7bb1d956a147cdc9bc6b8faa0b9 (diff)
downloadeclipse.platform.text-79782e1b3df69cff447cb2c40093172cd769117b.tar.gz
eclipse.platform.text-79782e1b3df69cff447cb2c40093172cd769117b.tar.xz
eclipse.platform.text-79782e1b3df69cff447cb2c40093172cd769117b.zip
Bug 487095 - Move test bundles to JUnit 4
Change-Id: I1c249f6ccc23850c0cf3e992ff7f5805f44b7585 Signed-off-by: Sopot Cela <scela@redhat.com>
Diffstat (limited to 'org.eclipse.ui.editors.tests/src')
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ChainedPreferenceStoreTest.java35
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java30
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java31
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/GotoLineTest.java32
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java26
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java28
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ZoomTest.java20
7 files changed, 82 insertions, 120 deletions
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ChainedPreferenceStoreTest.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ChainedPreferenceStoreTest.java
index 77f822e8d..c2d33e3e5 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ChainedPreferenceStoreTest.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ChainedPreferenceStoreTest.java
@@ -11,12 +11,12 @@
package org.eclipse.ui.editors.tests;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceStore;
@@ -25,7 +25,7 @@ import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-public class ChainedPreferenceStoreTest extends TestCase {
+public class ChainedPreferenceStoreTest {
private class PropertyChangeListener implements IPropertyChangeListener {
@@ -43,14 +43,11 @@ public class ChainedPreferenceStoreTest extends TestCase {
private static final String DEFAULT_VALUE= "4";
private static final String DEFAULT_DEFAULT_VALUE= "";
- public static Test suite() {
- return new TestSuite(ChainedPreferenceStoreTest.class);
- }
-
/**
* [implementation] ChainedPreferenceStore
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=69419
*/
+ @Test
public void testChainedStore0() {
IPreferenceStore store1= new PreferenceStore();
IPreferenceStore store2= new PreferenceStore();
@@ -73,6 +70,7 @@ public class ChainedPreferenceStoreTest extends TestCase {
* Assertion failed in ChainedPreferenceStore.handlePropertyChangeEvent(..)
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=52827
*/
+ @Test
public void testChainedStore1() {
IPreferenceStore store1= new PreferenceStore();
IPreferenceStore store2= new PreferenceStore();
@@ -93,6 +91,7 @@ public class ChainedPreferenceStoreTest extends TestCase {
/**
* Third case where the initial implementation used to have an assertion which would fail in this case
*/
+ @Test
public void testChainedStore2() {
IPreferenceStore store1= new PreferenceStore();
IPreferenceStore store2= new PreferenceStore();
@@ -114,6 +113,7 @@ public class ChainedPreferenceStoreTest extends TestCase {
/**
* Case where the initial implementation used to throw an IAE
*/
+ @Test
public void testChainedStore3() {
IPreferenceStore store1= new PreferenceStore();
IPreferenceStore store2= new PreferenceStore();
@@ -132,23 +132,4 @@ public class ChainedPreferenceStoreTest extends TestCase {
assertEquals(DEFAULT_VALUE, event.getNewValue());
}
-// /**
-// * Case where the old value cannot be determined. (Not handled by the current implementation.)
-// */
-// public void testChainedStore4() {
-// IPreferenceStore store1= EditorsUI.getPreferenceStore();
-// IPreferenceStore store2= new PreferenceStore();
-// IPreferenceStore chainedStore= new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 });
-// store2.setDefault(PROPERTY, DEFAULT_VALUE);
-//
-// chainedStore.addPropertyChangeListener(fPropertyChangeListener);
-// store1.setValue(PROPERTY, VALUE);
-// chainedStore.removePropertyChangeListener(fPropertyChangeListener);
-//
-// assertEquals(1, fEvents.size());
-// PropertyChangeEvent event= (PropertyChangeEvent) fEvents.get(0);
-// assertEquals(PROPERTY, event.getProperty());
-// assertNull(event.getOldValue());
-// assertEquals(VALUE, event.getNewValue());
-// }
}
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java
index b2efda56e..7cac5a428 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EditorsTestSuite.java
@@ -11,26 +11,24 @@
*******************************************************************************/
package org.eclipse.ui.editors.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
/**
* Test Suite for org.eclipse.ui.editors.
*
* @since 3.0
*/
-public class EditorsTestSuite extends TestSuite {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Test Suite for org.eclipse.ui.editors"); //$NON-NLS-1$
- //$JUnit-BEGIN$
- suite.addTest(ChainedPreferenceStoreTest.suite());
- suite.addTest(EncodingChangeTests.suite());
- suite.addTest(GotoLineTest.suite());
- suite.addTest(SegmentedModeTest.suite());
- suite.addTest(MarkerAnnotationOrderTest.suite());
- suite.addTest(ZoomTest.suite());
- //$JUnit-END$
- return suite;
- }
+@RunWith(Suite.class)
+@SuiteClasses({
+ ChainedPreferenceStoreTest.class,
+ EncodingChangeTests.class,
+ GotoLineTest.class,
+ SegmentedModeTest.class,
+ MarkerAnnotationOrderTest.class,
+ ZoomTest.class
+})
+public class EditorsTestSuite {
+ //intentionally left blank
}
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java
index ad3feb1c2..4551beb93 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java
@@ -11,9 +11,11 @@
package org.eclipse.ui.editors.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StyledText;
@@ -52,15 +54,11 @@ import org.eclipse.ui.editors.text.TextEditor;
*
* @since 3.1
*/
-public class EncodingChangeTests extends TestCase {
+public class EncodingChangeTests {
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";
- public static Test suite() {
- return new TestSuite(EncodingChangeTests.class);
- }
-
public static void closeEditor(IEditorPart editor) {
IWorkbenchPartSite site;
IWorkbenchPage page;
@@ -77,22 +75,23 @@ public class EncodingChangeTests extends TestCase {
return ORIGINAL_CONTENT;
}
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
IFolder folder= ResourceHelper.createFolder("EncodingChangeTestProject/EncodingChangeTests/");
fFile= ResourceHelper.createFile(folder, "file" + fCount + ".txt", getOriginalContent());
fFile.setCharset(null, null);
fCount++;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
closeEditor(fEditor);
fEditor= null;
fFile= null;
ResourceHelper.deleteProject("EncodingChangeTestProject");
}
-
+
+ @Test
public void testChangeEncodingViaFile() {
IWorkbench workbench= PlatformUI.getWorkbench();
IWorkbenchPage page= workbench.getActiveWorkbenchWindow().getActivePage();
@@ -119,7 +118,8 @@ public class EncodingChangeTests extends TestCase {
fail();
}
}
-
+
+ @Test
public void testChangeEncodingViaEncodingSupport() {
IWorkbench workbench= PlatformUI.getWorkbench();
IWorkbenchPage page= workbench.getActiveWorkbenchWindow().getActivePage();
@@ -149,7 +149,8 @@ public class EncodingChangeTests extends TestCase {
fail();
}
}
-
+
+ @Test
public void testAInvalidEncoding() {
IWorkbench workbench= PlatformUI.getWorkbench();
IWorkbenchPage page= workbench.getActiveWorkbenchWindow().getActivePage();
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/GotoLineTest.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/GotoLineTest.java
index 32aee69b1..21064e305 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/GotoLineTest.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/GotoLineTest.java
@@ -10,9 +10,12 @@
*******************************************************************************/
package org.eclipse.ui.editors.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Control;
@@ -45,40 +48,39 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants;
*
* @since 3.1
*/
-public class GotoLineTest extends TestCase {
+public class GotoLineTest {
private static final String ORIGINAL_CONTENT= "line1\nline2\nline3";
- public static Test suite() {
- return new TestSuite(GotoLineTest.class);
- }
-
private IFile fFile;
private String getOriginalContent() {
return ORIGINAL_CONTENT;
}
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
IFolder folder= ResourceHelper.createFolder("GoToLineTestProject/goToLineTests/");
fFile= ResourceHelper.createFile(folder, "file.txt", getOriginalContent());
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
ResourceHelper.deleteProject("GoToLineTestProject");
fFile= null;
}
-
+
+ @Test
public void testGoToFirstLine() {
goToLine(0, 0);
}
-
+
+ @Test
public void testGoToLastLine() {
goToLine(2, 2);
}
-
+
+ @Test
public void testGoToInvalidLine() {
goToLine(1, 1);
goToLine(-1, 1);
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java
index 1da066152..c4e2f0420 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/MarkerAnnotationOrderTest.java
@@ -10,14 +10,15 @@
*******************************************************************************/
package org.eclipse.ui.editors.tests;
+import static org.junit.Assert.*;
+
import java.io.BufferedInputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.eclipse.core.runtime.ContributorFactorySimple;
@@ -40,18 +41,14 @@ import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.editors.text.EditorsUI;
-public class MarkerAnnotationOrderTest extends TestCase {
+public class MarkerAnnotationOrderTest {
IContributor pointContributor= null;
Object masterToken= null;
- public static Test suite() {
- return new TestSuite(MarkerAnnotationOrderTest.class);
- }
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
//add the marker updater extension point
IExtensionRegistry registry= Platform.getExtensionRegistry();
pointContributor= ContributorFactorySimple.createContributor(this);
@@ -71,8 +68,8 @@ public class MarkerAnnotationOrderTest extends TestCase {
}
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// remove the marker updater extension point
IExtensionRegistry registry= Platform.getExtensionRegistry();
IExtension[] extensions = registry.getExtensions(pointContributor);
@@ -82,6 +79,7 @@ public class MarkerAnnotationOrderTest extends TestCase {
}
}
+ @Test
public void testDirectDependency() {
final ArrayList<IStatus> list= new ArrayList<>(2);
Bundle bundle= Platform.getBundle(EditorsUI.PLUGIN_ID);
@@ -116,7 +114,7 @@ public class MarkerAnnotationOrderTest extends TestCase {
((Status)list.get(1)).getMessage());
}
-
+
public class TestMarkerAnnotationModel extends AbstractMarkerAnnotationModel {
@Override
protected IMarker[] retrieveMarkers() throws CoreException {
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java
index 498efc507..eac04e58a 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java
@@ -11,9 +11,11 @@
*******************************************************************************/
package org.eclipse.ui.editors.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Control;
@@ -36,34 +38,31 @@ import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.ITextEditor;
-public class SegmentedModeTest extends TestCase {
+public class SegmentedModeTest {
private static final String ORIGINAL_CONTENT= "this\nis\nthe\ncontent\nof\nthe\nfile";
- public static Test suite() {
- return new TestSuite(SegmentedModeTest.class);
- }
-
private IFile fFile;
private String getOriginalContent() {
return ORIGINAL_CONTENT;
}
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
IFolder folder= ResourceHelper.createFolder("project/folderA/folderB/");
fFile= ResourceHelper.createFile(folder, "file.txt", getOriginalContent());
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
ResourceHelper.deleteProject("project");
}
/*
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=70934
- */
+ */
+ @Test
public void testSegmentation() {
IWorkbench workbench= PlatformUI.getWorkbench();
IWorkbenchPage page= workbench.getActiveWorkbenchWindow().getActivePage();
@@ -100,7 +99,8 @@ public class SegmentedModeTest extends TestCase {
/*
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=465684
- */
+ */
+ @Test
public void testShowNothing() {
IWorkbench workbench= PlatformUI.getWorkbench();
IWorkbenchPage page= workbench.getActiveWorkbenchWindow().getActivePage();
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ZoomTest.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ZoomTest.java
index 5104e0b86..63733e06f 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ZoomTest.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/ZoomTest.java
@@ -19,8 +19,6 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.eclipse.test.OrderedTestSuite;
-
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Control;
@@ -41,14 +39,11 @@ import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.AbstractTextEditor;
-import junit.extensions.TestSetup;
-import junit.framework.TestCase;
-
/**
* @since 3.11
*
*/
-public class ZoomTest extends TestCase {
+public class ZoomTest {
private static IProject project;
private static IFile file;
@@ -71,10 +66,8 @@ public class ZoomTest extends TestCase {
project.delete(true, new NullProgressMonitor());
}
- @Override
@Before
public void setUp() throws Exception {
- super.setUp();
IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro();
if (intro != null) {
PlatformUI.getWorkbench().getIntroManager().closeIntro(intro);
@@ -110,15 +103,4 @@ public class ZoomTest extends TestCase {
}
}
- public static junit.framework.Test suite() {
- return new TestSetup(new OrderedTestSuite(ZoomTest.class)) {
- protected void setUp() throws Exception {
- ZoomTest.setUpBeforeClass();
- }
- protected void tearDown() throws Exception {
- ZoomTest.tearDownAfterClass();
- }
- };
- }
-
}

Back to the top