public abstract class AsmTest
extends java.lang.Object
allClassesAndAllApis()
method, selected test methods can be instantiated for each possible (precompiled class, ASM
API) tuple.
For instance, to run a test on all the precompiled classes, with all the APIs, use a subclass such as the following:
public class MyParameterizedTest extends AsmTest { @ParameterizedTest @MethodSource(ALL_CLASSES_AND_ALL_APIS) public void testSomeFeature(PrecompiledClass classParameter, Api apiParameter) { byte[] b = classParameter.getBytes(); ClassWriter classWriter = new ClassWriter(apiParameter.value(), 0); ... } }
Modifier and Type | Class and Description |
---|---|
static class |
AsmTest.Api
An ASM API version.
|
private static class |
AsmTest.ByteClassLoader
A simple ClassLoader to test that a class can be loaded in the JVM.
|
static class |
AsmTest.ClassSubject
Helper to make assertions about a class.
|
static class |
AsmTest.InvalidClass
An invalid class, hand-crafted to contain some set of invalid class file structures.
|
static class |
AsmTest.PrecompiledClass
A precompiled class, hand-crafted to contain some set of class file structures.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALL_CLASSES_AND_ALL_APIS
MethodSource name to be used in parameterized tests that must be instantiated for all possible
(precompiled class, api) pairs.
|
static java.lang.String |
ALL_CLASSES_AND_LATEST_API
MethodSource name to be used in parameterized tests that must be instantiated for all
precompiled classes, with the latest api.
|
private static int |
INPUT_STREAM_DATA_CHUNK_SIZE
The size of the temporary byte array used to read class input streams chunk by chunk.
|
private static java.lang.String |
MODULE_INFO
The name of JDK9 module classes.
|
Constructor and Description |
---|
AsmTest() |
Modifier and Type | Method and Description |
---|---|
static java.util.stream.Stream<org.junit.jupiter.params.provider.Arguments> |
allClassesAndAllApis()
Builds a list of test arguments for a parameterized test.
|
static java.util.stream.Stream<org.junit.jupiter.params.provider.Arguments> |
allClassesAndLatestApi()
Builds a list of test arguments for a parameterized test.
|
static AsmTest.ClassSubject |
assertThatClass(byte[] classFile)
Starts an assertion about the given class content.
|
private static java.util.stream.Stream<org.junit.jupiter.params.provider.Arguments> |
classesAndApis(AsmTest.Api... apis) |
(package private) static boolean |
doLoadAndInstantiate(java.lang.String className,
byte[] classContent)
Loads the given class in a new class loader.
|
private static byte[] |
getBytes(java.lang.String name) |
private static int |
getMajorJavaVersion() |
static boolean |
loadAndInstantiate(java.lang.String className,
byte[] classContent)
Loads the given class in a new class loader.
|
private static final int INPUT_STREAM_DATA_CHUNK_SIZE
private static final java.lang.String MODULE_INFO
public static final java.lang.String ALL_CLASSES_AND_ALL_APIS
public static final java.lang.String ALL_CLASSES_AND_LATEST_API
public static java.util.stream.Stream<org.junit.jupiter.params.provider.Arguments> allClassesAndAllApis()
@MethodSource("allClassesAndAllApis")
will be executed on all the possible
(precompiledClass, api) pairs.public static java.util.stream.Stream<org.junit.jupiter.params.provider.Arguments> allClassesAndLatestApi()
@MethodSource("allClassesAndLatestApi")
will be executed on all the precompiled
classes, with the latest api.private static java.util.stream.Stream<org.junit.jupiter.params.provider.Arguments> classesAndApis(AsmTest.Api... apis)
private static int getMajorJavaVersion()
public static AsmTest.ClassSubject assertThatClass(byte[] classFile)
classFile
- the content of a class.AsmTest.ClassSubject
to use to make actual assertions about the given class.public static boolean loadAndInstantiate(java.lang.String className, byte[] classContent)
className
- the name of the class to load.classContent
- the content of the class to load.static boolean doLoadAndInstantiate(java.lang.String className, byte[] classContent)
className
- the name of the class to load.classContent
- the content of the class to load.private static byte[] getBytes(java.lang.String name)