Search in sources :

Example 1 with TestImplementation

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") };
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) TestImplementation(com.palantir.tritium.test.TestImplementation) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with TestImplementation

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();
}
Also used : TestImplementation(com.palantir.tritium.test.TestImplementation) TestInterface(com.palantir.tritium.test.TestInterface) Test(org.junit.jupiter.api.Test)

Example 3 with TestImplementation

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);
}
Also used : TestImplementation(com.palantir.tritium.test.TestImplementation) TestInterface(com.palantir.tritium.test.TestInterface) Test(org.junit.jupiter.api.Test)

Example 4 with TestImplementation

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);
}
Also used : TestImplementation(com.palantir.tritium.test.TestImplementation) TestInterface(com.palantir.tritium.test.TestInterface) Test(org.junit.jupiter.api.Test)

Example 5 with TestImplementation

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);
}
Also used : TestImplementation(com.palantir.tritium.test.TestImplementation) TestInterface(com.palantir.tritium.test.TestInterface) Test(org.junit.jupiter.api.Test)

Aggregations

TestImplementation (com.palantir.tritium.test.TestImplementation)23 Test (org.junit.jupiter.api.Test)21 TestInterface (com.palantir.tritium.test.TestInterface)17 Logger (org.slf4j.Logger)8 ImmutableSet (com.google.common.collect.ImmutableSet)3 DefaultInvocationContext (com.palantir.tritium.event.DefaultInvocationContext)3 InvocationContext (com.palantir.tritium.event.InvocationContext)3 Set (java.util.Set)3 SimpleLogger (org.slf4j.impl.SimpleLogger)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 Timer (com.codahale.metrics.Timer)2 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)2 TaggedMetricRegistry (com.palantir.tritium.metrics.registry.TaggedMetricRegistry)2 Method (java.lang.reflect.Method)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ConsoleReporter (com.codahale.metrics.ConsoleReporter)1 Metric (com.codahale.metrics.Metric)1 Slf4jReporter (com.codahale.metrics.Slf4jReporter)1 LoggingLevel (com.codahale.metrics.Slf4jReporter.LoggingLevel)1 Stopwatch (com.google.common.base.Stopwatch)1