Class GrpcServerExtension

  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension

    public class GrpcServerExtension
    extends java.lang.Object
    implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)
      After the test has completed, clean up the channel and server.
      void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)
      Before the test has started, create the server and channel.
      GrpcServerExtension directExecutor()
      Returns this configured to use a direct executor for the ManagedChannel and Server.
      io.grpc.ManagedChannel getChannel()
      Returns a ManagedChannel connected to this service.
      io.grpc.Server getServer()
      Returns the underlying gRPC Server for this service.
      java.lang.String getServerName()
      Returns the randomly generated server name for this service.
      io.grpc.util.MutableHandlerRegistry getServiceRegistry()
      Returns the service registry for this service.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GrpcServerExtension

        public GrpcServerExtension()
    • Method Detail

      • directExecutor

        public final GrpcServerExtension directExecutor()
        Returns this configured to use a direct executor for the ManagedChannel and Server. This can only be called at the rule instantiation.
        Returns:
        a GrpcServerExtension
      • getChannel

        public final io.grpc.ManagedChannel getChannel()
        Returns a ManagedChannel connected to this service.
        Returns:
        a ManagedChannel
      • getServer

        public final io.grpc.Server getServer()
        Returns the underlying gRPC Server for this service.
        Returns:
        a Server
      • getServerName

        public final java.lang.String getServerName()
        Returns the randomly generated server name for this service.
        Returns:
        the server name
      • getServiceRegistry

        public final io.grpc.util.MutableHandlerRegistry getServiceRegistry()
        Returns the service registry for this service. The registry is used to add service instances (e.g. BindableService or ServerServiceDefinition to the server.
        Returns:
        a MutableHandlerRegistry
      • afterEach

        public void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                       throws java.lang.Exception
        After the test has completed, clean up the channel and server.
        Specified by:
        afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
        Throws:
        java.lang.Exception
      • beforeEach

        public void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                        throws java.lang.Exception
        Before the test has started, create the server and channel.
        Specified by:
        beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
        Throws:
        java.lang.Exception