You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/08/02 03:14:09 UTC
[1/3] Remove async from softlayer
Updated Branches:
refs/heads/master 82fe701c7 -> dae2c67d7
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java
deleted file mode 100644
index 4869658..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java
+++ /dev/null
@@ -1,175 +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.softlayer.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.http.functions.ParseJson;
-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.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests annotation parsing of {@code VirtualGuestAsyncClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest<VirtualGuestAsyncClient> {
-
- public void testListVirtualGuests() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VirtualGuestAsyncClient.class, "listVirtualGuests");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests.json?objectMask=virtualGuests.powerState%3BvirtualGuests.networkVlans%3BvirtualGuests.operatingSystem.passwords%3BvirtualGuests.datacenter%3BvirtualGuests.billingItem HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // now make sure request filters apply by replaying
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests.json?objectMask=virtualGuests.powerState%3BvirtualGuests.networkVlans%3BvirtualGuests.operatingSystem.passwords%3BvirtualGuests.datacenter%3BvirtualGuests.billingItem HTTP/1.1");
- // for example, using basic authentication, we should get "only one"
- // header
- assertNonPayloadHeadersEqual(httpRequest,
- "Accept: application/json\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testGetVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VirtualGuestAsyncClient.class, "getVirtualGuest", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234.json?objectMask=powerState%3BnetworkVlans%3BoperatingSystem.passwords%3Bdatacenter%3BbillingItem HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testRebootHardVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VirtualGuestAsyncClient.class, "rebootHardVirtualGuest", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/rebootHard.json HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testPowerOffVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VirtualGuestAsyncClient.class, "powerOffVirtualGuest", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/powerOff.json HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testPowerOnVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VirtualGuestAsyncClient.class, "powerOnVirtualGuest", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/powerOn.json HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testPauseVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VirtualGuestAsyncClient.class, "pauseVirtualGuest", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/pause.json HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testResumeVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VirtualGuestAsyncClient.class, "resumeVirtualGuest", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/resume.json HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientExpectTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientExpectTest.java
deleted file mode 100644
index 45a3fa8..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientExpectTest.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.softlayer.features;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.rest.internal.BaseRestClientExpectTest;
-import org.jclouds.softlayer.SoftLayerClient;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "SoftLayerClientExpectTest")
-public class VirtualGuestClientExpectTest extends BaseRestClientExpectTest<SoftLayerClient> {
-
-
- public VirtualGuestClientExpectTest() {
- provider = "softlayer";
- }
-
- public void testCancelGuestReturnsTrueOn200AndFalseOn404() {
-
- HttpRequest cancelGuest11 = HttpRequest.builder().method("GET")
- .endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Billing_Item/11/cancelService.json")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build();
-
- HttpResponse found = HttpResponse.builder().statusCode(200).build();
-
- SoftLayerClient clientWhenServiceExists = requestSendsResponse(cancelGuest11, found);
-
- assert clientWhenServiceExists.getVirtualGuestClient().cancelService(11l);
-
-
- HttpResponse notFound = HttpResponse.builder().statusCode(404).build();
-
- SoftLayerClient clientWhenServiceDoesntExist = requestSendsResponse(cancelGuest11, notFound);
-
- assert !clientWhenServiceDoesntExist.getVirtualGuestClient().cancelService(11l);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java
deleted file mode 100644
index ad9a4fb..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java
+++ /dev/null
@@ -1,169 +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.softlayer.features;
-
-import static org.jclouds.softlayer.predicates.ProductItemPredicates.capacity;
-import static org.jclouds.softlayer.predicates.ProductItemPredicates.categoryCode;
-import static org.jclouds.softlayer.predicates.ProductItemPredicates.units;
-import static org.jclouds.softlayer.predicates.ProductPackagePredicates.named;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Map;
-import java.util.Properties;
-import java.util.Random;
-import java.util.Set;
-
-import org.jclouds.softlayer.SoftLayerClient;
-import org.jclouds.softlayer.compute.functions.ProductItems;
-import org.jclouds.softlayer.domain.ProductItem;
-import org.jclouds.softlayer.domain.ProductItemPrice;
-import org.jclouds.softlayer.domain.ProductOrder;
-import org.jclouds.softlayer.domain.ProductOrderReceipt;
-import org.jclouds.softlayer.domain.ProductPackage;
-import org.jclouds.softlayer.domain.VirtualGuest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.Module;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code VirtualGuestClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live")
-public class VirtualGuestClientLiveTest extends BaseSoftLayerClientLiveTest {
-
- private static final String TEST_HOSTNAME_PREFIX = "livetest";
-
- @Test
- public void testListVirtualGuests() throws Exception {
- Set<VirtualGuest> response = api().listVirtualGuests();
- assert null != response;
- assertTrue(response.size() >= 0);
- for (VirtualGuest vg : response) {
- VirtualGuest newDetails = api().getVirtualGuest(vg.getId());
- assertEquals(vg.getId(), newDetails.getId());
- checkVirtualGuest(vg);
- }
- }
-
- @Test(enabled = false, groups = "live")
- public void testCancelAndPlaceOrder() {
-
- // This method was not working needs testing out.
-
- // TODO: Should also check if there are active transactions before trying to cancel.
- // objectMask: virtualGuests.activeTransaction
- for (VirtualGuest guest : api().listVirtualGuests()) {
- if (guest.getHostname().startsWith(TEST_HOSTNAME_PREFIX)) {
- if (guest.getBillingItemId() != -1) {
- api().cancelService(guest.getBillingItemId());
- }
- }
- }
-
- int pkgId = Iterables.find(api.getAccountClient().getActivePackages(),
- named(ProductPackageClientLiveTest.CLOUD_SERVER_PACKAGE_NAME)).getId();
- ProductPackage productPackage = api.getProductPackageClient().getProductPackage(pkgId);
-
- Iterable<ProductItem> ramItems = Iterables.filter(productPackage.getItems(), Predicates.and(categoryCode("ram"),
- capacity(2.0f)));
-
- Map<Float, ProductItem> ramToProductItem = Maps.uniqueIndex(ramItems, ProductItems.capacity());
-
- ProductItemPrice ramPrice = ProductItems.price().apply(ramToProductItem.get(2.0f));
-
- Iterable<ProductItem> cpuItems = Iterables.filter(productPackage.getItems(), Predicates.and(
- units("PRIVATE_CORE"), capacity(2.0f)));
- Map<Float, ProductItem> coresToProductItem = Maps.uniqueIndex(cpuItems, ProductItems.capacity());
-
- ProductItemPrice cpuPrice = ProductItems.price().apply(coresToProductItem.get(2.0f));
-
- Iterable<ProductItem> operatingSystems = Iterables.filter(productPackage.getItems(), categoryCode("os"));
- Map<String, ProductItem> osToProductItem = Maps.uniqueIndex(operatingSystems, ProductItems.description());
- ProductItemPrice osPrice = ProductItems.price().apply(
- osToProductItem.get("Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (64 bit)"));
-
- Builder<ProductItemPrice> prices = ImmutableSet.builder();
- prices.addAll(defaultPrices);
- prices.add(ramPrice);
- prices.add(cpuPrice);
- prices.add(osPrice);
-
- VirtualGuest guest = VirtualGuest.builder().domain("jclouds.org").hostname(
- TEST_HOSTNAME_PREFIX + new Random().nextInt()).build();
-
- ProductOrder order = ProductOrder.builder().packageId(pkgId).quantity(1).useHourlyPricing(true).prices(
- prices.build()).virtualGuests(guest).build();
-
- ProductOrderReceipt receipt = api().orderVirtualGuest(order);
- ProductOrder order2 = receipt.getOrderDetails();
- VirtualGuest result = Iterables.get(order2.getVirtualGuests(), 0);
-
- ProductOrder order3 = api().getOrderTemplate(result.getId());
-
- assertEquals(order.getPrices(), order3.getPrices());
- assertNotNull(receipt);
- }
-
- private Iterable<ProductItemPrice> defaultPrices;
-
- @Override
- protected SoftLayerClient create(Properties props, Iterable<Module> modules) {
- Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
- defaultPrices = injector.getInstance(Key.get(new TypeLiteral<Iterable<ProductItemPrice>>() {
- }));
- return injector.getInstance(SoftLayerClient.class);
- }
-
- private VirtualGuestClient api() {
- return api.getVirtualGuestClient();
- }
-
- private void checkVirtualGuest(VirtualGuest vg) {
- if (vg.getBillingItemId() == -1)
- return;// Quotes and shutting down guests
-
- assert vg.getAccountId() > 0 : vg;
- assert vg.getCreateDate() != null : vg;
- assert vg.getDomain() != null : vg;
- assert vg.getFullyQualifiedDomainName() != null : vg;
- assert vg.getHostname() != null : vg;
- assert vg.getId() > 0 : vg;
- assert vg.getMaxCpu() > 0 : vg;
- assert vg.getMaxCpuUnits() != null : vg;
- assert vg.getMaxMemory() > 0 : vg;
- assert vg.getMetricPollDate() != null : vg;
- assert vg.getModifyDate() != null : vg;
- assert vg.getStartCpus() > 0 : vg;
- assert vg.getStatusId() >= 0 : vg;
- assert vg.getUuid() != null : vg;
- assert vg.getPrimaryBackendIpAddress() != null : vg;
- assert vg.getPrimaryIpAddress() != null : vg;
- }
-
-}
[2/3] Remove async from softlayer
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiTest.java
new file mode 100644
index 0000000..ccee098
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.softlayer.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests annotation parsing of {@code AccountApi}
+ *
+ * @author Jason King
+ */
+@Test(groups = "unit")
+public class AccountApiTest extends BaseSoftLayerApiTest<AccountApi> {
+
+ public void testGetActivePackages() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(AccountApi.class, "getActivePackages");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Account/ActivePackages.json HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java
deleted file mode 100644
index a5ff473..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java
+++ /dev/null
@@ -1,55 +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.softlayer.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.functions.ParseJson;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests annotation parsing of {@code AccountAsyncClient}
- *
- * @author Jason King
- */
-@Test(groups = "unit")
-public class AccountAsyncClientTest extends BaseSoftLayerAsyncClientTest<AccountAsyncClient> {
-
- public void testGetActivePackages() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(AccountAsyncClient.class, "getActivePackages");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Account/ActivePackages.json HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountClientLiveTest.java
deleted file mode 100644
index 936c784..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountClientLiveTest.java
+++ /dev/null
@@ -1,47 +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.softlayer.features;
-
-import static org.testng.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.jclouds.softlayer.domain.ProductPackage;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code AccountClient}
- *
- * @author Jason King
- */
-@Test(groups = "live")
-public class AccountClientLiveTest extends BaseSoftLayerClientLiveTest {
-
- @Test
- public void testGetActivePackages() {
- Set<ProductPackage> response = api.getAccountClient().getActivePackages();
- assert null != response;
-
- assertTrue(response.size() >= 0);
- for (ProductPackage productPackage: response) {
- assert productPackage.getId() > 0 : response;
- assert productPackage.getName() != null : response;
- assert productPackage.getDescription() != null : response;
- assertTrue(productPackage.getItems().isEmpty());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerApiLiveTest.java
new file mode 100644
index 0000000..3bf529f
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerApiLiveTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.softlayer.features;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.softlayer.SoftLayerApi;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code SoftLayerApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live")
+public class BaseSoftLayerApiLiveTest extends BaseApiLiveTest<SoftLayerApi> {
+
+ public BaseSoftLayerApiLiveTest() {
+ this.provider = "softlayer";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerApiTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerApiTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerApiTest.java
new file mode 100644
index 0000000..31da8ffd
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerApiTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.softlayer.features;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
+import org.jclouds.softlayer.SoftLayerProviderMetadata;
+
+/**
+ * @author Adrian Cole
+ */
+public abstract class BaseSoftLayerApiTest<T> extends BaseAsyncClientTest<T> {
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 1);
+ assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
+ }
+
+ @Override
+ public ProviderMetadata createProviderMetadata() {
+ return new SoftLayerProviderMetadata();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java
deleted file mode 100644
index bcf103b..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java
+++ /dev/null
@@ -1,43 +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.softlayer.features;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.internal.BaseAsyncClientTest;
-import org.jclouds.softlayer.SoftLayerProviderMetadata;
-
-/**
- * @author Adrian Cole
- */
-public abstract class BaseSoftLayerAsyncClientTest<T> extends BaseAsyncClientTest<T> {
-
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 1);
- assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
- }
-
- @Override
- public ProviderMetadata createProviderMetadata() {
- return new SoftLayerProviderMetadata();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java
deleted file mode 100644
index 109a0aa..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java
+++ /dev/null
@@ -1,34 +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.softlayer.features;
-
-import org.jclouds.apis.BaseApiLiveTest;
-import org.jclouds.softlayer.SoftLayerClient;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code SoftLayerClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live")
-public class BaseSoftLayerClientLiveTest extends BaseApiLiveTest<SoftLayerClient> {
-
- public BaseSoftLayerClientLiveTest() {
- this.provider = "softlayer";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiLiveTest.java
new file mode 100644
index 0000000..ad9df2e
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiLiveTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.softlayer.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.softlayer.domain.Address;
+import org.jclouds.softlayer.domain.Datacenter;
+import org.jclouds.softlayer.domain.Region;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * Tests behavior of {@code DatacenterApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live")
+public class DatacenterApiLiveTest extends BaseSoftLayerApiLiveTest {
+
+ @Test
+ public void testListDatacenters() {
+ Set<Datacenter> response = api().listDatacenters();
+ assert null != response;
+ assertTrue(response.size() >= 0);
+ for (Datacenter vg : response) {
+ Datacenter newDetails = api().getDatacenter(vg.getId());
+ assertEquals(vg.getId(), newDetails.getId());
+ checkDatacenter(newDetails);
+ }
+ }
+
+ @Test
+ public void testListDatacentersContent() {
+ Builder<Datacenter> builder = ImmutableSet.builder();
+ builder.add(Datacenter.builder().id(265592).name("ams01").longName("Amsterdam 1").build());
+ builder.add(Datacenter.builder().id(3).name("dal01").longName("Dallas").build());
+ builder.add(Datacenter.builder().id(18171).name("sea01").longName("Seattle").build());
+ builder.add(Datacenter.builder().id(168642).name("sjc01").longName("San Jose 1").build());
+ builder.add(Datacenter.builder().id(2).name("dal00").longName("Corporate HQ").build());
+ builder.add(Datacenter.builder().id(37473).name("wdc01").longName("Washington, DC").build());
+ builder.add(Datacenter.builder().id(154770).name("dal02").longName("Dallas 2").build());
+ builder.add(Datacenter.builder().id(138124).name("dal05").longName("Dallas 5").build());
+ builder.add(Datacenter.builder().id(167093).name("hou01").longName("Houston 1").build());
+ builder.add(Datacenter.builder().id(167094).name("lon01").longName("London 1").build());
+ builder.add(Datacenter.builder().id(167092).name("dal04").longName("Dallas 4").build());
+ builder.add(Datacenter.builder().id(224092).name("sng01").longName("Singapore 1").build());
+ builder.add(Datacenter.builder().id(142775).name("hou02").longName("Houston 2").build());
+ builder.add(Datacenter.builder().id(142776).name("dal07").longName("Dallas 7").build());
+ builder.add(Datacenter.builder().id(154820).name("dal06").longName("Dallas 6").build());
+ Set<Datacenter> response = api().listDatacenters();
+ Set<Datacenter> expected = builder.build();
+
+ assertEquals(response.size(),expected.size());
+ assertTrue(response.containsAll(expected));
+
+ for(Datacenter datacenter: response) {
+ Address address = datacenter.getLocationAddress();
+ if(address!=null) checkAddress(address);
+ }
+ }
+
+ private DatacenterApi api() {
+ return api.getDatacenterApi();
+ }
+
+ private void checkDatacenter(Datacenter dc) {
+ assert dc.getId() > 0 : dc;
+ assert dc.getName() != null : dc;
+ assert dc.getLongName() != null : dc;
+ for( Region region: dc.getRegions()) checkRegion(region);
+ }
+
+ private void checkRegion(Region region) {
+ assert !region.getDescription().isEmpty() : region;
+ assert !region.getKeyname().isEmpty() : region;
+ }
+
+ private void checkAddress(Address address) {
+ assert address.getId() >0 : address;
+ assert address.getCountry() != null : address;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiTest.java
new file mode 100644
index 0000000..7a7a37a
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterApiTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.softlayer.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests annotation parsing of {@code DatacenterApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class DatacenterApiTest extends BaseSoftLayerApiTest<DatacenterApi> {
+
+ public void testListDatacenters() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(DatacenterApi.class, "listDatacenters");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Location_Datacenter/Datacenters.json?objectMask=locationAddress%3Bregions HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Location_Datacenter/Datacenters.json?objectMask=locationAddress%3Bregions HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest,
+ "Accept: application/json\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testGetDatacenter() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(DatacenterApi.class, "getDatacenter", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Location_Datacenter/1234.json?objectMask=locationAddress%3Bregions HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java
deleted file mode 100644
index fd38c1d..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java
+++ /dev/null
@@ -1,85 +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.softlayer.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.functions.ParseJson;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests annotation parsing of {@code DatacenterAsyncClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class DatacenterAsyncClientTest extends BaseSoftLayerAsyncClientTest<DatacenterAsyncClient> {
-
- public void testListDatacenters() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(DatacenterAsyncClient.class, "listDatacenters");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Location_Datacenter/Datacenters.json?objectMask=locationAddress%3Bregions HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // now make sure request filters apply by replaying
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Location_Datacenter/Datacenters.json?objectMask=locationAddress%3Bregions HTTP/1.1");
- // for example, using basic authentication, we should get "only one"
- // header
- assertNonPayloadHeadersEqual(httpRequest,
- "Accept: application/json\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testGetDatacenter() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(DatacenterAsyncClient.class, "getDatacenter", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Location_Datacenter/1234.json?objectMask=locationAddress%3Bregions HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterClientLiveTest.java
deleted file mode 100644
index 438efd1..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterClientLiveTest.java
+++ /dev/null
@@ -1,102 +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.softlayer.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.jclouds.softlayer.domain.Address;
-import org.jclouds.softlayer.domain.Datacenter;
-import org.jclouds.softlayer.domain.Region;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-
-/**
- * Tests behavior of {@code DatacenterClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live")
-public class DatacenterClientLiveTest extends BaseSoftLayerClientLiveTest {
-
- @Test
- public void testListDatacenters() {
- Set<Datacenter> response = api().listDatacenters();
- assert null != response;
- assertTrue(response.size() >= 0);
- for (Datacenter vg : response) {
- Datacenter newDetails = api().getDatacenter(vg.getId());
- assertEquals(vg.getId(), newDetails.getId());
- checkDatacenter(newDetails);
- }
- }
-
- @Test
- public void testListDatacentersContent() {
- Builder<Datacenter> builder = ImmutableSet.builder();
- builder.add(Datacenter.builder().id(265592).name("ams01").longName("Amsterdam 1").build());
- builder.add(Datacenter.builder().id(3).name("dal01").longName("Dallas").build());
- builder.add(Datacenter.builder().id(18171).name("sea01").longName("Seattle").build());
- builder.add(Datacenter.builder().id(168642).name("sjc01").longName("San Jose 1").build());
- builder.add(Datacenter.builder().id(2).name("dal00").longName("Corporate HQ").build());
- builder.add(Datacenter.builder().id(37473).name("wdc01").longName("Washington, DC").build());
- builder.add(Datacenter.builder().id(154770).name("dal02").longName("Dallas 2").build());
- builder.add(Datacenter.builder().id(138124).name("dal05").longName("Dallas 5").build());
- builder.add(Datacenter.builder().id(167093).name("hou01").longName("Houston 1").build());
- builder.add(Datacenter.builder().id(167094).name("lon01").longName("London 1").build());
- builder.add(Datacenter.builder().id(167092).name("dal04").longName("Dallas 4").build());
- builder.add(Datacenter.builder().id(224092).name("sng01").longName("Singapore 1").build());
- builder.add(Datacenter.builder().id(142775).name("hou02").longName("Houston 2").build());
- builder.add(Datacenter.builder().id(142776).name("dal07").longName("Dallas 7").build());
- builder.add(Datacenter.builder().id(154820).name("dal06").longName("Dallas 6").build());
- Set<Datacenter> response = api().listDatacenters();
- Set<Datacenter> expected = builder.build();
-
- assertEquals(response.size(),expected.size());
- assertTrue(response.containsAll(expected));
-
- for(Datacenter datacenter: response) {
- Address address = datacenter.getLocationAddress();
- if(address!=null) checkAddress(address);
- }
- }
-
- private DatacenterClient api() {
- return api.getDatacenterClient();
- }
-
- private void checkDatacenter(Datacenter dc) {
- assert dc.getId() > 0 : dc;
- assert dc.getName() != null : dc;
- assert dc.getLongName() != null : dc;
- for( Region region: dc.getRegions()) checkRegion(region);
- }
-
- private void checkRegion(Region region) {
- assert !region.getDescription().isEmpty() : region;
- assert !region.getKeyname().isEmpty() : region;
- }
-
- private void checkAddress(Address address) {
- assert address.getId() >0 : address;
- assert address.getCountry() != null : address;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageApiLiveTest.java
new file mode 100644
index 0000000..90172f1
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageApiLiveTest.java
@@ -0,0 +1,218 @@
+/*
+ * 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.softlayer.features;
+
+import static org.jclouds.softlayer.predicates.ProductItemPredicates.capacity;
+import static org.jclouds.softlayer.predicates.ProductItemPredicates.categoryCode;
+import static org.jclouds.softlayer.predicates.ProductItemPredicates.units;
+import static org.jclouds.softlayer.predicates.ProductPackagePredicates.named;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.softlayer.compute.functions.ProductItems;
+import org.jclouds.softlayer.domain.Address;
+import org.jclouds.softlayer.domain.Datacenter;
+import org.jclouds.softlayer.domain.ProductItem;
+import org.jclouds.softlayer.domain.ProductItemCategory;
+import org.jclouds.softlayer.domain.ProductItemPrice;
+import org.jclouds.softlayer.domain.ProductPackage;
+import org.jclouds.softlayer.domain.Region;
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+
+/**
+ * Tests behavior of {@code ProductPackageApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "ProductPackageApiLiveTest")
+public class ProductPackageApiLiveTest extends BaseSoftLayerApiLiveTest {
+
+ /**
+ * Name of the package used for ordering virtual guests. For real this is
+ * passed in using the property
+ *
+ * @{code org.jclouds.softlayer.reference.SoftLayerConstants.
+ * PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME}
+ */
+ public static final String CLOUD_SERVER_PACKAGE_NAME = "Cloud Server";
+
+ @BeforeGroups(groups = { "live" })
+ public void setup() {
+ super.setup();
+ client = api.getProductPackageApi();
+ accountApi = api.getAccountApi();
+
+ // This is used several times, so cache to speed up the test.
+ cloudServerPackageId = Iterables.find(accountApi.getActivePackages(), named(CLOUD_SERVER_PACKAGE_NAME))
+ .getId();
+ cloudServerProductPackage = client.getProductPackage(cloudServerPackageId);
+ }
+
+ private ProductPackageApi client;
+ private AccountApi accountApi;
+
+ private int cloudServerPackageId;
+ private ProductPackage cloudServerProductPackage;
+
+ @Test
+ public void testGetProductPackage() {
+ for (ProductPackage productPackage : accountApi.getActivePackages()) {
+ ProductPackage response = client.getProductPackage(productPackage.getId());
+
+ assert null != response;
+ assert response.getId() > 0 : response;
+ assert response.getName() != null : response;
+ assert response.getDescription() != null : response;
+
+ assertTrue(response.getItems().size() >= 0);
+ for (ProductItem item : response.getItems()) {
+ // ProductItem newDetails = client.getProductItem(item.getId());
+ // assertEquals(item.getId(), newDetails.getId());
+ checkProductItem(item);
+ }
+
+ assertTrue(response.getDatacenters().size() > 0);
+ for (Datacenter datacenter : response.getDatacenters()) {
+ checkDatacenter(datacenter);
+ }
+ }
+ }
+
+ @Test
+ public void testDatacentersForCloudLayer() {
+
+ ImmutableSet.Builder<Datacenter> builder = ImmutableSet.builder();
+ builder.add(Datacenter.builder().id(18171).name("sea01").longName("Seattle").build());
+ builder.add(Datacenter.builder().id(37473).name("wdc01").longName("Washington, DC").build());
+ builder.add(Datacenter.builder().id(138124).name("dal05").longName("Dallas 5").build());
+ builder.add(Datacenter.builder().id(168642).name("sjc01").longName("San Jose 1").build());
+ builder.add(Datacenter.builder().id(224092).name("sng01").longName("Singapore 1").build());
+ builder.add(Datacenter.builder().id(265592).name("ams01").longName("Amsterdam 1").build());
+
+ Set<Datacenter> expected = builder.build();
+
+ Set<Datacenter> datacenters = cloudServerProductPackage.getDatacenters();
+ assert datacenters.size() == expected.size() : datacenters;
+ assertTrue(datacenters.containsAll(expected));
+
+ for (Datacenter dataCenter : datacenters) {
+ Address address = dataCenter.getLocationAddress();
+ assertNotNull(address);
+ checkAddress(address);
+ }
+ }
+
+ @Test
+ public void testGetOneGBRamPrice() {
+ // Predicate p =
+ // Predicates.and(ProductItemPredicates.categoryCode("ram"),ProductItemPredicates.capacity(1.0f));
+ Iterable<ProductItem> ramItems = Iterables.filter(cloudServerProductPackage.getItems(),
+ Predicates.and(categoryCode("ram"), capacity(1.0f)));
+
+ // capacity is key in GB (1Gb = 1.0f)
+ Map<Float, ProductItem> ramToProductItem = Maps.uniqueIndex(ramItems, ProductItems.capacity());
+
+ ProductItemPrice price = ProductItems.price().apply(ramToProductItem.get(1.0f));
+ assert Integer.valueOf(1644).equals(price.getId());
+ }
+
+ @Test
+ public void testGetTwoCPUCoresPrice() {
+ // If use ProductItemPredicates.categoryCode("guest_core") get duplicate
+ // capacities (units =
+ // PRIVATE_CORE and N/A)
+ Iterable<ProductItem> cpuItems = Iterables.filter(cloudServerProductPackage.getItems(),
+ Predicates.and(units("PRIVATE_CORE"), capacity(2.0f)));
+
+ // number of cores is the key
+ Map<Float, ProductItem> coresToProductItem = Maps.uniqueIndex(cpuItems, ProductItems.capacity());
+
+ ProductItemPrice price = ProductItems.price().apply(coresToProductItem.get(2.0f));
+ assert Integer.valueOf(1963).equals(price.getId());
+ }
+
+ @Test
+ public void testGetUbuntuPrice() {
+ Iterable<ProductItem> operatingSystems = Iterables.filter(cloudServerProductPackage.getItems(),
+ categoryCode("os"));
+
+ Map<String, ProductItem> osToProductItem = Maps.uniqueIndex(operatingSystems, ProductItems.description());
+
+ ProductItemPrice price = ProductItems.price().apply(
+ osToProductItem.get("Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (64 bit)"));
+ assert Integer.valueOf(1693).equals(price.getId());
+ }
+
+ private void checkProductItem(ProductItem item) {
+ assert item.getId() > 0 : item;
+ assert item.getDescription() != null : item;
+ checkCategories(item.getCategories());
+ // units and capacity may be null
+
+ assertTrue(item.getPrices().size() >= 0);
+
+ for (ProductItemPrice price : item.getPrices()) {
+ // ProductItemPrice newDetails =
+ // client.getProductItemPrice(prices.getId());
+ // assertEquals(item.getId(), newDetails.getId());
+ checkPrice(price);
+ }
+ }
+
+ private void checkPrice(ProductItemPrice price) {
+ assert price.getId() > 0 : price;
+ assert price.getItemId() > 0 : price;
+ assert price.getRecurringFee() != null || price.getHourlyRecurringFee() != null : price;
+ }
+
+ private void checkDatacenter(Datacenter datacenter) {
+ assert datacenter.getId() > 0 : datacenter;
+ assert datacenter.getName() != null : datacenter;
+ assert datacenter.getLongName() != null : datacenter;
+ for (Region region : datacenter.getRegions())
+ checkRegion(region);
+ }
+
+ private void checkRegion(Region region) {
+ assert !region.getDescription().isEmpty() : region;
+ assert !region.getKeyname().isEmpty() : region;
+ }
+
+ private void checkAddress(Address address) {
+ assert address.getId() > 0 : address;
+ assert address.getCountry() != null : address;
+ if (!ImmutableSet.of("SG", "NL").contains(address.getCountry()))
+ assert address.getState() != null : address;
+ }
+
+ private void checkCategories(Set<ProductItemCategory> categories) {
+ for (ProductItemCategory category : categories) {
+ assert category.getId() > 0 : category;
+ assert category.getName() != null : category;
+ assert category.getCategoryCode() != null : category;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageApiTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageApiTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageApiTest.java
new file mode 100644
index 0000000..196a99e
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageApiTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.softlayer.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests annotation parsing of {@code ProductPackageApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class ProductPackageApiTest extends BaseSoftLayerApiTest<ProductPackageApi> {
+
+ public void testGetProductPackage() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ProductPackageApi.class, "getProductPackage", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/1234.json?objectMask=items.prices%3Bitems.categories%3Blocations.locationAddress%3Blocations.regions HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java
deleted file mode 100644
index ed7c354..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java
+++ /dev/null
@@ -1,55 +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.softlayer.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.functions.ParseJson;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests annotation parsing of {@code ProductPackageAsyncClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ProductPackageAsyncClientTest extends BaseSoftLayerAsyncClientTest<ProductPackageAsyncClient> {
-
- public void testGetProductPackage() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ProductPackageAsyncClient.class, "getProductPackage", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/1234.json?objectMask=items.prices%3Bitems.categories%3Blocations.locationAddress%3Blocations.regions HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java
deleted file mode 100644
index 7d3dc9c..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java
+++ /dev/null
@@ -1,218 +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.softlayer.features;
-
-import static org.jclouds.softlayer.predicates.ProductItemPredicates.capacity;
-import static org.jclouds.softlayer.predicates.ProductItemPredicates.categoryCode;
-import static org.jclouds.softlayer.predicates.ProductItemPredicates.units;
-import static org.jclouds.softlayer.predicates.ProductPackagePredicates.named;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.softlayer.compute.functions.ProductItems;
-import org.jclouds.softlayer.domain.Address;
-import org.jclouds.softlayer.domain.Datacenter;
-import org.jclouds.softlayer.domain.ProductItem;
-import org.jclouds.softlayer.domain.ProductItemCategory;
-import org.jclouds.softlayer.domain.ProductItemPrice;
-import org.jclouds.softlayer.domain.ProductPackage;
-import org.jclouds.softlayer.domain.Region;
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-
-/**
- * Tests behavior of {@code ProductPackageClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "ProductPackageClientLiveTest")
-public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest {
-
- /**
- * Name of the package used for ordering virtual guests. For real this is
- * passed in using the property
- *
- * @{code org.jclouds.softlayer.reference.SoftLayerConstants.
- * PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME}
- */
- public static final String CLOUD_SERVER_PACKAGE_NAME = "Cloud Server";
-
- @BeforeGroups(groups = { "live" })
- public void setup() {
- super.setup();
- client = api.getProductPackageClient();
- accountClient = api.getAccountClient();
-
- // This is used several times, so cache to speed up the test.
- cloudServerPackageId = Iterables.find(accountClient.getActivePackages(), named(CLOUD_SERVER_PACKAGE_NAME))
- .getId();
- cloudServerProductPackage = client.getProductPackage(cloudServerPackageId);
- }
-
- private ProductPackageClient client;
- private AccountClient accountClient;
-
- private int cloudServerPackageId;
- private ProductPackage cloudServerProductPackage;
-
- @Test
- public void testGetProductPackage() {
- for (ProductPackage productPackage : accountClient.getActivePackages()) {
- ProductPackage response = client.getProductPackage(productPackage.getId());
-
- assert null != response;
- assert response.getId() > 0 : response;
- assert response.getName() != null : response;
- assert response.getDescription() != null : response;
-
- assertTrue(response.getItems().size() >= 0);
- for (ProductItem item : response.getItems()) {
- // ProductItem newDetails = client.getProductItem(item.getId());
- // assertEquals(item.getId(), newDetails.getId());
- checkProductItem(item);
- }
-
- assertTrue(response.getDatacenters().size() > 0);
- for (Datacenter datacenter : response.getDatacenters()) {
- checkDatacenter(datacenter);
- }
- }
- }
-
- @Test
- public void testDatacentersForCloudLayer() {
-
- ImmutableSet.Builder<Datacenter> builder = ImmutableSet.builder();
- builder.add(Datacenter.builder().id(18171).name("sea01").longName("Seattle").build());
- builder.add(Datacenter.builder().id(37473).name("wdc01").longName("Washington, DC").build());
- builder.add(Datacenter.builder().id(138124).name("dal05").longName("Dallas 5").build());
- builder.add(Datacenter.builder().id(168642).name("sjc01").longName("San Jose 1").build());
- builder.add(Datacenter.builder().id(224092).name("sng01").longName("Singapore 1").build());
- builder.add(Datacenter.builder().id(265592).name("ams01").longName("Amsterdam 1").build());
-
- Set<Datacenter> expected = builder.build();
-
- Set<Datacenter> datacenters = cloudServerProductPackage.getDatacenters();
- assert datacenters.size() == expected.size() : datacenters;
- assertTrue(datacenters.containsAll(expected));
-
- for (Datacenter dataCenter : datacenters) {
- Address address = dataCenter.getLocationAddress();
- assertNotNull(address);
- checkAddress(address);
- }
- }
-
- @Test
- public void testGetOneGBRamPrice() {
- // Predicate p =
- // Predicates.and(ProductItemPredicates.categoryCode("ram"),ProductItemPredicates.capacity(1.0f));
- Iterable<ProductItem> ramItems = Iterables.filter(cloudServerProductPackage.getItems(),
- Predicates.and(categoryCode("ram"), capacity(1.0f)));
-
- // capacity is key in GB (1Gb = 1.0f)
- Map<Float, ProductItem> ramToProductItem = Maps.uniqueIndex(ramItems, ProductItems.capacity());
-
- ProductItemPrice price = ProductItems.price().apply(ramToProductItem.get(1.0f));
- assert Integer.valueOf(1644).equals(price.getId());
- }
-
- @Test
- public void testGetTwoCPUCoresPrice() {
- // If use ProductItemPredicates.categoryCode("guest_core") get duplicate
- // capacities (units =
- // PRIVATE_CORE and N/A)
- Iterable<ProductItem> cpuItems = Iterables.filter(cloudServerProductPackage.getItems(),
- Predicates.and(units("PRIVATE_CORE"), capacity(2.0f)));
-
- // number of cores is the key
- Map<Float, ProductItem> coresToProductItem = Maps.uniqueIndex(cpuItems, ProductItems.capacity());
-
- ProductItemPrice price = ProductItems.price().apply(coresToProductItem.get(2.0f));
- assert Integer.valueOf(1963).equals(price.getId());
- }
-
- @Test
- public void testGetUbuntuPrice() {
- Iterable<ProductItem> operatingSystems = Iterables.filter(cloudServerProductPackage.getItems(),
- categoryCode("os"));
-
- Map<String, ProductItem> osToProductItem = Maps.uniqueIndex(operatingSystems, ProductItems.description());
-
- ProductItemPrice price = ProductItems.price().apply(
- osToProductItem.get("Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (64 bit)"));
- assert Integer.valueOf(1693).equals(price.getId());
- }
-
- private void checkProductItem(ProductItem item) {
- assert item.getId() > 0 : item;
- assert item.getDescription() != null : item;
- checkCategories(item.getCategories());
- // units and capacity may be null
-
- assertTrue(item.getPrices().size() >= 0);
-
- for (ProductItemPrice price : item.getPrices()) {
- // ProductItemPrice newDetails =
- // client.getProductItemPrice(prices.getId());
- // assertEquals(item.getId(), newDetails.getId());
- checkPrice(price);
- }
- }
-
- private void checkPrice(ProductItemPrice price) {
- assert price.getId() > 0 : price;
- assert price.getItemId() > 0 : price;
- assert price.getRecurringFee() != null || price.getHourlyRecurringFee() != null : price;
- }
-
- private void checkDatacenter(Datacenter datacenter) {
- assert datacenter.getId() > 0 : datacenter;
- assert datacenter.getName() != null : datacenter;
- assert datacenter.getLongName() != null : datacenter;
- for (Region region : datacenter.getRegions())
- checkRegion(region);
- }
-
- private void checkRegion(Region region) {
- assert !region.getDescription().isEmpty() : region;
- assert !region.getKeyname().isEmpty() : region;
- }
-
- private void checkAddress(Address address) {
- assert address.getId() > 0 : address;
- assert address.getCountry() != null : address;
- if (!ImmutableSet.of("SG", "NL").contains(address.getCountry()))
- assert address.getState() != null : address;
- }
-
- private void checkCategories(Set<ProductItemCategory> categories) {
- for (ProductItemCategory category : categories) {
- assert category.getId() > 0 : category;
- assert category.getName() != null : category;
- assert category.getCategoryCode() != null : category;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java
new file mode 100644
index 0000000..b35c139
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.softlayer.features;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.rest.internal.BaseRestClientExpectTest;
+import org.jclouds.softlayer.SoftLayerApi;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "SoftLayerClientExpectTest")
+public class VirtualGuestApiExpectTest extends BaseRestClientExpectTest<SoftLayerApi> {
+
+
+ public VirtualGuestApiExpectTest() {
+ provider = "softlayer";
+ }
+
+ public void testCancelGuestReturnsTrueOn200AndFalseOn404() {
+
+ HttpRequest cancelGuest11 = HttpRequest.builder().method("GET")
+ .endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Billing_Item/11/cancelService.json")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build();
+
+ HttpResponse found = HttpResponse.builder().statusCode(200).build();
+
+ SoftLayerApi clientWhenServiceExists = requestSendsResponse(cancelGuest11, found);
+
+ assert clientWhenServiceExists.getVirtualGuestApi().cancelService(11l);
+
+
+ HttpResponse notFound = HttpResponse.builder().statusCode(404).build();
+
+ SoftLayerApi clientWhenServiceDoesntExist = requestSendsResponse(cancelGuest11, notFound);
+
+ assert !clientWhenServiceDoesntExist.getVirtualGuestApi().cancelService(11l);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiLiveTest.java
new file mode 100644
index 0000000..fb69a7c
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiLiveTest.java
@@ -0,0 +1,169 @@
+/*
+ * 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.softlayer.features;
+
+import static org.jclouds.softlayer.predicates.ProductItemPredicates.capacity;
+import static org.jclouds.softlayer.predicates.ProductItemPredicates.categoryCode;
+import static org.jclouds.softlayer.predicates.ProductItemPredicates.units;
+import static org.jclouds.softlayer.predicates.ProductPackagePredicates.named;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Random;
+import java.util.Set;
+
+import org.jclouds.softlayer.SoftLayerApi;
+import org.jclouds.softlayer.compute.functions.ProductItems;
+import org.jclouds.softlayer.domain.ProductItem;
+import org.jclouds.softlayer.domain.ProductItemPrice;
+import org.jclouds.softlayer.domain.ProductOrder;
+import org.jclouds.softlayer.domain.ProductOrderReceipt;
+import org.jclouds.softlayer.domain.ProductPackage;
+import org.jclouds.softlayer.domain.VirtualGuest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests behavior of {@code VirtualGuestApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live")
+public class VirtualGuestApiLiveTest extends BaseSoftLayerApiLiveTest {
+
+ private static final String TEST_HOSTNAME_PREFIX = "livetest";
+
+ @Test
+ public void testListVirtualGuests() throws Exception {
+ Set<VirtualGuest> response = api().listVirtualGuests();
+ assert null != response;
+ assertTrue(response.size() >= 0);
+ for (VirtualGuest vg : response) {
+ VirtualGuest newDetails = api().getVirtualGuest(vg.getId());
+ assertEquals(vg.getId(), newDetails.getId());
+ checkVirtualGuest(vg);
+ }
+ }
+
+ @Test(enabled = false, groups = "live")
+ public void testCancelAndPlaceOrder() {
+
+ // This method was not working needs testing out.
+
+ // TODO: Should also check if there are active transactions before trying to cancel.
+ // objectMask: virtualGuests.activeTransaction
+ for (VirtualGuest guest : api().listVirtualGuests()) {
+ if (guest.getHostname().startsWith(TEST_HOSTNAME_PREFIX)) {
+ if (guest.getBillingItemId() != -1) {
+ api().cancelService(guest.getBillingItemId());
+ }
+ }
+ }
+
+ int pkgId = Iterables.find(api.getAccountApi().getActivePackages(),
+ named(ProductPackageApiLiveTest.CLOUD_SERVER_PACKAGE_NAME)).getId();
+ ProductPackage productPackage = api.getProductPackageApi().getProductPackage(pkgId);
+
+ Iterable<ProductItem> ramItems = Iterables.filter(productPackage.getItems(), Predicates.and(categoryCode("ram"),
+ capacity(2.0f)));
+
+ Map<Float, ProductItem> ramToProductItem = Maps.uniqueIndex(ramItems, ProductItems.capacity());
+
+ ProductItemPrice ramPrice = ProductItems.price().apply(ramToProductItem.get(2.0f));
+
+ Iterable<ProductItem> cpuItems = Iterables.filter(productPackage.getItems(), Predicates.and(
+ units("PRIVATE_CORE"), capacity(2.0f)));
+ Map<Float, ProductItem> coresToProductItem = Maps.uniqueIndex(cpuItems, ProductItems.capacity());
+
+ ProductItemPrice cpuPrice = ProductItems.price().apply(coresToProductItem.get(2.0f));
+
+ Iterable<ProductItem> operatingSystems = Iterables.filter(productPackage.getItems(), categoryCode("os"));
+ Map<String, ProductItem> osToProductItem = Maps.uniqueIndex(operatingSystems, ProductItems.description());
+ ProductItemPrice osPrice = ProductItems.price().apply(
+ osToProductItem.get("Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (64 bit)"));
+
+ Builder<ProductItemPrice> prices = ImmutableSet.builder();
+ prices.addAll(defaultPrices);
+ prices.add(ramPrice);
+ prices.add(cpuPrice);
+ prices.add(osPrice);
+
+ VirtualGuest guest = VirtualGuest.builder().domain("jclouds.org").hostname(
+ TEST_HOSTNAME_PREFIX + new Random().nextInt()).build();
+
+ ProductOrder order = ProductOrder.builder().packageId(pkgId).quantity(1).useHourlyPricing(true).prices(
+ prices.build()).virtualGuests(guest).build();
+
+ ProductOrderReceipt receipt = api().orderVirtualGuest(order);
+ ProductOrder order2 = receipt.getOrderDetails();
+ VirtualGuest result = Iterables.get(order2.getVirtualGuests(), 0);
+
+ ProductOrder order3 = api().getOrderTemplate(result.getId());
+
+ assertEquals(order.getPrices(), order3.getPrices());
+ assertNotNull(receipt);
+ }
+
+ private Iterable<ProductItemPrice> defaultPrices;
+
+ @Override
+ protected SoftLayerApi create(Properties props, Iterable<Module> modules) {
+ Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
+ defaultPrices = injector.getInstance(Key.get(new TypeLiteral<Iterable<ProductItemPrice>>() {
+ }));
+ return injector.getInstance(SoftLayerApi.class);
+ }
+
+ private VirtualGuestApi api() {
+ return api.getVirtualGuestApi();
+ }
+
+ private void checkVirtualGuest(VirtualGuest vg) {
+ if (vg.getBillingItemId() == -1)
+ return;// Quotes and shutting down guests
+
+ assert vg.getAccountId() > 0 : vg;
+ assert vg.getCreateDate() != null : vg;
+ assert vg.getDomain() != null : vg;
+ assert vg.getFullyQualifiedDomainName() != null : vg;
+ assert vg.getHostname() != null : vg;
+ assert vg.getId() > 0 : vg;
+ assert vg.getMaxCpu() > 0 : vg;
+ assert vg.getMaxCpuUnits() != null : vg;
+ assert vg.getMaxMemory() > 0 : vg;
+ assert vg.getMetricPollDate() != null : vg;
+ assert vg.getModifyDate() != null : vg;
+ assert vg.getStartCpus() > 0 : vg;
+ assert vg.getStatusId() >= 0 : vg;
+ assert vg.getUuid() != null : vg;
+ assert vg.getPrimaryBackendIpAddress() != null : vg;
+ assert vg.getPrimaryIpAddress() != null : vg;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiTest.java
new file mode 100644
index 0000000..499c018
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.softlayer.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.http.functions.ParseJson;
+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.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests annotation parsing of {@code VirtualGuestApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class VirtualGuestApiTest extends BaseSoftLayerApiTest<VirtualGuestApi> {
+
+ public void testListVirtualGuests() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VirtualGuestApi.class, "listVirtualGuests");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests.json?objectMask=virtualGuests.powerState%3BvirtualGuests.networkVlans%3BvirtualGuests.operatingSystem.passwords%3BvirtualGuests.datacenter%3BvirtualGuests.billingItem HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Account/VirtualGuests.json?objectMask=virtualGuests.powerState%3BvirtualGuests.networkVlans%3BvirtualGuests.operatingSystem.passwords%3BvirtualGuests.datacenter%3BvirtualGuests.billingItem HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest,
+ "Accept: application/json\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testGetVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VirtualGuestApi.class, "getVirtualGuest", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234.json?objectMask=powerState%3BnetworkVlans%3BoperatingSystem.passwords%3Bdatacenter%3BbillingItem HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testRebootHardVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VirtualGuestApi.class, "rebootHardVirtualGuest", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/rebootHard.json HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testPowerOffVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VirtualGuestApi.class, "powerOffVirtualGuest", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/powerOff.json HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testPowerOnVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VirtualGuestApi.class, "powerOnVirtualGuest", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/powerOn.json HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testPauseVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VirtualGuestApi.class, "pauseVirtualGuest", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/pause.json HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testResumeVirtualGuest() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VirtualGuestApi.class, "resumeVirtualGuest", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1234));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/resume.json HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+}
[3/3] git commit: Remove async from softlayer
Posted by ab...@apache.org.
Remove async from softlayer
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/dae2c67d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/dae2c67d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/dae2c67d
Branch: refs/heads/master
Commit: dae2c67d795c35d994193f5925a4ce3f4ca7b9ac
Parents: 82fe701
Author: Andrew Bayer <an...@gmail.com>
Authored: Thu Aug 1 13:07:09 2013 -0700
Committer: Andrew Bayer <an...@gmail.com>
Committed: Thu Aug 1 18:13:48 2013 -0700
----------------------------------------------------------------------
.../org/jclouds/softlayer/SoftLayerApi.java | 59 +++++
.../jclouds/softlayer/SoftLayerApiMetadata.java | 24 +-
.../jclouds/softlayer/SoftLayerAsyncClient.java | 63 ------
.../org/jclouds/softlayer/SoftLayerClient.java | 60 -----
.../SoftLayerComputeServiceContextModule.java | 16 +-
.../functions/VirtualGuestToNodeMetadata.java | 18 +-
.../SoftLayerComputeServiceAdapter.java | 31 ++-
.../config/SoftLayerHttpApiModule.java | 67 ++++++
.../config/SoftLayerRestClientModule.java | 90 --------
.../jclouds/softlayer/features/AccountApi.java | 59 +++++
.../softlayer/features/AccountAsyncClient.java | 56 -----
.../softlayer/features/AccountClient.java | 44 ----
.../softlayer/features/DatacenterApi.java | 69 ++++++
.../features/DatacenterAsyncClient.java | 68 ------
.../softlayer/features/DatacenterClient.java | 46 ----
.../softlayer/features/ProductPackageApi.java | 57 +++++
.../features/ProductPackageAsyncClient.java | 58 -----
.../features/ProductPackageClient.java | 39 ----
.../softlayer/features/VirtualGuestApi.java | 178 +++++++++++++++
.../features/VirtualGuestAsyncClient.java | 152 -------------
.../softlayer/features/VirtualGuestClient.java | 118 ----------
.../org/jclouds/softlayer/SoftLayerApiTest.java | 55 +++++
.../softlayer/SoftLayerAsyncClientTest.java | 63 ------
.../SoftLayerComputeServiceAdapterLiveTest.java | 10 +-
.../VirtualGuestToNodeMetadataTest.java | 4 +-
.../softlayer/features/AccountApiLiveTest.java | 47 ++++
.../softlayer/features/AccountApiTest.java | 55 +++++
.../features/AccountAsyncClientTest.java | 55 -----
.../features/AccountClientLiveTest.java | 47 ----
.../features/BaseSoftLayerApiLiveTest.java | 34 +++
.../features/BaseSoftLayerApiTest.java | 43 ++++
.../features/BaseSoftLayerAsyncClientTest.java | 43 ----
.../features/BaseSoftLayerClientLiveTest.java | 34 ---
.../features/DatacenterApiLiveTest.java | 102 +++++++++
.../softlayer/features/DatacenterApiTest.java | 85 ++++++++
.../features/DatacenterAsyncClientTest.java | 85 --------
.../features/DatacenterClientLiveTest.java | 102 ---------
.../features/ProductPackageApiLiveTest.java | 218 +++++++++++++++++++
.../features/ProductPackageApiTest.java | 55 +++++
.../features/ProductPackageAsyncClientTest.java | 55 -----
.../features/ProductPackageClientLiveTest.java | 218 -------------------
.../features/VirtualGuestApiExpectTest.java | 58 +++++
.../features/VirtualGuestApiLiveTest.java | 169 ++++++++++++++
.../softlayer/features/VirtualGuestApiTest.java | 175 +++++++++++++++
.../features/VirtualGuestAsyncClientTest.java | 175 ---------------
.../features/VirtualGuestClientExpectTest.java | 58 -----
.../features/VirtualGuestClientLiveTest.java | 169 --------------
47 files changed, 1631 insertions(+), 1955 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java
new file mode 100644
index 0000000..98383b7
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApi.java
@@ -0,0 +1,59 @@
+/*
+ * 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.softlayer;
+
+import java.io.Closeable;
+
+import org.jclouds.rest.annotations.Delegate;
+import org.jclouds.softlayer.features.AccountApi;
+import org.jclouds.softlayer.features.DatacenterApi;
+import org.jclouds.softlayer.features.ProductPackageApi;
+import org.jclouds.softlayer.features.VirtualGuestApi;
+
+/**
+ * Provides synchronous access to SoftLayer.
+ * <p/>
+ *
+ * @see <a href="http://sldn.softlayer.com/article/REST" />
+ * @author Adrian Cole
+ */
+public interface SoftLayerApi extends Closeable {
+
+ /**
+ * Provides synchronous access to VirtualGuest features.
+ */
+ @Delegate
+ VirtualGuestApi getVirtualGuestApi();
+
+ /**
+ * Provides synchronous access to Datacenter features.
+ */
+ @Delegate
+ DatacenterApi getDatacenterApi();
+
+ /**
+ * Provides synchronous access to ProductPackage features.
+ */
+ @Delegate
+ ProductPackageApi getProductPackageApi();
+
+ /**
+ * Provides synchronous access to Account features.
+ */
+ @Delegate
+ AccountApi getAccountApi();
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java
index fb7e386..97fea12 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java
@@ -23,12 +23,11 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
import org.jclouds.softlayer.compute.config.SoftLayerComputeServiceContextModule;
-import org.jclouds.softlayer.config.SoftLayerRestClientModule;
+import org.jclouds.softlayer.config.SoftLayerHttpApiModule;
import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
@@ -36,17 +35,9 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class SoftLayerApiMetadata extends BaseRestApiMetadata {
+public class SoftLayerApiMetadata extends BaseHttpApiMetadata<SoftLayerApi> {
+
- /**
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(SoftLayerClient.class)} as
- * {@link SoftLayerAsyncClient} interface will be removed in jclouds 1.7.
- */
- @Deprecated
- public static final TypeToken<org.jclouds.rest.RestContext<SoftLayerClient, SoftLayerAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<SoftLayerClient, SoftLayerAsyncClient>>() {
- private static final long serialVersionUID = 1L;
- };
-
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@@ -61,17 +52,16 @@ public class SoftLayerApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
- Properties properties = BaseRestApiMetadata.defaultProperties();
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty("jclouds.ssh.max-retries", "5");
properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties;
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<SoftLayerApi, Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
- super(SoftLayerClient.class, SoftLayerAsyncClient.class);
id("softlayer")
.name("SoftLayer API")
.identityName("API Username")
@@ -81,7 +71,7 @@ public class SoftLayerApiMetadata extends BaseRestApiMetadata {
.defaultEndpoint("https://api.softlayer.com/rest")
.defaultProperties(SoftLayerApiMetadata.defaultProperties())
.view(typeToken(ComputeServiceContext.class))
- .defaultModules(ImmutableSet.<Class<? extends Module>>of(SoftLayerRestClientModule.class, SoftLayerComputeServiceContextModule.class));
+ .defaultModules(ImmutableSet.<Class<? extends Module>>of(SoftLayerHttpApiModule.class, SoftLayerComputeServiceContextModule.class));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java
deleted file mode 100644
index 62b62d6..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.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.softlayer;
-
-import java.io.Closeable;
-
-import org.jclouds.rest.annotations.Delegate;
-import org.jclouds.softlayer.features.AccountAsyncClient;
-import org.jclouds.softlayer.features.DatacenterAsyncClient;
-import org.jclouds.softlayer.features.ProductPackageAsyncClient;
-import org.jclouds.softlayer.features.VirtualGuestAsyncClient;
-
-/**
- * Provides asynchronous access to SoftLayer via their REST API.
- * <p/>
- *
- * @see SoftLayerClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Adrian Cole
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(SoftLayerClient.class)} as
- * {@link SoftLayerAsyncClient} interface will be removed in jclouds 1.7.
- */
-@Deprecated
-public interface SoftLayerAsyncClient extends Closeable {
-
- /**
- * Provides asynchronous access to VirtualGuest features.
- */
- @Delegate
- VirtualGuestAsyncClient getVirtualGuestClient();
-
- /**
- * Provides asynchronous access to Datacenter features.
- */
- @Delegate
- DatacenterAsyncClient getDatacenterClient();
-
- /**
- * Provides asynchronous access to ProductPackage features.
- */
- @Delegate
- ProductPackageAsyncClient getProductPackageClient();
-
- /**
- * Provides asynchronous access to Account features.
- */
- @Delegate
- AccountAsyncClient getAccountClient();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java
deleted file mode 100644
index f76141c..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java
+++ /dev/null
@@ -1,60 +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.softlayer;
-
-import java.io.Closeable;
-
-import org.jclouds.rest.annotations.Delegate;
-import org.jclouds.softlayer.features.AccountClient;
-import org.jclouds.softlayer.features.DatacenterClient;
-import org.jclouds.softlayer.features.ProductPackageClient;
-import org.jclouds.softlayer.features.VirtualGuestClient;
-
-/**
- * Provides synchronous access to SoftLayer.
- * <p/>
- *
- * @see SoftLayerAsyncClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Adrian Cole
- */
-public interface SoftLayerClient extends Closeable {
-
- /**
- * Provides synchronous access to VirtualGuest features.
- */
- @Delegate
- VirtualGuestClient getVirtualGuestClient();
-
- /**
- * Provides synchronous access to Datacenter features.
- */
- @Delegate
- DatacenterClient getDatacenterClient();
-
- /**
- * Provides synchronous access to ProductPackage features.
- */
- @Delegate
- ProductPackageClient getProductPackageClient();
-
- /**
- * Provides synchronous access to Account features.
- */
- @Delegate
- AccountClient getAccountClient();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java
index a84b6e9..f4c87f1 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java
@@ -37,7 +37,7 @@ import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.Location;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
-import org.jclouds.softlayer.SoftLayerClient;
+import org.jclouds.softlayer.SoftLayerApi;
import org.jclouds.softlayer.compute.functions.DatacenterToLocation;
import org.jclouds.softlayer.compute.functions.ProductItemToImage;
import org.jclouds.softlayer.compute.functions.ProductItemsToHardware;
@@ -49,8 +49,8 @@ import org.jclouds.softlayer.domain.ProductItem;
import org.jclouds.softlayer.domain.ProductItemPrice;
import org.jclouds.softlayer.domain.ProductPackage;
import org.jclouds.softlayer.domain.VirtualGuest;
-import org.jclouds.softlayer.features.AccountClient;
-import org.jclouds.softlayer.features.ProductPackageClient;
+import org.jclouds.softlayer.features.AccountApi;
+import org.jclouds.softlayer.features.ProductPackageApi;
import com.google.common.base.Function;
import com.google.common.base.Objects;
@@ -93,16 +93,16 @@ public class SoftLayerComputeServiceContextModule extends
@Singleton
@Memoized
public Supplier<ProductPackage> getProductPackage(AtomicReference<AuthorizationException> authException,
- @Named(PROPERTY_SESSION_INTERVAL) long seconds, final SoftLayerClient client,
+ @Named(PROPERTY_SESSION_INTERVAL) long seconds, final SoftLayerApi client,
@Named(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME) final String virtualGuestPackageName) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
new Supplier<ProductPackage>() {
@Override
public ProductPackage get() {
- AccountClient accountClient = client.getAccountClient();
- ProductPackageClient productPackageClient = client.getProductPackageClient();
- ProductPackage p = find(accountClient.getActivePackages(), named(virtualGuestPackageName));
- return productPackageClient.getProductPackage(p.getId());
+ AccountApi accountApi = client.getAccountApi();
+ ProductPackageApi productPackageApi = client.getProductPackageApi();
+ ProductPackage p = find(accountApi.getActivePackages(), named(virtualGuestPackageName));
+ return productPackageApi.getProductPackage(p.getId());
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
index 93f0fc4..6475a33 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadata.java
@@ -34,7 +34,7 @@ import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.compute.functions.GroupNamingConvention;
import org.jclouds.domain.Location;
import org.jclouds.location.predicates.LocationPredicates;
-import org.jclouds.softlayer.SoftLayerClient;
+import org.jclouds.softlayer.SoftLayerApi;
import org.jclouds.softlayer.domain.ProductItem;
import org.jclouds.softlayer.domain.ProductOrder;
import org.jclouds.softlayer.domain.VirtualGuest;
@@ -105,13 +105,13 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
@Singleton
public static class GetHardwareForVirtualGuest {
- private final SoftLayerClient client;
+ private final SoftLayerApi api;
private final Function<Iterable<ProductItem>, Hardware> productItemsToHardware;
@Inject
- public GetHardwareForVirtualGuest(SoftLayerClient client,
+ public GetHardwareForVirtualGuest(SoftLayerApi api,
Function<Iterable<ProductItem>, Hardware> productItemsToHardware) {
- this.client = checkNotNull(client, "client");
+ this.api = checkNotNull(api, "api");
this.productItemsToHardware = checkNotNull(productItemsToHardware, "productItemsToHardware");
}
@@ -120,7 +120,7 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
// 'bad' orders have no start cpu's and cause the order lookup to fail.
if (guest.getStartCpus() < 1)
return null;
- ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId());
+ ProductOrder order = api.getVirtualGuestApi().getOrderTemplate(guest.getId());
if (order == null)
return null;
Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
@@ -131,18 +131,18 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
@Singleton
public static class GetImageForVirtualGuest {
- private SoftLayerClient client;
+ private SoftLayerApi api;
@Inject
- public GetImageForVirtualGuest(SoftLayerClient client) {
- this.client = client;
+ public GetImageForVirtualGuest(SoftLayerApi api) {
+ this.api = api;
}
public Image getImage(VirtualGuest guest) {
// 'bad' orders have no start cpu's and cause the order lookup to fail.
if (guest.getStartCpus() < 1)
return null;
- ProductOrder order = client.getVirtualGuestClient().getOrderTemplate(guest.getId());
+ ProductOrder order = api.getVirtualGuestApi().getOrderTemplate(guest.getId());
if (order == null)
return null;
Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java
index 5e614bb..aad6afb 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java
@@ -48,7 +48,7 @@ import org.jclouds.compute.domain.Template;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.Logger;
-import org.jclouds.softlayer.SoftLayerClient;
+import org.jclouds.softlayer.SoftLayerApi;
import org.jclouds.softlayer.compute.functions.ProductItemToImage;
import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
import org.jclouds.softlayer.domain.Datacenter;
@@ -65,10 +65,9 @@ import com.google.common.base.Splitter;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
-import com.google.common.collect.Iterables;
/**
- * defines the connection between the {@link SoftLayerClient} implementation and
+ * defines the connection between the {@link SoftLayerApi} implementation and
* the jclouds {@link ComputeService}
*
*/
@@ -80,7 +79,7 @@ public class SoftLayerComputeServiceAdapter implements
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
- private final SoftLayerClient client;
+ private final SoftLayerApi client;
private final Supplier<ProductPackage> productPackageSupplier;
private final Predicate<VirtualGuest> loginDetailsTester;
private final long guestLoginDelay;
@@ -90,7 +89,7 @@ public class SoftLayerComputeServiceAdapter implements
private final Iterable<ProductItemPrice> prices;
@Inject
- public SoftLayerComputeServiceAdapter(SoftLayerClient client,
+ public SoftLayerComputeServiceAdapter(SoftLayerApi client,
VirtualGuestHasLoginDetailsPresent virtualGuestHasLoginDetailsPresent,
@Memoized Supplier<ProductPackage> productPackageSupplier, Iterable<ProductItemPrice> prices,
@Named(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX) String cpuRegex,
@@ -127,7 +126,7 @@ public class SoftLayerComputeServiceAdapter implements
.virtualGuests(newGuest).build();
logger.debug(">> ordering new virtualGuest domain(%s) hostname(%s)", domainName, name);
- ProductOrderReceipt productOrderReceipt = client.getVirtualGuestClient().orderVirtualGuest(order);
+ ProductOrderReceipt productOrderReceipt = client.getVirtualGuestApi().orderVirtualGuest(order);
VirtualGuest result = get(productOrderReceipt.getOrderDetails().getVirtualGuests(), 0);
logger.trace("<< virtualGuest(%s)", result.getId());
@@ -137,7 +136,7 @@ public class SoftLayerComputeServiceAdapter implements
checkState(orderInSystem, "order for guest %s doesn't have login details within %sms", result,
Long.toString(guestLoginDelay));
- result = client.getVirtualGuestClient().getVirtualGuest(result.getId());
+ result = client.getVirtualGuestApi().getVirtualGuest(result.getId());
Password pw = get(result.getOperatingSystem().getPasswords(), 0);
return new NodeAndInitialCredentials<VirtualGuest>(result, result.getId() + "", LoginCredentials.builder().user(pw.getUsername()).password(
@@ -197,7 +196,7 @@ public class SoftLayerComputeServiceAdapter implements
@Override
public Iterable<VirtualGuest> listNodes() {
- return filter(client.getVirtualGuestClient().listVirtualGuests(), new Predicate<VirtualGuest>() {
+ return filter(client.getVirtualGuestApi().listVirtualGuests(), new Predicate<VirtualGuest>() {
@Override
public boolean apply(VirtualGuest arg0) {
@@ -230,7 +229,7 @@ public class SoftLayerComputeServiceAdapter implements
@Override
public VirtualGuest getNode(String id) {
long serverId = Long.parseLong(id);
- return client.getVirtualGuestClient().getVirtualGuest(serverId);
+ return client.getVirtualGuestApi().getVirtualGuest(serverId);
}
@Override
@@ -244,29 +243,29 @@ public class SoftLayerComputeServiceAdapter implements
id));
logger.debug(">> canceling service for guest(%s) billingItem(%s)", id, guest.getBillingItemId());
- client.getVirtualGuestClient().cancelService(guest.getBillingItemId());
+ client.getVirtualGuestApi().cancelService(guest.getBillingItemId());
}
@Override
public void rebootNode(String id) {
- client.getVirtualGuestClient().rebootHardVirtualGuest(Long.parseLong(id));
+ client.getVirtualGuestApi().rebootHardVirtualGuest(Long.parseLong(id));
}
@Override
public void resumeNode(String id) {
- client.getVirtualGuestClient().resumeVirtualGuest(Long.parseLong(id));
+ client.getVirtualGuestApi().resumeVirtualGuest(Long.parseLong(id));
}
@Override
public void suspendNode(String id) {
- client.getVirtualGuestClient().pauseVirtualGuest(Long.parseLong(id));
+ client.getVirtualGuestApi().pauseVirtualGuest(Long.parseLong(id));
}
public static class VirtualGuestHasLoginDetailsPresent implements Predicate<VirtualGuest> {
- private final SoftLayerClient client;
+ private final SoftLayerApi client;
@Inject
- public VirtualGuestHasLoginDetailsPresent(SoftLayerClient client) {
+ public VirtualGuestHasLoginDetailsPresent(SoftLayerApi client) {
this.client = checkNotNull(client, "client was null");
}
@@ -274,7 +273,7 @@ public class SoftLayerComputeServiceAdapter implements
public boolean apply(VirtualGuest guest) {
checkNotNull(guest, "virtual guest was null");
- VirtualGuest newGuest = client.getVirtualGuestClient().getVirtualGuest(guest.getId());
+ VirtualGuest newGuest = client.getVirtualGuestApi().getVirtualGuest(guest.getId());
boolean hasBackendIp = newGuest.getPrimaryBackendIpAddress() != null;
boolean hasPrimaryIp = newGuest.getPrimaryIpAddress() != null;
boolean hasPasswords = newGuest.getOperatingSystem() != null
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerHttpApiModule.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerHttpApiModule.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerHttpApiModule.java
new file mode 100644
index 0000000..f20a3f5
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerHttpApiModule.java
@@ -0,0 +1,67 @@
+/*
+ * 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.softlayer.config;
+
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpRetryHandler;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.Redirection;
+import org.jclouds.http.annotation.ServerError;
+import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
+import org.jclouds.location.config.LocationModule;
+import org.jclouds.location.suppliers.ImplicitLocationSupplier;
+import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
+import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.config.HttpApiModule;
+import org.jclouds.softlayer.SoftLayerApi;
+import org.jclouds.softlayer.handlers.SoftLayerErrorHandler;
+
+import com.google.inject.Scopes;
+
+/**
+ * Configures the SoftLayer connection.
+ *
+ * @author Adrian Cole
+ */
+@ConfiguresRestClient
+public class SoftLayerHttpApiModule extends HttpApiModule<SoftLayerApi> {
+
+ @Override
+ protected void configure() {
+ install(new SoftLayerParserModule());
+ super.configure();
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(SoftLayerErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(SoftLayerErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(SoftLayerErrorHandler.class);
+ }
+
+ @Override
+ protected void bindRetryHandlers() {
+ bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(BackoffLimitedRetryHandler.class);
+ }
+
+ @Override
+ protected void installLocations() {
+ install(new LocationModule());
+ bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java
deleted file mode 100644
index 1b0e591..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java
+++ /dev/null
@@ -1,90 +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.softlayer.config;
-
-import java.util.Map;
-
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.HttpRetryHandler;
-import org.jclouds.http.annotation.ClientError;
-import org.jclouds.http.annotation.Redirection;
-import org.jclouds.http.annotation.ServerError;
-import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
-import org.jclouds.location.config.LocationModule;
-import org.jclouds.location.suppliers.ImplicitLocationSupplier;
-import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.config.RestClientModule;
-import org.jclouds.softlayer.SoftLayerAsyncClient;
-import org.jclouds.softlayer.SoftLayerClient;
-import org.jclouds.softlayer.features.AccountAsyncClient;
-import org.jclouds.softlayer.features.AccountClient;
-import org.jclouds.softlayer.features.DatacenterAsyncClient;
-import org.jclouds.softlayer.features.DatacenterClient;
-import org.jclouds.softlayer.features.ProductPackageAsyncClient;
-import org.jclouds.softlayer.features.ProductPackageClient;
-import org.jclouds.softlayer.features.VirtualGuestAsyncClient;
-import org.jclouds.softlayer.features.VirtualGuestClient;
-import org.jclouds.softlayer.handlers.SoftLayerErrorHandler;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Scopes;
-
-/**
- * Configures the SoftLayer connection.
- *
- * @author Adrian Cole
- */
-@ConfiguresRestClient
-public class SoftLayerRestClientModule extends RestClientModule<SoftLayerClient, SoftLayerAsyncClient> {
-
- public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
- .put(VirtualGuestClient.class, VirtualGuestAsyncClient.class)//
- .put(DatacenterClient.class, DatacenterAsyncClient.class)//
- .put(ProductPackageClient.class, ProductPackageAsyncClient.class)//
- .put(AccountClient.class, AccountAsyncClient.class)//
- .build();
-
- public SoftLayerRestClientModule() {
- super(DELEGATE_MAP);
- }
-
- @Override
- protected void configure() {
- install(new SoftLayerParserModule());
- super.configure();
- }
-
- @Override
- protected void bindErrorHandlers() {
- bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(SoftLayerErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(SoftLayerErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(SoftLayerErrorHandler.class);
- }
-
- @Override
- protected void bindRetryHandlers() {
- bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(BackoffLimitedRetryHandler.class);
- }
-
- @Override
- protected void installLocations() {
- install(new LocationModule());
- bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountApi.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountApi.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountApi.java
new file mode 100644
index 0000000..568d849
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountApi.java
@@ -0,0 +1,59 @@
+/*
+ * 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.softlayer.features;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.softlayer.domain.ProductPackage;
+
+/**
+ * Provides synchronous access to Account.
+ * <p/>
+ *
+ * @see <a href="http://sldn.softlayer.com/article/REST" />
+ * @author Jason King
+ */
+@RequestFilters(BasicAuthentication.class)
+@Path("/v{jclouds.api-version}")
+public interface AccountApi {
+
+ /**
+ *
+ * @return Gets all the active packages.
+ * This will give you a basic description of the packages that are currently
+ * active and from which you can order a server or additional services.
+ *
+ * Calling ProductPackage.getItems() will return an empty set.
+ * Use ProductPackageApi.getProductPackage(long id) to obtain items data.
+ * @see ProductPackageApi#getProductPackage
+ */
+ @GET
+ @Path("/SoftLayer_Account/ActivePackages.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Set<ProductPackage> getActivePackages();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountAsyncClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountAsyncClient.java
deleted file mode 100644
index 2b60572..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountAsyncClient.java
+++ /dev/null
@@ -1,56 +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.softlayer.features;
-
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.softlayer.domain.ProductPackage;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to Account via their REST API.
- * <p/>
- *
- * @see AccountClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Jason King
- */
-@RequestFilters(BasicAuthentication.class)
-@Path("/v{jclouds.api-version}")
-public interface AccountAsyncClient {
-
- /**
- * @see AccountClient#getActivePackages()
- */
- @GET
- @Path("/SoftLayer_Account/ActivePackages.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Set<ProductPackage>> getActivePackages();
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountClient.java
deleted file mode 100644
index c6fc31e..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/AccountClient.java
+++ /dev/null
@@ -1,44 +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.softlayer.features;
-
-import java.util.Set;
-import org.jclouds.softlayer.domain.ProductPackage;
-
-/**
- * Provides synchronous access to Account.
- * <p/>
- *
- * @see AccountAsyncClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Jason King
- */
-public interface AccountClient {
-
- /**
- *
- * @return Gets all the active packages.
- * This will give you a basic description of the packages that are currently
- * active and from which you can order a server or additional services.
- *
- * Calling ProductPackage.getItems() will return an empty set.
- * Use ProductPackageClient.getProductPackage(long id) to obtain items data.
- * @see ProductPackageClient#getProductPackage
- */
- Set<ProductPackage> getActivePackages();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterApi.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterApi.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterApi.java
new file mode 100644
index 0000000..8e7965a
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterApi.java
@@ -0,0 +1,69 @@
+/*
+ * 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.softlayer.features;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.softlayer.domain.Datacenter;
+
+/**
+ * Provides synchronous access to LocationDatacenter.
+ * <p/>
+ *
+ * @see <a href="http://sldn.softlayer.com/article/REST" />
+ * @author Adrian Cole
+ */
+@RequestFilters(BasicAuthentication.class)
+@Path("/v{jclouds.api-version}")
+public interface DatacenterApi {
+
+ /**
+ *
+ * @return an account's associated datacenter objects.
+ */
+ @GET
+ @Path("/SoftLayer_Location_Datacenter/Datacenters.json")
+ @QueryParams(keys = "objectMask", values = "locationAddress;regions")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
+ Set<Datacenter> listDatacenters();
+
+ /**
+ *
+ * @param id
+ * id of the datacenter
+ * @return datacenter or null if not found
+ */
+ @GET
+ @Path("/SoftLayer_Location_Datacenter/{id}.json")
+ @QueryParams(keys = "objectMask", values = "locationAddress;regions")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Datacenter getDatacenter(@PathParam("id") long id);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java
deleted file mode 100644
index e995c56..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java
+++ /dev/null
@@ -1,68 +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.softlayer.features;
-
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.softlayer.domain.Datacenter;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to LocationDatacenter via their REST API.
- * <p/>
- *
- * @see DatacenterClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Adrian Cole
- */
-@RequestFilters(BasicAuthentication.class)
-@Path("/v{jclouds.api-version}")
-public interface DatacenterAsyncClient {
-
- /**
- * @see DatacenterClient#listDatacenters
- */
- @GET
- @Path("/SoftLayer_Location_Datacenter/Datacenters.json")
- @QueryParams(keys = "objectMask", values = "locationAddress;regions")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(EmptySetOnNotFoundOr404.class)
- ListenableFuture<Set<Datacenter>> listDatacenters();
-
- /**
- * @see DatacenterClient#getDatacenter
- */
- @GET
- @Path("/SoftLayer_Location_Datacenter/{id}.json")
- @QueryParams(keys = "objectMask", values = "locationAddress;regions")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Datacenter> getDatacenter(@PathParam("id") long id);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java
deleted file mode 100644
index 6034dc7..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java
+++ /dev/null
@@ -1,46 +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.softlayer.features;
-
-import java.util.Set;
-import org.jclouds.softlayer.domain.Datacenter;
-
-/**
- * Provides synchronous access to LocationDatacenter.
- * <p/>
- *
- * @see DatacenterAsyncClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Adrian Cole
- */
-public interface DatacenterClient {
-
- /**
- *
- * @return an account's associated datacenter objects.
- */
- Set<Datacenter> listDatacenters();
-
- /**
- *
- * @param id
- * id of the datacenter
- * @return datacenter or null if not found
- */
- Datacenter getDatacenter(long id);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageApi.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageApi.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageApi.java
new file mode 100644
index 0000000..efe1d9a
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageApi.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.softlayer.features;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.softlayer.domain.ProductPackage;
+
+/**
+ * Provides synchronous access to ProductPackage.
+ * <p/>
+ *
+ * @see <a href="http://sldn.softlayer.com/article/REST" />
+ * @author Adrian Cole
+ */
+@RequestFilters(BasicAuthentication.class)
+@Path("/v{jclouds.api-version}")
+public interface ProductPackageApi {
+ public static String PRODUCT_MASK = "items.prices;items.categories;locations.locationAddress;locations.regions";
+
+ /**
+ *
+ * @param id
+ * id of the product package
+ * @return product package or null if not found
+ */
+ @GET
+ @Path("/SoftLayer_Product_Package/{id}.json")
+ @QueryParams(keys = "objectMask", values = PRODUCT_MASK)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ ProductPackage getProductPackage(@PathParam("id") long id);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java
deleted file mode 100644
index 29bdb7f..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.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.softlayer.features;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.softlayer.domain.ProductPackage;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to ProductPackage via their REST API.
- * <p/>
- *
- * @see ProductPackageClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Adrian Cole
- */
-@RequestFilters(BasicAuthentication.class)
-@Path("/v{jclouds.api-version}")
-public interface ProductPackageAsyncClient {
- public static String PRODUCT_MASK = "items.prices;items.categories;locations.locationAddress;locations.regions";
-
- /**
- * @see ProductPackageClient#getProductPackage
- */
- @GET
- @Path("/SoftLayer_Product_Package/{id}.json")
- @QueryParams(keys = "objectMask", values = PRODUCT_MASK)
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<ProductPackage> getProductPackage(@PathParam("id") long id);
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java
deleted file mode 100644
index 76acd3b..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java
+++ /dev/null
@@ -1,39 +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.softlayer.features;
-
-import org.jclouds.softlayer.domain.ProductPackage;
-
-/**
- * Provides synchronous access to ProductPackage.
- * <p/>
- *
- * @see ProductPackageAsyncClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Adrian Cole
- */
-public interface ProductPackageClient {
-
- /**
- *
- * @param id
- * id of the product package
- * @return product package or null if not found
- */
- ProductPackage getProductPackage(long id);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java
new file mode 100644
index 0000000..6b76822
--- /dev/null
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java
@@ -0,0 +1,178 @@
+/*
+ * 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.softlayer.features;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.softlayer.binders.ProductOrderToJson;
+import org.jclouds.softlayer.domain.ProductOrder;
+import org.jclouds.softlayer.domain.ProductOrderReceipt;
+import org.jclouds.softlayer.domain.VirtualGuest;
+
+/**
+ * Provides synchronous access to VirtualGuest.
+ * <p/>
+ *
+ * @see <a href="http://sldn.softlayer.com/article/REST" />
+ * @author Adrian Cole
+ */
+@RequestFilters(BasicAuthentication.class)
+@Path("/v{jclouds.api-version}")
+public interface VirtualGuestApi {
+ public static String LIST_GUEST_MASK = "virtualGuests.powerState;virtualGuests.networkVlans;virtualGuests.operatingSystem.passwords;virtualGuests.datacenter;virtualGuests.billingItem";
+ public static String GUEST_MASK = "powerState;networkVlans;operatingSystem.passwords;datacenter;billingItem";
+
+ /**
+ *
+ * @return an account's associated virtual guest objects.
+ */
+ @GET
+ @Path("/SoftLayer_Account/VirtualGuests.json")
+ @QueryParams(keys = "objectMask", values = LIST_GUEST_MASK)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
+ Set<VirtualGuest> listVirtualGuests();
+
+ /**
+ *
+ * @param id
+ * id of the virtual guest
+ * @return virtual guest or null if not found
+ */
+ @GET
+ @Path("/SoftLayer_Virtual_Guest/{id}.json")
+ @QueryParams(keys = "objectMask", values = GUEST_MASK)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ VirtualGuest getVirtualGuest(@PathParam("id") long id);
+
+ /**
+ * hard reboot the guest.
+ *
+ * @param id
+ * id of the virtual guest
+ */
+ @GET
+ @Path("/SoftLayer_Virtual_Guest/{id}/rebootHard.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ void rebootHardVirtualGuest(@PathParam("id") long id);
+
+ /**
+ * Power off a guest
+ *
+ * @param id
+ * id of the virtual guest
+ */
+ @GET
+ @Path("/SoftLayer_Virtual_Guest/{id}/powerOff.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ void powerOffVirtualGuest(@PathParam("id") long id);
+
+ /**
+ * Power on a guest
+ *
+ * @param id
+ * id of the virtual guest
+ */
+ @GET
+ @Path("/SoftLayer_Virtual_Guest/{id}/powerOn.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ void powerOnVirtualGuest(@PathParam("id") long id);
+
+ /**
+ * pause the guest.
+ *
+ * @param id
+ * id of the virtual guest
+ */
+ @GET
+ @Path("/SoftLayer_Virtual_Guest/{id}/pause.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ void pauseVirtualGuest(@PathParam("id") long id);
+
+ /**
+ * resume the guest.
+ *
+ * @param id
+ * id of the virtual guest
+ */
+ @GET
+ @Path("/SoftLayer_Virtual_Guest/{id}/resume.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ void resumeVirtualGuest(@PathParam("id") long id);
+
+ /**
+ * Cancel the resource or service for a billing Item
+ *
+ * @param id
+ * The id of the billing item to cancel
+ * @return true or false
+ */
+ @GET
+ @Path("/SoftLayer_Billing_Item/{id}/cancelService.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.FalseOnNotFoundOr404.class)
+ boolean cancelService(@PathParam("id") long id);
+
+ /**
+ * Use this method for placing server orders and additional services orders.
+ * @param order
+ * Details required to order.
+ * @return A receipt for the order
+ * @see <a href="http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder" />
+ */
+ @POST
+ @Path("/SoftLayer_Product_Order/placeOrder.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ ProductOrderReceipt orderVirtualGuest(@BinderParam(ProductOrderToJson.class)ProductOrder order);
+
+ /**
+ * Obtain an order container that is ready to be sent to the orderVirtualGuest method.
+ * This container will include all services that the selected computing instance has.
+ * If desired you may remove prices which were returned.
+ * @see <a href=" @see <a href="http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder" />
+ * @param id
+ * The id of the existing Virtual Guest
+ * @return
+ * The ProductOrder used to create the VirtualGust or null if not available
+ */
+ @GET
+ @Path("SoftLayer_Virtual_Guest/{id}/getOrderTemplate/MONTHLY.json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ ProductOrder getOrderTemplate(@PathParam("id") long id);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java
deleted file mode 100644
index 30fddc0..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.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.softlayer.features;
-
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.softlayer.binders.ProductOrderToJson;
-import org.jclouds.softlayer.domain.ProductOrder;
-import org.jclouds.softlayer.domain.ProductOrderReceipt;
-import org.jclouds.softlayer.domain.VirtualGuest;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to VirtualGuest via their REST API.
- * <p/>
- *
- * @see VirtualGuestClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Adrian Cole
- */
-@RequestFilters(BasicAuthentication.class)
-@Path("/v{jclouds.api-version}")
-public interface VirtualGuestAsyncClient {
- public static String LIST_GUEST_MASK = "virtualGuests.powerState;virtualGuests.networkVlans;virtualGuests.operatingSystem.passwords;virtualGuests.datacenter;virtualGuests.billingItem";
- public static String GUEST_MASK = "powerState;networkVlans;operatingSystem.passwords;datacenter;billingItem";
-
- /**
- * @see VirtualGuestClient#listVirtualGuests
- */
- @GET
- @Path("/SoftLayer_Account/VirtualGuests.json")
- @QueryParams(keys = "objectMask", values = LIST_GUEST_MASK)
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(EmptySetOnNotFoundOr404.class)
- ListenableFuture<Set<VirtualGuest>> listVirtualGuests();
-
- /**
- * @see VirtualGuestClient#getVirtualGuest
- */
- @GET
- @Path("/SoftLayer_Virtual_Guest/{id}.json")
- @QueryParams(keys = "objectMask", values = GUEST_MASK)
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<VirtualGuest> getVirtualGuest(@PathParam("id") long id);
-
- /**
- * @see VirtualGuestClient#rebootHardVirtualGuest
- */
- @GET
- @Path("/SoftLayer_Virtual_Guest/{id}/rebootHard.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> rebootHardVirtualGuest(@PathParam("id") long id);
-
- /**
- * @see VirtualGuestClient#powerOffVirtualGuest
- */
- @GET
- @Path("/SoftLayer_Virtual_Guest/{id}/powerOff.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> powerOffVirtualGuest(@PathParam("id") long id);
-
- /**
- * @see VirtualGuestClient#powerOnVirtualGuest
- */
- @GET
- @Path("/SoftLayer_Virtual_Guest/{id}/powerOn.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> powerOnVirtualGuest(@PathParam("id") long id);
-
- /**
- * @see VirtualGuestClient#pauseVirtualGuest
- */
- @GET
- @Path("/SoftLayer_Virtual_Guest/{id}/pause.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> pauseVirtualGuest(@PathParam("id") long id);
-
- /**
- * @see VirtualGuestClient#resumeVirtualGuest
- */
- @GET
- @Path("/SoftLayer_Virtual_Guest/{id}/resume.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> resumeVirtualGuest(@PathParam("id") long id);
-
- /**
- * @see VirtualGuestClient#cancelService
- */
- @GET
- @Path("/SoftLayer_Billing_Item/{id}/cancelService.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(FalseOnNotFoundOr404.class)
- ListenableFuture<Boolean> cancelService(@PathParam("id") long id);
-
- /**
- * @see org.jclouds.softlayer.features.VirtualGuestClient#orderVirtualGuest
- */
- @POST
- @Path("/SoftLayer_Product_Order/placeOrder.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<ProductOrderReceipt> orderVirtualGuest(@BinderParam(ProductOrderToJson.class)ProductOrder order);
-
- /**
- * Throws an Internal Server Error if called on bad orders (mapped to HttpResponseException)
- * @see VirtualGuestClient#getOrderTemplate
- * @throws org.jclouds.http.HttpResponseException if called with a 'bad' order.
- */
- @GET
- @Path("SoftLayer_Virtual_Guest/{id}/getOrderTemplate/MONTHLY.json")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<ProductOrder> getOrderTemplate(@PathParam("id") long id);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java
deleted file mode 100644
index 0ebf166..0000000
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java
+++ /dev/null
@@ -1,118 +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.softlayer.features;
-
-import java.util.Set;
-import org.jclouds.softlayer.domain.ProductOrder;
-import org.jclouds.softlayer.domain.ProductOrderReceipt;
-import org.jclouds.softlayer.domain.VirtualGuest;
-
-/**
- * Provides synchronous access to VirtualGuest.
- * <p/>
- *
- * @see VirtualGuestAsyncClient
- * @see <a href="http://sldn.softlayer.com/article/REST" />
- * @author Adrian Cole
- */
-public interface VirtualGuestClient {
-
- /**
- *
- * @return an account's associated virtual guest objects.
- */
- Set<VirtualGuest> listVirtualGuests();
-
- /**
- *
- * @param id
- * id of the virtual guest
- * @return virtual guest or null if not found
- */
- VirtualGuest getVirtualGuest(long id);
-
- /**
- * hard reboot the guest.
- *
- * @param id
- * id of the virtual guest
- */
- void rebootHardVirtualGuest(long id);
-
- /**
- * Power off a guest
- *
- * @param id
- * id of the virtual guest
- */
- void powerOffVirtualGuest(long id);
-
- /**
- * Power on a guest
- *
- * @param id
- * id of the virtual guest
- */
- void powerOnVirtualGuest(long id);
-
- /**
- * pause the guest.
- *
- * @param id
- * id of the virtual guest
- */
- void pauseVirtualGuest(long id);
-
- /**
- * resume the guest.
- *
- * @param id
- * id of the virtual guest
- */
- void resumeVirtualGuest(long id);
-
-
- /**
- * Cancel the resource or service for a billing Item
- *
- * @param id
- * The id of the billing item to cancel
- * @return true or false
- */
- boolean cancelService(long id);
-
- /**
- * Use this method for placing server orders and additional services orders.
- * @param order
- * Details required to order.
- * @return A receipt for the order
- * @see <a href="http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder" />
- */
- ProductOrderReceipt orderVirtualGuest(ProductOrder order);
-
- /**
- * Obtain an order container that is ready to be sent to the orderVirtualGuest method.
- * This container will include all services that the selected computing instance has.
- * If desired you may remove prices which were returned.
- * @see <a href=" @see <a href="http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder" />
- * @param id
- * The id of the existing Virtual Guest
- * @return
- * The ProductOrder used to create the VirtualGust or null if not available
- */
- ProductOrder getOrderTemplate(long id);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerApiTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerApiTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerApiTest.java
new file mode 100644
index 0000000..b0458c0
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerApiTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.softlayer;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.softlayer.features.BaseSoftLayerApiTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code SoftLayerApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "SoftLayerApiTest")
+public class SoftLayerApiTest extends BaseSoftLayerApiTest<SoftLayerApi> {
+
+ private SoftLayerApi syncClient;
+
+ public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
+ assert syncClient.getVirtualGuestApi() != null;
+ assert syncClient.getDatacenterApi() != null;
+ assert syncClient.getProductPackageApi() != null;
+ }
+
+ @BeforeClass
+ @Override
+ protected void setupFactory() throws IOException {
+ super.setupFactory();
+ syncClient = injector.getInstance(SoftLayerApi.class);
+ }
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerAsyncClientTest.java
deleted file mode 100644
index e3e5354..0000000
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerAsyncClientTest.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.softlayer;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.softlayer.features.BaseSoftLayerAsyncClientTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code SoftLayerAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "SoftLayerAsyncClientTest")
-public class SoftLayerAsyncClientTest extends BaseSoftLayerAsyncClientTest<SoftLayerAsyncClient> {
-
- private SoftLayerAsyncClient asyncClient;
- private SoftLayerClient syncClient;
-
- public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
- assert syncClient.getVirtualGuestClient() != null;
- assert syncClient.getDatacenterClient() != null;
- assert syncClient.getProductPackageClient() != null;
- }
-
- public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
- assert asyncClient.getVirtualGuestClient() != null;
- assert asyncClient.getDatacenterClient() != null;
- assert asyncClient.getProductPackageClient() != null;
- }
-
- @BeforeClass
- @Override
- protected void setupFactory() throws IOException {
- super.setupFactory();
- asyncClient = injector.getInstance(SoftLayerAsyncClient.class);
- syncClient = injector.getInstance(SoftLayerClient.class);
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
index 425918c..61a8b82 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
@@ -29,12 +29,12 @@ import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate;
import org.jclouds.domain.LoginCredentials;
-import org.jclouds.softlayer.SoftLayerClient;
+import org.jclouds.softlayer.SoftLayerApi;
import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
import org.jclouds.softlayer.compute.strategy.SoftLayerComputeServiceAdapter;
import org.jclouds.softlayer.domain.ProductItem;
import org.jclouds.softlayer.domain.VirtualGuest;
-import org.jclouds.softlayer.features.BaseSoftLayerClientLiveTest;
+import org.jclouds.softlayer.features.BaseSoftLayerApiLiveTest;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshClient.Factory;
import org.jclouds.sshj.config.SshjSshClientModule;
@@ -49,7 +49,7 @@ import com.google.inject.Injector;
import com.google.inject.Module;
@Test(groups = "live", singleThreaded = true, testName = "SoftLayerComputeServiceAdapterLiveTest")
-public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientLiveTest {
+public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerApiLiveTest {
private SoftLayerComputeServiceAdapter adapter;
private TemplateBuilder templateBuilder;
@@ -57,12 +57,12 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL
private NodeAndInitialCredentials<VirtualGuest> guest;
@Override
- protected SoftLayerClient create(Properties props, Iterable<Module> modules) {
+ protected SoftLayerApi create(Properties props, Iterable<Module> modules) {
Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
adapter = injector.getInstance(SoftLayerComputeServiceAdapter.class);
templateBuilder = injector.getInstance(TemplateBuilder.class);
sshFactory = injector.getInstance(SshClient.Factory.class);
- return injector.getInstance(SoftLayerClient.class);
+ return injector.getInstance(SoftLayerApi.class);
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java
index 208fb48..aac0081 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java
@@ -31,7 +31,7 @@ import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.functions.GroupNamingConvention;
import org.jclouds.domain.Location;
-import org.jclouds.softlayer.SoftLayerClient;
+import org.jclouds.softlayer.SoftLayerApi;
import org.jclouds.softlayer.domain.VirtualGuest;
import org.jclouds.softlayer.parse.ParseBadVirtualGuest;
import org.jclouds.softlayer.parse.ParseVirtualGuestHaltedTest;
@@ -192,7 +192,7 @@ public class VirtualGuestToNodeMetadataTest {
private static class GetHardwareForVirtualGuestMock extends VirtualGuestToNodeMetadata.GetHardwareForVirtualGuest {
@SuppressWarnings("unchecked")
public GetHardwareForVirtualGuestMock() {
- super(createNiceMock(SoftLayerClient.class), createNiceMock(Function.class));
+ super(createNiceMock(SoftLayerApi.class), createNiceMock(Function.class));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/dae2c67d/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiLiveTest.java
new file mode 100644
index 0000000..f80b0cc
--- /dev/null
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountApiLiveTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.softlayer.features;
+
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.softlayer.domain.ProductPackage;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code AccountApi}
+ *
+ * @author Jason King
+ */
+@Test(groups = "live")
+public class AccountApiLiveTest extends BaseSoftLayerApiLiveTest {
+
+ @Test
+ public void testGetActivePackages() {
+ Set<ProductPackage> response = api.getAccountApi().getActivePackages();
+ assert null != response;
+
+ assertTrue(response.size() >= 0);
+ for (ProductPackage productPackage: response) {
+ assert productPackage.getId() > 0 : response;
+ assert productPackage.getName() != null : response;
+ assert productPackage.getDescription() != null : response;
+ assertTrue(productPackage.getItems().isEmpty());
+ }
+ }
+}