Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2016-02-03 10:16:39 -0500
committerSopot Cela2016-02-03 10:16:39 -0500
commitfec66960072003e3f884ea68ed4f19ea82dce76e (patch)
treec264a0ca9744c7d359bbcf53b127b61b4b3f18b4 /org.eclipse.search.tests
parentb0506297da6a094d95545ef5aa683ea71091420c (diff)
downloadeclipse.platform.text-fec66960072003e3f884ea68ed4f19ea82dce76e.tar.gz
eclipse.platform.text-fec66960072003e3f884ea68ed4f19ea82dce76e.tar.xz
eclipse.platform.text-fec66960072003e3f884ea68ed4f19ea82dce76e.zip
Bug 487095 - Move test bundles to JUnit 4
Change-Id: I9f1bf08e859ec436d67760db20f17d643683bada Signed-off-by: Sopot Cela <scela@redhat.com>
Diffstat (limited to 'org.eclipse.search.tests')
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java29
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java11
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java21
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java25
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java57
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java49
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java53
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java85
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java60
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java41
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java37
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java37
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java42
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java34
14 files changed, 230 insertions, 351 deletions
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java
index 0b89109f0..05c483be3 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/AllSearchModelTests.java
@@ -10,27 +10,16 @@
*******************************************************************************/
package org.eclipse.search.core.tests;
-import junit.framework.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
import junit.framework.TestSuite;
+@RunWith(Suite.class)
+@SuiteClasses({QueryManagerTest.class,
+ TestSearchResult.class,
+ LineConversionTest.class})
public class AllSearchModelTests extends TestSuite {
-
- /*
- * Returns the suite. This is required to
- * use the JUnit Launcher.
- */
- public static Test suite() {
- return new AllSearchModelTests();
- }
-
- /**
- * Construct the test suite.
- */
- public AllSearchModelTests() {
- addTest(new TestSuite(QueryManagerTest.class));
- addTest(new TestSuite(TestSearchResult.class));
- addTest(new TestSuite(QueryManagerTest.class));
- addTest(new TestSuite(LineConversionTest.class));
- }
-
+ //intentionally left empty
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
index b846ab5a0..74b84cbdf 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/QueryManagerTest.java
@@ -10,7 +10,10 @@
*******************************************************************************/
package org.eclipse.search.core.tests;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
import org.eclipse.search.ui.IQueryListener;
import org.eclipse.search.ui.ISearchQuery;
@@ -18,7 +21,9 @@ import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search2.internal.ui.InternalSearchUI;
-public class QueryManagerTest extends TestCase {
+public class QueryManagerTest {
+
+ @Test
public void testRemoveQuery() {
ISearchQuery query= new NullQuery();
InternalSearchUI.getInstance().addQuery(query);
@@ -30,6 +35,7 @@ public class QueryManagerTest extends TestCase {
}
}
+ @Test
public void testAddQuery() {
ISearchQuery query= new NullQuery();
InternalSearchUI.getInstance().addQuery(query);
@@ -41,6 +47,7 @@ public class QueryManagerTest extends TestCase {
assertTrue(false);
}
+ @Test
public void testQueryListener() {
final boolean [] wasAdded= { false };
final boolean [] wasRemoved= { false };
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
index dcf767326..6bc3e15ea 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/TestSearchResult.java
@@ -10,7 +10,12 @@
*******************************************************************************/
package org.eclipse.search.core.tests;
-import junit.framework.TestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.ISearchResultListener;
@@ -19,8 +24,9 @@ import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.Match;
import org.eclipse.search.ui.text.MatchEvent;
-public class TestSearchResult extends TestCase {
+public class TestSearchResult {
+ @Test
public void testAddMatch() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
@@ -37,6 +43,7 @@ public class TestSearchResult extends TestCase {
assertEquals(result.getMatchCount(), 2);
}
+ @Test
public void testAddMatchDifferentStart() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
@@ -56,6 +63,7 @@ public class TestSearchResult extends TestCase {
assertTrue("matches[2]", matches[2] == match1);
}
+ @Test
public void testAddMatchDifferentStartInOrder() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
@@ -75,6 +83,7 @@ public class TestSearchResult extends TestCase {
assertTrue("matches[2]", matches[2] == match3);
}
+ @Test
public void testAddMatchDifferentLength() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
@@ -91,6 +100,7 @@ public class TestSearchResult extends TestCase {
assertTrue("matches[1]", matches[1] == match1);
}
+ @Test
public void testAddMatchOrderPreserving() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
@@ -107,8 +117,7 @@ public class TestSearchResult extends TestCase {
assertTrue("matches[1]", matches[1] == match2);
}
-
-
+ @Test
public void testAddMatches() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
@@ -123,6 +132,7 @@ public class TestSearchResult extends TestCase {
assertEquals(result.getMatchCount(), 2);
}
+ @Test
public void testRemoveMatch() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
@@ -142,6 +152,7 @@ public class TestSearchResult extends TestCase {
}
+ @Test
public void testRemoveMatches() {
ISearchQuery query= new NullQuery();
AbstractTextSearchResult result= (AbstractTextSearchResult) query.getSearchResult();
@@ -158,6 +169,7 @@ public class TestSearchResult extends TestCase {
}
+ @Test
public void testMatchEvent() {
final boolean [] wasAdded= { false };
final boolean [] wasRemoved= { false };
@@ -201,6 +213,7 @@ public class TestSearchResult extends TestCase {
assertFalse(wasRemoved[0]);
}
+ @Test
public void testBatchedMatchEvent() {
final boolean [] wasAdded= { false };
final boolean [] wasRemoved= { false };
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java
index d620ef675..8c4ae7cca 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/AllSearchTests.java
@@ -10,20 +10,17 @@
*******************************************************************************/
package org.eclipse.search.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.search.tests.filesearch.AllFileSearchTests;
-import org.eclipse.search.core.tests.AllSearchModelTests;
-
-public class AllSearchTests extends TestSuite {
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
- public static Test suite() {
- return new AllSearchTests();
- }
-
- public AllSearchTests() {
- addTest(AllFileSearchTests.suite());
- addTest(AllSearchModelTests.suite());
- }
+import org.eclipse.search.core.tests.AllSearchModelTests;
+import org.eclipse.search.tests.filesearch.AllFileSearchTests;
+@RunWith(Suite.class)
+@SuiteClasses({AllFileSearchTests.class,
+ AllSearchModelTests.class
+})
+public class AllSearchTests {
+ //intentionally left blank
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java
index ebbca4a73..3708c55ab 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AllFileSearchTests.java
@@ -10,27 +10,46 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
-public class AllFileSearchTests extends TestSuite {
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
- public static Test suite() {
- return new AllFileSearchTests();
- }
+import org.eclipse.search.tests.ResourceHelper;
- public AllFileSearchTests() {
-
- TestSuite suite= new TestSuite();
- suite.addTest(AnnotationManagerTest.allTests());
- suite.addTest(FileSearchTests.allTests());
- suite.addTest(LineAnnotationManagerTest.allTests());
- suite.addTest(PositionTrackerTest.allTests());
- suite.addTest(ResultUpdaterTest.allTests());
- suite.addTest(SearchResultPageTest.allTests());
- suite.addTest(SortingTest.allTests());
-
- addTest(new JUnitSourceSetup(suite));
- }
+@RunWith(Suite.class)
+@SuiteClasses({
+ AnnotationManagerTest.class,
+ FileSearchTests.class,
+ LineAnnotationManagerTest.class,
+ PositionTrackerTest.class,
+ ResultUpdaterTest.class,
+ SearchResultPageTest.class,
+ SortingTest.class
+})
+public class AllFileSearchTests {
+
+ public static final String STANDARD_PROJECT_NAME= "JUnitSource";
+
+ private static IProject fProject;
+ @BeforeClass
+ public static void globalSetUp() throws Exception {
+ IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(STANDARD_PROJECT_NAME);
+ if (!project.exists()) { // allow nesting of JUnitSetups
+ fProject= ResourceHelper.createJUnitSourceProject(STANDARD_PROJECT_NAME);
+ }
+ }
+
+ @AfterClass
+ public static void globalTearDown() throws Exception {
+ if (fProject != null) { // delete only by the setup who created the project
+ ResourceHelper.deleteProject(STANDARD_PROJECT_NAME);
+ fProject= null;
+ }
+ }
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
index 1c98bdb66..05143ed89 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
@@ -10,9 +10,16 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashSet;
import java.util.Iterator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -39,35 +46,14 @@ import org.eclipse.search.ui.text.Match;
import org.eclipse.search2.internal.ui.InternalSearchUI;
import org.eclipse.search2.internal.ui.text.EditorAnnotationManager;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class AnnotationManagerTest extends TestCase {
+public class AnnotationManagerTest {
private FileSearchQuery fQuery1;
private FileSearchQuery fQuery2;
private AnnotationTypeLookup fAnnotationTypeLookup= EditorsUI.getAnnotationTypeLookup();
- public AnnotationManagerTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(AnnotationManagerTest.class));
- }
-
- public static Test suite() {
- return allTests();
- }
-
- public static Test setUpTest(Test test) {
- return new JUnitSourceSetup(test);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() {
SearchTestPlugin.ensureWelcomePageClosed();
EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLIGHTER_ANNOTATION);
String[] fileNamePattern= { "*.java" };
@@ -76,17 +62,17 @@ public class AnnotationManagerTest extends TestCase {
fQuery2= new FileSearchQuery("Test", false, true, scope); //$NON-NLS-1$//$NON-NLS-2$
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() {
InternalSearchUI.getInstance().removeAllQueries();
fQuery1= null;
fQuery2= null;
EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLLIGHTER_ANY);
- super.tearDown();
}
-
+
+ @Test
public void testAddAnnotation() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
@@ -118,6 +104,7 @@ public class AnnotationManagerTest extends TestCase {
}
}
+ @Test
public void testBogusAnnotation() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
FileSearchResult result= (FileSearchResult) fQuery1.getSearchResult();
@@ -126,6 +113,7 @@ public class AnnotationManagerTest extends TestCase {
result.addMatch(new FileMatch(file));
}
+ @Test
public void testRemoveQuery() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
@@ -151,7 +139,7 @@ public class AnnotationManagerTest extends TestCase {
}
}
-
+ @Test
public void testReplaceQuery() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
@@ -178,7 +166,8 @@ public class AnnotationManagerTest extends TestCase {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
-
+
+ @Test
public void testSwitchQuery() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java
index 0a20f6679..21bb28c3d 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileCharSequenceTests.java
@@ -10,11 +10,14 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
+import static org.junit.Assert.assertFalse;
+
import java.io.IOException;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.core.runtime.CoreException;
@@ -25,39 +28,23 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.search.internal.core.text.FileCharSequenceProvider;
import org.eclipse.search.tests.ResourceHelper;
-public class FileCharSequenceTests extends TestCase {
+public class FileCharSequenceTests {
private final String TEST_CONTENT= "ABCDEFGHIJKLMNOPQRSTUVWXYZÜöäüèéùabcdefghijklmnopqrstuvwxyz1234567890@\'\"\n$¢"; //€
private IProject fProject;
- public FileCharSequenceTests(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(FileCharSequenceTests.class));
- }
-
- public static Test setUpTest(Test test) {
- return new JUnitSourceSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fProject= ResourceHelper.createProject("my-project"); //$NON-NLS-1$
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
ResourceHelper.deleteProject("my-project"); //$NON-NLS-1$
}
-
+ @Test
public void testFileCharSequence() throws Exception {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < 500; i++) {
@@ -66,7 +53,8 @@ public class FileCharSequenceTests extends TestCase {
String encoding= "ISO-8859-1";
testForEncoding(buf, encoding);
}
-
+
+ @Test
public void testFileCharSequence2() throws Exception {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < 2000; i++) {
@@ -75,7 +63,8 @@ public class FileCharSequenceTests extends TestCase {
String encoding= "UTF-8";
testForEncoding(buf, encoding);
}
-
+
+ @Test
public void testFileCharSequence3() throws Exception {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < FileCharSequenceProvider.BUFFER_SIZE * 2; i++) {
@@ -124,17 +113,17 @@ public class FileCharSequenceTests extends TestCase {
private void assertEquals(String desc, CharSequence actual, CharSequence expected) {
for (int i= 0; i < expected.length(); i++) {
- assertEquals(desc + " - forward " + i, expected.charAt(i), actual.charAt(i));
+ Assert.assertEquals(desc + " - forward " + i, expected.charAt(i), actual.charAt(i));
}
- assertEquals(desc + " - length", expected.length(), actual.length());
+ Assert.assertEquals(desc + " - length", expected.length(), actual.length());
for (int i= expected.length() - 1; i >= 0; i--) {
- assertEquals(desc + " - backward " + i, expected.charAt(i), actual.charAt(i));
+ Assert.assertEquals(desc + " - backward " + i, expected.charAt(i), actual.charAt(i));
}
for (int i= 0; i < expected.length(); i+= 567) {
- assertEquals(desc + " - forward - steps" + i, expected.charAt(i), actual.charAt(i));
+ Assert.assertEquals(desc + " - forward - steps" + i, expected.charAt(i), actual.charAt(i));
}
for (int i= 0; i < expected.length(); i+= FileCharSequenceProvider.BUFFER_SIZE) {
- assertEquals(desc + " - forward - buffersize" + i, expected.charAt(i), actual.charAt(i));
+ Assert.assertEquals(desc + " - forward - buffersize" + i, expected.charAt(i), actual.charAt(i));
}
assertOutOfBound(desc + "access at length", actual, expected.length());
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
index 86e76d62b..06384d2cb 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
@@ -12,16 +12,23 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.ui.IWorkbenchPage;
@@ -35,11 +42,7 @@ import org.eclipse.search.tests.ResourceHelper;
import org.eclipse.search.tests.SearchTestPlugin;
import org.eclipse.search.ui.text.FileTextSearchScope;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class FileSearchTests extends TestCase {
+public class FileSearchTests {
private static class TestResult {
public IResource resource;
@@ -109,36 +112,22 @@ public class FileSearchTests extends TestCase {
private IProject fProject;
- public FileSearchTests(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(FileSearchTests.class));
- }
-
- public static Test setUpTest(Test test) {
- return new JUnitSourceSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception{
fProject= ResourceHelper.createProject("my-project"); //$NON-NLS-1$
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
ResourceHelper.deleteProject("my-project"); //$NON-NLS-1$
}
+ @Test
public void testSimpleFilesSerial() throws Exception {
testSimpleFiles(new SerialTestResultCollector());
}
-
+
+ @Test
public void testSimpleFilesParallel() throws Exception {
testSimpleFiles(new ParallelTestResultCollector());
}
@@ -164,11 +153,13 @@ public class FileSearchTests extends TestCase {
assertMatches(results, 2, file1, buf.toString(), "hello");
assertMatches(results, 2, file2, buf.toString(), "hello");
}
-
+
+ @Test
public void testWildCards1Serial() throws Exception {
testWildCards1(new SerialTestResultCollector());
}
-
+
+ @Test
public void testWildCards1Parallel() throws Exception {
testWildCards1(new ParallelTestResultCollector());
}
@@ -192,11 +183,13 @@ public class FileSearchTests extends TestCase {
TestResult[] results= collector.getResults();
assertEquals("Number of total results", 6, results.length);
}
-
+
+ @Test
public void testWildCards2Serial() throws Exception {
testWildCards2(new SerialTestResultCollector());
}
-
+
+ @Test
public void testWildCards2Parallel() throws Exception {
testWildCards2(new ParallelTestResultCollector());
}
@@ -220,18 +213,20 @@ public class FileSearchTests extends TestCase {
TestResult[] results= collector.getResults();
assertEquals("Number of total results", 4, results.length);
}
-
+
+ @Test
public void testWildCards3Serial() throws Exception {
testWildCards3(new SerialTestResultCollector());
}
-
+
+ @Test
public void testWildCards3Parallel() throws Exception {
testWildCards3(new ParallelTestResultCollector());
}
private void testWildCards3(TestResultCollector collector) throws Exception {
- IProject project= JUnitSourceSetup.getStandardProject();
+ IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(AllFileSearchTests.STANDARD_PROJECT_NAME);
IFile openFile1= (IFile) project.findMember("junit/framework/TestCase.java");
IFile openFile2= (IFile) project.findMember("junit/extensions/ExceptionTestCase.java");
IFile openFile3= (IFile) project.findMember("junit/framework/Assert.java");
@@ -262,11 +257,13 @@ public class FileSearchTests extends TestCase {
}
}
-
+
+ @Test
public void testWholeWordSerial() throws Exception {
testWholeWord(new SerialTestResultCollector());
}
-
+
+ @Test
public void testWholeWordParallel() throws Exception {
testWholeWord(new ParallelTestResultCollector());
}
@@ -316,11 +313,13 @@ public class FileSearchTests extends TestCase {
assertEquals("Number of partial-word results", 22, collector.getNumberOfResults());
}
}
-
+
+ @Test
public void testFileOpenInEditorSerial() throws Exception {
testFileOpenInEditor(new SerialTestResultCollector());
}
-
+
+ @Test
public void testFileOpenInEditorParallel() throws Exception {
testFileOpenInEditor(new ParallelTestResultCollector());
}
@@ -352,11 +351,13 @@ public class FileSearchTests extends TestCase {
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
-
+
+ @Test
public void testDerivedFilesSerial() throws Exception {
testDerivedFiles(new SerialTestResultCollector());
}
-
+
+ @Test
public void testDerivedFilesParallel() throws Exception {
testDerivedFiles(new ParallelTestResultCollector());
}
@@ -438,11 +439,13 @@ public class FileSearchTests extends TestCase {
assertEquals(0, collector.getNumberOfResults());
}
}
-
+
+ @Test
public void testFileNamePatternsSerial() throws Exception {
testFileNamePatterns(new SerialTestResultCollector());
}
-
+
+ @Test
public void testFileNamePatternsParallel() throws Exception {
testFileNamePatterns(new ParallelTestResultCollector());
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java
deleted file mode 100644
index 8c3066cb4..000000000
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/JUnitSourceSetup.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.search.tests.filesearch;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-import org.eclipse.search.tests.ResourceHelper;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-public class JUnitSourceSetup extends TestSetup {
-
- public static final String STANDARD_PROJECT_NAME= "JUnitSource";
-
- private IProject fProject= null;
- private final String fProjectName;
-
- public static IProject getStandardProject() {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(STANDARD_PROJECT_NAME);
- }
-
- public JUnitSourceSetup(Test test) {
- this(test, STANDARD_PROJECT_NAME);
- }
-
- public JUnitSourceSetup(Test test, String projectName) {
- super(test);
- fProjectName= projectName;
- }
-
- @Override
- protected void setUp() throws Exception {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(fProjectName);
- if (!project.exists()) { // allow nesting of JUnitSetups
- fProject= ResourceHelper.createJUnitSourceProject(fProjectName);
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (fProject != null) { // delete only by the setup who created the project
- ResourceHelper.deleteProject(fProjectName);
- fProject= null;
- }
- }
-
-
-
-
-}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
index 78896fe4e..b8a11aaf3 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
@@ -10,9 +10,15 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Iterator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -38,34 +44,13 @@ import org.eclipse.search2.internal.ui.InternalSearchUI;
import org.eclipse.search2.internal.ui.text.EditorAnnotationManager;
import org.eclipse.search2.internal.ui.text.PositionTracker;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class LineAnnotationManagerTest extends TestCase {
+public class LineAnnotationManagerTest {
private LineBasedFileSearch fLineQuery;
private AnnotationTypeLookup fAnnotationTypeLookup= EditorsUI.getAnnotationTypeLookup();
- public LineAnnotationManagerTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(LineAnnotationManagerTest.class));
- }
-
- public static Test suite() {
- return allTests();
- }
-
- public static Test setUpTest(Test test) {
- return new JUnitSourceSetup(test);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLIGHTER_ANNOTATION);
String[] fileNamePatterns= { "*.java" };
@@ -74,15 +59,15 @@ public class LineAnnotationManagerTest extends TestCase {
fLineQuery= new LineBasedFileSearch(scope, false, true, "Test");
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
InternalSearchUI.getInstance().removeAllQueries();
fLineQuery= null;
EditorAnnotationManager.debugSetHighlighterType(EditorAnnotationManager.HIGHLLIGHTER_ANY);
- super.tearDown();
}
-
+
+ @Test
public void testLineBasedQuery() throws Exception {
NewSearchUI.runQueryInForeground(null, fLineQuery);
AbstractTextSearchResult result= (AbstractTextSearchResult) fLineQuery.getSearchResult();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
index 7846c1c94..80275ca5a 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
@@ -10,6 +10,12 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.filebuffers.FileBuffers;
@@ -33,39 +39,19 @@ import org.eclipse.search.ui.text.Match;
import org.eclipse.search2.internal.ui.InternalSearchUI;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class PositionTrackerTest extends TestCase {
+public class PositionTrackerTest {
FileSearchQuery fQuery1;
- public PositionTrackerTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(PositionTrackerTest.class));
- }
-
- public static Test suite() {
- return allTests();
- }
-
- public static Test setUpTest(Test test) {
- return new JUnitSourceSetup(test);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
+
+ @Test
public void testInsertAt0() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
@@ -79,6 +65,7 @@ public class PositionTrackerTest extends TestCase {
}
}
+ @Test
public void testInsertInsideMatch() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
FileSearchResult result= (FileSearchResult) fQuery1.getSearchResult();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java
index f2520164d..aba4fcc05 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/ResultUpdaterTest.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
-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.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -26,32 +28,15 @@ import org.eclipse.search.internal.ui.text.FileSearchQuery;
import org.eclipse.search.tests.ResourceHelper;
-public class ResultUpdaterTest extends TestCase {
+public class ResultUpdaterTest {
private FileSearchQuery fQuery1;
private IProject fProject;
private static final String PROJECT_TO_MODIFY= "ModifiableProject";
- public ResultUpdaterTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(ResultUpdaterTest.class));
- }
-
- public static Test setUpTest(Test test) {
- return test;
- }
-
- public static Test suite() {
- return allTests();
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
// create a own project to make modifications
fProject= ResourceHelper.createJUnitSourceProject(PROJECT_TO_MODIFY);
@@ -61,11 +46,12 @@ public class ResultUpdaterTest extends TestCase {
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
ResourceHelper.deleteProject(PROJECT_TO_MODIFY);
}
+ @Test
public void testRemoveFile() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
@@ -77,6 +63,7 @@ public class ResultUpdaterTest extends TestCase {
assertEquals(0, result.getMatchCount(elements[0]));
}
+ @Test
public void testRemoveProject() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
index c023d1c14..c75674625 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SearchResultPageTest.java
@@ -11,9 +11,11 @@
package org.eclipse.search.tests.filesearch;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Item;
@@ -37,29 +39,11 @@ import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
import org.eclipse.search.ui.text.FileTextSearchScope;
import org.eclipse.search.ui.text.Match;
-public class SearchResultPageTest extends TestCase {
+public class SearchResultPageTest {
FileSearchQuery fQuery1;
- public SearchResultPageTest(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(SearchResultPageTest.class));
- }
-
-
- public static Test setUpTest(Test test) {
- return new JUnitSourceSetup(test);
- }
-
- public static Test suite() {
- return allTests();
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
SearchTestPlugin.ensureWelcomePageClosed();
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
@@ -67,7 +51,9 @@ public class SearchResultPageTest extends TestCase {
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
- public void atestBasicDisplay() throws Exception {
+ @Test
+ @Ignore
+ public void testBasicDisplay() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
ISearchResultViewPart view= NewSearchUI.getSearchResultView();
FileSearchPage page= (FileSearchPage) view.getActivePage();
@@ -90,7 +76,10 @@ public class SearchResultPageTest extends TestCase {
}
}
- public void atestRemoveTreeMatches() throws Exception {
+
+ @Test
+ @Ignore
+ public void testRemoveTreeMatches() throws Exception {
NewSearchUI.runQueryInForeground(null, fQuery1);
ISearchResultViewPart view= NewSearchUI.getSearchResultView();
FileSearchPage page= (FileSearchPage) view.getActivePage();
@@ -135,6 +124,7 @@ public class SearchResultPageTest extends TestCase {
assertTrue(item.getText().indexOf(String.valueOf(itemCount)) >= 0);
}
+ @Test
public void testTableNavigation() {
NewSearchUI.runQueryInForeground(null, fQuery1);
ISearchResultViewPart view= NewSearchUI.getSearchResultView();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
index c45cd30b6..402a97bef 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/SortingTest.java
@@ -10,48 +10,32 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.search.internal.ui.text.FileSearchQuery;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.FileTextSearchScope;
import org.eclipse.search.ui.text.Match;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class SortingTest extends TestCase {
+public class SortingTest {
FileSearchQuery fQuery1;
- public SortingTest(String name) {
- super(name);
- }
-
- public static Test setUpTest(Test test) {
- return new JUnitSourceSetup(test);
- }
-
- public static Test allTests() {
- return setUpTest(new TestSuite(SortingTest.class));
- }
-
- public static Test suite() {
- return allTests();
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
String[] fileNamePatterns= { "*.java" };
FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(fileNamePatterns, false);
fQuery1= new FileSearchQuery("Test", false, true, scope);
}
+ @Test
public void testSorted() throws Exception {
NewSearchUI.activateSearchResultView();
NewSearchUI.runQueryInForeground(null, fQuery1);

Back to the top