use of com.palantir.tritium.test.TestImplementation in project tritium by palantir.
the class TracingInvocationEventHandlerTest method before.
@BeforeEach
// testing trace output to system out
@SuppressWarnings("SystemOut")
public void before() throws Exception {
Tracer.getAndClearTrace();
MDC.clear();
handler = TracingInvocationEventHandler.create("testComponent");
assertThat(handler).isInstanceOf(TracingInvocationEventHandler.class);
Tracer.setSampler(AlwaysSampler.INSTANCE);
Tracer.subscribe("sysout", System.out::println);
Tracer.subscribe("mock", mockSpanObserver);
instance = new TestImplementation();
method = instance.getClass().getDeclaredMethod("bulk", Set.class);
args = new Object[] { ImmutableSet.of("testArg") };
}
use of com.palantir.tritium.test.TestImplementation in project tritium by palantir.
the class InstrumentationTest method testEmptyHandlers.
@Test
void testEmptyHandlers() {
TestInterface delegate = new TestImplementation();
TestInterface instrumented = Instrumentation.wrap(TestInterface.class, delegate, Collections.emptyList(), InstrumentationFilters.INSTRUMENT_NONE);
assertThat(instrumented).isEqualTo(delegate);
assertThat(Proxy.isProxyClass(instrumented.getClass())).isFalse();
}
use of com.palantir.tritium.test.TestImplementation in project tritium by palantir.
the class InstrumentationTest method testFilterSkips.
@Test
void testFilterSkips(@Mock InvocationEventHandler<InvocationContext> mockHandler) {
TestInterface delegate = new TestImplementation();
TestInterface instrumented = Instrumentation.builder(TestInterface.class, delegate).withFilter(methodNameFilter("bulk")).withHandler(mockHandler).build();
when(mockHandler.isEnabled()).thenReturn(true);
instrumented.test();
verify(mockHandler).isEnabled();
verifyNoMoreInteractions(mockHandler);
}
use of com.palantir.tritium.test.TestImplementation in project tritium by palantir.
the class InstrumentationTest method testToString_delegateWithoutInstrumentation.
@Test
void testToString_delegateWithoutInstrumentation(@Mock InvocationEventHandler<InvocationContext> mockHandler) {
TestInterface delegate = new TestImplementation();
TestInterface instrumented = Instrumentation.builder(TestInterface.class, delegate).withHandler(mockHandler).build();
assertThat(instrumented).asString().isEqualTo("com.palantir.tritium.test.TestImplementation");
verifyNoMoreInteractions(mockHandler);
}
use of com.palantir.tritium.test.TestImplementation in project tritium by palantir.
the class InstrumentationTest method testEquals_sameInstance.
@Test
void testEquals_sameInstance() {
TestInterface proxy = Instrumentation.builder(TestInterface.class, new TestImplementation()).withPerformanceTraceLogging().build();
assertThat(proxy).isEqualTo(proxy);
}
Aggregations