Skip to content

Commit

Permalink
Removal of JUnit4 (#3462)
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon authored May 24, 2024
2 parents 55ab074 + 9be815d commit 99658cc
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 93 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ subprojects {
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
testImplementation project(':key.util')

testCompileOnly 'junit:junit:4.13.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
}

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

import org.key_project.util.helper.FindResources;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
3 changes: 0 additions & 3 deletions recoder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ dependencies {
implementation 'org.apache-extras.beanshell:bsh:2.0b6'
implementation 'net.sf.retrotranslator:retrotranslator-runtime:1.2.9'
implementation 'net.sf.retrotranslator:retrotranslator-transformer:1.2.9'

testCompileOnly 'junit:junit:4.13.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.10.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import java.io.IOException;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import recoder.ParserException;
import recoder.io.DefaultProjectFileIO;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* SPDX-License-Identifier: GPL-2.0-only */
package recoder.testsuite.basic;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.fail;
import static recoder.testsuite.basic.BasicTestsSuite.getConfig;

@Ignore
@Disabled
public class SetupModelTest {
@Test
public void testSetupModel() {
if (getConfig().getProjectSettings().ensureSystemClassesAreInPath()) {
getConfig().getChangeHistory().updateModel();
} else {
fail("Problem with system setup: Cannot locate system classes");
Assertions.fail("Problem with system setup: Cannot locate system classes");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import java.util.List;
import java.util.zip.GZIPOutputStream;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import recoder.abstraction.ProgramModelElement;
import recoder.abstraction.Type;
import recoder.convenience.Format;
Expand All @@ -30,9 +31,8 @@
import recoder.util.Order;
import recoder.util.Sorting;

import static org.junit.Assert.fail;

@Ignore
@Disabled
public class AnalysisReportTest {

final static Order UNIT_NAME_ORDER = new Order.CustomLexicalOrder() {
Expand Down Expand Up @@ -76,7 +76,7 @@ public void testAnalysisReport() throws IOException {
FileOutputStream fos = new FileOutputStream(referenceLogFile);
baos.writeTo(fos);
fos.close();
fail("No reference log - created " + referenceLogFile.getPath());
Assertions.fail("No reference log - created " + referenceLogFile.getPath());
}
InputStream is = new FileInputStream(referenceLogFile);
byte[] referenceBuffer = new byte[buffer.length];
Expand All @@ -88,7 +88,8 @@ public void testAnalysisReport() throws IOException {
FileOutputStream fos = new FileOutputStream(failureFile);
baos.writeTo(fos);
fos.close();
fail("Reference report did not match - created protocol " + failureFile.getPath());
Assertions.fail(
"Reference report did not match - created protocol " + failureFile.getPath());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import java.util.ArrayList;
import java.util.List;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import recoder.abstraction.ClassType;
import recoder.abstraction.Method;
import recoder.abstraction.Type;
Expand All @@ -17,10 +18,8 @@
import recoder.service.NameInfo;
import recoder.testsuite.basic.BasicTestsSuite;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

@Ignore
@Disabled
public class GetAllRelatedMethodsTest {
final static String PACKAGE = "testdata.";
CrossReferenceSourceInfo xrsi;
Expand All @@ -30,7 +29,7 @@ private ClassType loadClass(String localname) {
String name = PACKAGE + localname;
ClassType ct = ni.getClassType(name);
if (ct == null) {
fail("Could not load test data " + name);
Assertions.fail("Could not load test data " + name);
}
return ct;
}
Expand Down Expand Up @@ -70,14 +69,14 @@ private void checkRelatedMethodsCount(ClassType ct, String methodName, int expec
if (ml.size() != expectedNumber) {
System.err.println("Aha");
}
assertEquals(methodName, expectedNumber, ml.size());
Assertions.assertEquals(expectedNumber, ml.size(), methodName);
checkSignatures(ml, methodName, new ArrayList<>(0));
}

private void checkSignatures(List<Method> ml, String methodName, List<Type> signature) {
for (Method method : ml) {
assertEquals(method.getName(), methodName);
assertEquals(method.getSignature(), signature);
Assertions.assertEquals(method.getName(), methodName);
Assertions.assertEquals(method.getSignature(), signature);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import recoder.abstraction.Field;
import recoder.abstraction.Variable;
import recoder.convenience.TreeWalker;
Expand All @@ -34,7 +34,7 @@ public void testLocalVariableXReferenceCompletenessTest() {
for (VariableReference r : list) {
Variable y = xrsi.getVariable(r);
if (x != y) {
Assert.fail(makeResolutionError(r, x, y));
Assertions.fail(makeResolutionError(r, x, y));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import java.util.List;

import junit.framework.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import recoder.abstraction.ClassType;
import recoder.abstraction.Constructor;
import recoder.abstraction.Field;
Expand Down Expand Up @@ -36,7 +36,7 @@ public void testMemberXReferenceCompletenessTest() {
MethodReference r = (MethodReference) memberReference;
Method y = xrsi.getMethod(r);
if (x != y) {
Assert.fail(makeResolutionError(r, x, y));
Assertions.fail(makeResolutionError(r, x, y));
}
}
}
Expand All @@ -47,7 +47,7 @@ public void testMemberXReferenceCompletenessTest() {
for (ConstructorReference r : list) {
Constructor y = xrsi.getConstructor(r);
if (x != y) {
Assert.fail(makeResolutionError(r, x, y));
Assertions.fail(makeResolutionError(r, x, y));
}
}
}
Expand All @@ -58,7 +58,7 @@ public void testMemberXReferenceCompletenessTest() {
for (FieldReference r : list) {
Field y = xrsi.getField(r);
if (x != y) {
Assert.fail(makeResolutionError(r, x, y));
Assertions.fail(makeResolutionError(r, x, y));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import java.util.List;

import junit.framework.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import recoder.abstraction.ClassType;
import recoder.java.CompilationUnit;
import recoder.java.declaration.TypeDeclaration;
Expand All @@ -24,7 +24,7 @@
* @author AL
* @since 0.72
*/
@Ignore
@Disabled
public class ModelRebuildTest extends AnalysisReportTest {

@Test
Expand All @@ -46,13 +46,13 @@ public ProblemReport execute() {

// model should be cleared now except for byte code and implicitly
// defined stuff
Assert.assertEquals(
Assertions.assertEquals(
BasicTestsSuite.getConfig().getSourceFileRepository().getKnownCompilationUnits().size(),
0);
List<ClassType> ctl = BasicTestsSuite.getConfig().getNameInfo().getClassTypes();
for (int i = ctl.size() - 1; i >= 0; i -= 1) {
Assert.assertFalse("Syntax tree left in an emptied model",
ctl.get(i) instanceof TypeDeclaration);
Assertions.assertFalse(ctl.get(i) instanceof TypeDeclaration,
"Syntax tree left in an emptied model");
}

ch.rollback(clearAll);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import java.util.List;

import junit.framework.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import recoder.abstraction.Type;
import recoder.java.reference.TypeReference;
import recoder.service.CrossReferenceSourceInfo;
Expand All @@ -27,7 +27,7 @@ public void testPackageXReferenceCompleteness() {
for (TypeReference r : list) {
Type y = xrsi.getType(r);
if (x != y) {
Assert.fail(makeResolutionError(r, x, y));
Assertions.fail(makeResolutionError(r, x, y));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import java.util.List;

import junit.framework.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import recoder.abstraction.*;
import recoder.abstraction.Package;
import recoder.convenience.Format;
Expand Down Expand Up @@ -42,14 +42,14 @@ public void testReferenceCompleteness() {
while (tw.next()) {
ProgramElement pe = tw.getProgramElement();
if (pe instanceof Reference) {
Assert.assertFalse("Uncollated reference detected",
pe instanceof UncollatedReferenceQualifier);
Assertions.assertFalse(pe instanceof UncollatedReferenceQualifier,
"Uncollated reference detected");
if (pe instanceof VariableReference) {
VariableReference r = (VariableReference) pe;
Variable x = xrsi.getVariable(r);
List<? extends VariableReference> list = xrsi.getReferences(x);
if (!list.contains(r)) {
Assert.fail(makeReferenceError(r, x));
Assertions.fail(makeReferenceError(r, x));
}
} else if (pe instanceof TypeReference) {
TypeReference r = (TypeReference) pe;
Expand All @@ -58,29 +58,29 @@ public void testReferenceCompleteness() {
if (x != null) {
List<TypeReference> list = xrsi.getReferences(x);
if (!list.contains(r)) {
Assert.fail(makeReferenceError(r, x));
Assertions.fail(makeReferenceError(r, x));
}
}
} else if (pe instanceof MethodReference) {
MethodReference r = (MethodReference) pe;
Method x = xrsi.getMethod(r);
List<? extends MemberReference> list = xrsi.getReferences(x);
if (!list.contains(r)) {
Assert.fail(makeReferenceError(r, x));
Assertions.fail(makeReferenceError(r, x));
}
} else if (pe instanceof ConstructorReference) {
ConstructorReference r = (ConstructorReference) pe;
Constructor x = xrsi.getConstructor(r);
List<ConstructorReference> list = xrsi.getReferences(x);
if (!list.contains(r)) {
Assert.fail(makeReferenceError(r, x));
Assertions.fail(makeReferenceError(r, x));
}
} else if (pe instanceof PackageReference) {
PackageReference r = (PackageReference) pe;
Package x = xrsi.getPackage(r);
List<PackageReference> list = xrsi.getReferences(x);
if (!list.contains(r)) {
Assert.fail(makeReferenceError(r, x));
Assertions.fail(makeReferenceError(r, x));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

import java.util.List;

import junit.framework.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import recoder.abstraction.Type;
import recoder.java.reference.TypeReference;
import recoder.service.CrossReferenceSourceInfo;
import recoder.service.NameInfo;
import recoder.testsuite.basic.BasicTestsSuite;

import static org.junit.jupiter.api.Assertions.fail;

public class TypeXReferenceCompletenessTest extends XReferenceCompletenessTest {

@Test
Expand All @@ -27,7 +28,7 @@ public void testTypeXReferenceCompleteness() {
for (TypeReference r : list) {
Type y = xrsi.getType(r);
if (x != y) {
Assert.fail(makeResolutionError(r, x, y));
fail(makeResolutionError(r, x, y));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@

import java.util.List;

import junit.framework.Assert;
import junit.framework.TestCase;
import org.junit.jupiter.api.Test;
import recoder.ProgramFactory;
import recoder.convenience.Format;
import recoder.io.SourceFileRepository;
import recoder.java.CompilationUnit;
import recoder.java.ProgramElement;
import recoder.testsuite.basic.BasicTestsSuite;

public class CloneTest extends TestCase {
import static org.junit.jupiter.api.Assertions.fail;

public class CloneTest {

@Test
public void testClone() {
SourceFileRepository sfr = BasicTestsSuite.getConfig().getSourceFileRepository();
ProgramFactory pf = BasicTestsSuite.getConfig().getProgramFactory();
Expand All @@ -25,12 +27,11 @@ public void testClone() {
String buffer1 = cu.toSource();
CompilationUnit cv = cu.deepClone();
if (!ProgramElement.STRUCTURAL_EQUALITY.equals(cu, cv)) {
Assert.fail(
"Printed tree of " + Format.toString("%u", cu) + " has changed its structure");
fail("Printed tree of " + Format.toString("%u", cu) + " has changed its structure");
}
String buffer2 = cv.toSource();
if (!buffer1.equals(buffer2)) {
Assert.fail(Format.toString("Reprint of parsed %u differs", cu));
fail(Format.toString("Reprint of parsed %u differs", cu));
}
}
}
Expand Down
Loading

0 comments on commit 99658cc

Please sign in to comment.