Annotation Type AutoConfigureGrpcMock
Annotation for test classes that want to start a gRPC Mock server as part of the Spring Application Context.
It is recommended to use 0 for gRPC Mock port, as a random free port will be
selected and used. Once a random port is selected it can be access via
${grpcmock.server.port} property and used in gRPC Channel creation.
Mapping stubs will be cleared after each test run and after each test class run. If test class was run with a fixed port, the test context will be marked as dirty to reinitialise a new one.
- Author:
- Fadelis
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionDefines the file path for the cert chain.Defines executor bean to be used for the gRPC server.intDefines executor thread count to be used for the server, which will create aExecutorviaExecutors.newFixedThreadPool(int).Class<? extends io.grpc.ServerInterceptor>[]DefinesServerInterceptorfor the gRPC Mock server.Defines the name of in-process server configured.intDefines the port value for the gRPC Mock server.Defines the file path for the private key.booleanSet this to true to use InProcessServer instead of netty based one.
-
Element Details
-
port
int portDefines the port value for the gRPC Mock server. If set to0a random free port will be picked.- Default:
- 0
-
useInProcessServer
boolean useInProcessServerSet this to true to use InProcessServer instead of netty based one.- Default:
- false
-
name
String nameDefines the name of in-process server configured. If empty, a random name will be generated- Default:
- ""
-
interceptors
Class<? extends io.grpc.ServerInterceptor>[] interceptorsDefinesServerInterceptorfor the gRPC Mock server. Interceptors defined here must have a default constructor without any arguments.- Default:
- {}
-
executorThreadCount
int executorThreadCountDefines executor thread count to be used for the server, which will create a
ExecutorviaExecutors.newFixedThreadPool(int).If
executorBeanName()is defined it will take priority over this. If none of these are defined a defaultExecutorwill be used fromServer.- Default:
- -1
-
executorBeanName
String executorBeanNameDefines executor bean to be used for the gRPC server.
This will take priority over
executorThreadCount(). If none of these are defined a defaultExecutorwill be used fromServerBuilder.- Default:
- ""
-
certChainFile
String certChainFileDefines the file path for the cert chain. Both this andprivateKeyFile()must be defined in order to configure server security viaServerBuilder.useTransportSecurity(java.io.File, java.io.File).- Default:
- ""
-
privateKeyFile
String privateKeyFileDefines the file path for the private key. Both this andcertChainFile()must be defined in order to configure server security viaServerBuilder.useTransportSecurity(java.io.File, java.io.File).- Default:
- ""
-