Examples of TargetLoader


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(name, source)
        .getTargetClass();

    // Check added field:
    final Field f = targetClass.getField("$jacocoAccess");
    assertEquals(Modifier.PUBLIC | Modifier.STATIC, f.getModifiers(), 0.0);
View Full Code Here

Examples of org.jacoco.core.test.TargetLoader

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

    writer.visitEnd();

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

Examples of org.jacoco.core.test.TargetLoader

  private ExecutionDataStore execute(final ClassReader reader)
      throws Exception {
    IRuntime runtime = new SystemPropertiesRuntime();
    runtime.startup();
    final byte[] bytes = new Instrumenter(runtime).instrument(reader);
    final TargetLoader loader = new TargetLoader(target, bytes);
    run(loader.getTargetClass());
    final ExecutionDataStore store = new ExecutionDataStore();
    runtime.collect(store, false);
    runtime.shutdown();
    return store;
  }
View Full Code Here

Examples of org.jacoco.core.test.TargetLoader

    ClassReader reader = new ClassReader(TargetLoader.getClassData(target));
    IRuntime runtime = new LoggerRuntime();
    runtime.startup();
    final Instrumenter instr = new Instrumenter(runtime);
    final byte[] instrumentedBuffer = instr.instrument(reader);
    final TargetLoader loader = new TargetLoader(target, instrumentedBuffer);

    return (Runnable) loader.newTargetInstance();
  }
View Full Code Here

Examples of org.jacoco.core.test.TargetLoader

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

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

Examples of org.jacoco.core.test.TargetLoader

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

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

Examples of org.jacoco.core.test.TargetLoader

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

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

Examples of org.jacoco.core.test.TargetLoader

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

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

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(name, source)
        .getTargetClass();

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

Examples of org.jacoco.core.test.TargetLoader

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

    writer.visitEnd();

    final TargetLoader loader = new TargetLoader(
        className.replace('/', '.'), writer.toByteArray());
    return (ITarget) loader.newTargetInstance();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.