-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ada7316
commit f612f93
Showing
7 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...sions/jaeger/deployment/src/test/java/io/quarkus/jaeger/test/QuarkusJaegerTracerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package io.quarkus.jaeger.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.MockedStatic; | ||
import org.mockito.Mockito; | ||
|
||
import io.jaegertracing.Configuration; | ||
import io.jaegertracing.internal.JaegerTracer; | ||
import io.jaegertracing.internal.JaegerTracer.Builder; | ||
import io.jaegertracing.spi.Reporter; | ||
import io.jaegertracing.zipkin.ZipkinV2Reporter; | ||
import io.opentracing.Tracer; | ||
import io.quarkus.jaeger.runtime.QuarkusJaegerTracer; | ||
|
||
public class QuarkusJaegerTracerTest { | ||
|
||
@Test | ||
public void withzipkinCompatibilityMode() { | ||
|
||
try (MockedStatic<Configuration> mockedStaticConfiguration = Mockito.mockStatic(Configuration.class)) { | ||
Configuration mockedInstanceConfiguration = Mockito.mock(Configuration.class); | ||
Builder mockedBuilder = Mockito.mock(Builder.class); | ||
Tracer mockedTracer = Mockito.mock(JaegerTracer.class); | ||
|
||
mockedStaticConfiguration.when(() -> Configuration.fromEnv()).thenReturn(mockedInstanceConfiguration); | ||
mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.withMetricsFactory(Mockito.any())).thenReturn(mockedInstanceConfiguration); | ||
mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.getTracerBuilder()).thenReturn(mockedBuilder); | ||
mockedStaticConfiguration.when(() -> mockedBuilder.withScopeManager(Mockito.any())).thenReturn(mockedBuilder); | ||
mockedStaticConfiguration.when(() -> mockedBuilder.withReporter(Mockito.any())).thenReturn(mockedBuilder); | ||
mockedStaticConfiguration.when(() -> mockedBuilder.build()).thenReturn(mockedTracer); | ||
|
||
QuarkusJaegerTracer tracer = new QuarkusJaegerTracer(); | ||
tracer.setZipkinCompatibilityMode(true); | ||
tracer.setEndpoint("http://localhost"); | ||
tracer.toString(); | ||
tracer.close(); | ||
|
||
ArgumentCaptor<Reporter> argument = ArgumentCaptor.forClass(Reporter.class); | ||
Mockito.verify(mockedBuilder).withReporter(argument.capture()); | ||
assertEquals(ZipkinV2Reporter.class, argument.getValue().getClass()); | ||
} | ||
|
||
} | ||
|
||
@Test | ||
public void withoutZipkinCompatibilityMode() { | ||
try (MockedStatic<Configuration> mockedStaticConfiguration = Mockito.mockStatic(Configuration.class)) { | ||
Configuration mockedInstanceConfiguration = Mockito.mock(Configuration.class); | ||
Builder mockedBuilder = Mockito.mock(Builder.class); | ||
Tracer mockedTracer = Mockito.mock(JaegerTracer.class); | ||
|
||
mockedStaticConfiguration.when(() -> Configuration.fromEnv()).thenReturn(mockedInstanceConfiguration); | ||
mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.withMetricsFactory(Mockito.any())).thenReturn(mockedInstanceConfiguration); | ||
mockedStaticConfiguration.when(() -> mockedInstanceConfiguration.getTracerBuilder()).thenReturn(mockedBuilder); | ||
mockedStaticConfiguration.when(() -> mockedBuilder.withScopeManager(Mockito.any())).thenReturn(mockedBuilder); | ||
mockedStaticConfiguration.when(() -> mockedBuilder.withReporter(Mockito.any())).thenReturn(mockedBuilder); | ||
mockedStaticConfiguration.when(() -> mockedBuilder.build()).thenReturn(mockedTracer); | ||
|
||
QuarkusJaegerTracer tracer = new QuarkusJaegerTracer(); | ||
tracer.toString(); | ||
tracer.close(); | ||
|
||
ArgumentCaptor<Reporter> argument = ArgumentCaptor.forClass(Reporter.class); | ||
Mockito.verify(mockedBuilder).withReporter(argument.capture()); | ||
assertNull(argument.getValue()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters