Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2020-02-12 12:42:28 +0000
committerAlexander Kurtakov2020-02-12 14:26:55 +0000
commit932c6095358ec0eca5bd16d591c1174ae7f2df36 (patch)
tree89fdc664aab295fb0d9efb1c3a3ea6ef5a4da724
parent673682248b2d7b18ecf828d7caf2e9db03321888 (diff)
downloadeclipse.platform.team-932c6095358ec0eca5bd16d591c1174ae7f2df36.tar.gz
eclipse.platform.team-932c6095358ec0eca5bd16d591c1174ae7f2df36.tar.xz
eclipse.platform.team-932c6095358ec0eca5bd16d591c1174ae7f2df36.zip
Convert o.e.core.tests.net and o.e.compare.tests to JUnit4
Had to drop apitooling as it caused errors but API on test bundles is pure insanity. Change-Id: Iffa4a8617a388d094fc9147ea1e17688738361fe Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AsyncExecTests.java25
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareFileRevisionEditorInputTest.java7
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java35
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DiffTest.java111
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java227
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FilterTest.java28
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java78
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchLinesTest.java25
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java213
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchUITest.java29
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/RangeDifferencerThreeWayDiffTest.java64
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StreamMergerTest.java125
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java26
-rw-r--r--tests/org.eclipse.core.tests.net/.cvsignore1
-rw-r--r--tests/org.eclipse.core.tests.net/.project6
-rw-r--r--tests/org.eclipse.core.tests.net/META-INF/MANIFEST.MF2
-rw-r--r--tests/org.eclipse.core.tests.net/pom.xml2
-rw-r--r--tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/AllNetTests.java4
-rw-r--r--tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java100
19 files changed, 537 insertions, 571 deletions
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AsyncExecTests.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AsyncExecTests.java
index 79d1c6944..9028f8369 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AsyncExecTests.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AsyncExecTests.java
@@ -13,29 +13,22 @@
*******************************************************************************/
package org.eclipse.compare.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
import org.eclipse.compare.internal.WorkQueue;
import org.eclipse.compare.internal.Worker;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.*;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-
-public class AsyncExecTests extends TestCase {
-
- public AsyncExecTests() {
- super();
- }
-
- public AsyncExecTests(String name) {
- super(name);
- }
+public class AsyncExecTests {
+ @Test
public void testQueueAdd() {
WorkQueue q = new WorkQueue();
assertTrue(q.isEmpty());
@@ -78,6 +71,7 @@ public class AsyncExecTests extends TestCase {
assertTrue(q.isEmpty());
}
+ @Test
public void testWorker() {
final Worker w = new Worker("");
final List<IRunnableWithProgress> worked = new ArrayList<>();
@@ -140,6 +134,7 @@ public class AsyncExecTests extends TestCase {
assertEquals(r2, worked.get(0));
}
+ @Test
public void testCancelOnRequeue() {
final Worker w = new Worker("");
final List<IRunnableWithProgress> worked = new ArrayList<>();
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareFileRevisionEditorInputTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareFileRevisionEditorInputTest.java
index 4efd43153..44347c748 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareFileRevisionEditorInputTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareFileRevisionEditorInputTest.java
@@ -21,11 +21,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.internal.ui.history.CompareFileRevisionEditorInput;
import org.eclipse.ui.IWorkbenchPage;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-public class CompareFileRevisionEditorInputTest extends TestCase {
-
+public class CompareFileRevisionEditorInputTest {
+ @Test
public void testPrepareCompareInputWithNonLocalResourceTypedElements()
throws InvocationTargetException, InterruptedException {
TestFriendlyCompareFileRevisionEditorInput input = new TestFriendlyCompareFileRevisionEditorInput(
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java
index 708a00cb3..f531b7e14 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java
@@ -13,21 +13,22 @@
*******************************************************************************/
package org.eclipse.compare.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import junit.framework.TestCase;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.*;
import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.ViewerDescriptor;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
+import org.junit.Test;
-public class CompareUIPluginTest extends TestCase {
+public class CompareUIPluginTest {
private static class UnknownTypedElement implements ITypedElement {
@Override
@@ -82,43 +83,49 @@ public class CompareUIPluginTest extends TestCase {
@Override
public InputStream getContents() throws CoreException {
/*
- * Whatever we return has no importance as long as it is not "null", this is only to make
- * CompareUIPlugin#guessType happy. However, it is only happy if what we return resembles a text.
+ * Whatever we return has no importance as long as it is not "null", this is
+ * only to make CompareUIPlugin#guessType happy. However, it is only happy if
+ * what we return resembles a text.
*/
- return new ByteArrayInputStream(new byte[] {' '});
+ return new ByteArrayInputStream(new byte[] { ' ' });
}
}
+ @Test
public void testFindContentViewerDescriptor_UnknownType() {
CompareConfiguration cc = new CompareConfiguration();
DiffNode in = new DiffNode(new UnknownTypedElement(), new UnknownTypedElement());
ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
- // API Compatibility : "no descriptor found" should return a null array instead of a 0-lengthed one.
+ // API Compatibility : "no descriptor found" should return a null array instead
+ // of a 0-lengthed one.
assertNull(result);
}
+ @Test
public void testFindContentViewerDescriptor_TextType_NotStreamAccessor() {
CompareConfiguration cc = new CompareConfiguration();
DiffNode in = new DiffNode(new TextTypedElement(), new TextTypedElement());
ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
/*
- * "TextTypedElement" is "text" typed : it thus has a Content Viewer attached. However, this content
- * viewer is currently NOT returned because of bug 293926
+ * "TextTypedElement" is "text" typed : it thus has a Content Viewer attached.
+ * However, this content viewer is currently NOT returned because of bug 293926
*/
assertNotNull(result);
assertEquals(1, result.length);
}
+ @Test
public void testFindContentViewerDescriptorForTextType_StreamAccessor() {
CompareConfiguration cc = new CompareConfiguration();
DiffNode in = new DiffNode(new TextTypedElementStreamAccessor(), new TextTypedElementStreamAccessor());
ViewerDescriptor[] result = CompareUIPlugin.getDefault().findContentViewerDescriptor(null, in, cc);
/*
- * "TextTypedElement" is "text" typed : it thus has a Content Viewer attached. However, the content
- * viewer will only be returned because we made our "ITypedElement" be an IStreamContentAccessor.
+ * "TextTypedElement" is "text" typed : it thus has a Content Viewer attached.
+ * However, the content viewer will only be returned because we made our
+ * "ITypedElement" be an IStreamContentAccessor.
*/
assertNotNull(result);
assertEquals(1, result.length);
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DiffTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DiffTest.java
index 1882bbfb6..43babda70 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DiffTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DiffTest.java
@@ -13,45 +13,33 @@
*******************************************************************************/
package org.eclipse.compare.tests;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertTrue;
import org.eclipse.compare.internal.DocLineComparator;
import org.eclipse.compare.internal.core.TextLineLCS;
-import org.eclipse.compare.rangedifferencer.IRangeComparator;
-import org.eclipse.compare.rangedifferencer.RangeDifference;
-import org.eclipse.compare.rangedifferencer.RangeDifferencer;
+import org.eclipse.compare.rangedifferencer.*;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
+import org.junit.Test;
-public class DiffTest extends TestCase {
+public class DiffTest {
- private static final String ABC= "abc"; //$NON-NLS-1$
- private static final String DEF= "def"; //$NON-NLS-1$
- //private static final String BAR= "bar"; //$NON-NLS-1$
- //private static final String FOO= "foo"; //$NON-NLS-1$
- private static final String XYZ= "xyz"; //$NON-NLS-1$
- private static final String _123= "123"; //$NON-NLS-1$
- //private static final String _456= "456"; //$NON-NLS-1$
+ private static final String ABC = "abc"; //$NON-NLS-1$
+ private static final String DEF = "def"; //$NON-NLS-1$
+ // private static final String BAR= "bar"; //$NON-NLS-1$
+ // private static final String FOO= "foo"; //$NON-NLS-1$
+ private static final String XYZ = "xyz"; //$NON-NLS-1$
+ private static final String _123 = "123"; //$NON-NLS-1$
+ // private static final String _456= "456"; //$NON-NLS-1$
- static final String SEPARATOR= System.getProperty("line.separator"); //$NON-NLS-1$
-
- public DiffTest() {
- super();
- }
-
- public DiffTest(String name) {
- super(name);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
+ static final String SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
+ @Test
public void testLineAddition() {
- String s1= ABC + SEPARATOR + DEF + SEPARATOR + XYZ;
- String s2= ABC + SEPARATOR + DEF + SEPARATOR + _123 + SEPARATOR + XYZ;
+ String s1 = ABC + SEPARATOR + DEF + SEPARATOR + XYZ;
+ String s2 = ABC + SEPARATOR + DEF + SEPARATOR + _123 + SEPARATOR + XYZ;
TextLineLCS.TextLine[] l1 = TextLineLCS.getTextLines(s1);
TextLineLCS.TextLine[] l2 = TextLineLCS.getTextLines(s2);
TextLineLCS lcs = new TextLineLCS(l1, l2);
@@ -70,9 +58,10 @@ public class DiffTest extends TestCase {
assertTrue(result[1][2].lineNumber() == 3);
}
+ @Test
public void testLineDeletion() {
- String s1= ABC + SEPARATOR + DEF + SEPARATOR + _123 + SEPARATOR + XYZ;
- String s2= ABC + SEPARATOR + DEF + SEPARATOR + XYZ;
+ String s1 = ABC + SEPARATOR + DEF + SEPARATOR + _123 + SEPARATOR + XYZ;
+ String s2 = ABC + SEPARATOR + DEF + SEPARATOR + XYZ;
TextLineLCS.TextLine[] l1 = TextLineLCS.getTextLines(s1);
TextLineLCS.TextLine[] l2 = TextLineLCS.getTextLines(s2);
TextLineLCS lcs = new TextLineLCS(l1, l2);
@@ -90,9 +79,10 @@ public class DiffTest extends TestCase {
assertTrue(result[1][2].lineNumber() == 2);
}
+ @Test
public void testLineAppendEnd() {
- String s1= ABC + SEPARATOR + DEF;
- String s2= ABC + SEPARATOR + DEF + SEPARATOR + _123;
+ String s1 = ABC + SEPARATOR + DEF;
+ String s2 = ABC + SEPARATOR + DEF + SEPARATOR + _123;
TextLineLCS.TextLine[] l1 = TextLineLCS.getTextLines(s1);
TextLineLCS.TextLine[] l2 = TextLineLCS.getTextLines(s2);
TextLineLCS lcs = new TextLineLCS(l1, l2);
@@ -109,9 +99,10 @@ public class DiffTest extends TestCase {
assertTrue(result[1][1].lineNumber() == 1);
}
+ @Test
public void testLineDeleteEnd() {
- String s1= ABC + SEPARATOR + DEF + SEPARATOR + _123;
- String s2= ABC + SEPARATOR + DEF;
+ String s1 = ABC + SEPARATOR + DEF + SEPARATOR + _123;
+ String s2 = ABC + SEPARATOR + DEF;
TextLineLCS.TextLine[] l1 = TextLineLCS.getTextLines(s1);
TextLineLCS.TextLine[] l2 = TextLineLCS.getTextLines(s2);
TextLineLCS lcs = new TextLineLCS(l1, l2);
@@ -128,9 +119,10 @@ public class DiffTest extends TestCase {
assertTrue(result[1][1].lineNumber() == 1);
}
+ @Test
public void testLineAppendStart() {
- String s1= ABC + SEPARATOR + DEF;
- String s2= _123 + SEPARATOR + ABC + SEPARATOR + DEF;
+ String s1 = ABC + SEPARATOR + DEF;
+ String s2 = _123 + SEPARATOR + ABC + SEPARATOR + DEF;
TextLineLCS.TextLine[] l1 = TextLineLCS.getTextLines(s1);
TextLineLCS.TextLine[] l2 = TextLineLCS.getTextLines(s2);
TextLineLCS lcs = new TextLineLCS(l1, l2);
@@ -147,9 +139,10 @@ public class DiffTest extends TestCase {
assertTrue(result[1][1].lineNumber() == 2);
}
+ @Test
public void testLineDeleteStart() {
- String s1= _123 + SEPARATOR + ABC + SEPARATOR + DEF;
- String s2= ABC + SEPARATOR + DEF;
+ String s1 = _123 + SEPARATOR + ABC + SEPARATOR + DEF;
+ String s2 = ABC + SEPARATOR + DEF;
TextLineLCS.TextLine[] l1 = TextLineLCS.getTextLines(s1);
TextLineLCS.TextLine[] l2 = TextLineLCS.getTextLines(s2);
TextLineLCS lcs = new TextLineLCS(l1, l2);
@@ -167,27 +160,24 @@ public class DiffTest extends TestCase {
}
private IRangeComparator toRangeComparator(String s) {
- IDocument doc1= new Document();
+ IDocument doc1 = new Document();
doc1.set(s);
return new DocLineComparator(doc1, null, true);
}
private RangeDifference[] getDifferences(String s1, String s2) {
- IRangeComparator comp1= toRangeComparator(s1);
- IRangeComparator comp2= toRangeComparator(s2);
+ IRangeComparator comp1 = toRangeComparator(s1);
+ IRangeComparator comp2 = toRangeComparator(s2);
RangeDifference[] differences = RangeDifferencer.findDifferences(comp1, comp2);
RangeDifference[] oldDifferences = RangeDifferencer.findDifferences(comp1, comp2);
- assertTrue(differences.length == oldDifferences.length);
- for (int i = 0; i < oldDifferences.length; i++) {
- assertEquals(oldDifferences[i], differences[i]);
-
- }
+ assertArrayEquals(differences, oldDifferences);
return differences;
}
+ @Test
public void testDocAddition() {
- String s1= ABC + SEPARATOR + DEF + SEPARATOR + XYZ;
- String s2= ABC + SEPARATOR + DEF + SEPARATOR + _123 + SEPARATOR + XYZ;
+ String s1 = ABC + SEPARATOR + DEF + SEPARATOR + XYZ;
+ String s2 = ABC + SEPARATOR + DEF + SEPARATOR + _123 + SEPARATOR + XYZ;
RangeDifference[] result = getDifferences(s1, s2);
@@ -198,9 +18