Commit 809bf6db authored by Eric Bruneton's avatar Eric Bruneton

Switch to JUnit 5.

parent 3f8159e0
Pipeline #288 passed with stage
in 6 minutes and 28 seconds
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree.analysis; package org.objectweb.asm.tree.analysis;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.fail;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
...@@ -53,7 +53,7 @@ public class AnalyzerUnitTest { ...@@ -53,7 +53,7 @@ public class AnalyzerUnitTest {
private Label start; private Label start;
@Before @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
cw = new ClassWriter(0); cw = new ClassWriter(0);
cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC, "C", null, "java/lang/Object", null); cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC, "C", null, "java/lang/Object", null);
...@@ -845,8 +845,8 @@ public class AnalyzerUnitTest { ...@@ -845,8 +845,8 @@ public class AnalyzerUnitTest {
mLocals = Math.max(mLocals, frames[i].getLocals()); mLocals = Math.max(mLocals, frames[i].getLocals());
} }
} }
assertEquals("maxStack", maxStack, mStack); assertEquals(maxStack, mStack, "maxStack");
assertEquals("maxLocals", maxLocals, mLocals); assertEquals(maxLocals, mLocals, "maxLocals");
} catch (Exception e) { } catch (Exception e) {
fail(e.getMessage()); fail(e.getMessage());
} }
......
...@@ -27,10 +27,8 @@ ...@@ -27,10 +27,8 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree.analysis; package org.objectweb.asm.tree.analysis;
import java.util.Collection; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.Test;
import org.junit.runners.Parameterized.Parameters;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
...@@ -43,19 +41,15 @@ import org.objectweb.asm.tree.MethodNode; ...@@ -43,19 +41,15 @@ import org.objectweb.asm.tree.MethodNode;
*/ */
public class BasicInterpreterTest extends AsmTest { public class BasicInterpreterTest extends AsmTest {
/** @return test parameters to test all the precompiled classes with ASM6. */
@Parameters(name = NAME)
public static Collection<Object[]> data() {
return data(Api.ASM6);
}
/** /**
* Tests that the precompiled classes can be successfully analyzed with a BasicInterpreter. * Tests that the precompiled classes can be successfully analyzed with a BasicInterpreter.
* *
* @throws AnalyzerException * @throws AnalyzerException
*/ */
@Test @ParameterizedTest
public void testAnalyze() throws AnalyzerException { @MethodSource(ALL_CLASSES_AND_LATEST_API)
public void testAnalyze(PrecompiledClass classParameter, Api apiParameter)
throws AnalyzerException {
ClassNode classNode = new ClassNode(); ClassNode classNode = new ClassNode();
new ClassReader(classParameter.getBytes()).accept(classNode, 0); new ClassReader(classParameter.getBytes()).accept(classNode, 0);
for (MethodNode methodNode : classNode.methods) { for (MethodNode methodNode : classNode.methods) {
......
...@@ -27,10 +27,8 @@ ...@@ -27,10 +27,8 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree.analysis; package org.objectweb.asm.tree.analysis;
import java.util.Collection; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.Test;
import org.junit.runners.Parameterized.Parameters;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
...@@ -43,19 +41,15 @@ import org.objectweb.asm.tree.MethodNode; ...@@ -43,19 +41,15 @@ import org.objectweb.asm.tree.MethodNode;
*/ */
public class BasicVerifierTest extends AsmTest { public class BasicVerifierTest extends AsmTest {
/** @return test parameters to test all the precompiled classes with ASM6. */
@Parameters(name = NAME)
public static Collection<Object[]> data() {
return data(Api.ASM6);
}
/** /**
* Tests that the precompiled classes can be successfully analyzed with a BasicVerifier. * Tests that the precompiled classes can be successfully analyzed with a BasicVerifier.
* *
* @throws AnalyzerException * @throws AnalyzerException
*/ */
@Test @ParameterizedTest
public void testAnalyze() throws AnalyzerException { @MethodSource(ALL_CLASSES_AND_LATEST_API)
public void testAnalyze(PrecompiledClass classParameter, Api apiParameter)
throws AnalyzerException {
ClassNode classNode = new ClassNode(); ClassNode classNode = new ClassNode();
new ClassReader(classParameter.getBytes()).accept(classNode, 0); new ClassReader(classParameter.getBytes()).accept(classNode, 0);
for (MethodNode methodNode : classNode.methods) { for (MethodNode methodNode : classNode.methods) {
......
...@@ -27,10 +27,8 @@ ...@@ -27,10 +27,8 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree.analysis; package org.objectweb.asm.tree.analysis;
import java.util.Collection; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.Test;
import org.junit.runners.Parameterized.Parameters;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
...@@ -43,19 +41,15 @@ import org.objectweb.asm.tree.MethodNode; ...@@ -43,19 +41,15 @@ import org.objectweb.asm.tree.MethodNode;
*/ */
public class SimpleVerifierTest extends AsmTest { public class SimpleVerifierTest extends AsmTest {
/** @return test parameters to test all the precompiled classes with ASM6. */
@Parameters(name = NAME)
public static Collection<Object[]> data() {
return data(Api.ASM6);
}
/** /**
* Tests that the precompiled classes can be successfully analyzed with a SimpleVerifier. * Tests that the precompiled classes can be successfully analyzed with a SimpleVerifier.
* *
* @throws AnalyzerException * @throws AnalyzerException
*/ */
@Test @ParameterizedTest
public void testAnalyze() throws AnalyzerException { @MethodSource(ALL_CLASSES_AND_LATEST_API)
public void testAnalyze(PrecompiledClass classParameter, Api apiParameter)
throws AnalyzerException {
ClassNode classNode = new ClassNode(); ClassNode classNode = new ClassNode();
new ClassReader(classParameter.getBytes()).accept(classNode, 0); new ClassReader(classParameter.getBytes()).accept(classNode, 0);
for (MethodNode methodNode : classNode.methods) { for (MethodNode methodNode : classNode.methods) {
......
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree.analysis; package org.objectweb.asm.tree.analysis;
import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.objectweb.asm.Label; import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
...@@ -49,7 +49,7 @@ public class SimpleVerifierUnitTest implements Opcodes { ...@@ -49,7 +49,7 @@ public class SimpleVerifierUnitTest implements Opcodes {
private MethodNode mn; private MethodNode mn;
@Before @BeforeEach
public void setUp() { public void setUp() {
Type c = Type.getType("LC;"); Type c = Type.getType("LC;");
Type d = Type.getType("Ljava/lang/Number;"); Type d = Type.getType("Ljava/lang/Number;");
...@@ -73,13 +73,7 @@ public class SimpleVerifierUnitTest implements Opcodes { ...@@ -73,13 +73,7 @@ public class SimpleVerifierUnitTest implements Opcodes {
private void assertInvalid() { private void assertInvalid() {
mn.visitInsn(RETURN); mn.visitInsn(RETURN);
mn.visitMaxs(10, 10); mn.visitMaxs(10, 10);
try { assertThrows(AnalyzerException.class, () -> a.analyze("C", mn));
a.analyze("C", mn);
fail();
} catch (AnalyzerException e) {
success();
} catch (RuntimeException e) {
}
} }
@Test @Test
...@@ -343,13 +337,7 @@ public class SimpleVerifierUnitTest implements Opcodes { ...@@ -343,13 +337,7 @@ public class SimpleVerifierUnitTest implements Opcodes {
@Test @Test
public void testInvalidFalloff() { public void testInvalidFalloff() {
mn.visitMaxs(10, 10); mn.visitMaxs(10, 10);
try { assertThrows(AnalyzerException.class, () -> a.analyze("C", mn));
a.analyze("C", mn);
fail();
} catch (AnalyzerException e) {
success();
} catch (RuntimeException e) {
}
} }
@Test @Test
...@@ -363,13 +351,7 @@ public class SimpleVerifierUnitTest implements Opcodes { ...@@ -363,13 +351,7 @@ public class SimpleVerifierUnitTest implements Opcodes {
mn.visitLabel(l0); mn.visitLabel(l0);
mn.visitJumpInsn(JSR, l1); mn.visitJumpInsn(JSR, l1);
mn.visitMaxs(10, 10); mn.visitMaxs(10, 10);
try { assertThrows(AnalyzerException.class, () -> a.analyze("C", mn));
a.analyze("C", mn);
fail();
} catch (AnalyzerException e) {
success();
} catch (RuntimeException e) {
}
} }
@Test @Test
...@@ -419,7 +401,7 @@ public class SimpleVerifierUnitTest implements Opcodes { ...@@ -419,7 +401,7 @@ public class SimpleVerifierUnitTest implements Opcodes {
assertValid(); assertValid();
} }
@Ignore("TODO currently Analyzer can not detect this situation") @Disabled("TODO currently Analyzer can not detect this situation")
@Test @Test
public void testOverlappingSubroutines() { public void testOverlappingSubroutines() {
// The problem is that other overlapping subroutine situations are valid, such as // The problem is that other overlapping subroutine situations are valid, such as
...@@ -474,13 +456,6 @@ public class SimpleVerifierUnitTest implements Opcodes { ...@@ -474,13 +456,6 @@ public class SimpleVerifierUnitTest implements Opcodes {
mn.visitVarInsn(ASTORE, 1); mn.visitVarInsn(ASTORE, 1);
mn.visitJumpInsn(GOTO, l0); mn.visitJumpInsn(GOTO, l0);
mn.visitMaxs(10, 10); mn.visitMaxs(10, 10);
try { assertThrows(Exception.class, () -> a.analyze("C", mn));
a.analyze("C", mn);
fail();
} catch (Exception e) {
}
} }
/** Dummy method to avoid a FindBugs warning. */
private static void success() {}
} }
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree.analysis; package org.objectweb.asm.tree.analysis;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Set; import java.util.Set;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* SmallSet unit tests. * SmallSet unit tests.
......
...@@ -27,10 +27,8 @@ ...@@ -27,10 +27,8 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree.analysis; package org.objectweb.asm.tree.analysis;
import java.util.Collection; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.Test;
import org.junit.runners.Parameterized.Parameters;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
...@@ -43,19 +41,15 @@ import org.objectweb.asm.tree.MethodNode; ...@@ -43,19 +41,15 @@ import org.objectweb.asm.tree.MethodNode;
*/ */
public class SourceInterpreterTest extends AsmTest { public class SourceInterpreterTest extends AsmTest {
/** @return test parameters to test all the precompiled classes with ASM6. */
@Parameters(name = NAME)
public static Collection<Object[]> data() {
return data(Api.ASM6);
}
/** /**
* Tests that the precompiled classes can be successfully analyzed with a SourceInterpreter. * Tests that the precompiled classes can be successfully analyzed with a SourceInterpreter.
* *
* @throws AnalyzerException * @throws AnalyzerException
*/ */
@Test @ParameterizedTest
public void testAnalyze() throws AnalyzerException { @MethodSource(ALL_CLASSES_AND_LATEST_API)
public void testAnalyze(PrecompiledClass classParameter, Api apiParameter)
throws AnalyzerException {
ClassNode classNode = new ClassNode(); ClassNode classNode = new ClassNode();
new ClassReader(classParameter.getBytes()).accept(classNode, 0); new ClassReader(classParameter.getBytes()).accept(classNode, 0);
for (MethodNode methodNode : classNode.methods) { for (MethodNode methodNode : classNode.methods) {
......
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree.analysis; package org.objectweb.asm.tree.analysis;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* BasicValue and SourceValue unit tests. * BasicValue and SourceValue unit tests.
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.commons; package org.objectweb.asm.commons;
import java.util.Collection; import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.Test; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.runners.Parameterized.Parameters; import org.junit.jupiter.params.provider.MethodSource;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
...@@ -45,25 +45,28 @@ import org.objectweb.asm.test.AsmTest; ...@@ -45,25 +45,28 @@ import org.objectweb.asm.test.AsmTest;
*/ */
public class AdviceAdapterTest extends AsmTest { public class AdviceAdapterTest extends AsmTest {
/** @return test parameters to test all the precompiled classes with all the apis. */ @ParameterizedTest
@Parameters(name = NAME) @MethodSource(ALL_CLASSES_AND_ALL_APIS)
public static Collection<Object[]> data() { public void testEmptyAdviceAdapter(PrecompiledClass classParameter, Api apiParameter)
return data(Api.ASM4, Api.ASM5, Api.ASM6); throws Exception {
}
@Test
public void testEmptyAdviceAdapter() throws Exception {
ClassReader classReader = new ClassReader(classParameter.getBytes()); ClassReader classReader = new ClassReader(classParameter.getBytes());
ClassWriter expectedClassWriter = new ClassWriter(0); ClassWriter expectedClassWriter = new ClassWriter(0);
ClassWriter actualClassWriter = new ClassWriter(0); ClassWriter actualClassWriter = new ClassWriter(0);
ClassVisitor expectedClassVisitor =
new ReferenceClassAdapter(apiParameter.value(), expectedClassWriter);
ClassVisitor actualClassVisitor =
new AdviceClassAdapter(apiParameter.value(), actualClassWriter);
if (classParameter.isMoreRecentThan(apiParameter)) { if (classParameter.isMoreRecentThan(apiParameter)) {
thrown.expect(RuntimeException.class); assertThrows(
RuntimeException.class,
() -> classReader.accept(expectedClassVisitor, ClassReader.EXPAND_FRAMES));
assertThrows(
RuntimeException.class,
() -> classReader.accept(actualClassVisitor, ClassReader.EXPAND_FRAMES));
return;
} }
classReader.accept( classReader.accept(expectedClassVisitor, ClassReader.EXPAND_FRAMES);
new ReferenceClassAdapter(apiParameter.value(), expectedClassWriter), classReader.accept(actualClassVisitor, ClassReader.EXPAND_FRAMES);
ClassReader.EXPAND_FRAMES);
classReader.accept(
new AdviceClassAdapter(apiParameter.value(), actualClassWriter), ClassReader.EXPAND_FRAMES);
assertThatClass(actualClassWriter.toByteArray()).isEqualTo(expectedClassWriter.toByteArray()); assertThatClass(actualClassWriter.toByteArray()).isEqualTo(expectedClassWriter.toByteArray());
} }
...@@ -84,7 +87,7 @@ public class AdviceAdapterTest extends AsmTest { ...@@ -84,7 +87,7 @@ public class AdviceAdapterTest extends AsmTest {
if (mv == null || (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) > 0) { if (mv == null || (access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_NATIVE)) > 0) {
return mv; return mv;
} }
return new LocalVariablesSorter(access, desc, mv); return new LocalVariablesSorter(api, access, desc, mv);
} }
} }
......
...@@ -31,7 +31,7 @@ import java.io.IOException; ...@@ -31,7 +31,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
......
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.commons; package org.objectweb.asm.commons;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.jupiter.api.function.Executable;
import org.junit.runners.Parameterized.Parameters; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
...@@ -51,19 +51,15 @@ import org.objectweb.asm.test.AsmTest; ...@@ -51,19 +51,15 @@ import org.objectweb.asm.test.AsmTest;
*/ */
public class AnalyzerAdapterTest extends AsmTest { public class AnalyzerAdapterTest extends AsmTest {
/** @return test parameters to test all the precompiled classes with all the apis. */
@Parameters(name = NAME)
public static Collection<Object[]> data() {
return data(Api.ASM4, Api.ASM5, Api.ASM6);
}
/** /**
* Tests that classes with additional frames inserted at each instruction, using the results of an * Tests that classes with additional frames inserted at each instruction, using the results of an
* AnalyzerAdapter, can be instantiated and loaded. This makes sure the intermediate frames * AnalyzerAdapter, can be instantiated and loaded. This makes sure the intermediate frames
* computed by AnalyzerAdapter are correct, i.e. pass bytecode verification. * computed by AnalyzerAdapter are correct, i.e. pass bytecode verification.
*/ */
@Test @ParameterizedTest
public void testAnalyzeLoadAndInstantiate() throws Exception { @MethodSource(ALL_CLASSES_AND_ALL_APIS)
public void testAnalyzeLoadAndInstantiate(PrecompiledClass classParameter, Api apiParameter)
throws Exception {
byte[] classFile = classParameter.getBytes(); byte[] classFile = classParameter.getBytes();
ClassReader classReader = new ClassReader(classFile); ClassReader classReader = new ClassReader(classFile);
ClassWriter classWriter = new ClassWriter(0); ClassWriter classWriter = new ClassWriter(0);
...@@ -100,17 +96,22 @@ public class AnalyzerAdapterTest extends AsmTest { ...@@ -100,17 +96,22 @@ public class AnalyzerAdapterTest extends AsmTest {
return analyzerAdapter; return analyzerAdapter;
} }
}; };
Executable test =
() -> {
classReader.accept(classVisitor, ClassReader.EXPAND_FRAMES);
loadAndInstantiate(classParameter.getName(), classWriter.toByteArray());
};
// jdk3.AllInstructions and jdk3.LargeMethod contain jsr/ret instructions, // jdk3.AllInstructions and jdk3.LargeMethod contain jsr/ret instructions,
// which are not supported. // which are not supported.
if (classParameter == PrecompiledClass.JDK3_ALL_INSTRUCTIONS if (classParameter == PrecompiledClass.JDK3_ALL_INSTRUCTIONS
|| classParameter == PrecompiledClass.JDK3_LARGE_METHOD || classParameter == PrecompiledClass.JDK3_LARGE_METHOD
|| classParameter.isMoreRecentThan(apiParameter)) { || classParameter.isMoreRecentThan(apiParameter)) {
thrown.expect(RuntimeException.class); assertThrows(RuntimeException.class, test);
} else if (classParameter.isMoreRecentThanCurrentJdk()) { } else {
thrown.expect(UnsupportedClassVersionError.class); assertThat(test)
.succeedsOrThrows(UnsupportedClassVersionError.class)
.when(classParameter.isMoreRecentThanCurrentJdk());
} }
classReader.accept(classVisitor, ClassReader.EXPAND_FRAMES);
assertTrue(loadAndInstantiate(classParameter.getName(), classWriter.toByteArray()));
} }
/** /**
......
...@@ -27,27 +27,20 @@ ...@@ -27,27 +27,20 @@
// THE POSSIBILITY OF SUCH DAMAGE. // THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.commons; package org.objectweb.asm.commons;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Collection; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.Test;
import org.junit.runners.Parameterized.Parameters;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest;
public class ClassRemapperTest extends AsmTest { public class ClassRemapperTest extends AsmTest {
/** @return test parameters to test all the precompiled classes with all the apis. */
@Parameters(name = NAME)
public static Collection<Object[]> data() {
return data(Api.ASM4, Api.ASM5, Api.ASM6);
}
/** Tests that classes transformed with a ClassRemapper can be loaded and instantiated. */ /** Tests that classes transformed with a ClassRemapper can be loaded and instantiated. */
@Test @ParameterizedTest
public void testRemapLoadAndInstantiate() { @MethodSource(ALL_CLASSES_AND_ALL_APIS)
public void testRemapLoadAndInstantiate(PrecompiledClass classParameter, Api apiParameter) {
ClassReader classReader = new ClassReader(classParameter.getBytes()); ClassReader classReader = new ClassReader(classParameter.getBytes());
ClassWriter classWriter = new ClassWriter(0); ClassWriter classWriter = new ClassWriter(0);
Remapper upperCaseRemapper = Remapper upperCaseRemapper =
...@@ -78,13 +71,16 @@ public class ClassRemapperTest extends AsmTest { ...@@ -78,13 +71,16 @@ public class ClassRemapperTest extends AsmTest {
: typeName; : typeName;
} }
}; };
ClassRemapper classRemapper =