Created
August 25, 2015 05:48
-
-
Save iocanel/3dbb1b4d0f3def21ef66 to your computer and use it in GitHub Desktop.
Example of the KubernetesMockClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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