Package org.jacoco.core.test

Examples of org.jacoco.core.test.TargetLoader


  }

  private static void verifyInstrumentedClass(String name, byte[] source)
      throws Exception {
    name = name.replace('/', '.');
    final Class<?> targetClass = new TargetLoader().add(name, source);

    // Check added field:
    final Field f = targetClass.getField("$jacocoAccess");
    assertTrue(Modifier.isPublic(f.getModifiers()));
    assertTrue(Modifier.isStatic(f.getModifiers()));
View Full Code Here


    gen.visitMaxs(3, 0);
    gen.visitEnd();

    writer.visitEnd();

    final TargetLoader loader = new TargetLoader();
    return (ITarget) loader.add(className.replace('/', '.'),
        writer.toByteArray()).newInstance();
  }
View Full Code Here

    mv.visitInsn(Opcodes.ARETURN);
    mv.visitMaxs(5, 1);
    mv.visitEnd();

    writer.visitEnd();
    final TargetLoader loader = new TargetLoader();
    Callable<?> callable = (Callable<?>) loader.add("Sample",
        writer.toByteArray()).newInstance();
    final Object[] args = (Object[]) callable.call();
    assertEquals(3, args.length, 0.0);
    assertEquals(Long.valueOf(1000), args[0]);
    assertEquals("Sample", args[1]);
View Full Code Here

    writer.visitField(Opcodes.ACC_PRIVATE, "access", "Ljava/lang/Object;",
        null, null);

    writer.visitEnd();
    final TargetLoader loader = new TargetLoader();
    Callable<?> callable = (Callable<?>) loader
        .add("Sample", writer.toByteArray())
        .getConstructor(Object.class).newInstance(data);
    assertSame(probes, callable.call());
  }
View Full Code Here

  @Test
  public void testInstrumentClass() throws Exception {
    byte[] bytes = instrumenter.instrument(
        TargetLoader.getClassDataAsBytes(InstrumenterTest.class),
        "Test");
    TargetLoader loader = new TargetLoader();
    Class<?> clazz = loader.add(InstrumenterTest.class, bytes);
    assertEquals("org.jacoco.core.instr.InstrumenterTest", clazz.getName());
  }
View Full Code Here

  @Test
  public void testSerialization() throws Exception {
    // Create instrumented instance:
    byte[] bytes = instrumenter.instrument(
        TargetLoader.getClassData(SerializationTarget.class), "Test");
    TargetLoader loader = new TargetLoader();
    Object obj1 = loader.add(SerializationTarget.class, bytes)
        .getConstructor(String.class, Integer.TYPE)
        .newInstance("Hello", Integer.valueOf(42));

    // Serialize instrumented instance:
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
View Full Code Here

    this.target = target;
  }

  @Before
  public void setup() throws Exception {
    loader = new TargetLoader();
    final ClassReader reader = new ClassReader(
        TargetLoader.getClassData(target));
    final ExecutionDataStore store = execute(reader);
    analyze(reader, store);
    source = Source.getSourceFor(target);
View Full Code Here

TOP

Related Classes of org.jacoco.core.test.TargetLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.