Skip to content

Instantly share code, notes, and snippets.

@iocanel
Created August 25, 2015 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iocanel/3dbb1b4d0f3def21ef66 to your computer and use it in GitHub Desktop.
Save iocanel/3dbb1b4d0f3def21ef66 to your computer and use it in GitHub Desktop.
Example of the KubernetesMockClient
KubernetesMockClient mock = new KubernetesMockClient();
//Define the behaviour
mock.services().inNamespace(or("default","fabric8")).withName("fabric8-console-service").get().andReturn(
new ServiceBuilder()
.withNewMetadata().withName("fabric8-console-service").endMetadata()
.withNewSpec()
.addNewPort()
.withProtocol("TCP")
.withPort(80)
.withNewTargetPort(9090)
.endPort()
.endSpec()
.build()
).anyTimes();
//Get an instance of the client mock
KubernetesClient client = mock.replay();
//Use the client
Assert.assertNotNull(client.services().inNamespace("fabric8").withName("fabric8-console-service").get());
Assert.assertNotNull(client.services().inNamespace("default").withName("fabric8-console-service").get());
//Verify the client
EasyMock.verify(client);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment