Package org.jacoco.core.data

Examples of org.jacoco.core.data.ExecutionDataStore


  public void testDump() throws Exception {
    final byte[] dump = controller.dump(false);
    final ByteArrayInputStream input = new ByteArrayInputStream(dump);

    final ExecutionDataReader reader = new ExecutionDataReader(input);
    final ExecutionDataStore execStore = new ExecutionDataStore();
    reader.setExecutionDataVisitor(execStore);
    final SessionInfoStore infoStore = new SessionInfoStore();
    reader.setSessionInfoVisitor(infoStore);
    reader.read();

    assertEquals("Foo", execStore.get(0x12345678).getName());

    final List<SessionInfo> infos = infoStore.getInfos();
    assertEquals(1, infos.size());
    assertEquals("stubid", infos.get(0).getId());
View Full Code Here


  @Test
  public void testWriteExecutionData() throws Exception {
    controller.writeExecutionData();

    final ExecutionDataStore execStore = new ExecutionDataStore();
    remoteReader.setExecutionDataVisitor(execStore);
    final SessionInfoStore infoStore = new SessionInfoStore();
    remoteReader.setSessionInfoVisitor(infoStore);

    remoteReader.read();

    assertEquals("Foo", execStore.get(0x12345678).getName());

    final List<SessionInfo> infos = infoStore.getInfos();
    assertEquals(1, infos.size());
    assertEquals("stubid", infos.get(0).getId());
View Full Code Here

    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, null, false);
    runtime.shutdown();

    // Together with the original class definition we can calculate coverage
    // information:
View Full Code Here

public final class ClassInfo implements ICoverageVisitor {

  private final Analyzer analyzer;

  private ClassInfo() {
    analyzer = new Analyzer(new ExecutionDataStore(), this);
  }
View Full Code Here

  private void loadExecutionData() throws IOException {
    final FileInputStream fis = new FileInputStream(executionDataFile);
    final ExecutionDataReader executionDataReader = new ExecutionDataReader(
        fis);
    executionDataStore = new ExecutionDataStore();
    sessionInfoStore = new SessionInfoStore();

    executionDataReader.setExecutionDataVisitor(executionDataStore);
    executionDataReader.setSessionInfoVisitor(sessionInfoStore);
View Full Code Here

  /**
   * Creates a new runtime.
   */
  protected AbstractRuntime() {
    store = new ExecutionDataStore();
    access = new ExecutionDataAccess(store);
    sessionId = createRandomId();
  }
View Full Code Here

    if (destfile.exists() && (!destfile.canWrite() || !destfile.isFile())) {
      throw new BuildException("Unable to write to destination file");
    }

    final ExecutionDataStore dataStore = new ExecutionDataStore();

    int numFilesMerged = 0;

    final Iterator<?> resourceIterator = files.iterator();
    while (resourceIterator.hasNext()) {
      final Resource resource = (Resource) resourceIterator.next();

      if (resource.isDirectory()) {
        continue;
      }

      log(String.format("Merging %s", resource.getName()),
          Project.MSG_DEBUG);

      InputStream resourceStream = null;
      try {
        resourceStream = resource.getInputStream();
        final ExecutionDataReader reader = new ExecutionDataReader(
            resourceStream);
        reader.setExecutionDataVisitor(dataStore);
        reader.read();

        numFilesMerged++;
      } catch (final IOException e) {
        throw new BuildException(String.format("Unable to read %s",
            resource.getName()), e);
      } finally {
        FileUtils.close(resourceStream);
      }
    }

    log(String.format("%d files merged", Integer.valueOf(numFilesMerged)),
        Project.MSG_INFO);

    OutputStream outputStream = null;
    try {
      destfile.getParentFile().mkdirs();
      destfile.createNewFile();
      outputStream = new BufferedOutputStream(new FileOutputStream(
          destfile));
      final ExecutionDataWriter dataWriter = new ExecutionDataWriter(
          outputStream);
      dataStore.accept(dataWriter);
    } catch (final IOException e) {
      throw new BuildException(String.format(
          "Unable to write merged file %s", destfile.getName()), e);
    } finally {
      FileUtils.close(outputStream);
View Full Code Here

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

    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, null, false);
    runtime.shutdown();
    return store;
  }
View Full Code Here

  @Before
  public void setup() throws Exception {
    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.data.ExecutionDataStore

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.