Search in sources :

Example 1 with IAgentOutput

use of org.jacoco.agent.rt.internal.output.IAgentOutput 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);
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) IAgentOutput(org.jacoco.agent.rt.internal.output.IAgentOutput) InstanceNotFoundException(javax.management.InstanceNotFoundException) AgentOptions(org.jacoco.core.runtime.AgentOptions) Test(org.junit.Test)

Example 2 with IAgentOutput

use of org.jacoco.agent.rt.internal.output.IAgentOutput 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);
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) IAgentOutput(org.jacoco.agent.rt.internal.output.IAgentOutput) IOException(java.io.IOException) InstanceNotFoundException(javax.management.InstanceNotFoundException) AgentOptions(org.jacoco.core.runtime.AgentOptions) Test(org.junit.Test)

Example 3 with IAgentOutput

use of org.jacoco.agent.rt.internal.output.IAgentOutput in project jacoco by jacoco.

the class AgentTest method startup_should_log_and_rethrow_exception.

@Test
public void startup_should_log_and_rethrow_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) {
                }
            };
        }
    };
    try {
        agent.startup();
        fail("Exception expected");
    } catch (Exception actual) {
        assertSame(expected, actual);
        assertSame(expected, loggedException);
    }
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) IAgentOutput(org.jacoco.agent.rt.internal.output.IAgentOutput) InstanceNotFoundException(javax.management.InstanceNotFoundException) AgentOptions(org.jacoco.core.runtime.AgentOptions) Test(org.junit.Test)

Aggregations

InstanceNotFoundException (javax.management.InstanceNotFoundException)3 IAgentOutput (org.jacoco.agent.rt.internal.output.IAgentOutput)3 AgentOptions (org.jacoco.core.runtime.AgentOptions)3 RuntimeData (org.jacoco.core.runtime.RuntimeData)3 Test (org.junit.Test)3 IOException (java.io.IOException)1