Skip to content

Commit

Permalink
dogfooding migration to junit 5
Browse files Browse the repository at this point in the history
test to run the upcoming junit 4 to junit 5 migration cleanup
  • Loading branch information
carstenartur committed Oct 20, 2024
1 parent 4f8849c commit f89dd86
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.changes;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
Expand Down Expand Up @@ -72,7 +72,7 @@ public class TextDiffContentTest {

private TextEditChangeGroup fChange3;

@Before
@BeforeEach
public void setUp() throws Exception {
fDocument = new Document(MODIFIED_SOURCE_CONTENTS);
fDocumentChange = new DocumentChange("Changes to document", fDocument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.changes;

import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertFalse;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.eclipse.core.runtime.NullProgressMonitor;

Expand All @@ -39,15 +39,15 @@ public class TrackPositionTest {
private IDocument fDocument;
private DocumentChange fChange;

@Before
@BeforeEach
public void setUp() throws Exception {
fDocument= new Document("0123456789");
fChange= new DocumentChange(NN, fDocument);
fChange.setKeepPreviewEdits(true);
fChange.initializeValidationData(new NullProgressMonitor());
}

@After
@AfterEach
public void tearDown() throws Exception {
fChange= null;
}
Expand All @@ -65,8 +65,8 @@ public void test2() throws Exception {
TextEdit edit= new ReplaceEdit(5, 3, "xy");
TextChangeCompatibility.addTextEdit(fChange, NN, edit);
IDocument preview= fChange.getPreviewDocument(new NullProgressMonitor());
Assert.assertEquals("0123456789", fDocument.get());
Assert.assertEquals("01234xy89", preview.get());
Assertions.assertEquals("0123456789", fDocument.get());
Assertions.assertEquals("01234xy89", preview.get());
assertEquals(fChange.getPreviewEdit(edit).getRegion(), 5, 2);
}

Expand All @@ -80,7 +80,7 @@ private void executeChange() throws Exception {
}

private static void assertEquals(IRegion r, int offset, int length) {
Assert.assertEquals("Offset", offset, r.getOffset());
Assert.assertEquals("Length", length, r.getLength());
Assertions.assertEquals(offset, r.getOffset(), "Offset");
Assertions.assertEquals(length, r.getLength(), "Length");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.nls;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.eclipse.jdt.internal.ui.refactoring.nls.MultiStateCellEditor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.nls;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement;

Expand All @@ -28,7 +28,7 @@ public class NLSElementTester{
private int fOff, fLen;
private String fVal;

@Before
@BeforeEach
public void setUp(){
fOff= 3;
fLen= 5;
Expand All @@ -38,40 +38,40 @@ public void setUp(){

@Test
public void test0() {
assertEquals("Position offset", fOff, fEl.getPosition().getOffset()); //$NON-NLS-1$
assertEquals(fOff, fEl.getPosition().getOffset(), "Position offset"); //$NON-NLS-1$
}

@Test
public void test1() {
assertEquals("Position length", fLen, fEl.getPosition().getLength()); //$NON-NLS-1$
assertEquals(fLen, fEl.getPosition().getLength(), "Position length"); //$NON-NLS-1$
}

@Test
public void test2() {
assertEquals("value", fVal, fEl.getValue()); //$NON-NLS-1$
assertEquals(fVal, fEl.getValue(), "value"); //$NON-NLS-1$
}

@Test
public void test3() {
assertNull("tagposition", fEl.getTagPosition()); //$NON-NLS-1$
assertNull(fEl.getTagPosition(), "tagposition"); //$NON-NLS-1$
}

@Test
public void test3a() {
fEl.setTagPosition(1, 2);
assertEquals("tagposition.length", 2, fEl.getTagPosition().getLength()); //$NON-NLS-1$
assertEquals("tagposition.offset", 1, fEl.getTagPosition().getOffset()); //$NON-NLS-1$
assertEquals(2, fEl.getTagPosition().getLength(), "tagposition.length"); //$NON-NLS-1$
assertEquals(1, fEl.getTagPosition().getOffset(), "tagposition.offset"); //$NON-NLS-1$
}


@Test
public void test4() {
assertFalse("hastag", fEl.hasTag()); //$NON-NLS-1$
assertFalse(fEl.hasTag(), "hastag"); //$NON-NLS-1$
}

@Test
public void test4a() {
fEl.setTagPosition(1, 2);
assertTrue("hastag", fEl.hasTag()); //$NON-NLS-1$
assertTrue(fEl.hasTag(), "hastag"); //$NON-NLS-1$
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.nls;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement;
import org.eclipse.jdt.internal.corext.refactoring.nls.NLSLine;
Expand All @@ -29,77 +29,77 @@ public class NLSScannerTester {
public void test0() throws Exception{
String text= "fred"; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
assertEquals("empty", 0, l.length); //$NON-NLS-1$
assertEquals(0, l.length, "empty"); //$NON-NLS-1$
}

@Test
public void test1() throws Exception{
String text= "fred\"x\"";
NLSLine[] l= NLSScanner.scan(text);
assertEquals("1 line", 1, l.length);
assertEquals(1, l.length, "1 line");
}

@Test
public void test1a() throws Exception{
String text= "fred\n\"x\""; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
assertEquals("1 line", 1, l.length); //$NON-NLS-1$
assertEquals(1, l.length, "1 line"); //$NON-NLS-1$
}

@Test
public void test2() throws Exception{
String text= "fred\"x\"\n\"xx\"";
NLSLine[] l= NLSScanner.scan(text);
assertEquals("2 line", 2, l.length);
assertEquals(2, l.length, "2 line");
}

@Test
public void test2a() throws Exception{
String text= "fred\n\"x\" \"xx\""; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
assertEquals("1 lines", 1, l.length); //$NON-NLS-1$
assertEquals(1, l.length, "1 lines"); //$NON-NLS-1$
}

@Test
public void test3() throws Exception{
String text= "fred\"x\"\n \"xx\"";
NLSLine[] l= NLSScanner.scan(text);
assertEquals("2 lines", 2, l.length);
assertEquals(2, l.length, "2 lines");
}


@Test
public void test4() throws Exception{
String text= "fred\n \"xx\""; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
assertEquals("1 line", 1, l.length); //$NON-NLS-1$
assertEquals(1, l.length, "1 line"); //$NON-NLS-1$
}

@Test
public void test5() throws Exception{
String text= "\n \"xx\""; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("1 string", 1, line.size()); //$NON-NLS-1$
assertEquals(1, line.size(), "1 string"); //$NON-NLS-1$
}

@Test
public void test6() throws Exception{
String text= "\n \"xx\" \"dff\""; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("2 string", 2, line.size()); //$NON-NLS-1$
assertEquals(2, line.size(), "2 string"); //$NON-NLS-1$
}

@Test
public void test7() throws Exception{
String text= "\n \"xx\" \n\"dff\""; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("1 string A", 1, line.size()); //$NON-NLS-1$
assertEquals(1, line.size(), "1 string A"); //$NON-NLS-1$

line= l[1];
assertEquals("1 string B", 1, line.size()); //$NON-NLS-1$
assertEquals(1, line.size(), "1 string B"); //$NON-NLS-1$
}


Expand All @@ -108,10 +108,10 @@ public void test8() throws Exception{
String text= "\n \"xx\" \n\"dff\" \"ccc\""; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("1 string A", 1, line.size()); //$NON-NLS-1$
assertEquals(1, line.size(), "1 string A"); //$NON-NLS-1$

line= l[1];
assertEquals("2 strings B", 2, line.size()); //$NON-NLS-1$
assertEquals(2, line.size(), "2 strings B"); //$NON-NLS-1$
}

@Test
Expand All @@ -120,7 +120,7 @@ public void test9() throws Exception{
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
NLSElement el= line.get(0);
assertTrue("has tag", el.hasTag()); //$NON-NLS-1$
assertTrue(el.hasTag(), "has tag"); //$NON-NLS-1$
}


Expand All @@ -130,7 +130,7 @@ public void test10() throws Exception{
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
NLSElement el= line.get(0);
assertFalse("has tag", el.hasTag()); //$NON-NLS-1$
assertFalse(el.hasTag(), "has tag"); //$NON-NLS-1$
}

@Test
Expand All @@ -142,13 +142,13 @@ public void test11() throws Exception{
+ "\n"; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("2 strings", 2, line.size()); //$NON-NLS-1$
assertEquals(2, line.size(), "2 strings"); //$NON-NLS-1$

NLSElement el= line.get(0);
assertTrue("0 has tag", el.hasTag()); //$NON-NLS-1$
assertTrue(el.hasTag(), "0 has tag"); //$NON-NLS-1$

el= line.get(1);
assertTrue("1 has tag", el.hasTag()); //$NON-NLS-1$
assertTrue(el.hasTag(), "1 has tag"); //$NON-NLS-1$
}

@Test
Expand All @@ -160,13 +160,13 @@ public void test12() throws Exception{
+ "\n"; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("2 strings", 2, line.size()); //$NON-NLS-1$
assertEquals(2, line.size(), "2 strings"); //$NON-NLS-1$

NLSElement el= line.get(0);
assertTrue("0 has tag", el.hasTag()); //$NON-NLS-1$
assertTrue(el.hasTag(), "0 has tag"); //$NON-NLS-1$

el= line.get(1);
assertTrue("1 has tag", el.hasTag()); //$NON-NLS-1$
assertTrue(el.hasTag(), "1 has tag"); //$NON-NLS-1$
}

@Test
Expand All @@ -177,13 +177,13 @@ public void test13() throws Exception{
+ "\n"; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("2 strings", 2, line.size()); //$NON-NLS-1$
assertEquals(2, line.size(), "2 strings"); //$NON-NLS-1$

NLSElement el= line.get(0);
assertTrue("0 has tag", el.hasTag()); //$NON-NLS-1$
assertTrue(el.hasTag(), "0 has tag"); //$NON-NLS-1$

el= line.get(1);
assertFalse("1 has no tag", el.hasTag()); //$NON-NLS-1$
assertFalse(el.hasTag(), "1 has no tag"); //$NON-NLS-1$
}

@Test
Expand All @@ -194,13 +194,13 @@ public void test14() throws Exception{
+ "\n"; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("2 strings", 2, line.size()); //$NON-NLS-1$
assertEquals(2, line.size(), "2 strings"); //$NON-NLS-1$

NLSElement el= line.get(0);
assertFalse("0 has no tag", el.hasTag()); //$NON-NLS-1$
assertFalse(el.hasTag(), "0 has no tag"); //$NON-NLS-1$

el= line.get(1);
assertTrue("1 has tag", el.hasTag()); //$NON-NLS-1$
assertTrue(el.hasTag(), "1 has tag"); //$NON-NLS-1$
}

// test for bug 102132
Expand Down Expand Up @@ -433,9 +433,9 @@ public void test54() throws Exception{
+ "\n"; //$NON-NLS-1$
NLSLine[] l= NLSScanner.scan(text);
NLSLine line=l[0];
assertEquals("1 strings", 1, line.size()); //$NON-NLS-1$
assertEquals(1, line.size(), "1 strings"); //$NON-NLS-1$

NLSElement el= line.get(0);
assertFalse("0 has no tag", el.hasTag()); //$NON-NLS-1$
assertFalse(el.hasTag(), "0 has no tag"); //$NON-NLS-1$
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.nls;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Properties;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.eclipse.jdt.internal.corext.refactoring.nls.NLSSubstitution;

Expand Down
Loading

0 comments on commit f89dd86

Please sign in to comment.