Skip to content

Commit

Permalink
Migration to junit 5 (#1725)
Browse files Browse the repository at this point in the history
* dogfooding migration to junit 5
* Version bump(s) for 4.35 stream

---------

Co-authored-by: Eclipse JDT Bot <[email protected]>
  • Loading branch information
carstenartur and eclipse-jdt-bot authored Dec 3, 2024
1 parent 49d5dd2 commit 673d5e7
Show file tree
Hide file tree
Showing 46 changed files with 642 additions and 724 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.text.tests
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.jdt.text.tests;singleton:=true
Bundle-Version: 3.14.600.qualifier
Bundle-Version: 3.14.700.qualifier
Bundle-Activator: org.eclipse.jdt.text.tests.JdtTextTestPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Plugin.providerName
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.text.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.text.tests</artifactId>
<version>3.14.600-SNAPSHOT</version>
<version>3.14.700-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.spelling;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
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.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -25,9 +25,9 @@
import java.util.Locale;
import java.util.Set;

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

import org.eclipse.jface.preference.IPreferenceStore;

Expand Down Expand Up @@ -83,7 +83,7 @@ protected final boolean contains(Set<RankedWordProposal> words, String word) {
return false;
}

@Before
@BeforeEach
public void setUp() throws Exception {

fUSDictionary.addWord(TRUCK);
Expand All @@ -97,7 +97,7 @@ public void setUp() throws Exception {
fEngine.registerGlobalDictionary(fGlobalDictionary);
}

@After
@AfterEach
public void tearDown() throws Exception {

fUSDictionary.unload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.templates;

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 java.util.Arrays;
import java.util.List;

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

import org.eclipse.jdt.testplugin.JavaProjectHelper;

Expand Down Expand Up @@ -54,15 +54,15 @@ public class TemplateCompletionTests {

private IPackageFragment pkg;

@Before
@BeforeEach
public void setUp() throws Exception {
fJProject= JavaProjectHelper.createJavaProject("TestProject", "bin");
JavaProjectHelper.addRTJar18(fJProject);
javaSrc= JavaProjectHelper.addSourceContainer(fJProject, "src");
pkg= javaSrc.createPackageFragment("test", false, null);
}

@After
@AfterEach
public void tearDown() throws Exception {
JavaProjectHelper.delete(fJProject);
}
Expand Down Expand Up @@ -102,7 +102,7 @@ public void testExepectNoProposals() throws Exception {
List<ICompletionProposal> proposals= computeCompletionProposals(cu, completionIndex);

boolean fail= proposals.stream().anyMatch(p -> "new_class - create new class".equals(p.getDisplayString()));
assertFalse("Proposal '" + propDisplay + "' should not exist", fail);
assertFalse(fail, "Proposal '" + propDisplay + "' should not exist");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.util.Iterator;

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

import org.eclipse.jface.text.templates.ContextTypeRegistry;
import org.eclipse.jface.text.templates.Template;
Expand Down
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");
}
}

This file was deleted.

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$
}
}
Loading

0 comments on commit 673d5e7

Please sign in to comment.