use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class CoverageTransformerTest method setup.
@Before
public void setup() {
recorder = new ExceptionRecorder();
options = new AgentOptions();
classLoader = getClass().getClassLoader();
protectionDomain = getClass().getProtectionDomain();
runtime = new StubRuntime();
}
use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class FileOutputTest method testWriteData.
@Test
public void testWriteData() throws Exception {
File destFile = folder.newFile("jacoco.exec");
AgentOptions options = new AgentOptions();
options.setDestfile(destFile.getAbsolutePath());
FileOutput controller = new FileOutput();
controller.startup(options, new RuntimeData());
controller.writeExecutionData(false);
controller.shutdown();
assertTrue("Execution data file should be created", destFile.exists());
assertTrue("Execution data file should have contents", destFile.length() > 0);
}
use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class FileOutputTest method testCreateDestFileOnStartup.
@Test
public void testCreateDestFileOnStartup() throws Exception {
File destFile = folder.newFile("jacoco.exec");
AgentOptions options = new AgentOptions();
options.setDestfile(destFile.getAbsolutePath());
FileOutput controller = new FileOutput();
controller.startup(options, new RuntimeData());
assertTrue("Execution data file should be created", destFile.exists());
assertEquals("Execution data file should be empty", 0, destFile.length());
}
use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class AbstractAgentMojo method createAgentOptions.
AgentOptions createAgentOptions() {
final AgentOptions agentOptions = new AgentOptions();
agentOptions.setDestfile(getDestFile().getAbsolutePath());
if (append != null) {
agentOptions.setAppend(append.booleanValue());
}
if (getIncludes() != null && !getIncludes().isEmpty()) {
final String agentIncludes = StringUtils.join(getIncludes().iterator(), ":");
agentOptions.setIncludes(agentIncludes);
}
if (getExcludes() != null && !getExcludes().isEmpty()) {
final String agentExcludes = StringUtils.join(getExcludes().iterator(), ":");
agentOptions.setExcludes(agentExcludes);
}
if (exclClassLoaders != null) {
agentOptions.setExclClassloader(exclClassLoaders);
}
if (inclBootstrapClasses != null) {
agentOptions.setInclBootstrapClasses(inclBootstrapClasses.booleanValue());
}
if (inclNoLocationClasses != null) {
agentOptions.setInclNoLocationClasses(inclNoLocationClasses.booleanValue());
}
if (sessionId != null) {
agentOptions.setSessionId(sessionId);
}
if (dumpOnExit != null) {
agentOptions.setDumpOnExit(dumpOnExit.booleanValue());
}
if (output != null) {
agentOptions.setOutput(output);
}
if (address != null) {
agentOptions.setAddress(address);
}
if (port != null) {
agentOptions.setPort(port.intValue());
}
if (classDumpDir != null) {
agentOptions.setClassDumpDir(classDumpDir.getAbsolutePath());
}
if (jmx != null) {
agentOptions.setJmx(jmx.booleanValue());
}
return agentOptions;
}
use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class AgentTest method startup_should_log_exception.
@Test
public void startup_should_log_exception() throws Exception {
final Exception expected = new Exception();
Agent agent = new Agent(options, this) {
@Override
IAgentOutput createAgentOutput() {
return new IAgentOutput() {
public void startup(AgentOptions options, RuntimeData data) throws Exception {
throw expected;
}
public void shutdown() {
}
public void writeExecutionData(boolean reset) {
}
};
}
};
agent.startup();
assertSame(expected, loggedException);
}
Aggregations