Search in sources :

Example 6 with SessionInfoStore

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

the class TcpConnectionTest method readAndAssertData.

private void readAndAssertData() throws IOException {
    final RemoteControlReader remoteReader = new RemoteControlReader(mockConnection.getSocketB().getInputStream());
    final ExecutionDataStore execStore = new ExecutionDataStore();
    remoteReader.setExecutionDataVisitor(execStore);
    final SessionInfoStore infoStore = new SessionInfoStore();
    remoteReader.setSessionInfoVisitor(infoStore);
    assertTrue(remoteReader.read());
    final List<SessionInfo> infos = infoStore.getInfos();
    assertEquals(1, infos.size());
    assertEquals("stubid", infos.get(0).getId());
    assertEquals("Foo", execStore.get(0x12345678).getName());
}
Also used : ExecutionDataStore(org.jacoco.core.data.ExecutionDataStore) SessionInfo(org.jacoco.core.data.SessionInfo) SessionInfoStore(org.jacoco.core.data.SessionInfoStore) RemoteControlReader(org.jacoco.core.runtime.RemoteControlReader)

Example 7 with SessionInfoStore

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

the class TcpConnectionTest method testRemoteReset.

@Test
public void testRemoteReset() throws Exception {
    data.getExecutionData(Long.valueOf(123), "Foo", 1).getProbes()[0] = true;
    final RemoteControlWriter remoteWriter = new RemoteControlWriter(mockConnection.getSocketB().getOutputStream());
    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);
    remoteWriter.visitDumpCommand(false, true);
    final RemoteControlReader remoteReader = new RemoteControlReader(mockConnection.getSocketB().getInputStream());
    final ExecutionDataStore execStore = new ExecutionDataStore();
    remoteReader.setExecutionDataVisitor(execStore);
    final SessionInfoStore infoStore = new SessionInfoStore();
    remoteReader.setSessionInfoVisitor(infoStore);
    assertTrue(remoteReader.read());
    assertTrue(infoStore.getInfos().isEmpty());
    assertTrue(execStore.getContents().isEmpty());
    assertFalse(data.getExecutionData(Long.valueOf(123), "Foo", 1).getProbes()[0]);
    con.close();
    f.get();
}
Also used : RemoteControlWriter(org.jacoco.core.runtime.RemoteControlWriter) ExecutionDataStore(org.jacoco.core.data.ExecutionDataStore) SessionInfoStore(org.jacoco.core.data.SessionInfoStore) IOException(java.io.IOException) RemoteControlReader(org.jacoco.core.runtime.RemoteControlReader) Test(org.junit.Test)

Example 8 with SessionInfoStore

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

the class ExecFileLoaderTest method assertFileContents.

private void assertFileContents(File file, String... expected) throws IOException {
    final InputStream in = new FileInputStream(file);
    final ExecutionDataStore execStore = new ExecutionDataStore();
    final SessionInfoStore sessionStore = new SessionInfoStore();
    final ExecutionDataReader reader = new ExecutionDataReader(in);
    reader.setExecutionDataVisitor(execStore);
    reader.setSessionInfoVisitor(sessionStore);
    reader.read();
    assertContents(execStore, sessionStore, expected);
}
Also used : ExecutionDataStore(org.jacoco.core.data.ExecutionDataStore) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) SessionInfoStore(org.jacoco.core.data.SessionInfoStore) FileInputStream(java.io.FileInputStream) ExecutionDataReader(org.jacoco.core.data.ExecutionDataReader)

Example 9 with SessionInfoStore

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

the class InstrumentingLoader method collect.

public ExecutionDataStore collect() {
    final ExecutionDataStore store = new ExecutionDataStore();
    data.collect(store, new SessionInfoStore(), false);
    runtime.shutdown();
    return store;
}
Also used : ExecutionDataStore(org.jacoco.core.data.ExecutionDataStore) SessionInfoStore(org.jacoco.core.data.SessionInfoStore)

Example 10 with SessionInfoStore

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

the class CyclomaticComplexityTest method analyze.

private ICounter analyze() throws IOException {
    final CoverageBuilder builder = new CoverageBuilder();
    final ExecutionDataStore store = new ExecutionDataStore();
    data.collect(store, new SessionInfoStore(), false);
    final Analyzer analyzer = new Analyzer(store, builder);
    analyzer.analyzeClass(bytes, "TestTarget");
    final Collection<IClassCoverage> classes = builder.getClasses();
    assertEquals(1, classes.size(), 0.0);
    final IClassCoverage classCoverage = classes.iterator().next();
    for (final IMethodCoverage m : classCoverage.getMethods()) {
        if (m.getName().equals("test")) {
            return m.getComplexityCounter();
        }
    }
    throw new AssertionError("No test() method.");
}
Also used : IMethodCoverage(org.jacoco.core.analysis.IMethodCoverage) ExecutionDataStore(org.jacoco.core.data.ExecutionDataStore) IClassCoverage(org.jacoco.core.analysis.IClassCoverage) CoverageBuilder(org.jacoco.core.analysis.CoverageBuilder) Analyzer(org.jacoco.core.analysis.Analyzer) SessionInfoStore(org.jacoco.core.data.SessionInfoStore)

Aggregations

ExecutionDataStore (org.jacoco.core.data.ExecutionDataStore)12 SessionInfoStore (org.jacoco.core.data.SessionInfoStore)12 Analyzer (org.jacoco.core.analysis.Analyzer)3 CoverageBuilder (org.jacoco.core.analysis.CoverageBuilder)3 IClassCoverage (org.jacoco.core.analysis.IClassCoverage)3 SessionInfo (org.jacoco.core.data.SessionInfo)3 RemoteControlReader (org.jacoco.core.runtime.RemoteControlReader)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 IMethodCoverage (org.jacoco.core.analysis.IMethodCoverage)2 RemoteControlWriter (org.jacoco.core.runtime.RemoteControlWriter)2 RuntimeData (org.jacoco.core.runtime.RuntimeData)2 TestListener (fr.inria.stamp.test.listener.TestListener)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 MalformedURLException (java.net.MalformedURLException)1 ServerSocket (java.net.ServerSocket)1 Socket (java.net.Socket)1 URL (java.net.URL)1