use of org.evosuite.runtime.mock.java.lang.MockThrowable in project evosuite by EvoSuite.
the class InstrumentingAgent_exceptionsIntTest method testReplacementCallInSubClassOfException.
@Test
public void testReplacementCallInSubClassOfException() {
Object obj = null;
try {
InstrumentingAgent.activate();
obj = new ExceptionHolder();
} finally {
InstrumentingAgent.deactivate();
}
try {
MockFramework.enable();
StackTraceElement[] traces = new MockThrowable().getStackTrace();
ExceptionHolder eh = (ExceptionHolder) obj;
StackTraceElement[] b = eh.getTraces();
Assert.assertEquals(traces[1], b[1]);
} finally {
MockFramework.disable();
}
}
use of org.evosuite.runtime.mock.java.lang.MockThrowable in project evosuite by EvoSuite.
the class MockIOException method getDelegate.
/*
* This is needed for when super constructors call overridden methods,
* and proper delegate method (right inputs) is not instantiated yet
*/
private MockThrowable getDelegate() {
if (delegate == null) {
// placeholder
delegate = new MockThrowable();
delegate.setOriginForDelegate(super.getStackTrace()[0]);
}
return delegate;
}
use of org.evosuite.runtime.mock.java.lang.MockThrowable in project evosuite by EvoSuite.
the class InstrumentingAgent_exceptionsIntTest method testExceptions.
@Test
public void testExceptions() {
Object obj = null;
try {
InstrumentingAgent.activate();
obj = new ExceptionHolder();
} finally {
InstrumentingAgent.deactivate();
}
try {
MockFramework.enable();
ExceptionHolder eh = (ExceptionHolder) obj;
Assert.assertFalse(eh.getNonMockedNPE() instanceof EvoSuiteMock);
Assert.assertTrue(eh.getMockedThrowable() instanceof EvoSuiteMock);
StackTraceElement[] traces = new MockThrowable().getStackTrace();
StackTraceElement[] a = eh.getTracesWhenCast();
Assert.assertEquals(traces[1], a[1]);
} finally {
MockFramework.disable();
}
}
Aggregations