use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class TcpClientOutputTest method setup.
@Before
public void setup() throws Exception {
logger = new ExceptionRecorder();
final MockSocketConnection con = new MockSocketConnection();
localSocket = con.getSocketA();
remoteSocket = con.getSocketB();
remoteWriter = new RemoteControlWriter(remoteSocket.getOutputStream());
controller = new TcpClientOutput(logger) {
@Override
protected Socket createSocket(AgentOptions options) throws IOException {
return localSocket;
}
};
data = new RuntimeData();
controller.startup(new AgentOptions(), data);
remoteReader = new RemoteControlReader(remoteSocket.getInputStream());
}
use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class TcpServerOutputTest method setup.
@Before
public void setup() throws Exception {
options = new AgentOptions();
logger = new ExceptionRecorder();
serverSocket = new MockServerSocket();
controller = new TcpServerOutput(logger) {
@Override
protected ServerSocket createServerSocket(AgentOptions options) throws IOException {
return serverSocket;
}
};
data = new RuntimeData();
controller.startup(options, data);
}
use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class PreMain method premain.
/**
* This method is called by the JVM to initialize Java agents.
*
* @param options
* agent options
* @param inst
* instrumentation callback provided by the JVM
* @throws Exception
* in case initialization fails
*/
public static void premain(final String options, final Instrumentation inst) throws Exception {
final AgentOptions agentOptions = new AgentOptions(options);
final Agent agent = Agent.getInstance(agentOptions);
final IRuntime runtime = createRuntime(inst);
runtime.startup(agent.getData());
inst.addTransformer(new CoverageTransformer(runtime, agentOptions, IExceptionLogger.SYSTEM_ERR));
}
use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class AgentTest method shutdown_should_log_exception.
@Test
public void shutdown_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) {
}
public void shutdown() throws Exception {
throw expected;
}
public void writeExecutionData(boolean reset) {
}
};
}
};
agent.startup();
agent.shutdown();
assertSame(expected, loggedException);
}
use of org.jacoco.core.runtime.AgentOptions in project jacoco by jacoco.
the class AgentTest method setup.
@Before
public void setup() {
options = new AgentOptions();
options.setOutput(OutputMode.file);
// avoid network access (DNS lookup for id generation):
options.setSessionId("test");
}
Aggregations