This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit cda7648dc206ea0f629f679fbd861d0b0957ad41 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Tue Jul 30 11:46:21 2019 +0200 Camel-Kubernetes: Fixed CS --- .../producer/KubernetesConfigMapsProducerTest.java | 4 +- .../KubernetesDeploymentsProducerTest.java | 61 +++++++--------------- .../producer/KubernetesHPAProducerTest.java | 2 +- .../producer/KubernetesJobProducerTest.java | 5 +- .../producer/KubernetesNamespacesProducerTest.java | 2 +- .../producer/KubernetesNodesProducerTest.java | 22 +++----- ...ernetesPersistentVolumesClaimsProducerTest.java | 2 +- .../KubernetesPersistentVolumesProducerTest.java | 2 +- .../producer/KubernetesPodsProducerTest.java | 2 +- ...bernetesReplicationControllersProducerTest.java | 2 +- .../KubernetesResourcesQuotaProducerTest.java | 21 +++----- .../producer/KubernetesSecretsProducerTest.java | 2 +- .../KubernetesServiceAccountsProducerTest.java | 2 +- .../producer/KubernetesServicesProducerTest.java | 2 +- 14 files changed, 47 insertions(+), 84 deletions(-) diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java index 14b90c6..83dcfd4 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java @@ -44,7 +44,7 @@ public class KubernetesConfigMapsProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test @@ -73,7 +73,7 @@ public class KubernetesConfigMapsProducerTest extends KubernetesTestSupport { assertEquals(3, result.size()); } - + @Test public void getConfigMapTestDefaultNamespace() throws Exception { ObjectMeta meta = new ObjectMeta(); diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesDeploymentsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesDeploymentsProducerTest.java index 5d544e4..9c59510 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesDeploymentsProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesDeploymentsProducerTest.java @@ -43,14 +43,13 @@ public class KubernetesDeploymentsProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } - + @Test public void listTest() throws Exception { server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/deployments").andReturn(200, new DeploymentListBuilder().addNewItem().and().build()).once(); - List<Deployment> result = template.requestBody("direct:list", "", - List.class); + List<Deployment> result = template.requestBody("direct:list", "", List.class); assertEquals(1, result.size()); } @@ -58,7 +57,7 @@ public class KubernetesDeploymentsProducerTest extends KubernetesTestSupport { @Test public void listByLabelsTest() throws Exception { server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/deployments?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")) - .andReturn(200, new DeploymentListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once(); + .andReturn(200, new DeploymentListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once(); Exchange ex = template.request("direct:listByLabels", new Processor() { @Override @@ -66,42 +65,23 @@ public class KubernetesDeploymentsProducerTest extends KubernetesTestSupport { Map<String, String> labels = new HashMap<>(); labels.put("key1", "value1"); labels.put("key2", "value2"); - exchange.getIn() - .setHeader( - KubernetesConstants.KUBERNETES_DEPLOYMENTS_LABELS, - labels); + exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_DEPLOYMENTS_LABELS, labels); } }); List<Deployment> result = ex.getOut().getBody(List.class); - + assertEquals(3, result.size()); } @Test public void createAndDeleteDeployment() throws Exception { - Deployment de1 = new DeploymentBuilder().withNewMetadata() - .withNamespace("test") - .withName("de1") - .withResourceVersion("1") - .withGeneration(2L) - .endMetadata() - .withNewSpec() - .withReplicas(0) - .endSpec() - .withNewStatus() - .withReplicas(1) - .withObservedGeneration(1L) - .endStatus() - .build(); - + Deployment de1 = new DeploymentBuilder().withNewMetadata().withNamespace("test").withName("de1").withResourceVersion("1").withGeneration(2L).endMetadata().withNewSpec() + .withReplicas(0).endSpec().withNewStatus().withReplicas(1).withObservedGeneration(1L).endStatus().build(); + server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/deployments/de1").andReturn(200, de1).once(); - server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/deployments/de1").andReturn(200, new DeploymentBuilder(de1) - .editStatus() - .withReplicas(0) - .withObservedGeneration(2L) - .endStatus() - .build()).times(5); + server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/deployments/de1") + .andReturn(200, new DeploymentBuilder(de1).editStatus().withReplicas(0).withObservedGeneration(2L).endStatus().build()).times(5); Exchange ex = template.request("direct:deleteDeployment", new Processor() { @@ -116,7 +96,7 @@ public class KubernetesDeploymentsProducerTest extends KubernetesTestSupport { assertTrue(deDeleted); } - + @Test public void createScaleAndDeleteDeployment() throws Exception { server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/deployments/de1").andReturn(200, new DeploymentBuilder().withNewMetadata().withName("de1") @@ -134,7 +114,7 @@ public class KubernetesDeploymentsProducerTest extends KubernetesTestSupport { } }); - //Thread.sleep(3000); + // Thread.sleep(3000); int replicas = ex.getOut().getBody(Integer.class); assertEquals(5, replicas); @@ -145,16 +125,11 @@ public class KubernetesDeploymentsProducerTest extends KubernetesTestSupport { return new RouteBuilder() { @Override public void configure() throws Exception { - from("direct:list") - .toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=listDeployments"); - from("direct:listByLabels") - .toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=listDeploymentsByLabels"); - from("direct:deleteDeployment") - .toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=deleteDeployment"); - from("direct:createDeployment") - .toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=createDeployment"); - from("direct:scaleDeployment") - .toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=scaleDeployment"); + from("direct:list").toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=listDeployments"); + from("direct:listByLabels").toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=listDeploymentsByLabels"); + from("direct:deleteDeployment").toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=deleteDeployment"); + from("direct:createDeployment").toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=createDeployment"); + from("direct:scaleDeployment").toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=scaleDeployment"); } }; } diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesHPAProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesHPAProducerTest.java index 6efd0d5..a7a1288 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesHPAProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesHPAProducerTest.java @@ -44,7 +44,7 @@ public class KubernetesHPAProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesJobProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesJobProducerTest.java index 4e4f81b..ef36fe3 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesJobProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesJobProducerTest.java @@ -44,12 +44,13 @@ public class KubernetesJobProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test public void listTest() throws Exception { - server.expect().withPath("/apis/batch/v1/namespaces/test/jobs").andReturn(200, new JobListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once(); + server.expect().withPath("/apis/batch/v1/namespaces/test/jobs").andReturn(200, new JobListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()) + .once(); List<Secret> result = template.requestBody("direct:list", "", List.class); assertEquals(3, result.size()); diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNamespacesProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNamespacesProducerTest.java index bf8134e..f7dc196 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNamespacesProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNamespacesProducerTest.java @@ -42,7 +42,7 @@ public class KubernetesNamespacesProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNodesProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNodesProducerTest.java index 703d9e7..8479acf 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNodesProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNodesProducerTest.java @@ -42,14 +42,13 @@ public class KubernetesNodesProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } - + @Test public void listTest() throws Exception { server.expect().withPath("/api/v1/nodes").andReturn(200, new NodeListBuilder().addNewItem().and().build()).once(); - List<Node> result = template.requestBody("direct:list", "", - List.class); + List<Node> result = template.requestBody("direct:list", "", List.class); assertEquals(1, result.size()); } @@ -57,7 +56,7 @@ public class KubernetesNodesProducerTest extends KubernetesTestSupport { @Test public void listByLabelsTest() throws Exception { server.expect().withPath("/api/v1/nodes?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")) - .andReturn(200, new NodeListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once(); + .andReturn(200, new NodeListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once(); Exchange ex = template.request("direct:listByLabels", new Processor() { @Override @@ -65,15 +64,12 @@ public class KubernetesNodesProducerTest extends KubernetesTestSupport { Map<String, String> labels = new HashMap<>(); labels.put("key1", "value1"); labels.put("key2", "value2"); - exchange.getIn() - .setHeader( - KubernetesConstants.KUBERNETES_NODES_LABELS, - labels); + exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NODES_LABELS, labels); } }); List<Node> result = ex.getOut().getBody(List.class); - + assertEquals(3, result.size()); } @@ -82,10 +78,8 @@ public class KubernetesNodesProducerTest extends KubernetesTestSupport { return new RouteBuilder() { @Override public void configure() throws Exception { - from("direct:list") - .toF("kubernetes-nodes:///?kubernetesClient=#kubernetesClient&operation=listNodes"); - from("direct:listByLabels") - .toF("kubernetes-nodes:///?kubernetesClient=#kubernetesClient&operation=listNodesByLabels"); + from("direct:list").toF("kubernetes-nodes:///?kubernetesClient=#kubernetesClient&operation=listNodes"); + from("direct:listByLabels").toF("kubernetes-nodes:///?kubernetesClient=#kubernetesClient&operation=listNodesByLabels"); } }; } diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesClaimsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesClaimsProducerTest.java index f036691..e48531b 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesClaimsProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesClaimsProducerTest.java @@ -45,7 +45,7 @@ public class KubernetesPersistentVolumesClaimsProducerTest extends KubernetesTes @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesProducerTest.java index 95fe316..f4cc6a0 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesProducerTest.java @@ -42,7 +42,7 @@ public class KubernetesPersistentVolumesProducerTest extends KubernetesTestSuppo @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPodsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPodsProducerTest.java index 0427f53..e80d976 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPodsProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPodsProducerTest.java @@ -43,7 +43,7 @@ public class KubernetesPodsProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesReplicationControllersProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesReplicationControllersProducerTest.java index 71cc9c0..6265d6b 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesReplicationControllersProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesReplicationControllersProducerTest.java @@ -43,7 +43,7 @@ public class KubernetesReplicationControllersProducerTest extends KubernetesTest @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesResourcesQuotaProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesResourcesQuotaProducerTest.java index 9010c6e..eb9dc3f 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesResourcesQuotaProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesResourcesQuotaProducerTest.java @@ -41,14 +41,13 @@ public class KubernetesResourcesQuotaProducerTest extends KubernetesTestSupport @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } - + @Test public void listTest() throws Exception { server.expect().withPath("/api/v1/resourcequotas").andReturn(200, new ResourceQuotaListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once(); - List<ResourceQuota> result = template.requestBody("direct:list", "", - List.class); + List<ResourceQuota> result = template.requestBody("direct:list", "", List.class); assertEquals(3, result.size()); } @@ -62,12 +61,8 @@ public class KubernetesResourcesQuotaProducerTest extends KubernetesTestSupport @Override public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader( - KubernetesConstants.KUBERNETES_NAMESPACE_NAME, - "test"); - exchange.getIn().setHeader( - KubernetesConstants.KUBERNETES_RESOURCES_QUOTA_NAME, - "rq1"); + exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "test"); + exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_RESOURCES_QUOTA_NAME, "rq1"); } }); @@ -81,10 +76,8 @@ public class KubernetesResourcesQuotaProducerTest extends KubernetesTestSupport return new RouteBuilder() { @Override public void configure() throws Exception { - from("direct:list") - .to("kubernetes-resources-quota:///?kubernetesClient=#kubernetesClient&operation=listResourcesQuota"); - from("direct:delete") - .to("kubernetes-resources-quota:///?kubernetesClient=#kubernetesClient&operation=deleteResourceQuota"); + from("direct:list").to("kubernetes-resources-quota:///?kubernetesClient=#kubernetesClient&operation=listResourcesQuota"); + from("direct:delete").to("kubernetes-resources-quota:///?kubernetesClient=#kubernetesClient&operation=deleteResourceQuota"); } }; } diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesSecretsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesSecretsProducerTest.java index b8ae4f2..c6a9165 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesSecretsProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesSecretsProducerTest.java @@ -43,7 +43,7 @@ public class KubernetesSecretsProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServiceAccountsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServiceAccountsProducerTest.java index 9af902f..f579138 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServiceAccountsProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServiceAccountsProducerTest.java @@ -43,7 +43,7 @@ public class KubernetesServiceAccountsProducerTest extends KubernetesTestSupport @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServicesProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServicesProducerTest.java index 23dda04..230a908 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServicesProducerTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServicesProducerTest.java @@ -44,7 +44,7 @@ public class KubernetesServicesProducerTest extends KubernetesTestSupport { @BindToRegistry("kubernetesClient") public KubernetesClient getClient() throws Exception { - return server.getClient(); + return server.getClient(); } @Test