Repository: camel Updated Branches: refs/heads/master 37d1f0894 -> fa947f01e
CAMEL-8714 Camel-Openshift: Add Environment Variables management Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fa947f01 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fa947f01 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fa947f01 Branch: refs/heads/master Commit: fa947f01edc53efff0558fea41f9738747d8e20a Parents: 37d1f08 Author: Andrea Cosentino <anco...@gmail.com> Authored: Mon Apr 27 23:19:13 2015 +0200 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Tue Apr 28 21:59:56 2015 +0200 ---------------------------------------------------------------------- .../component/openshift/OpenShiftConstants.java | 3 + .../component/openshift/OpenShiftOperation.java | 10 +- .../component/openshift/OpenShiftProducer.java | 186 +++++++++++++++++++ .../OpenShiftAddEnvironmentVariableTest.java | 60 ++++++ ...OpenShiftGetAllEnvironmentVariablesTest.java | 60 ++++++ .../OpenShiftGetDeploymentTypeTest.java | 60 ++++++ ...penShiftGetEnvironmentVariableValueTest.java | 60 ++++++ .../openshift/OpenShiftGetGearProfileTest.java | 60 ++++++ .../OpenShiftRemoveEnvironmentVariableTest.java | 60 ++++++ .../OpenShiftSetDeploymentTypeTest.java | 60 ++++++ .../OpenShiftUpdateEnvironmentVariableTest.java | 60 ++++++ 11 files changed, 678 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java index 7084885..e390fe0 100644 --- a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java +++ b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftConstants.java @@ -24,6 +24,9 @@ public final class OpenShiftConstants { public static final String EVENT_OLD_STATE = "CamelOpenShiftEventOldState"; public static final String EVENT_NEW_STATE = "CamelOpenShiftEventNewState"; public static final String EMBEDDED_CARTRIDGE_NAME = "CamelOpenShiftEmbeddedCartridgeName"; + public static final String DEPLOYMENT_TYPE = "CamelOpenShiftDeploymentType"; + public static final String ENVIRONMENT_VARIABLE_NAME = "CamelOpenShiftEnvironmentVariableName"; + public static final String ENVIRONMENT_VARIABLE_VALUE = "CamelOpenShiftEnvironmentVariableValue"; private OpenShiftConstants() { } http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java index 8ba9a0c..3295565 100644 --- a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java +++ b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftOperation.java @@ -29,5 +29,13 @@ public enum OpenShiftOperation { removeEmbeddedCartridge, scaleUp, scaleDown, - getGitUrl + getGitUrl, + getDeploymentType, + setDeploymentType, + getAllEnvironmentVariables, + addEnvironmentVariable, + updateEnvironmentVariable, + getEnvironmentVariableValue, + removeEnvironmentVariable, + getGearProfile } http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java index 7f80251..09661f7 100644 --- a/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java +++ b/components/camel-openshift/src/main/java/org/apache/camel/component/openshift/OpenShiftProducer.java @@ -20,12 +20,15 @@ import java.text.SimpleDateFormat; import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.Map; import com.openshift.client.ApplicationScale; import com.openshift.client.IApplication; import com.openshift.client.IDomain; +import com.openshift.client.IEnvironmentVariable; import com.openshift.client.IGear; import com.openshift.client.IGearGroup; +import com.openshift.client.IGearProfile; import com.openshift.client.OpenShiftException; import com.openshift.client.cartridge.IDeployedStandaloneCartridge; import com.openshift.client.cartridge.IEmbeddableCartridge; @@ -95,6 +98,30 @@ public class OpenShiftProducer extends DefaultProducer { case scaleDown: doScaleDown(exchange, domain); break; + case getDeploymentType: + doGetDeploymentType(exchange, domain); + break; + case setDeploymentType: + doSetDeploymentType(exchange, domain); + break; + case addEnvironmentVariable: + doAddEnvironmentVariable(exchange, domain); + break; + case updateEnvironmentVariable: + doUpdateEnvironmentVariable(exchange, domain); + break; + case getAllEnvironmentVariables: + doGetAllEnvironmentVariables(exchange, domain); + break; + case getEnvironmentVariableValue: + doGetEnvironmentVariableValue(exchange, domain); + break; + case removeEnvironmentVariable: + doRemoveEnvironmentVariable(exchange, domain); + break; + case getGearProfile: + doGetGearProfile(exchange, domain); + break; case list: default: // and do list by default @@ -372,4 +399,163 @@ public class OpenShiftProducer extends DefaultProducer { exchange.getIn().setBody(gitUrl); } } + + protected void doGetDeploymentType(Exchange exchange, IDomain domain) throws CamelExchangeException { + String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); + if (name == null) { + throw new CamelExchangeException("Application not specified", exchange); + } + + IApplication app = domain.getApplicationByName(name); + if (app == null) { + throw new CamelExchangeException("Application with id " + name + " not found.", exchange); + } else { + String deploymentType = app.getDeploymentType(); + exchange.getIn().setBody(deploymentType); + } + } + + protected void doSetDeploymentType(Exchange exchange, IDomain domain) throws CamelExchangeException { + String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); + if (name == null) { + throw new CamelExchangeException("Application not specified", exchange); + } + + IApplication app = domain.getApplicationByName(name); + if (app == null) { + throw new CamelExchangeException("Application with id " + name + " not found.", exchange); + } else { + String deploymentType = exchange.getIn().getHeader(OpenShiftConstants.DEPLOYMENT_TYPE, getEndpoint().getApplication(), String.class); + if (!ObjectHelper.isEmpty(deploymentType) && deploymentType != null) { + String result = app.setDeploymentType(deploymentType); + exchange.getIn().setBody(result); + } else { + throw new CamelExchangeException("Deployment Type not specified", exchange); + } + } + } + + protected void doAddEnvironmentVariable(Exchange exchange, IDomain domain) throws CamelExchangeException { + String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); + if (name == null) { + throw new CamelExchangeException("Application not specified", exchange); + } + + IApplication app = domain.getApplicationByName(name); + if (app == null) { + throw new CamelExchangeException("Application with id " + name + " not found.", exchange); + } else { + String variableName = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_NAME, getEndpoint().getApplication(), String.class); + String variableValue = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_VALUE, getEndpoint().getApplication(), String.class); + if ((!app.canUpdateEnvironmentVariables())) { + throw new CamelExchangeException("The application with id " + name + " can't update Environment Variables", exchange); + } + if ((!ObjectHelper.isEmpty(variableName) && variableName != null) || (!ObjectHelper.isEmpty(variableValue) && variableValue != null)) { + IEnvironmentVariable result = app.addEnvironmentVariable(variableName, variableValue); + exchange.getIn().setBody(result.getName()); + } else { + throw new CamelExchangeException("Environment variable not correctly specified", exchange); + } + } + } + + protected void doUpdateEnvironmentVariable(Exchange exchange, IDomain domain) throws CamelExchangeException { + String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); + if (name == null) { + throw new CamelExchangeException("Application not specified", exchange); + } + + IApplication app = domain.getApplicationByName(name); + if (app == null) { + throw new CamelExchangeException("Application with id " + name + " not found.", exchange); + } else { + String variableName = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_NAME, getEndpoint().getApplication(), String.class); + String variableValue = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_VALUE, getEndpoint().getApplication(), String.class); + if ((!app.canUpdateEnvironmentVariables())) { + throw new CamelExchangeException("The application with id " + name + " can't update Environment Variables", exchange); + } + if ((!ObjectHelper.isEmpty(variableName) && variableName != null) || (!ObjectHelper.isEmpty(variableValue) && variableValue != null)) { + IEnvironmentVariable result = app.updateEnvironmentVariable(variableName, variableValue); + exchange.getIn().setBody(result.getName()); + } else { + throw new CamelExchangeException("Environment variable not correctly specified", exchange); + } + } + } + + protected void doGetEnvironmentVariableValue(Exchange exchange, IDomain domain) throws CamelExchangeException { + String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); + if (name == null) { + throw new CamelExchangeException("Application not specified", exchange); + } + + IApplication app = domain.getApplicationByName(name); + if (app == null) { + throw new CamelExchangeException("Application with id " + name + " not found.", exchange); + } else { + String variableName = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_NAME, getEndpoint().getApplication(), String.class); + if ((!app.canGetEnvironmentVariables())) { + throw new CamelExchangeException("The application with id " + name + " can't get Environment Variables", exchange); + } + if ((!ObjectHelper.isEmpty(variableName) && variableName != null)) { + IEnvironmentVariable result = app.getEnvironmentVariable(variableName); + exchange.getIn().setBody(result.getValue()); + } else { + throw new CamelExchangeException("Environment variable name not specified", exchange); + } + } + } + + protected void doGetAllEnvironmentVariables(Exchange exchange, IDomain domain) throws CamelExchangeException { + String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); + if (name == null) { + throw new CamelExchangeException("Application not specified", exchange); + } + + IApplication app = domain.getApplicationByName(name); + if (app == null) { + throw new CamelExchangeException("Application with id " + name + " not found.", exchange); + } else { + Map<String, IEnvironmentVariable> result = app.getEnvironmentVariables(); + exchange.getIn().setBody(result); + } + } + + protected void doRemoveEnvironmentVariable(Exchange exchange, IDomain domain) throws CamelExchangeException { + String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); + if (name == null) { + throw new CamelExchangeException("Application not specified", exchange); + } + + IApplication app = domain.getApplicationByName(name); + if (app == null) { + throw new CamelExchangeException("Application with id " + name + " not found.", exchange); + } else { + String variableName = exchange.getIn().getHeader(OpenShiftConstants.ENVIRONMENT_VARIABLE_NAME, getEndpoint().getApplication(), String.class); + if ((!app.canGetEnvironmentVariables())) { + throw new CamelExchangeException("The application with id " + name + " can't get Environment Variables", exchange); + } + if ((!ObjectHelper.isEmpty(variableName) && variableName != null)) { + app.removeEnvironmentVariable(variableName); + exchange.getIn().setBody(variableName); + } else { + throw new CamelExchangeException("Environment variable name not specified", exchange); + } + } + } + + protected void doGetGearProfile(Exchange exchange, IDomain domain) throws CamelExchangeException { + String name = exchange.getIn().getHeader(OpenShiftConstants.APPLICATION, getEndpoint().getApplication(), String.class); + if (name == null) { + throw new CamelExchangeException("Application not specified", exchange); + } + + IApplication app = domain.getApplicationByName(name); + if (app == null) { + throw new CamelExchangeException("Application with id " + name + " not found.", exchange); + } else { + IGearProfile result = app.getGearProfile(); + exchange.getIn().setBody(result.getName()); + } + } } http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftAddEnvironmentVariableTest.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftAddEnvironmentVariableTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftAddEnvironmentVariableTest.java new file mode 100644 index 0000000..607c964 --- /dev/null +++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftAddEnvironmentVariableTest.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.openshift; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class OpenShiftAddEnvironmentVariableTest extends CamelTestSupport { + + private String username; + private String password; + + @Override + public void setUp() throws Exception { + // INSERT credentials here + username = null; + password = null; + super.setUp(); + } + + @Test + public void testAddEnvironmentVariable() throws Exception { + if (username == null) { + return; + } + + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .toF("openshift:myApp?operation=addEnvironmentVariable&mode=json&username=%s&password=%s", username, password) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetAllEnvironmentVariablesTest.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetAllEnvironmentVariablesTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetAllEnvironmentVariablesTest.java new file mode 100644 index 0000000..b65d2ae --- /dev/null +++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetAllEnvironmentVariablesTest.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.openshift; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class OpenShiftGetAllEnvironmentVariablesTest extends CamelTestSupport { + + private String username; + private String password; + + @Override + public void setUp() throws Exception { + // INSERT credentials here + username = null; + password = null; + super.setUp(); + } + + @Test + public void testGetGitUrl() throws Exception { + if (username == null) { + return; + } + + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .toF("openshift:myApp?operation=getAllEnvironmentVariables&mode=json&username=%s&password=%s", username, password) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetDeploymentTypeTest.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetDeploymentTypeTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetDeploymentTypeTest.java new file mode 100644 index 0000000..4ae93bf --- /dev/null +++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetDeploymentTypeTest.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.openshift; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class OpenShiftGetDeploymentTypeTest extends CamelTestSupport { + + private String username; + private String password; + + @Override + public void setUp() throws Exception { + // INSERT credentials here + username = null; + password = null; + super.setUp(); + } + + @Test + public void testGetDeploymentType() throws Exception { + if (username == null) { + return; + } + + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .toF("openshift:myApp?operation=getDeploymentType&mode=json&username=%s&password=%s", username, password) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetEnvironmentVariableValueTest.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetEnvironmentVariableValueTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetEnvironmentVariableValueTest.java new file mode 100644 index 0000000..11f8b45 --- /dev/null +++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetEnvironmentVariableValueTest.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.openshift; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class OpenShiftGetEnvironmentVariableValueTest extends CamelTestSupport { + + private String username; + private String password; + + @Override + public void setUp() throws Exception { + // INSERT credentials here + username = null; + password = null; + super.setUp(); + } + + @Test + public void testGetEnvironmentVariable() throws Exception { + if (username == null) { + return; + } + + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .toF("openshift:myApp?operation=getEnvironmentVariableValue&mode=json&username=%s&password=%s", username, password) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetGearProfileTest.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetGearProfileTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetGearProfileTest.java new file mode 100644 index 0000000..872d6f8 --- /dev/null +++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftGetGearProfileTest.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.openshift; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class OpenShiftGetGearProfileTest extends CamelTestSupport { + + private String username; + private String password; + + @Override + public void setUp() throws Exception { + // INSERT credentials here + username = null; + password = null; + super.setUp(); + } + + @Test + public void testGetGearProfile() throws Exception { + if (username == null) { + return; + } + + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .toF("openshift:myApp?operation=getGearProfile&mode=json&username=%s&password=%s", username, password) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftRemoveEnvironmentVariableTest.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftRemoveEnvironmentVariableTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftRemoveEnvironmentVariableTest.java new file mode 100644 index 0000000..e3b5e9d --- /dev/null +++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftRemoveEnvironmentVariableTest.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.openshift; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class OpenShiftRemoveEnvironmentVariableTest extends CamelTestSupport { + + private String username; + private String password; + + @Override + public void setUp() throws Exception { + // INSERT credentials here + username = null; + password = null; + super.setUp(); + } + + @Test + public void testRemoveEnvironmentVariable() throws Exception { + if (username == null) { + return; + } + + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .toF("openshift:myApp?operation=removeEnvironmentVariable&mode=json&username=%s&password=%s", username, password) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftSetDeploymentTypeTest.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftSetDeploymentTypeTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftSetDeploymentTypeTest.java new file mode 100644 index 0000000..eecb5d3 --- /dev/null +++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftSetDeploymentTypeTest.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.openshift; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class OpenShiftSetDeploymentTypeTest extends CamelTestSupport { + + private String username; + private String password; + + @Override + public void setUp() throws Exception { + // INSERT credentials here + username = null; + password = null; + super.setUp(); + } + + @Test + public void testSetDeploymentType() throws Exception { + if (username == null) { + return; + } + + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .toF("openshift:myApp?operation=setDeploymentType&mode=json&username=%s&password=%s", username, password) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/fa947f01/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftUpdateEnvironmentVariableTest.java ---------------------------------------------------------------------- diff --git a/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftUpdateEnvironmentVariableTest.java b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftUpdateEnvironmentVariableTest.java new file mode 100644 index 0000000..29a10f0 --- /dev/null +++ b/components/camel-openshift/src/test/java/org/apache/camel/component/openshift/OpenShiftUpdateEnvironmentVariableTest.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.openshift; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class OpenShiftUpdateEnvironmentVariableTest extends CamelTestSupport { + + private String username; + private String password; + + @Override + public void setUp() throws Exception { + // INSERT credentials here + username = null; + password = null; + super.setUp(); + } + + @Test + public void testUpdateEnvironmentVariable() throws Exception { + if (username == null) { + return; + } + + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .toF("openshift:myApp?operation=updateEnvironmentVariable&mode=json&username=%s&password=%s", username, password) + .to("mock:result"); + } + }; + } +}