Search in sources :

Example 1 with ExecutionDataWriter

use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.

the class TcpConnectionTest method testInvalidContent.

@Test(expected = IOException.class)
public void testInvalidContent() throws Exception {
    final OutputStream remoteOut = mockConnection.getSocketB().getOutputStream();
    new ExecutionDataWriter(remoteOut);
    final TcpConnection con = new TcpConnection(mockConnection.getSocketA(), data);
    con.init();
    remoteOut.write(123);
    con.run();
}
Also used : OutputStream(java.io.OutputStream) ExecutionDataWriter(org.jacoco.core.data.ExecutionDataWriter) Test(org.junit.Test)

Example 2 with ExecutionDataWriter

use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.

the class Agent method getExecutionData.

public byte[] getExecutionData(final boolean reset) {
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    try {
        final ExecutionDataWriter writer = new ExecutionDataWriter(buffer);
        data.collect(writer, writer, reset);
    } catch (final IOException e) {
        // Must not happen with ByteArrayOutputStream
        throw new AssertionError(e);
    }
    return buffer.toByteArray();
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) ExecutionDataWriter(org.jacoco.core.data.ExecutionDataWriter) IOException(java.io.IOException)

Example 3 with ExecutionDataWriter

use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.

the class MergeTest method createExecFile.

private File createExecFile(String name) throws IOException {
    File file = new File(tmp.getRoot(), name + ".exec");
    final FileOutputStream execout = new FileOutputStream(file);
    ExecutionDataWriter writer = new ExecutionDataWriter(execout);
    writer.visitClassExecution(new ExecutionData(name.hashCode(), name, new boolean[] { true }));
    execout.close();
    return file;
}
Also used : FileOutputStream(java.io.FileOutputStream) ExecutionDataWriter(org.jacoco.core.data.ExecutionDataWriter) File(java.io.File) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 4 with ExecutionDataWriter

use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.

the class ExecFileLoaderTest method createFile.

private File createFile(String id) throws IOException {
    final File file = new File(sourceFolder.getRoot(), id + ".exec");
    final FileOutputStream out = new FileOutputStream(file);
    final ExecutionDataWriter writer = new ExecutionDataWriter(out);
    final int value = id.length();
    writer.visitClassExecution(new ExecutionData(value, id, new boolean[] { true }));
    writer.visitSessionInfo(new SessionInfo(id, value, value));
    out.close();
    return file;
}
Also used : FileOutputStream(java.io.FileOutputStream) SessionInfo(org.jacoco.core.data.SessionInfo) ExecutionDataWriter(org.jacoco.core.data.ExecutionDataWriter) File(java.io.File) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 5 with ExecutionDataWriter

use of org.jacoco.core.data.ExecutionDataWriter in project jacoco by jacoco.

the class TcpConnectionTest method testLocalClose.

/**
 * Local socket is closed while waiting for commands.
 *
 * @throws Exception
 */
@Test
public void testLocalClose() throws Exception {
    final OutputStream remoteOut = mockConnection.getSocketB().getOutputStream();
    new ExecutionDataWriter(remoteOut);
    final TcpConnection con = new TcpConnection(mockConnection.getSocketA(), data);
    con.init();
    final Future<Void> f = executor.submit(new Callable<Void>() {

        public Void call() throws Exception {
            con.run();
            return null;
        }
    });
    assertBlocks(f);
    con.close();
    f.get();
}
Also used : OutputStream(java.io.OutputStream) ExecutionDataWriter(org.jacoco.core.data.ExecutionDataWriter) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

ExecutionDataWriter (org.jacoco.core.data.ExecutionDataWriter)15 FileOutputStream (java.io.FileOutputStream)10 ExecutionData (org.jacoco.core.data.ExecutionData)6 File (java.io.File)5 IOException (java.io.IOException)5 OutputStream (java.io.OutputStream)5 SessionInfo (org.jacoco.core.data.SessionInfo)4 Test (org.junit.Test)4 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ServerSocket (java.net.ServerSocket)1 Socket (java.net.Socket)1 Map (java.util.Map)1 ExecutionDataStore (org.jacoco.core.data.ExecutionDataStore)1 IExecutionDataVisitor (org.jacoco.core.data.IExecutionDataVisitor)1 ISessionInfoVisitor (org.jacoco.core.data.ISessionInfoVisitor)1 RemoteControlReader (org.jacoco.core.runtime.RemoteControlReader)1 RemoteControlWriter (org.jacoco.core.runtime.RemoteControlWriter)1 AnalysisException (org.sonar.java.AnalysisException)1