java.lang.Object
io.helidon.webserver.testing.junit5.DirectWebClient
All Implemented Interfaces:
RuntimeType.Api<WebClientConfig>, HttpClient<HttpClientRequest>, ReleasableResource, WebClient

public class DirectWebClient extends Object implements WebClient
Unit testing client that bypasses HTTP transport and directly invokes router.
  • Constructor Details

    • DirectWebClient

      public DirectWebClient(HttpRouting.Builder routing)
      Create a direct client for HTTP routing.
      Parameters:
      routing - routing to use
  • Method Details

    • method

      public HttpClientRequest method(Method method)
      Description copied from interface: HttpClient
      Create a request for a method.
      Specified by:
      method in interface HttpClient<HttpClientRequest>
      Parameters:
      method - HTTP method
      Returns:
      a new request (not thread safe)
    • closeResource

      public void closeResource()
      Description copied from interface: HttpClient
      Gracefully close all opened client specific connections.
      Specified by:
      closeResource in interface HttpClient<HttpClientRequest>
      Specified by:
      closeResource in interface ReleasableResource
    • prototype

      public WebClientConfig prototype()
      Description copied from interface: RuntimeType.Api
      The prototype as it was received when creating this runtime object instance.
      Specified by:
      prototype in interface RuntimeType.Api<WebClientConfig>
      Returns:
      prototype object used to create this instance
    • client

      public <T, C extends ProtocolConfig> T client(Protocol<T,C> protocol, C protocolConfig)
      Description copied from interface: WebClient
      To switch to a non-HTTP protocol client (or a client of a specific HTTP version). The resulting protocol will use this client as a base, so it will share all configuration that is relevant for the protocol.
      Specified by:
      client in interface WebClient
      Type Parameters:
      T - type of the protocol client
      C - type of the protocol config
      Parameters:
      protocol - protocol instance, usually defined as a constant on the protocol interface
      protocolConfig - configuration of the protocol to be used (if customization is required)
      Returns:
      a new protocol client instance
    • client

      public <T, C extends ProtocolConfig> T client(Protocol<T,C> protocol)
      Description copied from interface: WebClient
      To switch to a non-HTTP protocol client (or a client of a specific HTTP version) using its config configured when creating the client, or default config if none configured. The resulting protocol will use this client as a base, so it will share all configuration that is relevant for the protocol.
      Specified by:
      client in interface WebClient
      Type Parameters:
      T - type of the protocol client
      C - type of the protocol config
      Parameters:
      protocol - protocol instance, usually defined as a constant on the protocol interface
      Returns:
      a new protocol client instance
    • executor

      public ExecutorService executor()
      Description copied from interface: WebClient
      Executor services, uses virtual threads.
      Specified by:
      executor in interface WebClient
      Returns:
      executor service
    • cookieManager

      public WebClientCookieManager cookieManager()
      Description copied from interface: WebClient
      Cookie manager to use by this client.
      Specified by:
      cookieManager in interface WebClient
      Returns:
      cookie manager
    • setTls

      public DirectWebClient setTls(boolean tls)
      Whether to use tls (mark this connection as secure).
      Parameters:
      tls - use tls
      Returns:
      updated client
    • clientHost

      public DirectWebClient clientHost(String clientHost)
      Client host.
      Parameters:
      clientHost - client host to use in PeerInfo
      Returns:
      updated client
    • clientPort

      public DirectWebClient clientPort(int clientPort)
      Client port.
      Parameters:
      clientPort - client port to use in PeerInfo
      Returns:
      updated client
    • clientTlsPrincipal

      public DirectWebClient clientTlsPrincipal(Principal clientTlsPrincipal)
      Client peer TLS principal.
      Parameters:
      clientTlsPrincipal - principal to use in PeerInfo
      Returns:
      updated client
    • clientTlsCertificates

      public DirectWebClient clientTlsCertificates(Certificate[] clientTlsCertificates)
      Client peer TLS certificates.
      Parameters:
      clientTlsCertificates - certificates to use in PeerInfo
      Returns:
      updated client
    • serverHost

      public DirectWebClient serverHost(String serverHost)
      Server host.
      Parameters:
      serverHost - server host to use in PeerInfo
      Returns:
      updated client
    • serverPort

      public DirectWebClient serverPort(int serverPort)
      Server port.
      Parameters:
      serverPort - server port to use in PeerInfo
      Returns:
      updated client
    • serverTlsPrincipal

      public DirectWebClient serverTlsPrincipal(Principal serverTlsPrincipal)
      Server TLS principal.
      Parameters:
      serverTlsPrincipal - principal to use in PeerInfo
      Returns:
      updated client
    • serverTlsCertificates

      public DirectWebClient serverTlsCertificates(Certificate[] serverTlsCertificates)
      Server TLS certificates.
      Parameters:
      serverTlsCertificates - certificates to use in PeerInfo
      Returns:
      updated client
    • close

      public void close()
      Call this method once testing is done, to carry out after stop operations on routers.