You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-grpc-docs/src/main/antora/modules/ROOT/pages/server.adoc
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -241,7 +241,40 @@ If you include `spring-grpc-test` in your project, your gRPC server in a `@Sprin
241
241
All clients that connect to any server via the autoconfigured `GrpcChannelFactory` will be able to connect to it.
242
242
You can switch the in-process server on by setting `spring.grpc.test.inprocess.enabled` to `true` or by adding the `@AutoConfigureInProcessTransport` annotation to your `@SpringBootTest` class.
243
243
244
-
NOTE: When the in-process server is run in test mode (as opposed to <<in-process-server,running normally>>) it replaces the regular server and channel factories (e.g. Netty)
244
+
The in-process transport is an opt-in feature, so it requires an explicit configuration.
245
+
You can switch it on by setting `spring.grpc.test.inprocess.enabled` to `true` or by adding the `@AutoConfigureInProcessTransport` annotation to your `@SpringBootTest` class.
246
+
There is no need to set `spring.grpc.server.inprocess.name` as that is done automatically.
247
+
Using the annotation is equivalent to setting the "enabled" property to true, and in addition marking the in-process transport as "exclusive", meaning that no other transport will be used.
248
+
249
+
The `@AutoConfigureInProcessTransport` annotation works even if the test is not a `@SpringBootTest`, so if you only want to test the gRPC server layer you can use `@SpringJUnitConfig` with `@EnableAutoconfiguration` and add the `BindableService` beans that you want to test, either manually or as a `@ComponentScan`.
NOTE: When the in-process server is run in test mode (as opposed to <<in-process-server,running normally>>) it replaces the regular server and channel factories (e.g. Netty).
277
+
All channel target addresses are magically replaced with the in-process server name, so that clients can connect to it without any special configuration (hence the "default-channel" configuration in the example above, which is there purely to trigger automatic stub creation).
0 commit comments