Repository: stratos Updated Branches: refs/heads/stratos-4.1.x 540726691 -> f7263a885
unit test for IaaSProvider's ComputeService Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/d2a32378 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d2a32378 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d2a32378 Branch: refs/heads/stratos-4.1.x Commit: d2a32378d6014e7be2ebdfbdf7b1a207122aba4f Parents: fde5c2d Author: Isuru Haththotuwa <[email protected]> Authored: Tue Nov 10 12:42:41 2015 +0530 Committer: Isuru Haththotuwa <[email protected]> Committed: Tue Nov 10 12:44:50 2015 +0530 ---------------------------------------------------------------------- .../iaasprovider/IaaSProviderTest.java | 66 ++++++++++++++++++++ .../resources/cloud-controller-ec2-iaas.xml | 55 ++++++++++++++++ 2 files changed, 121 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/d2a32378/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/iaasprovider/IaaSProviderTest.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/iaasprovider/IaaSProviderTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/iaasprovider/IaaSProviderTest.java new file mode 100644 index 0000000..8c4c029 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/iaasprovider/IaaSProviderTest.java @@ -0,0 +1,66 @@ +/* + * 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.stratos.cloud.controller.iaasprovider; + +import junit.framework.TestCase; +import org.apache.axiom.om.OMElement; +import org.apache.stratos.cloud.controller.config.CloudControllerConfig; +import org.apache.stratos.cloud.controller.config.parser.CloudControllerConfigParser; +import org.apache.stratos.cloud.controller.domain.IaasProvider; +import org.apache.stratos.cloud.controller.iaases.Iaas; +import org.apache.stratos.common.util.AxiomXpathParserUtil; + +import java.io.File; +import java.util.ArrayList; + +public class IaaSProviderTest extends TestCase { + + private static final String IAAS_TYPE_EC2 = "ec2"; + private static final String IAAS_PROVIDER_EC2 = "aws-ec2"; + private static final String EC2_IAAS_IMPL_CLASS = "org.apache.stratos.cloud.controller.iaases.ec2.EC2Iaas"; + + private IaasProvider iaasProvider; + private File xmlFile = new File("src/test/resources/cloud-controller-ec2-iaas.xml"); + private OMElement docElt; + + protected void setUp() throws Exception { + super.setUp(); + docElt = AxiomXpathParserUtil.parse(xmlFile); + CloudControllerConfigParser.parse(docElt); + assertEquals(IAAS_TYPE_EC2, CloudControllerConfig.getInstance(). + getIaasProvider(IAAS_TYPE_EC2).getType()); + assertEquals(EC2_IAAS_IMPL_CLASS, CloudControllerConfig.getInstance(). + getIaasProvider(IAAS_TYPE_EC2).getClassName()); + assertEquals(IAAS_PROVIDER_EC2, CloudControllerConfig.getInstance(). + getIaasProvider(IAAS_TYPE_EC2).getProvider()); + } + + public void testComputeService () { + iaasProvider = CloudControllerConfig.getInstance().getIaasProvider(IAAS_TYPE_EC2); + iaasProvider.getIaas(); + assertNotNull(iaasProvider.getComputeService()); + } + + protected void tearDown() throws Exception { + CloudControllerConfig.getInstance().setIaasProviders(new ArrayList<IaasProvider>()); + iaasProvider = null; + super.tearDown(); + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/d2a32378/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller-ec2-iaas.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller-ec2-iaas.xml b/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller-ec2-iaas.xml new file mode 100644 index 0000000..4be09d4 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/test/resources/cloud-controller-ec2-iaas.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + # 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. + --> +<cloudController xmlns:svns="http://org.wso2.securevault/configuration"> + <svns:secureVault provider="org.wso2.securevault.secret.handler.SecretManagerSecretCallbackHandler"/> + + <!-- BAM data publisher configuration --> + <dataPublisher enable="false"> + <bamServer> + <!-- BAM server URL should be specified in carbon.xml --> + <adminUserName>admin</adminUserName> + <adminPassword svns:secretAlias="cloud.controller.bam.server.admin.password">admin</adminPassword> + </bamServer> + <!-- Default cron expression is '1 * * * * ? *' meaning 'first second of every minute'. + Optional element. --> + <cron>1 * * * * ? *</cron> + </dataPublisher> + + <!-- Complete topology event publisher cron configuration --> + <topologySync enable="true"> + <property name="cron" value="1 * * * * ? *"/> + </topologySync> + + <!-- Specify the properties that are common to an IaaS here. This element + is not necessary [0..1]. But you can use this section to avoid specifying + same property over and over again. --> + <iaasProviders> + <iaasProvider type="ec2" name="Amazon EC2"> + <className>org.apache.stratos.cloud.controller.iaases.ec2.EC2Iaas</className> + <provider>aws-ec2</provider> + <identity svns:secretAlias="cloud.controller.ec2.identity">xxxxxxxxx</identity> + <credential svns:secretAlias="cloud.controller.ec2.credential">yyyyyyyyy</credential> + <property name="jclouds.ec2.ami-query" value="owner-id=742434826329;state=available;image-type=machine"/> + <property name="securityGroups" value="sampleSecGroup"/> + <property name="autoAssignIp" value="true" /> + <property name="keyPair" value="sampleKey"/> + </iaasProvider> + </iaasProviders> +</cloudController> \ No newline at end of file
