You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by me...@apache.org on 2014/03/05 06:57:06 UTC
[05/18] Forking jclouds's vcloud API
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java
new file mode 100755
index 0000000..03ed047
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.UnknownHostException;
+
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.domain.NetworkConnection;
+import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code NetworkConnectionHandler}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "NetworkConnectionHandlerTest")
+public class NetworkConnectionHandlerTest extends BaseHandlerTest {
+
+ public void testDefault() throws UnknownHostException {
+ InputStream is = getClass().getResourceAsStream("/networkconnection.xml");
+
+ NetworkConnection result = factory.create(injector.getInstance(NetworkConnectionHandler.class)).parse(is);
+
+ checkNetworkConnection(result);
+
+ }
+
+ @Test(enabled = false)
+ public static void checkNetworkConnection(NetworkConnection result) {
+ assertEquals(result.getNetwork(), "internet01");
+ assertEquals(result.getNetworkConnectionIndex(), 0);
+ assertEquals(result.getIpAddress(), "174.47.101.164");
+ assertEquals(result.getExternalIpAddress(), null);
+ assertEquals(result.isConnected(), true);
+ assertEquals(result.getMACAddress(), "00:50:56:01:01:f2");
+ assertEquals(result.getIpAddressAllocationMode(), IpAddressAllocationMode.POOL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java
new file mode 100755
index 0000000..aec8c25
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code NetworkConnectionSectionHandler}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class NetworkConnectionSectionHandlerTest {
+ public void testVCloud1_0() {
+ InputStream is = getClass().getResourceAsStream("/networkconnectionsection.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ NetworkConnectionSection result = factory.create(injector.getInstance(NetworkConnectionSectionHandler.class))
+ .parse(is);
+ checkNetworkConnectionSection(result);
+ }
+
+ @Test(enabled = false)
+ static void checkNetworkConnectionSection(NetworkConnectionSection result) {
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/"));
+ assertEquals(result.getType(), VCloudMediaType.NETWORKCONNECTIONSECTION_XML);
+ assertEquals(result.getInfo(), "Specifies the available VM network connections");
+ assertEquals(result.getPrimaryNetworkConnectionIndex(), Integer.valueOf(0));
+ assertEquals(result.getEdit(), new ReferenceTypeImpl(null, VCloudMediaType.NETWORKCONNECTIONSECTION_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/")));
+ NetworkConnectionHandlerTest.checkNetworkConnection(Iterables.getOnlyElement(result.getConnections()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java
new file mode 100755
index 0000000..738a5a1
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
+import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML;
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.internal.OrgImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code OrgHandler}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class OrgHandlerTest {
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/org-1.0.xml");
+
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+
+ Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
+ assertEquals(result.getName(), "ExampleOrg");
+ assertEquals(result.getFullName(), "ExampleOrg");
+ assertEquals(result.getDescription(), "Example Corp's Primary Organization.");
+ assertEquals(result.getHref(), URI.create("http://vcloud.example.com/api/v1.0/org/5"));
+ assertEquals(result.getCatalogs(), ImmutableMap.of("Main Catalog", new ReferenceTypeImpl("Main Catalog",
+ CATALOG_XML, URI.create("http://vcloud.example.com/api/v1.0/catalog/32")), "Shared Catalog",
+ new ReferenceTypeImpl("Shared Catalog", CATALOG_XML, URI
+ .create("http://vcloud.example.com/api/v1.0/catalog/37"))));
+ assertEquals(result.getVDCs(), ImmutableMap.of("ExampleVdc01", new ReferenceTypeImpl("ExampleVdc01",
+ VCloudMediaType.VDC_XML, URI.create("http://vcloud.example.com/api/v1.0/vdc/5"))));
+ assertEquals(result.getNetworks(), ImmutableMap.of("TestNetwork", new ReferenceTypeImpl("TestNetwork",
+ VCloudMediaType.NETWORK_XML, URI.create("http://vcloud.example.com/api/v1.0/network/14")),
+ "ProductionNetwork", new ReferenceTypeImpl("ProductionNetwork", VCloudMediaType.NETWORK_XML, URI
+ .create("http://vcloud.example.com/api/v1.0/network/54"))));
+ assertEquals(result.getTasksList(), new ReferenceTypeImpl(null, TASKSLIST_XML, URI
+ .create("http://vcloud.example.com/api/v1.0/tasksList/5")));
+ }
+
+ public void testTerremark() {
+ InputStream is = getClass().getResourceAsStream("/org.xml");
+
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+
+ Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
+ assertEquals(result.getName(), "adrian@jclouds.org");
+ assertEquals(result.getFullName(), "adrian@jclouds.org");
+ assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
+ assertEquals(result.getCatalogs(), ImmutableMap.of("Miami Environment 1 Catalog", new ReferenceTypeImpl(
+ "Miami Environment 1 Catalog", CATALOG_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"))));
+ assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new ReferenceTypeImpl(
+ "Miami Environment 1", VCloudMediaType.VDC_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))));
+ assertEquals(result.getTasksList(), new ReferenceTypeImpl("Miami Environment 1 Tasks List", TASKSLIST_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/32")));
+ }
+
+ public void testHosting() {
+ InputStream is = getClass().getResourceAsStream("/org-hosting.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
+ assertEquals(result.getName(), "Customer 188849");
+ assertEquals(result.getFullName(), "Customer 188849");
+ assertEquals(result.getHref(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
+ assertEquals(result.getCatalogs(), ImmutableMap.of("HMS Shared Catalog", new ReferenceTypeImpl(
+ "HMS Shared Catalog", CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))));
+ assertEquals(result.getVDCs(), ImmutableMap.of("188849 Virtual DataCenter", new ReferenceTypeImpl(
+ "188849 Virtual DataCenter", VCloudMediaType.VDC_XML, URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"))));
+ assertEquals(result.getTasksList(), new ReferenceTypeImpl("188849 Task List", TASKSLIST_XML, URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849")));
+ }
+
+ public void testSavvis() {
+ InputStream is = getClass().getResourceAsStream("/org-savvis.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
+ assertEquals(result, new OrgImpl("607968.0", null, null, "607968.0", "Gravitant Inc", ImmutableMap
+ .<String, ReferenceType> of(), ImmutableMap.<String, ReferenceType> of("GravDataCenter1(Saved)",
+ new ReferenceTypeImpl("GravDataCenter1(Saved)", "application/vnd.vmware.vcloud.vdc+xml", URI
+ .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/607968.0/vdc/2826"))),
+ ImmutableMap.<String, ReferenceType> of(), null, ImmutableSet.<Task> of()));
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java
new file mode 100755
index 0000000..7887a56
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Map;
+
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests behavior of {@code OrgListHandler}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "OrgListHandlerTest")
+public class OrgListHandlerTest extends BaseHandlerTest {
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/orglist.xml");
+
+ Map<String, ReferenceType> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is);
+ assertEquals(result, ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
+ "application/vnd.vmware.vcloud.org+xml", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
+ }
+
+
+ public void testSavvis() {
+ InputStream is = getClass().getResourceAsStream("/orglist-savvis.xml");
+
+ Map<String, ReferenceType> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is);
+ assertEquals(result, ImmutableMap.of("SAVVISStation Integration Testing", new ReferenceTypeImpl("SAVVISStation Integration Testing",
+ "application/vnd.vmware.vcloud.org+xml", URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0"))));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java
new file mode 100755
index 0000000..e350131
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.network.DhcpService;
+import org.jclouds.vcloud.domain.network.FenceMode;
+import org.jclouds.vcloud.domain.network.IpRange;
+import org.jclouds.vcloud.domain.network.IpScope;
+import org.jclouds.vcloud.domain.network.OrgNetwork;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code OrgNetworkHandler}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class OrgNetworkHandlerTest {
+ public void testIsolated() {
+ InputStream is = getClass().getResourceAsStream("/orgnetwork-isolated.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is);
+ assertEquals(result.getName(), "isolation01");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
+ assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assert result.getConfiguration() != null;
+
+ assertEquals(result.getConfiguration().getIpScope(), new IpScope(false, "192.168.15.1", "255.255.255.0",
+ "23.172.173.113", null, null,
+ ImmutableSet.<IpRange> of(new IpRange("192.168.15.100", "192.168.15.199")), ImmutableSet.<String> of()));
+ assertEquals(result.getConfiguration().getParentNetwork(), null);
+ assertEquals(result.getConfiguration().getFenceMode(), FenceMode.ISOLATED);
+ assert result.getConfiguration().getFeatures() != null;
+
+ assertEquals(result.getConfiguration().getFeatures().getDhcpService(), new DhcpService(false, 3600, 7200,
+ new IpRange("192.168.15.2", "192.168.15.99")));
+ assertEquals(result.getConfiguration().getFeatures().getFirewallService(), null);
+ assertEquals(result.getConfiguration().getFeatures().getNatService(), null);
+
+ assertEquals(result.getNetworkPool(), null);
+ assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String> of());
+
+ }
+
+ public void testBridged() {
+ InputStream is = getClass().getResourceAsStream("/orgnetwork-bridged.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is);
+ assertEquals(result.getName(), "internet01");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
+ assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assert result.getConfiguration() != null;
+
+ assertEquals(result.getConfiguration().getIpScope(), new IpScope(true, "174.47.101.161", "255.255.255.224",
+ "24.172.173.113", null, null,
+ ImmutableSet.<IpRange> of(new IpRange("174.47.101.164", "174.47.101.190")), ImmutableSet.<String> of()));
+ assertEquals(result.getConfiguration().getParentNetwork(), null);
+ assertEquals(result.getConfiguration().getFenceMode(), FenceMode.BRIDGED);
+ assert result.getConfiguration().getFeatures() == null;
+ assertEquals(result.getNetworkPool(), null);
+ assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String> of());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java
new file mode 100755
index 0000000..e9f8cbb
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.SortedMap;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSortedMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code SupportedVersionsHandler}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class SupportedVersionsHandlerTest {
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/versions.xml");
+
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+
+ SortedMap<String, URI> result = factory.create(
+ injector.getInstance(SupportedVersionsHandler.class)).parse(is);
+ assertEquals(result, ImmutableSortedMap.of("0.8", URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/login")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java
new file mode 100755
index 0000000..45d5d07
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java
@@ -0,0 +1,135 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TaskStatus;
+import org.jclouds.vcloud.domain.VCloudError.MinorCode;
+import org.jclouds.vcloud.domain.internal.ErrorImpl;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.internal.TaskImpl;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code TaskHandler}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "TaskHandlerTest")
+public class TaskHandlerTest extends BaseHandlerTest {
+
+ private DateService dateService;
+
+ @BeforeTest
+ @Override
+ protected void setUpInjector() {
+ super.setUpInjector();
+ dateService = injector.getInstance(DateService.class);
+ }
+
+ public void testHrefWhenTaskElementIsNamespaced() {
+ InputStream is = getClass().getResourceAsStream("/task-vcd15.xml");
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+ assertEquals(result.getHref(), URI.create("https://mycloud.greenhousedata.com/api/v1.0/task/77a33fd4-3401-423c-8167-6711fc51ee9a"));
+ }
+
+ public void test() {
+ InputStream is = getClass().getResourceAsStream("/task-1.0.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+
+ Task expects = new TaskImpl(URI.create("https://vcenterprise.bluelock.com/api/v1.0/task/3cc08ir8oczbze3n1a3"),
+ "Creating Virtual Application vApp_acole_2(607806320)", TaskStatus.RUNNING, dateService
+ .iso8601DateParse("2010-08-23T02:09:52.443-04:00"), dateService
+ .iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService
+ .iso8601DateParse("2010-11-21T02:09:52.443-05:00"), new ReferenceTypeImpl("vApp_acole_2",
+ VCloudMediaType.VAPP_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320"))
+
+ , null
+
+ );
+ assertEquals(result, expects);
+
+ }
+
+ public void testTerremark() {
+ InputStream is = getClass().getResourceAsStream("/task.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+ Task expects = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), null,
+ TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService
+ .iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1",
+ VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null
+
+ );
+ assertEquals(result, expects);
+
+ }
+
+ public void testSelf() {
+ InputStream is = getClass().getResourceAsStream("/task-self.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+
+ Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), null,
+ TaskStatus.QUEUED, null, null, null, null, null);
+ assertEquals(result, expects);
+
+ }
+
+ public void testApplyInputStream2() {
+ InputStream is = getClass().getResourceAsStream("/task-hosting.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+
+ Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"), null,
+ TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService
+ .iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService
+ .iso8601SecondsDateParse("2010-01-15T20:05:02Z"),
+
+ new ReferenceTypeImpl("188849-96", VCloudMediaType.VAPP_XML, URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null);
+ assertEquals(result, expects);
+ }
+
+ public void testError() {
+ InputStream is = getClass().getResourceAsStream("/task-error.xml");
+
+ Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
+
+ Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), null, TaskStatus.ERROR,
+ dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"), dateService
+ .iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new ReferenceTypeImpl("testapp1",
+ VCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), new ErrorImpl(
+ "Error processing job", 500, MinorCode.UNRECOGNIZED,
+ " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00", null));
+ assertEquals(result, expects);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java
new file mode 100755
index 0000000..a5c83d5
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.TaskStatus;
+import org.jclouds.vcloud.domain.TasksList;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.internal.TaskImpl;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSortedSet;
+
+/**
+ * Tests behavior of {@code TasksListHandler}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "TasksListHandlerTest")
+public class TasksListHandlerTest extends BaseHandlerTest {
+
+ private DateService dateService;
+
+ @BeforeTest
+ @Override
+ protected void setUpInjector() {
+ super.setUpInjector();
+ dateService = injector.getInstance(DateService.class);
+ }
+
+ public void testApplyInputStream() {
+ InputStream is = getClass().getResourceAsStream("/taskslist.xml");
+
+ TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
+ assertEquals(result.getLocation(), URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"));
+ Task task1 = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"),
+ null, TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"), dateService
+ .iso8601DateParse("2009-08-24T21:30:32.63Z"), null, new ReferenceTypeImpl("Server1",
+ VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
+ Task task2 = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
+ null, TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService
+ .iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1",
+ VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
+ assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2));
+ }
+
+ public void testApplyInputStreamHosting() {
+ InputStream is = getClass().getResourceAsStream("/taskslist-hosting.xml");
+
+ TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
+ assertEquals(result.getLocation(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/188849"));
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java
new file mode 100755
index 0000000..e6c05c7
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code VAppHandler}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class VAppHandlerTest {
+
+ public void testRhelOffStatic() {
+ InputStream is = getClass().getResourceAsStream("/vapp-rhel-off-static.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule() {
+
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
+ }
+ });
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
+ assertEquals(result.getName(), "vApp_acole_2");
+ assertEquals(result.getDescription(), "foo");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vApp+xml");
+ assertEquals(result.getStatus(), Status.OFF);
+ assertEquals(
+ result.getVDC(),
+ new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439")));
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assert result.isOvfDescriptorUploaded();
+ assert result.getNetworkSection() != null;
+ Vm vm = Iterables.getOnlyElement(result.getChildren());
+ VmHandlerTest.checkVm(vm);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java
new file mode 100755
index 0000000..0accf60
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java
@@ -0,0 +1,164 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.ovf.Network;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.TaskStatus;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.internal.TaskImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code VAppTemplateHandler}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class VAppTemplateHandlerTest {
+
+ public void testUbuntuTemplate() {
+ VAppTemplate result = parseTemplate();
+ assertEquals(result.getName(), "Ubuntu Template");
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
+ assertEquals(result.getStatus(), Status.OFF);
+ assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assertEquals(result.getVAppScopedLocalId(), null);
+ assert result.isOvfDescriptorUploaded();
+ Vm vm = Iterables.getOnlyElement(result.getChildren());
+ assertEquals(vm.getName(), "Ubuntu1004");
+ assertEquals(vm.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194"));
+ // NOTE this is vAppTemplate not VM!
+ assertEquals(vm.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
+ assertEquals(vm.getStatus(), null);
+ assertEquals(vm.getParent(), new ReferenceTypeImpl(null, VCloudMediaType.VAPPTEMPLATE_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921")));
+ assertEquals(vm.getDescription(), null);
+ assertEquals(vm.getTasks(), ImmutableList.of());
+ assertEquals(vm.getVAppScopedLocalId(), "02_ubuntu_template");
+
+ GuestCustomizationSection guestC = vm.getGuestCustomizationSection();
+
+ assertEquals(guestC.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
+ assertEquals(
+ guestC.getHref(),
+ URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194/guestCustomizationSection/"));
+ assertEquals(guestC.getInfo(), "Specifies Guest OS Customization Settings");
+ assertEquals(guestC.isEnabled(), Boolean.TRUE);
+ assertEquals(guestC.shouldChangeSid(), Boolean.FALSE);
+ assertEquals(guestC.getVirtualMachineId(), "172837194");
+ assertEquals(guestC.isJoinDomainEnabled(), Boolean.FALSE);
+ assertEquals(guestC.useOrgSettings(), Boolean.FALSE);
+ assertEquals(guestC.getDomainName(), null);
+ assertEquals(guestC.getDomainUserName(), null);
+ assertEquals(guestC.getDomainUserPassword(), null);
+ assertEquals(guestC.isAdminPasswordEnabled(), Boolean.TRUE);
+ assertEquals(guestC.isAdminPasswordAuto(), Boolean.TRUE);
+ assertEquals(guestC.getAdminPassword(), "%3eD%gmF");
+ assertEquals(guestC.isResetPasswordRequired(), Boolean.FALSE);
+ assertEquals(
+ guestC.getCustomizationScript(),
+ "#!/bin/bash if [ \"$1\" = \"postcustomization\" ]; then echo \"post customization\" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo \"completed\" fi");
+ assertEquals(guestC.getComputerName(), "Ubuntu1004");
+ assertEquals(guestC.getEdit(), null);
+
+ VCloudNetworkSection network = result.getNetworkSection();
+ assertEquals(
+ network.getHref(),
+ URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/networkSection/"));
+ assertEquals(network.getType(), VCloudMediaType.NETWORKSECTION_XML);
+ assertEquals(network.getInfo(), "The list of logical networks");
+ assertEquals(network.getNetworks(), ImmutableSet.of(new Network("vAppNet-vApp Internal", null)));
+
+ }
+
+ public static VAppTemplate parseTemplate() {
+ InputStream is = VAppTemplateHandlerTest.class.getResourceAsStream("/vAppTemplate.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
+ return result;
+ }
+
+ public void testCopyingTemplate() {
+ InputStream is = getClass().getResourceAsStream("/vAppTemplate-copying.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ DateService dateService = injector.getInstance(DateService.class);
+
+ VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
+ assertEquals(result.getName(), "Ubuntu10.04_v2");
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
+ assertEquals(result.getStatus(), Status.UNRESOLVED);
+ assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/105186609")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of(new TaskImpl(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/task/q62gxhi32xgd9yrqvr"),
+ "Copying Virtual Application Template Ubuntu10.04_v2(699683881)", TaskStatus.RUNNING, dateService
+ .iso8601DateParse("2010-09-17T23:20:46.039-04:00"), dateService
+ .iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService
+ .iso8601DateParse("2010-12-16T23:20:46.039-05:00"), new ReferenceTypeImpl("Ubuntu10.04_v2",
+ "application/vnd.vmware.vcloud.vAppTemplate+xml",
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881")),
+ null)));
+ assertEquals(result.getVAppScopedLocalId(), null);
+ assert result.isOvfDescriptorUploaded();
+ assertEquals(result.getChildren(), ImmutableList.of());
+ assertEquals(result.getNetworkSection(), null);
+
+ }
+
+ public void testVAppTemplateWithNewlinesAndNamespacedElements() {
+ InputStream is = getClass().getResourceAsStream("/vAppTemplate1.0-vcd15_withNewlines.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+
+ factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java
new file mode 100755
index 0000000..869530b
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.AllocationModel;
+import org.jclouds.vcloud.domain.Capacity;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.domain.VDCStatus;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code VDCHandler}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class VDCHandlerTest {
+ public void testVCloud1_0() {
+ InputStream is = getClass().getResourceAsStream("/vdc-1.0.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
+ assertEquals(result.getName(), "Jclouds-Commit-compG1xstorA01");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vdc+xml");
+ assertEquals(result.getStatus(), VDCStatus.READY);
+ assertEquals(result.getOrg(), new ReferenceTypeImpl(null, VCloudMediaType.ORG_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assertEquals(result.getAllocationModel(), AllocationModel.ALLOCATION_POOL);
+ assertEquals(result.getStorageCapacity(), new Capacity("MB", 1024000, 1024000, 0, 0));
+ assertEquals(result.getCpuCapacity(), new Capacity("MHz", 20000, 20000, 0, 0));
+ assertEquals(result.getMemoryCapacity(), new Capacity("MB", 30720, 30720, 0, 0));
+ assertEquals(result.getResourceEntities(), ImmutableMap.<String, ReferenceType> of());
+ assertEquals(result.getAvailableNetworks(), ImmutableMap.of("isolation01", new ReferenceTypeImpl("isolation01",
+ "application/vnd.vmware.vcloud.network+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644")), "internet01",
+ new ReferenceTypeImpl("internet01", "application/vnd.vmware.vcloud.network+xml", URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723"))));
+ assertEquals(result.getNicQuota(), 0);
+ assertEquals(result.getNetworkQuota(), 100);
+ assertEquals(result.getVmQuota(), 50);
+ assert result.isEnabled();
+ }
+
+ public void testTerremark() {
+ InputStream is = getClass().getResourceAsStream("/vdc.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
+ assertEquals(result.getName(), "Miami Environment 1");
+ assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 100, 0, 8, 0));
+ assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 5000, 0, 0, 0));
+ assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 2^20", 10240, 0, 0, 0));
+ assertEquals(result.getVmQuota(), 0);
+ assertEquals(result.getResourceEntities(), ImmutableMap.<String, ReferenceType> of("adriantest",
+ new ReferenceTypeImpl("adriantest", VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15124")), "centos-53",
+ new ReferenceTypeImpl("centos-53", VCloudMediaType.VAPP_XML, URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15120"))));
+ assertEquals(result.getAvailableNetworks(), ImmutableMap.of("10.114.34.128/26", new ReferenceTypeImpl(
+ "10.114.34.128/26", "application/vnd.vmware.vcloud.network+xml", URI
+ .create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
+ }
+
+ public void testHostingDotCom() {
+ InputStream is = getClass().getResourceAsStream("/vdc-hosting.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule());
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
+ assertEquals(result.getName(), "vDC Name");
+ assertEquals(result.getHref(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"));
+ assertEquals(result.getDescription(), "vDC Name");
+ assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 0, 0, 40960, 0));
+ assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 0, 0, 2400, 0));
+ assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 10^9", 0, 0, 2, 0));
+ assertEquals(result.getVmQuota(), 0);
+ assertEquals(result.getResourceEntities(), new ImmutableMap.Builder<String, ReferenceType>().put(
+ "Plesk (Linux) 64-bit Template",
+ new ReferenceTypeImpl("Plesk (Linux) 64-bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
+ URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1"))).put(
+
+ "Windows 2008 Datacenter 64 Bit Template",
+ new ReferenceTypeImpl("Windows 2008 Datacenter 64 Bit Template",
+ "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"))).put(
+ "Cent OS 64 Bit Template",
+ new ReferenceTypeImpl("Cent OS 64 Bit Template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"))).put(
+ "cPanel (Linux) 64 Bit Template",
+ new ReferenceTypeImpl("cPanel (Linux) 64 Bit Template",
+ "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/4"))).put(
+ "188849-1",
+ new ReferenceTypeImpl("188849-1", "application/vnd.vmware.vcloud.vApp+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1"))).put(
+ "188849-2",
+ new ReferenceTypeImpl("188849-2", "application/vnd.vmware.vcloud.vApp+xml", URI
+ .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2"))).build());
+
+ assertEquals(result.getAvailableNetworks(), ImmutableMap.<String, ReferenceType> of());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java
new file mode 100755
index 0000000..2faa656
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.jclouds.vcloud.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemSectionHandlerTest;
+import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
+import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareSectionHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code VmHandler}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class VmHandlerTest {
+ public void testVCloud1_0() {
+ InputStream is = getClass().getResourceAsStream("/vm-rhel-off-static.xml");
+ Injector injector = Guice.createInjector(new SaxParserModule() {
+
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
+ }
+ });
+ Factory factory = injector.getInstance(ParseSax.Factory.class);
+ Vm result = factory.create(injector.getInstance(VmHandler.class)).parse(is);
+ checkVm(result);
+ }
+
+ static void checkVm(Vm result) {
+ assertEquals(result.getName(), "RHEL5");
+ assertEquals(result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.vm+xml");
+ assertEquals(result.getStatus(), Status.OFF);
+ assertEquals(result.getParent(), new ReferenceTypeImpl(null, VCloudMediaType.VAPP_XML, URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320")));
+ assertEquals(result.getDescription(), null);
+ assertEquals(result.getTasks(), ImmutableList.of());
+ assertEquals(result.getVAppScopedLocalId(), "10_rhel_template");
+ VCloudVirtualHardwareSectionHandlerTest.checkHardware(result.getVirtualHardwareSection());
+ VCloudOperatingSystemSectionHandlerTest.checkOs(result.getOperatingSystemSection());
+ NetworkConnectionSectionHandlerTest.checkNetworkConnectionSection(result.getNetworkConnectionSection());
+ GuestCustomizationSectionHandlerTest.checkGuestCustomization(result.getGuestCustomizationSection());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java
new file mode 100755
index 0000000..a5604ff
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.jclouds.vcloud.xml.ovf;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.UnknownHostException;
+
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code VCloudOperatingSystemSectionHandler}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "VCloudOperatingSystemSectionHandlerTest")
+public class VCloudOperatingSystemSectionHandlerTest extends BaseHandlerTest {
+
+ public void testDefault() throws UnknownHostException {
+ InputStream is = getClass().getResourceAsStream("/os.xml");
+
+ VCloudOperatingSystemSection result = factory.create(injector.getInstance(VCloudOperatingSystemHandler.class)).parse(is);
+
+ checkOs(result);
+
+ }
+
+ @Test(enabled = false)
+ public static void checkOs(VCloudOperatingSystemSection result) {
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/"));
+ assertEquals(result.getDescription(), "Red Hat Enterprise Linux 5 (64-bit)");
+ assertEquals(result.getEdit(), new ReferenceTypeImpl(null,
+ "application/vnd.vmware.vcloud.operatingSystemSection+xml",
+ URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/")));
+ assertEquals(result.getId(), Integer.valueOf(80));
+ assertEquals(result.getVmwOsType(), "rhel5_64Guest");
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.operatingSystemSection+xml");
+ assertEquals(result.getInfo(), "Specifies the operating system installed");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java
new file mode 100755
index 0000000..90b1470
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.jclouds.vcloud.xml.ovf;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.UnknownHostException;
+
+import org.jclouds.cim.ResourceAllocationSettingData;
+import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
+import org.jclouds.cim.VirtualSystemSettingData;
+import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.config.SaxParserModule;
+import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
+import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData;
+import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
+import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
+import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
+import org.jclouds.vcloud.xml.VCloudVirtualHardwareHandler;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Guice;
+
+/**
+ * Tests behavior of {@code VCloudVirtualHardwareSectionHandler}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "VCloudVirtualHardwareSectionHandlerTest")
+public class VCloudVirtualHardwareSectionHandlerTest extends BaseHandlerTest {
+ @BeforeTest
+ @Override
+ protected void setUpInjector() {
+ injector = Guice.createInjector(new SaxParserModule() {
+ public void configure() {
+ super.configure();
+ bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
+ }
+ });
+ factory = injector.getInstance(ParseSax.Factory.class);
+ assert factory != null;
+ }
+
+ public void testDefault() throws UnknownHostException {
+ InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml");
+
+ VCloudVirtualHardwareSection result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class))
+ .parse(is);
+
+ checkHardware(result);
+
+ }
+
+ @Test(enabled = false)
+ public static void checkHardware(VCloudVirtualHardwareSection result) {
+ VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName(
+ "Virtual Hardware Family").virtualSystemIdentifier("RHEL5").virtualSystemType("vmx-07").build();
+
+ assertEquals(result.getHref(), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/"));
+ assertEquals(result.getType(), "application/vnd.vmware.vcloud.virtualHardwareSection+xml");
+ assertEquals(result.getSystem().toString(), system.toString());
+ assertEquals(result.getInfo(), "Virtual hardware requirements");
+
+ assertEquals(Iterables.get(result.getItems(), 0).toString(), VCloudNetworkAdapter.builder()
+ .instanceID("1").elementName("Network adapter 0").description("PCNet32 ethernet adapter").resourceType(
+ ResourceType.ETHERNET_ADAPTER).resourceSubType("PCNet32").automaticAllocation(true).connection(
+ "internet01").address("00:50:56:01:01:f2").addressOnParent("0").ipAddress("174.47.101.164")
+ .primaryNetworkConnection(true).ipAddressingMode("POOL").build().toString());
+
+ assertEquals(Iterables.get(result.getItems(), 1).toString(), ResourceAllocationSettingData
+ .builder().instanceID("2").elementName("SCSI Controller 0").description("SCSI Controller").resourceType(
+ ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString());
+
+ assertEquals(Iterables.get(result.getItems(), 2).toString(), VCloudHardDisk.builder().instanceID(
+ "2000").elementName("Hard disk 1").description("Hard disk").resourceType(ResourceType.DISK_DRIVE)
+ .addressOnParent("0").parent("2").capacity(30720).busType(6).busSubType("lsilogic").build().toString());
+
+ assertEquals(Iterables.get(result.getItems(), 3).toString(), ResourceAllocationSettingData
+ .builder().instanceID("3").elementName("IDE Controller 0").description("IDE Controller").resourceType(
+ ResourceType.IDE_CONTROLLER).address("0").build().toString());
+
+ assertEquals(Iterables.get(result.getItems(), 4).toString(), ResourceAllocationSettingData
+ .builder().instanceID("3002").elementName("CD/DVD Drive 1").description("CD/DVD Drive").resourceType(
+ ResourceType.CD_DRIVE).addressOnParent("0").automaticAllocation(false).parent("3").build()
+ .toString());
+
+ assertEquals(Iterables.get(result.getItems(), 5).toString(), ResourceAllocationSettingData
+ .builder().instanceID("8000").elementName("Floppy Drive 1").description("Floppy Drive").resourceType(
+ ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString());
+
+ assertEquals(
+ Iterables.get(result.getItems(), 6).toString(),
+ EditableResourceAllocationSettingData
+ .builder()
+ .instanceID("4")
+ .elementName("1 virtual CPU(s)")
+ .description("Number of Virtual CPUs")
+ .resourceType(ResourceType.PROCESSOR)
+ .virtualQuantity(1l)
+ .allocationUnits("hertz * 10^6")
+ .reservation(0l)
+ .weight(0)
+ .edit(
+ new ReferenceTypeImpl(
+ null,
+ "application/vnd.vmware.vcloud.rasdItem+xml",
+ URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu")))
+ .build().toString());
+
+ assertEquals(
+ Iterables.get(result.getItems(), 7).toString(),
+ EditableResourceAllocationSettingData
+ .builder()
+ .instanceID("5")
+ .elementName("384 MB of memory")
+ .description("Memory Size")
+ .resourceType(ResourceType.MEMORY)
+ .virtualQuantity(384l)
+ .allocationUnits("byte * 2^20")
+ .reservation(0l)
+ .weight(0)
+ .edit(
+ new ReferenceTypeImpl(
+ null,
+ "application/vnd.vmware.vcloud.rasdItem+xml",
+ URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory")))
+ .build().toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/captureVApp-default.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/captureVApp-default.xml b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/captureVApp-default.xml
new file mode 100755
index 0000000..0570872
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/captureVApp-default.xml
@@ -0,0 +1 @@
+<CaptureVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-template" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/4181" type="application/vnd.vmware.vcloud.vApp+xml"/></CaptureVAppParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/captureVApp.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/captureVApp.xml b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/captureVApp.xml
new file mode 100755
index 0000000..35e62d0
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/captureVApp.xml
@@ -0,0 +1 @@
+<CaptureVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-template" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><Description>The description of the new vApp Template</Description><Source href="https://vcenterprise.bluelock.com/api/v1.0/vapp/201" type="application/vnd.vmware.vcloud.vApp+xml"/></CaptureVAppParams>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog-blank.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog-blank.xml b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog-blank.xml
new file mode 100755
index 0000000..6bc4038
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog-blank.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Catalog xmlns="http://www.vmware.com/vcloud/v1" name="Jclouds-private" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcenterprise.bluelock.com/api/v1.0/org/9566014"/>
+ <Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081/catalogItems"/>
+ <CatalogItems/>
+ <IsPublished>false</IsPublished>
+</Catalog>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog-hosting.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog-hosting.xml b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog-hosting.xml
new file mode 100755
index 0000000..be510a9
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog-hosting.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Catalog href="https://vcloud.safesecureweb.com/api/v0.8/catalog/1"
+ name="HMSCatalog" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8/catalog.xsd"
+ xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <Description>HMS Shared Catalog</Description>
+
+ <Link rel="add"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalog/1/catalogItems"
+ type="application/vnd.vmware.vcloud.catalogItem+xml" />
+
+ <CatalogItems>
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1"
+ name="Plesk (Linux) 64-bit Template" />
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"
+ name="Windows 2008 Datacenter 64 Bit Template" />
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/3"
+ name="Cent OS 64 Bit Template" />
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml"
+ href="https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4"
+ name="cPanel (Linux) 64 Bit Template" />
+ </CatalogItems>
+</Catalog>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog.xml b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog.xml
new file mode 100755
index 0000000..f2d5eaa
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog.xml
@@ -0,0 +1,27 @@
+<Catalog href="https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Miami Environment 1" xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <CatalogItems>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5" type="application/vnd.vmware.vcloud.catalogItem+xml" name="CentOS 5.3 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6" type="application/vnd.vmware.vcloud.catalogItem+xml" name="CentOS 5.3 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7" type="application/vnd.vmware.vcloud.catalogItem+xml" name="RHEL 5.3 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8" type="application/vnd.vmware.vcloud.catalogItem+xml" name="RHEL 5.3 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu JeOS 9.04 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu JeOS 9.04 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu Server 9.04 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Ubuntu Server 9.04 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Enterprise R2 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Enterprise R2 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Enterprise R2 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard R2 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 (32-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 (64-bit)"/>
+ <CatalogItem href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22" type="application/vnd.vmware.vcloud.catalogItem+xml" name="Windows Web Server 2008 R2 (64-bit)"/>
+ </CatalogItems>
+</Catalog>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog1.0-vcd15.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog1.0-vcd15.xml b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog1.0-vcd15.xml
new file mode 100755
index 0000000..0208e59
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/test/resources/catalog1.0-vcd15.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Catalog xmlns="http://www.vmware.com/vcloud/v1" name="jclouds" type="application/vnd.vmware.vcloud.catalog+xml" href="https://zone.myvcloud.com/api/v1.0/catalog/3155f393-1e1d-4572-8c9c-d76f72ddb658" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 https://zone.myvcloud.com/api/v1.0/schema/master.xsd">
+ <Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://zone.myvcloud.com/api/v1.0/org/c076f90a-397a-49fa-89b8-b294c1599cd0"/>
+ <Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://zone.myvcloud.com/api/v1.0/catalog/3155f393-1e1d-4572-8c9c-d76f72ddb658/catalogItems"/>
+ <CatalogItems>
+ <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="UbuntuServer-x64-2GB" href="https://zone.myvcloud.com/api/v1.0/catalogItem/ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c"/>
+ </CatalogItems>
+ <IsPublished>false</IsPublished>
+</Catalog>
\ No newline at end of file