http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalDomainApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalDomainApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalDomainApiLiveTest.java deleted file mode 100644 index 03fbe3d..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalDomainApiLiveTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.cloudstack.features; - -import static com.google.common.collect.Iterables.find; -import static org.jclouds.cloudstack.options.UpdateDomainOptions.Builder.name; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.cloudstack.domain.Domain; -import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; - -/** - * Tests behavior of {@code GlobalDomainApi} - */ -@Test(groups = "live", singleThreaded = true, testName = "GlobalDomainApiLiveTest") -public class GlobalDomainApiLiveTest extends BaseCloudStackApiLiveTest { - - private GlobalDomainApi domainClient; - private Domain rootDomain; - - @BeforeMethod - public void before() { - domainClient = globalAdminClient.getDomainClient(); - rootDomain = find(domainClient.listDomains(), new Predicate<Domain>() { - @Override - public boolean apply(Domain domain) { - return domain != null && domain.getName().equals("ROOT"); - } - }); - } - - @Test(expectedExceptions = IllegalStateException.class) - public void testCreateUpdateDeleteDomain() throws InterruptedException { - skipIfNotDomainAdmin(); - - Domain domain = null; - try { - domain = domainClient.createDomain(prefix + "-domain"); - checkDomain(domain, rootDomain, prefix + "-domain"); - - Domain updated = domainClient.updateDomain(domain.getId(), name(prefix + "-domain-2")); - checkDomain(updated, rootDomain, prefix + "-domain-2"); - assertEquals(updated.getId(), domain.getId()); - - } finally { - if (domain != null) { - domainClient.deleteDomainAndAttachedResources(domain.getId()); - } - } - Thread.sleep(5000); - assertNull(domainClient.getDomainById(domain.getId())); - } - - private void checkDomain(Domain domain, Domain rootDomain, String expectedName) { - assertEquals(domain.getParentDomainId(), rootDomain.getId()); - assertEquals(domain.getName(), expectedName); - assertEquals(domain.getParentDomainName(), rootDomain.getName()); - } -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiExpectTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiExpectTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiExpectTest.java deleted file mode 100644 index 9fd82db..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiExpectTest.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.testng.Assert.assertEquals; - -import java.util.Calendar; -import java.util.Date; -import java.util.Set; -import java.util.TimeZone; - -import org.jclouds.cloudstack.CloudStackContext; -import org.jclouds.cloudstack.domain.AllocationState; -import org.jclouds.cloudstack.domain.Cluster; -import org.jclouds.cloudstack.domain.Host; -import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest; -import org.jclouds.cloudstack.options.AddClusterOptions; -import org.jclouds.cloudstack.options.AddHostOptions; -import org.jclouds.cloudstack.options.AddSecondaryStorageOptions; -import org.jclouds.cloudstack.options.DeleteHostOptions; -import org.jclouds.cloudstack.options.UpdateClusterOptions; -import org.jclouds.cloudstack.options.UpdateHostOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Test the CloudStack GlobalHostApi - */ -@Test(groups = "unit", testName = "GlobalConfigurationApiExpectTest") -public class GlobalHostApiExpectTest extends BaseCloudStackExpectTest<GlobalHostApi> { - - @Test - public void testListHostsWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=listHosts&listAll=true&apiKey=identity&signature=NnYyyEy30G3V2dcIt7w4WZ68AU8%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/listhostsresponse.json")) - .statusCode(200).build(); - - Set<Host> actual = requestSendsResponse(request, response).listHosts(); - - Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00"); - Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00"); - Host host1 = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnough Capacity(false).allocationState(AllocationState.ENABLED).build(); - - Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00"); - lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "GMT+02:00"); - created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00"); - Host host2 = Host.builder().id("2").name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId("1").zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build(); - - lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00"); - created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 35, 51, "GMT+02:00"); - Host host3 = Host.builder().id("3").name("s-1-VM").state(Host.State.UP).type(Host.Type.SECONDARY_STORAGE_VM).ipAddress("10.26.26.81").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId("223098941760041").localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build(); - - lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00"); - created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 36, 46, "GMT+02:00"); - Host host4 = Host.builder().id("4").name("v-2-VM").state(Host.State.UP).type(Host.Type.CONSOLE_PROXY).ipAddress("10.26.26.96").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").lastPinged(lastPinged).managementServerId("223098941760041").localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build(); - - Set<Host> expected = ImmutableSet.of(host1, host2, host3, host4); - - assertEquals(actual, expected); - } - - @Test - public void testListHostsEmptyOn404() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=listHosts&listAll=true&apiKey=identity&signature=NnYyyEy30G3V2dcIt7w4WZ68AU8%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder().statusCode(404).build(); - GlobalHostApi client = requestSendsResponse(request, response); - - assertEquals(client.listHosts(), ImmutableSet.of()); - } - - HttpRequest addHost = HttpRequest.builder().method("GET") - .endpoint("http://localhost:8080/client/api") - .addQueryParam("response", "json") - .addQueryParam("command", "addHost") - .addQueryParam("zoneid", "1") - .addQueryParam("url", "http%3A//example.com") - .addQueryParam("hypervisor", "XenServer") - .addQueryParam("username", "fred") - .addQueryParam("password", "sekrit") - .addQueryParam("hosttags", "") - .addQueryParam("allocationstate", "Enabled") - .addQueryParam("clusterid", "1") - .addQueryParam("clustername", "Xen%20Clust%201") - .addQueryParam("podid", "1") - .addQueryParam("apiKey", "identity") - .addQueryParam("signature", "ExGaljKKQIlVbWk5hd0BnnjmBzs=") - .addHeader("Accept", "application/json").build(); - - @Test - public void testAddHostWhenResponseIs2xx() { - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/addhostresponse.json")) - .statusCode(200).build(); - - Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00"); - Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00"); - Host expected = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEno ughCapacity(false).allocationState(AllocationState.ENABLED).build(); - - Host actual = requestSendsResponse(addHost, response).addHost("1", "http://example.com", "XenServer", "fred", "sekrit", - AddHostOptions.Builder.hostTags(ImmutableSet.<String>of()).allocationState(AllocationState.ENABLED).clusterId("1").clusterName("Xen Clust 1").podId("1")); - - assertEquals(actual, expected); - } - - @Test - public void testUpdateHostWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=updateHost&id=1&allocationstate=Enabled&hosttags=&oscategoryid=5&apiKey=identity&signature=qTxNq9yQG8S108giqS/ROFzgev8%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/updatehostresponse.json")) - .statusCode(200).build(); - - Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00"); - Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00"); - Host expected = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEno ughCapacity(false).allocationState(AllocationState.ENABLED).build(); - - Host actual = requestSendsResponse(request, response).updateHost("1", UpdateHostOptions.Builder.allocationState(AllocationState.ENABLED).hostTags(ImmutableSet.<String>of()).osCategoryId("5")); - - assertEquals(actual, expected); - } - - HttpRequest updateHostPassword = HttpRequest.builder().method("GET") - .endpoint("http://localhost:8080/client/api") - .addQueryParam("response", "json") - .addQueryParam("command", "updateHostPassword") - .addQueryParam("hostid", "1") - .addQueryParam("username", "fred") - .addQueryParam("password", "sekrit") - .addQueryParam("apiKey", "identity") - .addQueryParam("signature", "g9nMKDWoiU72y0HhaRFekZCgfJc=") - .addHeader("Accept", "application/json").build(); - - @Test - public void testUpdateHostPasswordWhenResponseIs2xx() { - HttpResponse response = HttpResponse.builder() - .statusCode(200).build(); - requestSendsResponse(updateHostPassword, response).updateHostPassword("1", "fred", "sekrit"); - } - - @Test - public void testDeleteHostWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=deleteHost&id=1&forced=true&forcedestroylocalstorage=true&apiKey=identity&signature=ZdvO1BWBkdPiDAjsVlKtqDe6N7k%3D") - .addHeader("Accept", "application/json") - .build(); - HttpResponse response = HttpResponse.builder() - .statusCode(200).build(); - - requestSendsResponse(request, response).deleteHost("1", DeleteHostOptions.Builder.forced(true).forceDestroyLocalStorage(true)); - } - - @Test - public void testPrepareHostForMaintenanceWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=prepareHostForMaintenance&id=1&apiKey=identity&signature=9tDwdox/xAKmZr9kVrR6Ttnxf3U%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/preparehostformaintenanceresponse.json")) - .statusCode(200).build(); - - String actual = requestSendsResponse(request, response).prepareHostForMaintenance("1"); - assertEquals(actual, "2036"); - } - - @Test - public void testCancelHostMaintenanceWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=cancelHostMaintenance&id=1&apiKey=identity&signature=9RduzuBoyRZKNTzAoVqUo9gRTfk%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/cancelhostmaintenanceresponse.json")) - .statusCode(200).build(); - - String actual = requestSendsResponse(request, response).cancelHostMaintenance("1"); - assertEquals(actual, "2036"); - } - - @Test - public void testReconnectHostWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=reconnectHost&id=1&apiKey=identity&signature=wJEF02vwdyOnJOTa%2BWMMK906aRU%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/reconnecthostresponse.json")) - .statusCode(200).build(); - - String actual = requestSendsResponse(request, response).reconnectHost("1"); - assertEquals(actual, "2036"); - } - - @Test - public void testAddSecondaryStorageWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=addSecondaryStorage&url=nfs%3A//10.26.26.165/mnt/nfs/cs_sec&zoneid=1&apiKey=identity&signature=MccRKx1yPP43ImiO70WlhVDlAIA%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/addsecondarystorageresponse.json")) - .statusCode(200).build(); - - Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00"); - Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "GMT+02:00"); - Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00"); - Host expected = Host.builder().id("2").name("nfs://10.26.26.165/mnt/nfs/cs_sec").state(Host.State.ALERT).disconnected(disconnected).type(Host.Type.SECONDARY_STORAGE).ipAddress("nfs").zoneId("1").zoneName("Dev Zone 1").version("2.2.12.20110928142833").hypervisor("None").lastPinged(lastPinged).localStorageActive(false).created(created).events("ManagementServerDown; AgentDisconnected; Remove; MaintenanceRequested; AgentConnected; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build(); - - Host actual = requestSendsResponse(request, response).addSecondaryStorage("nfs://10.26.26.165/mnt/nfs/cs_sec", AddSecondaryStorageOptions.Builder.zoneId("1")); - - assertEquals(actual, expected); - } - - @Test - public void testListClustersWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=listClusters&listAll=true&apiKey=identity&signature=lbimqg0OKIq8sgQBpNmi4oQNFog%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/listclustersresponse.json")) - .statusCode(200).build(); - - Set<Cluster> actual = requestSendsResponse(request, response).listClusters(); - - Cluster cluster1 = Cluster.builder().id("1").name("Xen Clust 1").podId("1").podName("Dev Pod 1").zoneId("1").zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build(); - Cluster cluster2 = Cluster.builder().id("2").name("Xen Clust 1").podId("2").podName("Dev Pod 2").zoneId("2").zoneName("Dev Zone 2").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build(); - ImmutableSet<Cluster> expected = ImmutableSet.of(cluster1, cluster2); - - assertEquals(actual, expected); - } - - @Test - public void testListClustersEmptyOn404() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=listClusters&listAll=true&apiKey=identity&signature=lbimqg0OKIq8sgQBpNmi4oQNFog%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder().statusCode(404).build(); - GlobalHostApi client = requestSendsResponse(request, response); - - assertEquals(client.listClusters(), ImmutableSet.of()); - } - - HttpRequest addCluster = HttpRequest.builder().method("GET") - .endpoint("http://localhost:8080/client/api") - .addQueryParam("response", "json") - .addQueryParam("command", "addCluster") - .addQueryParam("zoneid", "1") - .addQueryParam("clustername", "Xen Clust 1") - .addQueryParam("clustertype", "CloudManaged") - .addQueryParam("hypervisor", "XenServer") - .addQueryParam("allocationstate", "Enabled") - .addQueryParam("podid", "1") - .addQueryParam("url", "http://example.com/cluster") - .addQueryParam("username", "fred") - .addQueryParam("password", "sekrit") - .addQueryParam("apiKey", "identity") - .addQueryParam("signature", "2uIQ5qF0bVycXK111wxvogWp1Yw=") - .addHeader("Accept", "application/json").build(); - - @Test - public void testAddClusterWhenResponseIs2xx() { - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/addclusterresponse.json")) - .statusCode(200).build(); - - Cluster expected = Cluster.builder().id("1").name("Xen Clust 1").podId("1").podName("Dev Pod 1").zoneId("1").zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build(); - - Cluster actual = requestSendsResponse(addCluster, response).addCluster("1", "Xen Clust 1", Host.ClusterType.CLOUD_MANAGED, "XenServer", AddClusterOptions.Builder.allocationState(AllocationState.ENABLED).podId("1").url("http://example.com/cluster").username("fred").password("sekrit")); - - assertEquals(actual, expected); - } - - HttpRequest updateCluster = HttpRequest.builder().method("GET") - .endpoint("http://localhost:8080/client/api") - .addQueryParam("response", "json") - .addQueryParam("command", "updateCluster") - .addQueryParam("id", "1") - .addQueryParam("allocationstate", "Enabled") - .addQueryParam("clustername", "Xen Clust 1") - .addQueryParam("clustertype", "CloudManaged") - .addQueryParam("hypervisor", "XenServer") - .addQueryParam("managedstate", "Managed") - .addQueryParam("apiKey", "identity") - .addQueryParam("signature", "/wbuYKwInciSXWkUf05lEfJZShQ=") - .addHeader("Accept", "application/json").build(); - - @Test - public void testUpdateClusterWhenResponseIs2xx() { - HttpResponse response = HttpResponse.builder() - .payload(payloadFromResource("/updateclusterresponse.json")) - .statusCode(200).build(); - - Cluster expected = Cluster.builder().id("1").name("Xen Clust 1").podId("1").podName("Dev Pod 1").zoneId("1").zoneName("Dev Zone 1").hypervisor("XenServer").clusterType(Host.ClusterType.CLOUD_MANAGED).allocationState(AllocationState.ENABLED).managedState(Cluster.ManagedState.MANAGED).build(); - - Cluster actual = requestSendsResponse(updateCluster, response).updateCluster("1", UpdateClusterOptions.Builder.allocationState(AllocationState.ENABLED).clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).hypervisor("XenServer").managedState(Cluster.ManagedState.MANAGED)); - - assertEquals(actual, expected); - } - - HttpRequest updateClusterPassword = HttpRequest.builder().method("GET") - .endpoint("http://localhost:8080/client/api") - .addQueryParam("response", "json") - .addQueryParam("command", "updateHostPassword") - .addQueryParam("clusterid", "1") - .addQueryParam("username", "fred") - .addQueryParam("password", "sekrit") - .addQueryParam("apiKey", "identity") - .addQueryParam("signature", "xwc83%2BoYK0cuAiFQAlg/7/1IVHE=") - .addHeader("Accept", "application/json").build(); - - @Test - public void testUpdateClusterPasswordWhenResponseIs2xx() { - HttpResponse response = HttpResponse.builder() - .statusCode(200).build(); - requestSendsResponse(updateClusterPassword, response).updateClusterPassword("1", "fred", "sekrit"); - } - - @Test - public void testDeleteClusterWhenResponseIs2xx() { - HttpRequest request = HttpRequest.builder() - .method("GET") - .endpoint("http://localhost:8080/client/api?response=json&command=deleteCluster&id=1&apiKey=identity&signature=CKH26MFgKGY7Sosd17LjBMNa3AI%3D") - .addHeader("Accept", "application/json").build(); - HttpResponse response = HttpResponse.builder() - .statusCode(200).build(); - - requestSendsResponse(request, response).deleteCluster("1"); - } - - private Date makeDate(int year, int month, int date, int hour, int minute, int second, String timeZoneName) { - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZoneName)); - cal.set(Calendar.YEAR, year); - cal.set(Calendar.MONTH, month); - cal.set(Calendar.DATE, date); - cal.set(Calendar.HOUR_OF_DAY, hour); - cal.set(Calendar.MINUTE, minute); - cal.set(Calendar.SECOND, second); - cal.set(Calendar.MILLISECOND, 0); - return cal.getTime(); - } - - @Override - protected GlobalHostApi clientFrom(CloudStackContext context) { - return context.getGlobalApi().getHostClient(); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiLiveTest.java deleted file mode 100644 index 1ed94fd..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiLiveTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.Set; - -import org.jclouds.cloudstack.domain.AllocationState; -import org.jclouds.cloudstack.domain.Cluster; -import org.jclouds.cloudstack.domain.Host; -import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.base.Strings; - -/** - * Tests behavior of {@code GlobalHostApi} - */ -@Test(groups = "live", singleThreaded = true, testName = "GlobalHostApiLiveTest") -public class GlobalHostApiLiveTest extends BaseCloudStackApiLiveTest { - - @Test(groups = "live", enabled = true) - public void testListHosts() throws Exception { - skipIfNotGlobalAdmin(); - - Set<Host> hosts = globalAdminClient.getHostClient().listHosts(); - assert !hosts.isEmpty() : hosts; - - for (Host host : hosts) { - checkHost(host); - } - } - - private void checkHost(Host host) { - if (host.getType() == Host.Type.ROUTING) { - assert host.getCpuNumber() > 0; - assert host.getAverageLoad() >= 0; - assert host.getHypervisor() != null; - } - assert host.getEvents() != null; - if (host.getType() == Host.Type.SECONDARY_STORAGE_VM) { - assert host.getName().startsWith("s-"); - } - if (host.getType() == Host.Type.CONSOLE_PROXY) { - assert host.getName().startsWith("v-"); - } - } - - @Test(groups = "live", enabled = true) - public void testListClusters() throws Exception { - skipIfNotGlobalAdmin(); - - Set<Cluster> clusters = globalAdminClient.getHostClient().listClusters(); - assert !clusters.isEmpty() : clusters; - - for (Cluster cluster : clusters) { - checkCluster(cluster); - } - } - - private void checkCluster(Cluster cluster) { - assertNotNull(cluster.getId()); - assertFalse(Strings.isNullOrEmpty(cluster.getName())); - assertNotEquals(AllocationState.UNKNOWN, cluster.getAllocationState()); - assertNotEquals(Host.ClusterType.UNKNOWN, cluster.getClusterType()); - assertFalse(Strings.isNullOrEmpty(cluster.getHypervisor())); - assertNotEquals(Cluster.ManagedState.UNRECOGNIZED, cluster.getManagedState()); - assertNotNull(cluster.getPodId()); - assertFalse(Strings.isNullOrEmpty(cluster.getPodName())); - assertNotNull(cluster.getZoneId()); - assertFalse(Strings.isNullOrEmpty(cluster.getZoneName())); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiTest.java deleted file mode 100644 index 8b1d986..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalHostApiTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.jclouds.reflect.Reflection2.method; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.cloudstack.internal.BaseCloudStackApiTest; -import org.jclouds.cloudstack.options.ListHostsOptions; -import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code GlobalHostApi} - */ -@Test(groups = "unit", testName = "GlobalHostApiTest") -public class GlobalHostApiTest extends BaseCloudStackApiTest<GlobalHostApi> { - - public void testListHosts() throws Exception { - Invokable<?, ?> method = method(GlobalHostApi.class, "listHosts", ListHostsOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=listHosts&listAll=true HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(httpRequest); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingApiLiveTest.java deleted file mode 100644 index 48117c0..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingApiLiveTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.cloudstack.features; - -import static com.google.common.collect.Iterables.getFirst; -import static org.jclouds.cloudstack.domain.NetworkOfferingAvailabilityType.OPTIONAL; -import static org.jclouds.cloudstack.domain.NetworkOfferingAvailabilityType.REQUIRED; -import static org.jclouds.cloudstack.options.CreateDiskOfferingOptions.Builder.diskSizeInGB; -import static org.jclouds.cloudstack.options.CreateServiceOfferingOptions.Builder.highlyAvailable; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.cloudstack.domain.DiskOffering; -import org.jclouds.cloudstack.domain.NetworkOffering; -import org.jclouds.cloudstack.domain.NetworkOfferingAvailabilityType; -import org.jclouds.cloudstack.domain.ServiceOffering; -import org.jclouds.cloudstack.domain.StorageType; -import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest; -import org.jclouds.cloudstack.options.UpdateDiskOfferingOptions; -import org.jclouds.cloudstack.options.UpdateNetworkOfferingOptions; -import org.jclouds.cloudstack.options.UpdateServiceOfferingOptions; -import org.jclouds.logging.Logger; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code GlobalOfferingApi} - */ -@Test(groups = "live", singleThreaded = true, testName = "GlobalOfferingApiLiveTest") -public class GlobalOfferingApiLiveTest extends BaseCloudStackApiLiveTest { - - @Test(groups = "live", enabled = true) - public void testCreateServiceOffering() throws Exception { - skipIfNotGlobalAdmin(); - - String name = prefix + "-test-create-service-offering"; - String displayText = name + "-display"; - ServiceOffering offering = null; - try { - offering = globalAdminClient.getOfferingApi(). - createServiceOffering(name, displayText, 2, 1024, 2048, highlyAvailable(true).storageType(StorageType.LOCAL)); - Logger.CONSOLE.info("Created Service Offering: " + offering); - - assertEquals(offering.getName(), name); - assertEquals(offering.getDisplayText(), displayText); - checkServiceOffering(offering); - - offering = globalAdminClient.getOfferingApi() - .updateServiceOffering(offering.getId(), - UpdateServiceOfferingOptions.Builder.name(name + "-2").displayText(displayText + "-2")); - - assertEquals(offering.getName(), name + "-2"); - assertEquals(offering.getDisplayText(), displayText + "-2"); - checkServiceOffering(offering); - - } finally { - if (offering != null) { - globalAdminClient.getOfferingApi().deleteServiceOffering(offering.getId()); - } - } - } - - private void checkServiceOffering(ServiceOffering offering) { - assertNotNull(offering.getId()); - assertEquals(offering.getCpuNumber(), 2); - assertEquals(offering.getCpuSpeed(), 1024); - assertEquals(offering.getMemory(), 2048); - assertTrue(offering.supportsHA()); - assertEquals(offering.getStorageType(), StorageType.LOCAL); - } - - @Test(groups = "live", enabled = true) - public void testCreateDiskOffering() throws Exception { - skipIfNotGlobalAdmin(); - - String name = prefix + "-test-create-disk-offering"; - String displayText = name + "-display"; - DiskOffering offering = null; - try { - offering = globalAdminClient.getOfferingApi(). - createDiskOffering(name, displayText, - diskSizeInGB(100).customized(true).tags(ImmutableSet.<String>of("dummy-tag"))); - - assertEquals(offering.getName(), name); - assertEquals(offering.getDisplayText(), displayText); - checkDiskOffering(offering); - - offering = globalAdminClient.getOfferingApi(). - updateDiskOffering(offering.getId(), - UpdateDiskOfferingOptions.Builder.name(name + "-2").displayText(displayText + "-2")); - - assertEquals(offering.getName(), name + "-2"); - assertEquals(offering.getDisplayText(), displayText + "-2"); - checkDiskOffering(offering); - - } finally { - if (offering != null) { - globalAdminClient.getOfferingApi().deleteDiskOffering(offering.getId()); - } - } - } - - private void checkDiskOffering(DiskOffering offering) { - assertTrue(offering.isCustomized()); - assertEquals(offering.getDiskSize(), 100); - assertTrue(offering.getTags().contains("dummy-tag")); - } - - @Test(groups = "live", enabled = true) - public void testUpdateNetworkOffering() throws Exception { - skipIfNotGlobalAdmin(); - - NetworkOffering offering = getFirst(globalAdminClient.getOfferingApi().listNetworkOfferings(), null); - assertNotNull(offering, "Unable to test, no network offering found."); - - String name = offering.getName(); - NetworkOfferingAvailabilityType availability = offering.getAvailability(); - - try { - NetworkOfferingAvailabilityType newValue = OPTIONAL; - if (availability == OPTIONAL) { - newValue = REQUIRED; - } - NetworkOffering updated = globalAdminClient.getOfferingApi().updateNetworkOffering(offering.getId(), - UpdateNetworkOfferingOptions.Builder.name(prefix + name).availability(newValue)); - - assertEquals(updated.getName(), prefix + name); - assertEquals(updated.getAvailability(), newValue); - - } finally { - globalAdminClient.getOfferingApi().updateNetworkOffering(offering.getId(), - UpdateNetworkOfferingOptions.Builder.name(name).availability(availability)); - } - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingApiTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingApiTest.java deleted file mode 100644 index b7243a4..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingApiTest.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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.cloudstack.features; -import static org.jclouds.reflect.Reflection2.method; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.cloudstack.internal.BaseCloudStackApiTest; -import org.jclouds.cloudstack.options.CreateDiskOfferingOptions; -import org.jclouds.cloudstack.options.CreateServiceOfferingOptions; -import org.jclouds.cloudstack.options.UpdateDiskOfferingOptions; -import org.jclouds.cloudstack.options.UpdateNetworkOfferingOptions; -import org.jclouds.cloudstack.options.UpdateServiceOfferingOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - -/** - * Tests behavior of {@code GlobalOfferingApi} - */ -@Test(groups = "unit", testName = "GlobalOfferingApiTest") -public class GlobalOfferingApiTest extends BaseCloudStackApiTest<GlobalOfferingApi> { - - HttpRequest createServiceOffering = HttpRequest.builder().method("GET") - .endpoint("http://localhost:8080/client/api") - .addQueryParam("response", "json") - .addQueryParam("command", "createServiceOffering") - .addQueryParam("name", "name") - .addQueryParam("displaytext", "displayText") - .addQueryParam("cpunumber", "1") - .addQueryParam("cpuspeed", "2") - .addQueryParam("memory", "3").build(); - - public void testCreateServiceOffering() throws Exception { - Invokable<?, ?> method = method(GlobalOfferingApi.class, "createServiceOffering", - String.class, String.class, int.class, int.class, int.class, CreateServiceOfferingOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name", "displayText", 1, 2, 3)); - - assertRequestLineEquals(httpRequest, createServiceOffering.getRequestLine()); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - } - - public void testUpdateServiceOffering() throws Exception { - Invokable<?, ?> method = method(GlobalOfferingApi.class, "updateServiceOffering", - String.class, UpdateServiceOfferingOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L)); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=updateServiceOffering&id=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - } - - public void testDeleteServiceOffering() throws Exception { - Invokable<?, ?> method = method(GlobalOfferingApi.class, "deleteServiceOffering", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L)); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=deleteServiceOffering&id=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - } - - public void testCreateDiskOffering() throws Exception { - Invokable<?, ?> method = method(GlobalOfferingApi.class, "createDiskOffering", - String.class, String.class, CreateDiskOfferingOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name", "displayText")); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=createDiskOffering&name=name&displaytext=displayText HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - } - - public void testUpdateDiskOffering() throws Exception { - Invokable<?, ?> method = method(GlobalOfferingApi.class, "updateDiskOffering", - String.class, UpdateDiskOfferingOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L)); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=updateDiskOffering&id=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - } - - public void testDeleteDiskOffering() throws Exception { - Invokable<?, ?> method = method(GlobalOfferingApi.class, "deleteDiskOffering", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L)); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=deleteDiskOffering&id=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - } - - public void testUpdateNetworkOffering() throws Exception { - Invokable<?, ?> method = method(GlobalOfferingApi.class, "updateNetworkOffering", - String.class, UpdateNetworkOfferingOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L)); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=updateNetworkOffering&id=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalPodApiExpectTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalPodApiExpectTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalPodApiExpectTest.java deleted file mode 100644 index 34eb37b..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalPodApiExpectTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.cloudstack.CloudStackContext; -import org.jclouds.cloudstack.domain.AllocationState; -import org.jclouds.cloudstack.domain.Pod; -import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest; -import org.jclouds.cloudstack.options.CreatePodOptions; -import org.jclouds.cloudstack.options.UpdatePodOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; - -/** - * Test the CloudStack PodClient - */ -@Test(groups = "unit", testName = "GlobalPodApiExpectTest") -public class GlobalPodApiExpectTest extends BaseCloudStackExpectTest<GlobalPodApi> { - - public void testListPodsWhenResponseIs2xx() { - GlobalPodApi client = requestSendsResponse( - HttpRequest.builder() - .method("GET") - .endpoint( - URI.create("http://localhost:8080/client/api?response=json&" + - "command=listPods&listAll=true&apiKey=identity&signature=MuowIOuZqOpKTPVQOfrDZEmpepw%3D")) - .headers( - ImmutableMultimap.<String, String>builder() - .put("Accept", "application/json") - .build()) - .build(), - HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/listpodsresponse.json")) - .build()); - - Pod pod1 = Pod.builder() - .id("1") - .name("Dev Pod 1") - .zoneId("1") - .zoneName("Dev Zone 1") - .gateway("10.26.26.254") - .netmask("255.255.255.0") - .startIp("10.26.26.50") - .endIp("10.26.26.100") - .allocationState(AllocationState.ENABLED) - .build(); - Pod pod2 = Pod.builder() - .id("2") - .name("Dev Pod 2") - .zoneId("2") - .zoneName("Dev Zone 2") - .gateway("10.22.22.254") - .netmask("255.255.255.0") - .startIp("10.22.22.25") - .endIp("10.22.22.50") - .allocationState(AllocationState.ENABLED) - .build(); - - assertEquals(client.listPods(), ImmutableSet.of(pod1, pod2)); - } - - public void testListPodsWhenResponseIs404() { - GlobalPodApi client = requestSendsResponse( - HttpRequest.builder() - .method("GET") - .endpoint( - URI.create("http://localhost:8080/client/api?response=json&" + - "command=listPods&listAll=true&apiKey=identity&signature=MuowIOuZqOpKTPVQOfrDZEmpepw%3D")) - .headers( - ImmutableMultimap.<String, String>builder() - .put("Accept", "application/json") - .build()) - .build(), - HttpResponse.builder() - .statusCode(404) - .build()); - - assertEquals(client.listPods(), ImmutableSet.of()); - } - - HttpRequest createPod = HttpRequest.builder().method("GET") - .endpoint("http://localhost:8080/client/api") - .addQueryParam("response", "json") - .addQueryParam("command", "createPod") - .addQueryParam("name", "richard-pod") - .addQueryParam("zoneid", "10") - .addQueryParam("startip", "172.20.0.1") - .addQueryParam("endip", "172.20.0.250") - .addQueryParam("gateway", "172.20.0.254") - .addQueryParam("netmask", "255.255.255.0") - .addQueryParam("allocationstate", "Enabled") - .addQueryParam("apiKey", "identity") - .addQueryParam("signature", "fwsoQ77BmNQWfuqv4nVlPcKvKbU=") - .addHeader("Accept", "application/json").build(); - - public void testCreatePodWhenResponseIs2xx() { - GlobalPodApi client = requestSendsResponse(createPod, - HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/createpodresponse.json")) - .build()); - - Pod expected = Pod.builder() - .id("6") - .name("richard-pod") - .zoneId("10") - .zoneName("richard-zone") - .gateway("172.20.0.254") - .netmask("255.255.255.0") - .startIp("172.20.0.1") - .endIp("172.20.0.250") - .allocationState(AllocationState.ENABLED) - .build(); - - Pod actual = client.createPod("richard-pod", "10", "172.20.0.1", "172.20.0.250", "172.20.0.254", "255.255.255.0", - CreatePodOptions.Builder.allocationState(AllocationState.ENABLED)); - - assertEquals(actual, expected); - } - - public void testUpdatePodWhenResponseIs2xx() { - GlobalPodApi client = requestSendsResponse( - HttpRequest.builder() - .method("GET") - .endpoint( - URI.create("http://localhost:8080/client/api?response=json&command=updatePod&id=7&netmask=255.255.255.128&name=richard-updatepod&startip=172.21.0.129&endip=172.21.0.250&gateway=172.21.0.254&allocationstate=Disabled&apiKey=identity&signature=QpdbRyyF/xJ78ioJWhPKXEWhthY%3D")) - .headers( - ImmutableMultimap.<String, String>builder() - .put("Accept", "application/json") - .build()) - .build(), - HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/updatepodresponse.json")) - .build()); - - Pod expected = Pod.builder() - .id("7") - .name("richard-updatedpod") - .zoneId("11") - .zoneName("richard-zone") - .gateway("172.21.0.254") - .netmask("255.255.255.128") - .startIp("172.21.0.129") - .endIp("172.21.0.250") - .allocationState(AllocationState.DISABLED) - .build(); - - Pod actual = client.updatePod("7", UpdatePodOptions.Builder - .netmask("255.255.255.128") - .name("richard-updatepod") - .startIp("172.21.0.129") - .endIp("172.21.0.250") - .gateway("172.21.0.254") - .allocationState(AllocationState.DISABLED) - ); - - assertEquals(actual, expected); - } - - public void testDeletePodWhenResponseIs2xx() { - GlobalPodApi client = requestSendsResponse( - HttpRequest.builder() - .method("GET") - .endpoint( - URI.create("http://localhost:8080/client/api?response=json&command=deletePod&id=3&apiKey=identity&signature=rm4ItuAL1Ztnj%2BHFFvBFzvHAIog%3D")) - .headers( - ImmutableMultimap.<String, String>builder() - .put("Accept", "application/json") - .build()) - .build(), - HttpResponse.builder() - .statusCode(200) - .build()); - - client.deletePod("3"); - } - - @Override - protected GlobalPodApi clientFrom(CloudStackContext context) { - return context.getGlobalApi().getPodClient(); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalPodApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalPodApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalPodApiLiveTest.java deleted file mode 100644 index 7749c26..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalPodApiLiveTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.cloudstack.domain.AllocationState; -import org.jclouds.cloudstack.domain.NetworkType; -import org.jclouds.cloudstack.domain.Pod; -import org.jclouds.cloudstack.domain.Zone; -import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest; -import org.jclouds.cloudstack.options.CreatePodOptions; -import org.jclouds.cloudstack.options.ListPodsOptions; -import org.jclouds.cloudstack.options.UpdatePodOptions; -import org.testng.annotations.AfterGroups; -import org.testng.annotations.Test; - -import com.google.common.base.Strings; -import com.google.common.collect.Iterables; - -/** - * Tests behavior of {@code GlobalPodApi} - */ -@Test(groups = "live", singleThreaded = true, testName = "GlobalPodApiLiveTest") -public class GlobalPodApiLiveTest extends BaseCloudStackApiLiveTest { - - private Zone zone; - private Pod pod; - - public void testListPods() throws Exception { - skipIfNotGlobalAdmin(); - - Set<Pod> response = globalAdminClient.getPodClient().listPods(); - assert null != response; - long podCount = response.size(); - assertTrue(podCount >= 0); - - for (Pod pod : response) { - Pod newDetails = Iterables.getOnlyElement(globalAdminClient.getPodClient().listPods( - ListPodsOptions.Builder.id(pod.getId()))); - assertEquals(pod, newDetails); - assertEquals(pod, globalAdminClient.getPodClient().getPod(pod.getId())); - assertNotNull(pod.getId()); - assertFalse(Strings.isNullOrEmpty(pod.getName())); - assertNotNull(pod.getZoneId()); - assertFalse(Strings.isNullOrEmpty(pod.getZoneName())); - assertFalse(Strings.isNullOrEmpty(pod.getGateway())); - assertFalse(Strings.isNullOrEmpty(pod.getNetmask())); - assertFalse(Strings.isNullOrEmpty(pod.getStartIp())); - assertFalse(Strings.isNullOrEmpty(pod.getEndIp())); - assertNotEquals(pod.getAllocationState(), AllocationState.UNKNOWN); - } - } - - @Test - public void testCreatePod() { - skipIfNotGlobalAdmin(); - - zone = globalAdminClient.getZoneApi().createZone(prefix + "-zone-for-pod", NetworkType.BASIC, "8.8.8.8", "10.10.10.10"); - pod = globalAdminClient.getPodClient().createPod(prefix + "-pod", zone.getId(), "172.20.0.1", "172.20.0.250", "172.20.0.254", "255.255.255.0", - CreatePodOptions.Builder.allocationState(AllocationState.ENABLED)); - - assertNotNull(pod); - assertEquals(pod.getName(), prefix + "-pod"); - assertEquals(pod.getZoneId(), zone.getId()); - assertEquals(pod.getZoneName(), prefix + "-zone-for-pod"); - assertEquals(pod.getStartIp(), "172.20.0.1"); - assertEquals(pod.getEndIp(), "172.20.0.250"); - assertEquals(pod.getGateway(), "172.20.0.254"); - assertEquals(pod.getNetmask(), "255.255.255.0"); - assertEquals(pod.getAllocationState(), AllocationState.ENABLED); - } - - @Test(dependsOnMethods = "testCreatePod") - public void testUpdatePod() { - Pod updated = globalAdminClient.getPodClient().updatePod(pod.getId(), UpdatePodOptions.Builder - .name(prefix + "-updatedpod") - .startIp("172.21.0.129") - .endIp("172.21.0.250") - .gateway("172.21.0.254") - .netmask("255.255.255.128") - .allocationState(AllocationState.DISABLED) - ); - - assertNotNull(updated); - assertEquals(updated.getName(), prefix + "-updatedpod"); - assertEquals(updated.getZoneId(), zone.getId()); - assertEquals(updated.getZoneName(), prefix + "-zone-for-pod"); - assertEquals(updated.getStartIp(), "172.21.0.129"); - assertEquals(updated.getEndIp(), "172.21.0.250"); - assertEquals(updated.getGateway(), "172.21.0.254"); - assertEquals(updated.getNetmask(), "255.255.255.128"); - assertEquals(updated.getAllocationState(), AllocationState.DISABLED); - } - - @AfterGroups(groups = "live") - @Override - protected void tearDownContext() { - if (pod != null) { - globalAdminClient.getPodClient().deletePod(pod.getId()); - pod = null; - } - if (zone != null) { - globalAdminClient.getZoneApi().deleteZone(zone.getId()); - zone = null; - } - super.tearDownContext(); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolApiLiveTest.java deleted file mode 100644 index 9d0bdfa..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolApiLiveTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.cloudstack.domain.StoragePool; -import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.base.Strings; - -/** - * Tests behavior of {@code GlobalStoragePoolApi} - */ -@Test(groups = "live", singleThreaded = true, testName = "GlobalStoragePoolApiLiveTest") -public class GlobalStoragePoolApiLiveTest extends BaseCloudStackApiLiveTest { - - @Test(groups = "live", enabled = true) - public void testListStoragePools() throws Exception { - skipIfNotGlobalAdmin(); - - Set<StoragePool> result = globalAdminClient.getStoragePoolClient().listStoragePools(); - assertNotNull(result); - assertTrue(!result.isEmpty()); - for (StoragePool pool : result) { - assertNotNull(pool.getId()); - assertFalse(Strings.isNullOrEmpty(pool.getName())); - assertFalse(Strings.isNullOrEmpty(pool.getPath())); - assertNotNull(pool.getTags()); - assertNotEquals(StoragePool.State.UNRECOGNIZED, pool.getState()); - assertNotEquals(StoragePool.Type.UNRECOGNIZED, pool.getType()); - assertNotNull(pool.getZoneId()); - assertFalse(Strings.isNullOrEmpty(pool.getZoneName())); - assertNotNull(pool.getPodId()); - assertFalse(Strings.isNullOrEmpty(pool.getPodName())); - assertNotNull(pool.getClusterId()); - assertFalse(Strings.isNullOrEmpty(pool.getClusterName())); - assertNotNull(pool.getCreated()); - assertTrue(pool.getDiskSizeTotal() > 0); - } - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolApiTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolApiTest.java deleted file mode 100644 index bf278ed..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolApiTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.jclouds.reflect.Reflection2.method; - -import org.jclouds.cloudstack.internal.BaseCloudStackApiTest; -import org.jclouds.cloudstack.options.ListStoragePoolsOptions; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code GlobalStoragePoolApi} - */ -@Test(groups = "unit", testName = "GlobalStoragePoolApiTest") -public class GlobalStoragePoolApiTest extends BaseCloudStackApiTest<GlobalStoragePoolApi> { - - public void testListStoragePools() throws NoSuchMethodException { - Invokable<?, ?> method = method(GlobalStoragePoolApi.class, "listStoragePools", ListStoragePoolsOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=listStoragePools&listAll=true HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - } - - public void testListStoragePoolsOptions() throws NoSuchMethodException { - Invokable<?, ?> method = method(GlobalStoragePoolApi.class, "listStoragePools", ListStoragePoolsOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListStoragePoolsOptions.Builder.clusterId("3").id("4").ipAddress("192.168.42.42").keyword("fred").name("bob").path("/mnt/store42").podId("4").zoneId("5"))); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=listStoragePools&listAll=true&clusterid=3&id=4&ipaddress=192.168.42.42&keyword=fred&name=bob&path=/mnt/store42&podid=4&zoneid=5 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiLiveTest.java deleted file mode 100644 index 14e48e7..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiLiveTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Calendar; -import java.util.Date; -import java.util.Set; -import java.util.TimeZone; - -import org.jclouds.cloudstack.domain.JobResult; -import org.jclouds.cloudstack.domain.UsageRecord; -import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest; -import org.jclouds.cloudstack.options.GenerateUsageRecordsOptions; -import org.jclouds.cloudstack.options.ListUsageRecordsOptions; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code GlobalUsageApi} - */ -@Test(groups = "live", singleThreaded = true, testName = "GlobalUsageApiLiveTest") -public class GlobalUsageApiLiveTest extends BaseCloudStackApiLiveTest { - - @Test(groups = "live", enabled = true) - public void testListUsage() { - skipIfNotGlobalAdmin(); - - Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - Date end = c.getTime(); - c.add(Calendar.MONTH, -1); - Date start = c.getTime(); - - JobResult result = globalAdminClient.getUsageClient().generateUsageRecords(start, end, GenerateUsageRecordsOptions.NONE); - assertNotNull(result); - assertTrue(result.isSuccess(), result.getDisplayText()); - - Set<UsageRecord> records = globalAdminClient.getUsageClient().listUsageRecords(start, end, ListUsageRecordsOptions.NONE); - assertNotNull(records); - assertTrue(records.size() >= 0); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/1d88fdf4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiTest.java deleted file mode 100644 index 2adf3e1..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/GlobalUsageApiTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.cloudstack.features; - -import static org.jclouds.reflect.Reflection2.method; - -import java.util.Calendar; -import java.util.Date; - -import org.jclouds.cloudstack.internal.BaseCloudStackApiTest; -import org.jclouds.cloudstack.options.GenerateUsageRecordsOptions; -import org.jclouds.cloudstack.options.ListUsageRecordsOptions; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code GlobalUsageApi} - */ -@Test(groups = "unit", testName = "GlobalUsageApiTest") -public class GlobalUsageApiTest extends BaseCloudStackApiTest<GlobalUsageApi> { - - public void testGenerateUsageRecords() throws Exception { - Calendar c = Calendar.getInstance(); - c.set(Calendar.YEAR, 2012); - c.set(Calendar.MONTH, Calendar.JANUARY); - c.set(Calendar.DAY_OF_MONTH, 1); - Date start = c.getTime(); - c.set(Calendar.DAY_OF_MONTH, 31); - Date end = c.getTime(); - - Invokable<?, ?> method = method(GlobalUsageApi.class, "generateUsageRecords", - Date.class, Date.class, GenerateUsageRecordsOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end)); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=generateUsageRecords&startdate=2012-01-01&enddate=2012-01-31 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - } - - public void testGenerateUsageRecordsOptions() throws Exception { - Calendar c = Calendar.getInstance(); - c.set(Calendar.YEAR, 2012); - c.set(Calendar.MONTH, Calendar.JANUARY); - c.set(Calendar.DAY_OF_MONTH, 1); - Date start = c.getTime(); - c.set(Calendar.DAY_OF_MONTH, 31); - Date end = c.getTime(); - - Invokable<?, ?> method = method(GlobalUsageApi.class, "generateUsageRecords", - Date.class, Date.class, GenerateUsageRecordsOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end, GenerateUsageRecordsOptions.Builder.domainId("42"))); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=generateUsageRecords&startdate=2012-01-01&enddate=2012-01-31&domainid=42 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - } - - public void testListUsageRecords() throws Exception { - Calendar c = Calendar.getInstance(); - c.set(Calendar.YEAR, 2012); - c.set(Calendar.MONTH, Calendar.JANUARY); - c.set(Calendar.DAY_OF_MONTH, 1); - Date start = c.getTime(); - c.set(Calendar.DAY_OF_MONTH, 31); - Date end = c.getTime(); - - Invokable<?, ?> method = method(GlobalUsageApi.class, "listUsageRecords", - Date.class, Date.class, ListUsageRecordsOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end)); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=listUsageRecords&listAll=true&startdate=2012-01-01&enddate=2012-01-31 HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - } - - public void testListUsageRecordsOptions() throws Exception { - Calendar c = Calendar.getInstance(); - c.set(Calendar.YEAR, 2012); - c.set(Calendar.MONTH, Calendar.JANUARY); - c.set(Calendar.DAY_OF_MONTH, 1); - Date start = c.getTime(); - c.set(Calendar.DAY_OF_MONTH, 31); - Date end = c.getTime(); - - Invokable<?, ?> method = method(GlobalUsageApi.class, "listUsageRecords", - Date.class, Date.class, ListUsageRecordsOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end, ListUsageRecordsOptions.Builder.accountInDomain("fred", "42").accountId("41").keyword("bob"))); - - assertRequestLineEquals(httpRequest, - "GET http://localhost:8080/client/api?response=json&command=listUsageRecords&listAll=true&startdate=2012-01-01&enddate=2012-01-31&account=fred&domainid=42&accountid=41&keyword=bob HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - } -}
