Class KubernetesMockServer

    • Constructor Detail

      • KubernetesMockServer

        public KubernetesMockServer()
      • KubernetesMockServer

        public KubernetesMockServer​(boolean useHttps)
      • KubernetesMockServer

        public KubernetesMockServer​(io.fabric8.mockwebserver.MockWebServer server,
                                    Map<io.fabric8.mockwebserver.ServerRequest,​Queue<io.fabric8.mockwebserver.ServerResponse>> responses,
                                    boolean useHttps)
      • KubernetesMockServer

        public KubernetesMockServer​(io.fabric8.mockwebserver.Context context,
                                    io.fabric8.mockwebserver.MockWebServer server,
                                    Map<io.fabric8.mockwebserver.ServerRequest,​Queue<io.fabric8.mockwebserver.ServerResponse>> responses,
                                    boolean useHttps)
      • KubernetesMockServer

        public KubernetesMockServer​(io.fabric8.mockwebserver.Context context,
                                    io.fabric8.mockwebserver.MockWebServer server,
                                    Map<io.fabric8.mockwebserver.ServerRequest,​Queue<io.fabric8.mockwebserver.ServerResponse>> responses,
                                    io.fabric8.mockwebserver.http.Dispatcher dispatcher,
                                    boolean useHttps)
      • KubernetesMockServer

        public KubernetesMockServer​(io.fabric8.mockwebserver.Context context,
                                    io.fabric8.mockwebserver.MockWebServer server,
                                    Map<io.fabric8.mockwebserver.ServerRequest,​Queue<io.fabric8.mockwebserver.ServerResponse>> responses,
                                    io.fabric8.mockwebserver.http.Dispatcher dispatcher,
                                    boolean useHttps,
                                    VersionInfo versionInfo)
    • Method Detail

      • onStart

        public void onStart()
        Specified by:
        onStart in interface io.fabric8.mockwebserver.MockServer
      • init

        public void init()
      • init

        public void init​(InetAddress address,
                         int port)
      • destroy

        public void destroy()
      • getRootPaths

        public String[] getRootPaths()
      • createClient

        public NamespacedKubernetesClient createClient​(Consumer<KubernetesClientBuilder> kubernetesClientBuilderCustomizer)
        Creates a client using the customized KubernetesClientBuilder provided in the Consumer parameter.

        The function is invoked using an initial Config instance that is initialized with the mock server's URL and the TlsVersion to use.

        The following snippet shows how you can use this method in your tests:

           @BeforeEach
           void setUp() {
             server = new KubernetesMockServer();
             server.start();
             client = server.createClient(b -> {/* customize builder */}));
           }
         }
        Parameters:
        kubernetesClientBuilderCustomizer - Consumer function to enable further customization of the provided KubernetesClientBuilder.
        Returns:
        a NamespacedKubernetesClient instance from the provided configuration.
      • setVersionInfo

        public final void setVersionInfo​(VersionInfo versionInfo)
        Replace the current VersionInfo instance.
        Parameters:
        versionInfo - the new VersionInfo.
      • setUnsupported

        public void setUnsupported​(String... unsupported)
        Used to exclude support for the given apiGroups.
        Each is a simple expression of the form: group[/version]
        where * is a wildcard.
        For example to exclude all openshift support, you would specify openshift.io
        To exclude a specific apiVersion, you would fully specify route.openshift.io/v1

        NOTE this affects calls to Client.hasApiGroup(String, boolean) and Client.supports(Class). Other calls to get the full root path or other api group metadata will not return valid results in mock scenarios.

        Parameters:
        unsupported - apiGroup patterns
      • clearExpectations

        public void clearExpectations()
        Removes all recorded expectations.
      • initConfig

        protected Config initConfig()
      • reset

        public void reset()
        Description copied from interface: Resetable
        return the resource to its initial state
        Specified by:
        reset in interface Resetable
        Overrides:
        reset in class io.fabric8.mockwebserver.DefaultMockServer