Package org.jacoco.core.runtime

Examples of org.jacoco.core.runtime.IRuntime


    int c;
    while ((c = in.read()) != -1) {
      out.write(c);
    }
    final byte[] buffer = out.toByteArray();
    final IRuntime runtime = new LoggerRuntime();
    return new Runnable() {

      public void run() {
        for (int i = 0; i < count; i++) {
          ClassReader reader = new ClassReader(buffer);
View Full Code Here


  public InstrumentationSizeSzenario(Class<?> target) {
    this.target = target;
  }

  public void run(IPerfOutput output) throws Exception {
    final IRuntime runtime = new LoggerRuntime();
    ClassReader reader = new ClassReader(TargetLoader.getClassData(target));
    final Instrumenter instr = new Instrumenter(runtime);
    instr.instrument(reader);
    output.writeByteResult("instrumented class",
        instr.instrument(reader).length, reader.b.length);
View Full Code Here

    */
   public InputStream openStream()
   {
      try
      {
         IRuntime runtime = ArquillianRuntime.getInstance();
         Instrumenter instrumenter = new Instrumenter(runtime);
         byte[] instrumented = instrumenter.instrument(asset.openStream(), EX_STRING);
        
         return new ByteArrayInputStream(instrumented);
      }
View Full Code Here

    @SuiteScoped
    private InstanceProducer<IRuntime> runtimeInst;

    public void createRuntime(@Observes BeforeSuite event) throws Exception
    {
        IRuntime runtime = ArquillianRuntime.getInstance();
        runtimeInst.set(runtime);
    }
View Full Code Here

    */
   public InputStream openStream()
   {
      try
      {
         IRuntime runtime = ArquillianRuntime.getInstance();
         Instrumenter instrumenter = new Instrumenter(runtime);
         byte[] instrumented = instrumenter.instrument(asset.openStream());
        
         return new ByteArrayInputStream(instrumented);
      }
View Full Code Here

    @SuiteScoped
    private InstanceProducer<IRuntime> runtimeInst;

    public void createRuntime(@Observes BeforeSuite event) throws Exception
    {
        IRuntime runtime = ArquillianRuntime.getInstance();
        runtime.setSessionId(UUID.randomUUID().toString());
        runtime.startup();

        runtimeInst.set(runtime);
    }
View Full Code Here

    @Inject
    private Instance<ServiceLoader> serviceLoader;

    public void writeCoverageData(@Observes AfterSuite arqEvent) throws Exception {
        IRuntime runtime = runtimeInst.get();
        if (runtime != null) {
            ByteArrayOutputStream coverageOutputStream = null;
            try {
                coverageOutputStream = new ByteArrayOutputStream();
                ExecutionDataWriter writer = new ExecutionDataWriter(coverageOutputStream);
                runtime.collect(writer, writer, true);
            } finally {
                runtime.shutdown();
                if (coverageOutputStream != null) {
                    try {
                        coverageOutputStream.close();
                    } catch (Exception e) {
                        throw new RuntimeException("Could not close coverage file", e);
View Full Code Here

  }

  @Override
  protected Runnable getInstrumentedRunnable() throws Exception {
    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

   *            instrumentation services
   * @throws Exception
   *             internal startup problem
   */
  public void init(final Instrumentation inst) throws Exception {
    final IRuntime runtime = createRuntime(inst);
    String sessionId = options.getSessionId();
    if (sessionId == null) {
      sessionId = createSessionId();
    }
    runtime.setSessionId(sessionId);
    runtime.startup();
    inst.addTransformer(new CoverageTransformer(runtime, options, logger));
    controller = createAgentController();
    controller.startup(options, runtime);
  }
View Full Code Here

    final String targetName = TestTarget.class.getName();

    // For instrumentation and runtime we need a IRuntime instance
    // to collect execution data:
    final IRuntime runtime = new LoggerRuntime();

    // The Instrumenter creates a modified version of our test target class
    // that contains additional probes for execution data recording:
    final Instrumenter instr = new Instrumenter(runtime);
    final byte[] instrumented = instr
        .instrument(getTargetClass(targetName));

    // Now we're ready to run our instrumented class and need to startup the
    // runtime first:
    runtime.startup();

    // In this tutorial we use a special class loader to directly load the
    // instrumented class definition from a byte[] instances.
    final MemoryClassLoader memoryClassLoader = new MemoryClassLoader();
    memoryClassLoader.addDefinition(targetName, instrumented);
    final Class<?> targetClass = memoryClassLoader.loadClass(targetName);

    // Here we execute our test target class through its Runnable interface:
    final Runnable targetInstance = (Runnable) targetClass.newInstance();
    targetInstance.run();

    // At the end of test execution we collect execution data and shutdown
    // the runtime:
    final ExecutionDataStore executionData = new ExecutionDataStore();
    runtime.collect(executionData, false);
    runtime.shutdown();

    // Together with the original class definition we can calculate coverage
    // information:
    final CoverageBuilder coverageBuilder = new CoverageBuilder(
        executionData);
View Full Code Here

TOP

Related Classes of org.jacoco.core.runtime.IRuntime

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.