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
  • Element Details

    • port

      int port
      Defines the port value for the gRPC Mock server. If set to 0 a random free port will be picked.
      Default:
      0
    • useInProcessServer

      boolean useInProcessServer
      Set this to true to use InProcessServer instead of netty based one.
      Default:
      false
    • name

      String name
      Defines the name of in-process server configured. If empty, a random name will be generated
      Default:
      ""
    • interceptors

      Class<? extends io.grpc.ServerInterceptor>[] interceptors
      Defines ServerInterceptor for the gRPC Mock server. Interceptors defined here must have a default constructor without any arguments.
      Default:
      {}
    • executorThreadCount

      int executorThreadCount

      Defines executor thread count to be used for the server, which will create a Executor via Executors.newFixedThreadPool(int).

      If executorBeanName() is defined it will take priority over this. If none of these are defined a default Executor will be used from Server.

      Default:
      -1
    • executorBeanName

      String executorBeanName

      Defines executor bean to be used for the gRPC server.

      This will take priority over executorThreadCount(). If none of these are defined a default Executor will be used from ServerBuilder.

      Default:
      ""
    • certChainFile

      String certChainFile
      Defines the file path for the cert chain. Both this and privateKeyFile() must be defined in order to configure server security via ServerBuilder.useTransportSecurity(java.io.File, java.io.File).
      Default:
      ""
    • privateKeyFile

      String privateKeyFile
      Defines the file path for the private key. Both this and certChainFile() must be defined in order to configure server security via ServerBuilder.useTransportSecurity(java.io.File, java.io.File).
      Default:
      ""