Search in sources :

Example 1 with SystemPropertiesRuntime

use of org.jacoco.core.runtime.SystemPropertiesRuntime in project jacoco by jacoco.

the class ClassFileVersionsTest method testVersion.

private void testVersion(int version, boolean frames) throws IOException {
    final byte[] original = createClass(version);
    IRuntime runtime = new SystemPropertiesRuntime();
    Instrumenter instrumenter = new Instrumenter(runtime);
    byte[] instrumented = instrumenter.instrument(original, "TestTarget");
    assertFrames(instrumented, frames);
}
Also used : SystemPropertiesRuntime(org.jacoco.core.runtime.SystemPropertiesRuntime) Instrumenter(org.jacoco.core.instr.Instrumenter) IRuntime(org.jacoco.core.runtime.IRuntime)

Example 2 with SystemPropertiesRuntime

use of org.jacoco.core.runtime.SystemPropertiesRuntime in project jacoco by jacoco.

the class CyclomaticComplexityTest method setup.

@Before
public void setup() throws Exception {
    data = new RuntimeData();
    runtime = new SystemPropertiesRuntime();
    runtime.startup(data);
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) SystemPropertiesRuntime(org.jacoco.core.runtime.SystemPropertiesRuntime) Before(org.junit.Before)

Example 3 with SystemPropertiesRuntime

use of org.jacoco.core.runtime.SystemPropertiesRuntime in project jacoco by jacoco.

the class FramesTest method testFrames.

private void testFrames(byte[] source) throws IOException {
    IRuntime runtime = new SystemPropertiesRuntime();
    Instrumenter instrumenter = new Instrumenter(runtime);
    source = calculateFrames(source);
    byte[] actual = instrumenter.instrument(source, "TestTarget");
    byte[] expected = calculateFrames(actual);
    assertEquals(dump(expected), dump(actual));
}
Also used : SystemPropertiesRuntime(org.jacoco.core.runtime.SystemPropertiesRuntime) Instrumenter(org.jacoco.core.instr.Instrumenter) IRuntime(org.jacoco.core.runtime.IRuntime)

Example 4 with SystemPropertiesRuntime

use of org.jacoco.core.runtime.SystemPropertiesRuntime in project jacoco by jacoco.

the class StructuredLockingTest method assertStructuredLocking.

private void assertStructuredLocking(byte[] source) throws Exception {
    IRuntime runtime = new SystemPropertiesRuntime();
    Instrumenter instrumenter = new Instrumenter(runtime);
    byte[] instrumented = instrumenter.instrument(source, "TestTarget");
    final int version = BytecodeVersion.get(instrumented);
    instrumented = BytecodeVersion.downgradeIfNeeded(version, instrumented);
    ClassNode cn = new ClassNode();
    new ClassReader(instrumented).accept(cn, 0);
    for (MethodNode mn : cn.methods) {
        assertStructuredLocking(cn.name, mn);
    }
}
Also used : ClassNode(org.objectweb.asm.tree.ClassNode) MethodNode(org.objectweb.asm.tree.MethodNode) SystemPropertiesRuntime(org.jacoco.core.runtime.SystemPropertiesRuntime) ClassReader(org.objectweb.asm.ClassReader) Instrumenter(org.jacoco.core.instr.Instrumenter) IRuntime(org.jacoco.core.runtime.IRuntime)

Aggregations

SystemPropertiesRuntime (org.jacoco.core.runtime.SystemPropertiesRuntime)4 Instrumenter (org.jacoco.core.instr.Instrumenter)3 IRuntime (org.jacoco.core.runtime.IRuntime)3 RuntimeData (org.jacoco.core.runtime.RuntimeData)1 Before (org.junit.Before)1 ClassReader (org.objectweb.asm.ClassReader)1 ClassNode (org.objectweb.asm.tree.ClassNode)1 MethodNode (org.objectweb.asm.tree.MethodNode)1