Annotation Type AutoConfigureGrpcMock
@Target(TYPE) @Retention(RUNTIME) @Import(GrpcMockConfiguration.class) @PropertyMapping("grpcmock.server") @Inherited public @interface 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 Elements Modifier and Type Optional Element Description StringcertChainFileDefines the file path for the cert chain.StringexecutorBeanNameDefines executor bean to be used for the gRPC server.intexecutorThreadCountDefines executor thread count to be used for the server, which will create aExecutorviaExecutors.newFixedThreadPool(int).Class<? extends io.grpc.ServerInterceptor>[]interceptorsDefinesServerInterceptorfor the gRPC Mock server.intportDefines the port value for the gRPC Mock server.StringprivateKeyFileDefines the file path for the private key.
-
Element Details
-
port
int portDefines the port value for the gRPC Mock server. If set to0a random free port will be picked.- Default:
- 0
-
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:
- ""
-