mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-20 14:39:36 +00:00
Polish "Add server-side support for custom gRPC conventions"
See gh-49730
This commit is contained in:
+10
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import io.grpc.BindableService;
|
||||
import io.grpc.ServerInterceptor;
|
||||
import io.micrometer.context.ContextRegistry;
|
||||
import io.micrometer.core.instrument.binder.grpc.GrpcServerObservationConvention;
|
||||
import io.micrometer.core.instrument.binder.grpc.ObservationGrpcServerInterceptor;
|
||||
import io.micrometer.core.instrument.kotlin.ObservationCoroutineContextServerInterceptor;
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
@@ -35,6 +36,7 @@ import org.springframework.grpc.server.GlobalServerInterceptor;
|
||||
import org.springframework.grpc.server.GrpcServerFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for the {@link GrpcServerObservationAutoConfiguration}.
|
||||
@@ -123,6 +125,14 @@ class GrpcServerObservationAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenCustomConventionBeanIsPresentThenInterceptorUsesIt() {
|
||||
GrpcServerObservationConvention customConvention = mock(GrpcServerObservationConvention.class);
|
||||
this.contextRunner.withBean(GrpcServerObservationConvention.class, () -> customConvention)
|
||||
.run((context) -> assertThat(context.getBean(ObservationGrpcServerInterceptor.class))
|
||||
.hasFieldOrPropertyWithValue("customConvention", customConvention));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenMicrometerContextPropagationIsNotOnClasspathCoroutineInterceptorIsNotCreated() {
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(ContextRegistry.class))
|
||||
|
||||
Reference in New Issue
Block a user