diff --git a/samples/grpc-server-netty-shaded/src/test/java/com/example/demo/DemoApplicationTests.java b/samples/grpc-server-netty-shaded/src/test/java/com/example/demo/DemoApplicationTests.java index 0fc9b8c..b6460db 100644 --- a/samples/grpc-server-netty-shaded/src/test/java/com/example/demo/DemoApplicationTests.java +++ b/samples/grpc-server-netty-shaded/src/test/java/com/example/demo/DemoApplicationTests.java @@ -12,7 +12,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Lazy; -import org.springframework.grpc.client.ChannelBuilderOptions; import org.springframework.grpc.client.GrpcChannelFactory; import org.springframework.grpc.test.LocalGrpcPort; import org.springframework.test.annotation.DirtiesContext; @@ -53,8 +52,7 @@ public class DemoApplicationTests { @Bean @Lazy SimpleGrpc.SimpleBlockingStub stub(GrpcChannelFactory channels, @LocalGrpcPort int port) { - return SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:" + port, ChannelBuilderOptions.defaults())); + return SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:" + port)); } } diff --git a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java index 675a3fe..266c4e2 100644 --- a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java +++ b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java @@ -12,7 +12,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Lazy; -import org.springframework.grpc.client.ChannelBuilderOptions; import org.springframework.grpc.client.GrpcChannelFactory; import org.springframework.grpc.sample.proto.HelloReply; import org.springframework.grpc.sample.proto.HelloRequest; @@ -52,8 +51,7 @@ public class GrpcServerApplicationTests { @Bean @Lazy SimpleGrpc.SimpleBlockingStub stub(GrpcChannelFactory channels, @LocalGrpcPort int port) { - return SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:" + port, ChannelBuilderOptions.defaults())); + return SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:" + port)); } } diff --git a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerHealthIntegrationTests.java b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerHealthIntegrationTests.java index 8e2fff9..f6640d7 100644 --- a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerHealthIntegrationTests.java +++ b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerHealthIntegrationTests.java @@ -32,7 +32,6 @@ import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.grpc.client.ChannelBuilderOptions; import org.springframework.grpc.client.GrpcChannelFactory; import org.springframework.grpc.sample.proto.HelloReply; import org.springframework.grpc.sample.proto.HelloRequest; @@ -63,7 +62,7 @@ class GrpcServerHealthIntegrationTests { @Test void loadBalancerRespectsServerHealth(@Autowired GrpcChannelFactory channels, @Autowired HealthStatusManager healthStatusManager) { - ManagedChannel channel = channels.createChannel("health-test", ChannelBuilderOptions.defaults()); + ManagedChannel channel = channels.createChannel("health-test"); SimpleGrpc.SimpleBlockingStub client = SimpleGrpc.newBlockingStub(channel); // put the service up (SERVING) and give load balancer time to update @@ -118,7 +117,7 @@ class GrpcServerHealthIntegrationTests { @Test void healthIndicatorsAdaptedToGrpcHealthStatus(@Autowired GrpcChannelFactory channels) { - var channel = channels.createChannel("0.0.0.0:0", ChannelBuilderOptions.defaults()); + var channel = channels.createChannel("0.0.0.0:0"); var healthStub = HealthGrpc.newBlockingStub(channel); var serviceName = "custom"; diff --git a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java index 9475087..7a7f723 100644 --- a/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java +++ b/samples/grpc-server/src/test/java/org/springframework/grpc/sample/GrpcServerIntegrationTests.java @@ -54,7 +54,7 @@ class GrpcServerIntegrationTests { @Test void servesResponseToClient(@Autowired GrpcChannelFactory channels) { - assertThatResponseIsServedToChannel(channels.createChannel("0.0.0.0:0", ChannelBuilderOptions.defaults())); + assertThatResponseIsServedToChannel(channels.createChannel("0.0.0.0:0")); } } @@ -65,8 +65,7 @@ class GrpcServerIntegrationTests { @Test void specificErrorResponse(@Autowired GrpcChannelFactory channels) { - SimpleGrpc.SimpleBlockingStub client = SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:0", ChannelBuilderOptions.defaults())); + SimpleGrpc.SimpleBlockingStub client = SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:0")); assertThat(assertThrows(StatusRuntimeException.class, () -> client.sayHello(HelloRequest.newBuilder().setName("error").build())) .getStatus() @@ -75,8 +74,7 @@ class GrpcServerIntegrationTests { @Test void defaultErrorResponseIsUnknown(@Autowired GrpcChannelFactory channels) { - SimpleGrpc.SimpleBlockingStub client = SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:0", ChannelBuilderOptions.defaults())); + SimpleGrpc.SimpleBlockingStub client = SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:0")); assertThat(assertThrows(StatusRuntimeException.class, () -> client.sayHello(HelloRequest.newBuilder().setName("internal").build())) .getStatus() @@ -91,8 +89,7 @@ class GrpcServerIntegrationTests { @Test void specificErrorResponse(@Autowired GrpcChannelFactory channels) { - SimpleGrpc.SimpleBlockingStub client = SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:0", ChannelBuilderOptions.defaults())); + SimpleGrpc.SimpleBlockingStub client = SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:0")); assertThat(assertThrows(StatusRuntimeException.class, () -> client.sayHello(HelloRequest.newBuilder().setName("error").build())) .getStatus() @@ -101,8 +98,7 @@ class GrpcServerIntegrationTests { @Test void defaultErrorResponseIsUnknown(@Autowired GrpcChannelFactory channels) { - SimpleGrpc.SimpleBlockingStub client = SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:0", ChannelBuilderOptions.defaults())); + SimpleGrpc.SimpleBlockingStub client = SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:0")); assertThat(assertThrows(StatusRuntimeException.class, () -> client.sayHello(HelloRequest.newBuilder().setName("internal").build())) .getStatus() @@ -119,8 +115,7 @@ class GrpcServerIntegrationTests { @Test void servesResponseToClientWithAnyIPv4AddressAndRandomPort(@Autowired GrpcChannelFactory channels, @LocalGrpcPort int port) { - assertThatResponseIsServedToChannel( - channels.createChannel("0.0.0.0:" + port, ChannelBuilderOptions.defaults())); + assertThatResponseIsServedToChannel(channels.createChannel("0.0.0.0:" + port)); } } @@ -133,8 +128,7 @@ class GrpcServerIntegrationTests { @Test void servesResponseToClientWithAnyIPv4AddressAndRandomPort(@Autowired GrpcChannelFactory channels, @LocalGrpcPort int port) { - assertThatResponseIsServedToChannel( - channels.createChannel("0.0.0.0:" + port, ChannelBuilderOptions.defaults())); + assertThatResponseIsServedToChannel(channels.createChannel("0.0.0.0:" + port)); } } @@ -147,8 +141,7 @@ class GrpcServerIntegrationTests { @Test void servesResponseToClientWithLocalhostAndRandomPort(@Autowired GrpcChannelFactory channels, @LocalGrpcPort int port) { - assertThatResponseIsServedToChannel( - channels.createChannel("127.0.0.1:" + port, ChannelBuilderOptions.defaults())); + assertThatResponseIsServedToChannel(channels.createChannel("127.0.0.1:" + port)); } } @@ -162,8 +155,7 @@ class GrpcServerIntegrationTests { @Test void servesResponseToClientWithConfiguredChannel(@Autowired GrpcChannelFactory channels) { - assertThatResponseIsServedToChannel( - channels.createChannel("test-channel", ChannelBuilderOptions.defaults())); + assertThatResponseIsServedToChannel(channels.createChannel("test-channel")); } } @@ -193,8 +185,7 @@ class GrpcServerIntegrationTests { @Test void clientChannelWithSsl(@Autowired GrpcChannelFactory channels) { - assertThatResponseIsServedToChannel( - channels.createChannel("test-channel", ChannelBuilderOptions.defaults())); + assertThatResponseIsServedToChannel(channels.createChannel("test-channel")); } } @@ -212,8 +203,7 @@ class GrpcServerIntegrationTests { @Test void clientChannelWithSsl(@Autowired GrpcChannelFactory channels) { - assertThatResponseIsServedToChannel( - channels.createChannel("test-channel", ChannelBuilderOptions.defaults())); + assertThatResponseIsServedToChannel(channels.createChannel("test-channel")); } } diff --git a/samples/grpc-tomcat/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java b/samples/grpc-tomcat/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java index eec7986..209caf1 100644 --- a/samples/grpc-tomcat/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java +++ b/samples/grpc-tomcat/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java @@ -13,7 +13,6 @@ import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Lazy; -import org.springframework.grpc.client.ChannelBuilderOptions; import org.springframework.grpc.client.GrpcChannelFactory; import org.springframework.grpc.sample.proto.HelloReply; import org.springframework.grpc.sample.proto.HelloRequest; @@ -51,8 +50,7 @@ public class GrpcServerApplicationTests { @Bean @Lazy SimpleGrpc.SimpleBlockingStub stub(GrpcChannelFactory channels, @LocalServerPort int port) { - return SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:" + port, ChannelBuilderOptions.defaults())); + return SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:" + port)); } } diff --git a/samples/grpc-tomcat/src/test/java/org/springframework/grpc/sample/ListenOnTwoPortsTests.java b/samples/grpc-tomcat/src/test/java/org/springframework/grpc/sample/ListenOnTwoPortsTests.java index 9a05a41..d6e689e 100644 --- a/samples/grpc-tomcat/src/test/java/org/springframework/grpc/sample/ListenOnTwoPortsTests.java +++ b/samples/grpc-tomcat/src/test/java/org/springframework/grpc/sample/ListenOnTwoPortsTests.java @@ -5,13 +5,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Lazy; -import org.springframework.grpc.client.ChannelBuilderOptions; import org.springframework.grpc.client.GrpcChannelFactory; import org.springframework.grpc.sample.proto.HelloReply; import org.springframework.grpc.sample.proto.HelloRequest; @@ -52,8 +52,7 @@ public class ListenOnTwoPortsTests { @Bean @Lazy SimpleGrpc.SimpleBlockingStub stub(GrpcChannelFactory channels, @LocalGrpcPort int port) { - return SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:" + port, ChannelBuilderOptions.defaults())); + return SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:" + port)); } } diff --git a/samples/grpc-webflux/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java b/samples/grpc-webflux/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java index aec62c8..6c58324 100644 --- a/samples/grpc-webflux/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java +++ b/samples/grpc-webflux/src/test/java/org/springframework/grpc/sample/GrpcServerApplicationTests.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.test.context.SpringBootTest; @@ -12,7 +13,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Lazy; -import org.springframework.grpc.client.ChannelBuilderOptions; import org.springframework.grpc.client.GrpcChannelFactory; import org.springframework.grpc.sample.proto.HelloReply; import org.springframework.grpc.sample.proto.HelloRequest; @@ -52,8 +52,7 @@ public class GrpcServerApplicationTests { @Bean @Lazy SimpleGrpc.SimpleBlockingStub stub(GrpcChannelFactory channels, @LocalGrpcPort int port) { - return SimpleGrpc - .newBlockingStub(channels.createChannel("0.0.0.0:" + port, ChannelBuilderOptions.defaults())); + return SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:" + port)); } } diff --git a/spring-grpc-core/src/test/java/org/springframework/grpc/client/GrpcChannelFactoryTests.java b/spring-grpc-core/src/test/java/org/springframework/grpc/client/GrpcChannelFactoryTests.java index 9a2165e..f721235 100644 --- a/spring-grpc-core/src/test/java/org/springframework/grpc/client/GrpcChannelFactoryTests.java +++ b/spring-grpc-core/src/test/java/org/springframework/grpc/client/GrpcChannelFactoryTests.java @@ -50,7 +50,7 @@ class GrpcChannelFactoryTests { var customizer2 = mock(GrpcChannelBuilderCustomizer.class); var channelFactory = new DefaultGrpcChannelFactory(List.of(customizer1, customizer2), mock()); channelFactory.setVirtualTargets(path -> path); - var channel = channelFactory.createChannel(channelName, ChannelBuilderOptions.defaults()); + var channel = channelFactory.createChannel(channelName); assertThat(channel).isNotNull(); var inOrder = inOrder(customizer1, customizer2); inOrder.verify(customizer1).customize(anyString(), any(ManagedChannelBuilder.class)); @@ -95,7 +95,7 @@ class GrpcChannelFactoryTests { var channelName = "localhost"; var channelFactory = new DefaultGrpcChannelFactory(List.of(), configurer); channelFactory.setVirtualTargets(path -> path); - var channel = channelFactory.createChannel(channelName, ChannelBuilderOptions.defaults()); + var channel = channelFactory.createChannel(channelName); assertThat(channel).isNotNull(); verify(configurer).configureInterceptors(any(ManagedChannelBuilder.class), assertArg((interceptors) -> assertThat(interceptors).isEmpty()), eq(false)); @@ -131,9 +131,8 @@ class GrpcChannelFactoryTests { var channel = channelFactory.createChannel(channelName, ChannelBuilderOptions.defaults().withCustomizer(customizer1)); assertThat(channel).isNotNull(); - verify(customizer1).customize(anyString(), ArgumentMatchers.assertArg((builder) -> { - assertThat(builder).isInstanceOf(NettyChannelBuilder.class); - })); + verify(customizer1).customize(anyString(), ArgumentMatchers + .assertArg((builder) -> assertThat(builder).isInstanceOf(NettyChannelBuilder.class))); } @Test @@ -145,9 +144,8 @@ class GrpcChannelFactoryTests { var channel = channelFactory.createChannel(channelName, ChannelBuilderOptions.defaults().withCustomizer(customizer1)); assertThat(channel).isNotNull(); - verify(customizer1).customize(anyString(), ArgumentMatchers.assertArg((builder) -> { - assertThat(builder).isInstanceOf(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.class); - })); + verify(customizer1).customize(anyString(), ArgumentMatchers.assertArg((builder) -> assertThat(builder) + .isInstanceOf(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.class))); } }