Code Formatting commit.

This commit is contained in:
vijaykiran 2011-10-29 16:03:15 +02:00
parent 60f70a0589
commit 6d4ce41d15
39 changed files with 472 additions and 459 deletions

View File

@ -18,15 +18,16 @@
*/
package org.jclouds.cloudstack;
import com.google.inject.TypeLiteral;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.jclouds.cloudstack.features.BaseCloudStackAsyncClientTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import com.google.inject.TypeLiteral;
/**
* Tests behavior of {@code CloudStackAsyncClient}

View File

@ -144,4 +144,4 @@
// super.tearDown();
// }
//
//}
// }

View File

@ -38,7 +38,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "AccountAsyncClientTest")
public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<AccountAsyncClient> {
@ -47,7 +48,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listAccounts HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listAccounts HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -61,11 +62,11 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
public void testListAccountsOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, ListAccountsOptions.Builder.accountInDomain("jclouds",
123));
HttpRequest httpRequest = processor.createRequest(method,
ListAccountsOptions.Builder.accountInDomain("jclouds", 123));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listAccounts&account=jclouds&domainid=123 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listAccounts&account=jclouds&domainid=123 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -82,7 +83,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
HttpRequest httpRequest = processor.createRequest(method, 3l);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listAccounts&id=3 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listAccounts&id=3 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -18,15 +18,15 @@
*/
package org.jclouds.cloudstack.features;
import static org.testng.Assert.assertEquals;
import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.User;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
/**
* Tests behavior of {@code AccountClient}
*
*
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "AccountClientLiveTest")

View File

@ -26,9 +26,9 @@ import org.jclouds.cloudstack.options.AssociateIPAddressOptions;
import org.jclouds.cloudstack.options.ListPublicIPAddressesOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -43,12 +43,12 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "AddressAsyncClientTest")
public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<AddressAsyncClient> {
public void testListPublicIPAddresses() throws SecurityException, NoSuchMethodException, IOException {
Method method = AddressAsyncClient.class.getMethod("listPublicIPAddresses",
ListPublicIPAddressesOptions[].class);
Method method = AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
@ -65,8 +65,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
}
public void testListPublicIPAddressesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = AddressAsyncClient.class.getMethod("listPublicIPAddresses",
ListPublicIPAddressesOptions[].class);
Method method = AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method,
ListPublicIPAddressesOptions.Builder.accountInDomain("adrian", 6).usesVirtualNetwork(true));
@ -103,12 +102,11 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
}
public void testAssociateIPAddressInZone() throws SecurityException, NoSuchMethodException, IOException {
Method method = AddressAsyncClient.class.getMethod("associateIPAddressInZone",
long.class, AssociateIPAddressOptions[].class);
Method method = AddressAsyncClient.class.getMethod("associateIPAddressInZone", long.class,
AssociateIPAddressOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 6);
assertRequestLineEquals(
httpRequest,
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=associateIpAddress&zoneid=6 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -54,7 +54,7 @@ public class AddressClientLiveTest extends BaseCloudStackClientLiveTest {
if (!networksEnabled)
return;
AsyncCreateResponse job = client.getAddressClient().associateIPAddressInZone(
Iterables.get(client.getNetworkClient().listNetworks(), 0).getZoneId());
Iterables.get(client.getNetworkClient().listNetworks(), 0).getZoneId());
checkState(jobComplete.apply(job.getJobId()), "job %d failed to complete", job.getJobId());
ip = client.getAsyncJobClient().<PublicIPAddress> getAsyncJob(job.getJobId()).getResult();
checkIP(ip);
@ -76,7 +76,7 @@ public class AddressClientLiveTest extends BaseCloudStackClientLiveTest {
assertTrue(response.size() >= 0);
for (PublicIPAddress ip : response) {
PublicIPAddress newDetails = getOnlyElement(client.getAddressClient().listPublicIPAddresses(
ListPublicIPAddressesOptions.Builder.id(ip.getId())));
ListPublicIPAddressesOptions.Builder.id(ip.getId())));
assertEquals(ip.getId(), newDetails.getId());
checkIP(ip);
}

View File

@ -37,7 +37,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "AsyncJobAsyncClientTest")
public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<AsyncJobAsyncClient> {

View File

@ -58,7 +58,8 @@ public class AsyncJobClientLiveTest extends BaseCloudStackClientLiveTest {
assert query.getResultCode() >= 0 : query;
assert query.getProgress() >= 0 : query;
if (query.getResultCode() == 0) {
if (query.getResult() != null)// null is ok for result of success = true
if (query.getResult() != null)// null is ok for result of success =
// true
// ensure we parsed properly
assert (query.getResult().getClass().getPackage().equals(AsyncJob.class.getPackage())) : query;
} else if (query.getResultCode() > 400) {

View File

@ -82,11 +82,11 @@ public class BaseCloudStackClientLiveTest {
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider
+ ".identity must be set. ex. apiKey");
+ ".identity must be set. ex. apiKey");
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
+ ".credential must be set. ex. secretKey");
+ ".credential must be set. ex. secretKey");
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider
+ ".endpoint must be set. ex. http://localhost:8080/client/api");
+ ".endpoint must be set. ex. http://localhost:8080/client/api");
apiversion = System.getProperty("test." + provider + ".apiversion");
}
@ -121,7 +121,7 @@ public class BaseCloudStackClientLiveTest {
setupCredentials();
Properties overrides = setupProperties();
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
overrides);
overrides);
client = context.getApi();
// check access
@ -130,8 +130,8 @@ public class BaseCloudStackClientLiveTest {
if (currentUser.getAccountType() != Account.Type.USER)
throw new IllegalArgumentException(String.format(
"invalid account type: %s, please specify an apiKey of a USER, for example: %s", currentUser
.getAccountType(), Iterables.filter(users, UserPredicates.isUserAccount())));
"invalid account type: %s, please specify an apiKey of a USER, for example: %s",
currentUser.getAccountType(), Iterables.filter(users, UserPredicates.isUserAccount())));
injector = Guice.createInjector(new SshjSshClientModule(), new Log4JLoggingModule());
sshFactory = injector.getInstance(SshClient.Factory.class);
@ -140,10 +140,10 @@ public class BaseCloudStackClientLiveTest {
jobComplete = new RetryablePredicate<Long>(new JobComplete(client), 1200, 1, 5, TimeUnit.SECONDS);
injector.injectMembers(jobComplete);
virtualMachineRunning = new RetryablePredicate<VirtualMachine>(new VirtualMachineRunning(client), 600, 5, 5,
TimeUnit.SECONDS);
TimeUnit.SECONDS);
injector.injectMembers(virtualMachineRunning);
virtualMachineDestroyed = new RetryablePredicate<VirtualMachine>(new VirtualMachineDestroyed(client), 600, 5, 5,
TimeUnit.SECONDS);
TimeUnit.SECONDS);
injector.injectMembers(virtualMachineDestroyed);
reuseOrAssociate = new ReuseOrAssociateNewPublicIPAddress(client, jobComplete);
injector.injectMembers(reuseOrAssociate);

View File

@ -34,7 +34,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "ConfigurationAsyncClientTest")
public class ConfigurationAsyncClientTest extends BaseCloudStackAsyncClientTest<ConfigurationAsyncClient> {
@ -43,7 +44,7 @@ public class ConfigurationAsyncClientTest extends BaseCloudStackAsyncClientTest<
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listCapabilities HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listCapabilities HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -23,9 +23,9 @@ import java.lang.reflect.Method;
import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
@ -39,16 +39,17 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "FirewallAsyncClientTest")
public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<FirewallAsyncClient> {
public void testListPortForwardingRules() throws SecurityException, NoSuchMethodException, IOException {
Method method = FirewallAsyncClient.class.getMethod("listPortForwardingRules",
ListPortForwardingRulesOptions[].class);
ListPortForwardingRulesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -62,11 +63,11 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
public void testListPortForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = FirewallAsyncClient.class.getMethod("listPortForwardingRules",
ListPortForwardingRulesOptions[].class);
ListPortForwardingRulesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, ListPortForwardingRulesOptions.Builder.IPAddressId(3));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&ipaddressid=3 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&ipaddressid=3 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -79,14 +80,14 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
}
public void testCreatePortForwardingRuleForVirtualMachine() throws SecurityException, NoSuchMethodException,
IOException {
IOException {
Method method = FirewallAsyncClient.class.getMethod("createPortForwardingRuleForVirtualMachine", long.class,
long.class, String.class, int.class, int.class);
long.class, String.class, int.class, int.class);
HttpRequest httpRequest = processor.createRequest(method, 6, 7, "tcp", 22, 22);
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createPortForwardingRule&virtualmachineid=6&protocol=tcp&ipaddressid=7&privateport=22&publicport=22 HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createPortForwardingRule&virtualmachineid=6&protocol=tcp&ipaddressid=7&privateport=22&publicport=22 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -103,7 +104,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deletePortForwardingRule&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=deletePortForwardingRule&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -58,7 +58,7 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest {
try {
network = find(client.getNetworkClient().listNetworks(), NetworkPredicates.supportsPortForwarding());
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, client, jobComplete,
virtualMachineRunning);
virtualMachineRunning);
if (vm.getPassword() != null)
password = vm.getPassword();
} catch (NoSuchElementException e) {
@ -73,7 +73,7 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest {
ip = reuseOrAssociate.apply(network);
try {
AsyncCreateResponse job = client.getFirewallClient().createPortForwardingRuleForVirtualMachine(vm.getId(),
ip.getId(), "tcp", 22, 22);
ip.getId(), "tcp", 22, 22);
assert jobComplete.apply(job.getJobId());
rule = findRuleWithId(job.getId());
} catch (IllegalStateException e) {

View File

@ -40,7 +40,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "GuestOSAsyncClientTest")
public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestOSAsyncClient> {
@ -49,7 +50,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
HttpRequest httpRequest = processor.createRequest(method, 11l);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listOsCategories&id=11 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listOsCategories&id=11 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null, null, false);
@ -66,7 +67,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listOsCategories HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listOsCategories HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null, null, false);
@ -83,7 +84,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
HttpRequest httpRequest = processor.createRequest(method, 11l);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&id=11 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&id=11 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -101,7 +102,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listOsTypes HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listOsTypes HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -118,7 +119,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
HttpRequest httpRequest = processor.createRequest(method, ListOSTypesOptions.Builder.OSCategoryId(11));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&oscategoryid=11 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&oscategoryid=11 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import org.jclouds.cloudstack.domain.OSType;
import org.jclouds.cloudstack.options.ListOSTypesOptions;
@ -44,7 +44,7 @@ public class GuestOSClientLiveTest extends BaseCloudStackClientLiveTest {
assertTrue(response.size() >= 0);
for (OSType type : response) {
OSType newDetails = getOnlyElement(client.getGuestOSClient().listOSTypes(
ListOSTypesOptions.Builder.id(type.getId())));
ListOSTypesOptions.Builder.id(type.getId())));
assertEquals(type.getId(), newDetails.getId());
checkOSType(type);
}

View File

@ -34,7 +34,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "HypervisorAsyncClientTest")
public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest<HypervisorAsyncClient> {
@ -43,7 +44,7 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest<Hyp
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listHypervisors HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listHypervisors HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null, null, false);
@ -60,7 +61,7 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest<Hyp
HttpRequest httpRequest = processor.createRequest(method, 11);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listHypervisors&zoneid=11 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listHypervisors&zoneid=11 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -38,16 +38,17 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "LoadBalancerAsyncClientTest")
public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<LoadBalancerAsyncClient> {
public void testListLoadBalancerRules() throws SecurityException, NoSuchMethodException, IOException {
Method method = LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
ListLoadBalancerRulesOptions[].class);
ListLoadBalancerRulesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -61,11 +62,11 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
public void testListLoadBalancerRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
ListLoadBalancerRulesOptions[].class);
ListLoadBalancerRulesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, ListLoadBalancerRulesOptions.Builder.publicIPId(3));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules&publicipid=3 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules&publicipid=3 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -79,12 +80,12 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
public void testCreateLoadBalancerRuleForPublicIP() throws SecurityException, NoSuchMethodException, IOException {
Method method = LoadBalancerAsyncClient.class.getMethod("createLoadBalancerRuleForPublicIP", long.class,
Algorithm.class, String.class, int.class, int.class);
Algorithm.class, String.class, int.class, int.class);
HttpRequest httpRequest = processor.createRequest(method, 6, Algorithm.LEASTCONN, "tcp", 22, 22);
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createLoadBalancerRule&publicipid=6&name=tcp&algorithm=leastconn&privateport=22&publicport=22 HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createLoadBalancerRule&publicipid=6&name=tcp&algorithm=leastconn&privateport=22&publicport=22 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -101,7 +102,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteLoadBalancerRule&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=deleteLoadBalancerRule&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -114,13 +115,13 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
}
public void testListVirtualMachinesAssignedToLoadBalancerRule() throws SecurityException, NoSuchMethodException,
IOException {
IOException {
Method method = LoadBalancerAsyncClient.class.getMethod("listVirtualMachinesAssignedToLoadBalancerRule",
long.class);
long.class);
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRuleInstances&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRuleInstances&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -28,11 +28,11 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.LoadBalancerRule.State;
import org.jclouds.cloudstack.domain.Network;
import org.jclouds.cloudstack.domain.PublicIPAddress;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm;
import org.jclouds.cloudstack.domain.LoadBalancerRule.State;
import org.jclouds.cloudstack.predicates.LoadBalancerRuleActive;
import org.jclouds.cloudstack.predicates.NetworkPredicates;
import org.jclouds.net.IPSocket;
@ -63,12 +63,12 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
super.setupClient();
loadBalancerRuleActive = new RetryablePredicate<LoadBalancerRule>(new LoadBalancerRuleActive(client), 60, 1, 1,
TimeUnit.SECONDS);
TimeUnit.SECONDS);
prefix += "rule";
try {
network = find(client.getNetworkClient().listNetworks(), NetworkPredicates.hasLoadBalancerService());
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, client, jobComplete,
virtualMachineRunning);
virtualMachineRunning);
if (vm.getPassword() != null)
password = vm.getPassword();
} catch (NoSuchElementException e) {
@ -83,7 +83,7 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
ip = reuseOrAssociate.apply(network);
try {
rule = client.getLoadBalancerClient().createLoadBalancerRuleForPublicIP(ip.getId(), Algorithm.LEASTCONN,
prefix, 22, 22);
prefix, 22, 22);
} catch (IllegalStateException e) {
// very likely an ip conflict, so retry;
}
@ -104,13 +104,14 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
if (networksDisabled)
return;
assert jobComplete.apply(client.getLoadBalancerClient().assignVirtualMachinesToLoadBalancerRule(rule.getId(),
vm.getId()));
vm.getId()));
assertEquals(client.getLoadBalancerClient().listVirtualMachinesAssignedToLoadBalancerRule(rule.getId()).size(), 1);
assert loadBalancerRuleActive.apply(rule) : rule;
loopAndCheckSSH();
}
// note that when in LB mode, there's a chance you'll have a connection failure
// note that when in LB mode, there's a chance you'll have a connection
// failure
private void loopAndCheckSSH() throws IOException {
for (int i = 0; i < 5; i++) {// retry loop TODO replace with predicate.
try {
@ -132,7 +133,7 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
if (networksDisabled)
throw new SshException();
assert jobComplete.apply(client.getLoadBalancerClient().removeVirtualMachinesFromLoadBalancerRule(rule.getId(),
vm.getId()));
vm.getId()));
assertEquals(client.getLoadBalancerClient().listVirtualMachinesAssignedToLoadBalancerRule(rule.getId()).size(), 0);
assertEquals(rule.getState(), State.ADD);
checkSSH(new IPSocket(ip.getIPAddress(), 22));

View File

@ -40,7 +40,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "NATAsyncClientTest")
public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncClient> {
public void testListIPForwardingRules() throws SecurityException, NoSuchMethodException, IOException {

View File

@ -61,7 +61,7 @@ public class NATClientLiveTest extends BaseCloudStackClientLiveTest {
try {
network = find(client.getNetworkClient().listNetworks(), NetworkPredicates.supportsStaticNAT());
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, client, jobComplete,
virtualMachineRunning);
virtualMachineRunning);
if (vm.getPassword() != null)
password = vm.getPassword();
} catch (NoSuchElementException e) {
@ -73,7 +73,7 @@ public class NATClientLiveTest extends BaseCloudStackClientLiveTest {
if (networksDisabled)
return;
for (ip = reuseOrAssociate.apply(network); (!ip.isStaticNAT() || ip.getVirtualMachineId() != vm.getId()); ip = reuseOrAssociate
.apply(network)) {
.apply(network)) {
// check to see if someone already grabbed this ip
if (ip.getVirtualMachineId() > 0 && ip.getVirtualMachineId() != vm.getId())
continue;
@ -130,7 +130,7 @@ public class NATClientLiveTest extends BaseCloudStackClientLiveTest {
assertTrue(response.size() >= 0);
for (IPForwardingRule rule : response) {
IPForwardingRule newDetails = getOnlyElement(client.getNATClient().listIPForwardingRules(
ListIPForwardingRulesOptions.Builder.id(rule.getId())));
ListIPForwardingRulesOptions.Builder.id(rule.getId())));
assertEquals(rule.getId(), newDetails.getId());
checkRule(rule);
}

View File

@ -41,7 +41,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "NetworkAsyncClientTest")
public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<NetworkAsyncClient> {
public void testListNetworks() throws SecurityException, NoSuchMethodException, IOException {
@ -49,7 +50,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listNetworks HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listNetworks HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -64,10 +65,10 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
public void testListNetworksOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, ListNetworksOptions.Builder.type(NetworkType.ADVANCED)
.domainId(6).id(5));
.domainId(6).id(5));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listNetworks&type=Advanced&domainid=6&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listNetworks&type=Advanced&domainid=6&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -84,7 +85,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
HttpRequest httpRequest = processor.createRequest(method, "id");
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listNetworks&id=id HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listNetworks&id=id HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -99,11 +100,12 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
public void testCreateNetworkInZone() throws SecurityException, NoSuchMethodException, IOException {
Method method = NetworkAsyncClient.class.getMethod("createNetworkInZone", long.class, long.class, String.class,
String.class, CreateNetworkOptions[].class);
String.class, CreateNetworkOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 1, 2, "named", "lovely");
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createNetwork&zoneid=1&name=named&networkofferingid=2&displaytext=lovely HTTP/1.1");
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createNetwork&zoneid=1&name=named&networkofferingid=2&displaytext=lovely HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -117,13 +119,14 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
public void testCreateNetworkInZoneOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = NetworkAsyncClient.class.getMethod("createNetworkInZone", long.class, long.class, String.class,
String.class, CreateNetworkOptions[].class);
String.class, CreateNetworkOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 1, 2, "named", "lovely", CreateNetworkOptions.Builder
.netmask("255.255.255.0").domainId(6));
.netmask("255.255.255.0").domainId(6));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createNetwork&zoneid=1&name=named&networkofferingid=2&displaytext=lovely&netmask=255.255.255.0&domainid=6 HTTP/1.1");
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createNetwork&zoneid=1&name=named&networkofferingid=2&displaytext=lovely&netmask=255.255.255.0&domainid=6 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -140,7 +143,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteNetwork&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=deleteNetwork&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -40,7 +40,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "ServiceOfferingAsyncClientTest")
public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<OfferingAsyncClient> {
public void testListDiskOfferings() throws SecurityException, NoSuchMethodException, IOException {

View File

@ -50,7 +50,7 @@ public class OfferingClientLiveTest extends BaseCloudStackClientLiveTest {
assertTrue(offeringCount >= 0);
for (DiskOffering offering : response) {
DiskOffering newDetails = Iterables.getOnlyElement(client.getOfferingClient().listDiskOfferings(
ListDiskOfferingsOptions.Builder.id(offering.getId())));
ListDiskOfferingsOptions.Builder.id(offering.getId())));
assertEquals(offering, newDetails);
assertEquals(offering, client.getOfferingClient().getDiskOffering(offering.getId()));
assert offering.getId() > 0 : offering;
@ -69,7 +69,7 @@ public class OfferingClientLiveTest extends BaseCloudStackClientLiveTest {
assertTrue(offeringCount >= 0);
for (ServiceOffering offering : response) {
ServiceOffering newDetails = Iterables.getOnlyElement(client.getOfferingClient().listServiceOfferings(
ListServiceOfferingsOptions.Builder.id(offering.getId())));
ListServiceOfferingsOptions.Builder.id(offering.getId())));
assertEquals(offering, newDetails);
assert offering.getId() > 0 : offering;
@ -91,7 +91,7 @@ public class OfferingClientLiveTest extends BaseCloudStackClientLiveTest {
assertTrue(offeringCount >= 0);
for (NetworkOffering offering : response) {
NetworkOffering newDetails = Iterables.getOnlyElement(client.getOfferingClient().listNetworkOfferings(
ListNetworkOfferingsOptions.Builder.id(offering.getId())));
ListNetworkOfferingsOptions.Builder.id(offering.getId())));
assertEquals(offering, newDetails);
assertEquals(offering, client.getOfferingClient().getNetworkOffering(offering.getId()));
assert offering.getId() > 0 : offering;

View File

@ -46,7 +46,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "SecurityGroupAsyncClientTest")
public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<SecurityGroupAsyncClient> {
@ -55,7 +56,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -70,11 +71,11 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testListSecurityGroupsOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, ListSecurityGroupsOptions.Builder.virtualMachineId(4)
.domainId(5).id(6));
.domainId(5).id(6));
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&virtualmachineid=4&domainid=5&id=6 HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&virtualmachineid=4&domainid=5&id=6 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -91,7 +92,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -109,7 +110,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
HttpRequest httpRequest = processor.createRequest(method, "goo");
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createSecurityGroup&name=goo HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=createSecurityGroup&name=goo HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -123,13 +124,13 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testAuthorizeIngressPortsToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToCIDRs", long.class,
String.class, int.class, int.class, Iterable.class, AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 2, "tcp", 22, 22, ImmutableSet.of("1.1.1.1/24",
"1.2.2.2/16"));
String.class, int.class, int.class, Iterable.class, AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 2, "tcp", 22, 22,
ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"));
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=authorizeSecurityGroupIngress&securitygroupid=2&startport=22&protocol=tcp&endport=22&cidrlist=1.1.1.1%2F24%2C1.2.2.2%2F16 HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=authorizeSecurityGroupIngress&securitygroupid=2&startport=22&protocol=tcp&endport=22&cidrlist=1.1.1.1%2F24%2C1.2.2.2%2F16 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -143,13 +144,13 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testAuthorizeIngressPortsToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToSecurityGroups", long.class,
String.class, int.class, int.class, Multimap.class, AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 2, "tcp", 22, 22, ImmutableMultimap.of("adrian",
"group1", "adrian", "group2", "bob", "group1"));
String.class, int.class, int.class, Multimap.class, AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 2, "tcp", 22, 22,
ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1"));
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=authorizeSecurityGroupIngress&securitygroupid=2&startport=22&protocol=tcp&endport=22&usersecuritygrouplist%5B0%5D.account=adrian&usersecuritygrouplist%5B0%5D.group=group1&usersecuritygrouplist%5B1%5D.account=adrian&usersecuritygrouplist%5B1%5D.group=group2&usersecuritygrouplist%5B2%5D.account=bob&usersecuritygrouplist%5B2%5D.group=group1 HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=authorizeSecurityGroupIngress&securitygroupid=2&startport=22&protocol=tcp&endport=22&usersecuritygrouplist%5B0%5D.account=adrian&usersecuritygrouplist%5B0%5D.group=group1&usersecuritygrouplist%5B1%5D.account=adrian&usersecuritygrouplist%5B1%5D.group=group2&usersecuritygrouplist%5B2%5D.account=bob&usersecuritygrouplist%5B2%5D.group=group1 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -163,12 +164,12 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testAuthorizeIngressICMPToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToCIDRs", long.class, int.class,
int.class, Iterable.class, AccountInDomainOptions[].class);
int.class, Iterable.class, AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 2, 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"));
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=authorizeSecurityGroupIngress&protocol=ICMP&securitygroupid=2&icmptype=22&icmpcode=22&cidrlist=1.1.1.1%2F24%2C1.2.2.2%2F16 HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=authorizeSecurityGroupIngress&protocol=ICMP&securitygroupid=2&icmptype=22&icmpcode=22&cidrlist=1.1.1.1%2F24%2C1.2.2.2%2F16 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -182,13 +183,13 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testAuthorizeIngressICMPToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToSecurityGroups", long.class,
int.class, int.class, Multimap.class, AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 2, 22, 22, ImmutableMultimap.of("adrian", "group1",
"adrian", "group2", "bob", "group1"));
int.class, int.class, Multimap.class, AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 2, 22, 22,
ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1"));
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=authorizeSecurityGroupIngress&protocol=ICMP&securitygroupid=2&icmptype=22&icmpcode=22&usersecuritygrouplist%5B0%5D.account=adrian&usersecuritygrouplist%5B0%5D.group=group1&usersecuritygrouplist%5B1%5D.account=adrian&usersecuritygrouplist%5B1%5D.group=group2&usersecuritygrouplist%5B2%5D.account=bob&usersecuritygrouplist%5B2%5D.group=group1 HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=authorizeSecurityGroupIngress&protocol=ICMP&securitygroupid=2&icmptype=22&icmpcode=22&usersecuritygrouplist%5B0%5D.account=adrian&usersecuritygrouplist%5B0%5D.group=group1&usersecuritygrouplist%5B1%5D.account=adrian&usersecuritygrouplist%5B1%5D.group=group2&usersecuritygrouplist%5B2%5D.account=bob&usersecuritygrouplist%5B2%5D.group=group1 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -202,12 +203,13 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testRevokeIngressRule() throws SecurityException, NoSuchMethodException, IOException {
Method method = SecurityGroupAsyncClient.class.getMethod("revokeIngressRule", long.class,
AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 5, AccountInDomainOptions.Builder.accountInDomain(
"adrian", 1));
AccountInDomainOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 5,
AccountInDomainOptions.Builder.accountInDomain("adrian", 1));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=revokeSecurityGroupIngress&id=5&account=adrian&domainid=1 HTTP/1.1");
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=revokeSecurityGroupIngress&id=5&account=adrian&domainid=1 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -224,7 +226,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteSecurityGroup&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=deleteSecurityGroup&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -39,7 +39,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "TemplateAsyncClientTest")
public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<TemplateAsyncClient> {
public void testListTemplates() throws SecurityException, NoSuchMethodException, IOException {
@ -47,7 +48,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listTemplates&templatefilter=executable HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listTemplates&templatefilter=executable HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -61,12 +62,15 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testListTemplatesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = TemplateAsyncClient.class.getMethod("listTemplates", ListTemplatesOptions.class);
HttpRequest httpRequest = processor.createRequest(method, ListTemplatesOptions.Builder.accountInDomain("adrian",
6).hypervisor("xen").filter(TemplateFilter.FEATURED));
HttpRequest httpRequest = processor
.createRequest(
method,
ListTemplatesOptions.Builder.accountInDomain("adrian", 6).hypervisor("xen")
.filter(TemplateFilter.FEATURED));
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listTemplates&account=adrian&domainid=6&hypervisor=xen&templatefilter=featured HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listTemplates&account=adrian&domainid=6&hypervisor=xen&templatefilter=featured HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -82,8 +86,9 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
Method method = TemplateAsyncClient.class.getMethod("getTemplateInZone", long.class, long.class);
HttpRequest httpRequest = processor.createRequest(method, 1, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listTemplates&templatefilter=executable&zoneid=1&id=5 HTTP/1.1");
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listTemplates&templatefilter=executable&zoneid=1&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -18,13 +18,13 @@
*/
package org.jclouds.cloudstack.features;
import static org.jclouds.cloudstack.options.ListTemplatesOptions.Builder.zoneId;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.Set;
import org.jclouds.cloudstack.domain.Template;
import static org.jclouds.cloudstack.options.ListTemplatesOptions.Builder.zoneId;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
@ -44,7 +44,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
assertTrue(templateCount >= 0);
for (Template template : response) {
Template newDetails = Iterables.getOnlyElement(client.getTemplateClient().listTemplates(
zoneId(template.getZoneId()).id(template.getId())));
zoneId(template.getZoneId()).id(template.getId())));
assertEquals(template, newDetails);
assertEquals(template, client.getTemplateClient().getTemplateInZone(template.getZoneId(), template.getId()));
assert template.getId() > 0 : template;

View File

@ -42,16 +42,17 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "VirtualMachineAsyncClientTest")
public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest<VirtualMachineAsyncClient> {
public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException {
Method method = VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
ListVirtualMachinesOptions[].class);
ListVirtualMachinesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -65,13 +66,13 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testListVirtualMachinesOptions() throws SecurityException, NoSuchMethodException, IOException {
Method method = VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
ListVirtualMachinesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, ListVirtualMachinesOptions.Builder.accountInDomain(
"adrian", 6).usesVirtualNetwork(true));
ListVirtualMachinesOptions[].class);
HttpRequest httpRequest = processor.createRequest(method,
ListVirtualMachinesOptions.Builder.accountInDomain("adrian", 6).usesVirtualNetwork(true));
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&account=adrian&domainid=6&forvirtualnetwork=true HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&account=adrian&domainid=6&forvirtualnetwork=true HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -88,7 +89,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -103,12 +104,12 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testDeployVirtualMachineInZone() throws SecurityException, NoSuchMethodException, IOException {
Method method = VirtualMachineAsyncClient.class.getMethod("deployVirtualMachineInZone", long.class, long.class,
long.class, DeployVirtualMachineOptions[].class);
long.class, DeployVirtualMachineOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, 6, 4, 5);
assertRequestLineEquals(
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deployVirtualMachine&zoneid=6&templateid=5&serviceofferingid=4 HTTP/1.1");
httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deployVirtualMachine&zoneid=6&templateid=5&serviceofferingid=4 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -125,7 +126,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=rebootVirtualMachine&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=rebootVirtualMachine&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -142,7 +143,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=startVirtualMachine&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=startVirtualMachine&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -159,7 +160,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=stopVirtualMachine&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=stopVirtualMachine&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -176,7 +177,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=resetPasswordForVirtualMachine&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=resetPasswordForVirtualMachine&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -193,7 +194,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=changeServiceForVirtualMachine&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=changeServiceForVirtualMachine&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -210,7 +211,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=updateVirtualMachine&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=updateVirtualMachine&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);
@ -227,7 +228,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
HttpRequest httpRequest = processor.createRequest(method, 5);
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=destroyVirtualMachine&id=5 HTTP/1.1");
"GET http://localhost:8080/client/api?response=json&command=destroyVirtualMachine&id=5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
assertPayloadEquals(httpRequest, null, null, false);

View File

@ -39,7 +39,8 @@ import com.google.inject.TypeLiteral;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "ZoneAsyncClientTest")
public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsyncClient> {
public void testListZones() throws SecurityException, NoSuchMethodException, IOException {

View File

@ -27,11 +27,11 @@ import java.util.Map;
import org.jclouds.PropertiesBuilder;
import org.jclouds.http.HttpRequest;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.jclouds.rest.RequestSigner;
import org.jclouds.rest.RestContextBuilder;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
@ -43,55 +43,57 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "QuerySignerTest")
public class QuerySignerTest {
@SuppressWarnings({ "unchecked", "rawtypes" })
public static final RestContextSpec<Map, List> DUMMY_SPEC = new RestContextSpec<Map, List>("cloudstack",
"http://localhost:8080/client/api", "2.2", "", "apiKey", "secretKey", Map.class, List.class,
PropertiesBuilder.class, (Class) RestContextBuilder.class, ImmutableList.<Module> of(new MockModule(),
new NullLoggingModule(), new AbstractModule() {
@Override
protected void configure() {
bind(RequestSigner.class).to(QuerySigner.class);
}
"http://localhost:8080/client/api", "2.2", "", "apiKey", "secretKey", Map.class, List.class,
PropertiesBuilder.class, (Class) RestContextBuilder.class, ImmutableList.<Module> of(new MockModule(),
new NullLoggingModule(), new AbstractModule() {
@Override
protected void configure() {
bind(RequestSigner.class).to(QuerySigner.class);
}
}));
}));
@Test
void testCreateStringToSign() {
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector().getInstance(
QuerySigner.class);
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector()
.getInstance(QuerySigner.class);
assertEquals(filter.createStringToSign(HttpRequest.builder().method("GET").endpoint(
URI.create("http://localhost:8080/client/api?command=listZones")).build()),
"apikey=apikey&command=listzones");
assertEquals(
filter.createStringToSign(HttpRequest.builder().method("GET")
.endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build()),
"apikey=apikey&command=listzones");
}
@Test
void testFilter() {
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector().getInstance(
QuerySigner.class);
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector()
.getInstance(QuerySigner.class);
assertEquals(
filter.filter(
HttpRequest.builder().method("GET").endpoint(
URI.create("http://localhost:8080/client/api?command=listZones")).build())
.getRequestLine(),
"GET http://localhost:8080/client/api?command=listZones&apiKey=apiKey&signature=2UG8AcnMaozL3BINdjgkJ%2BRzjEY%3D HTTP/1.1");
filter.filter(
HttpRequest.builder().method("GET")
.endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build())
.getRequestLine(),
"GET http://localhost:8080/client/api?command=listZones&apiKey=apiKey&signature=2UG8AcnMaozL3BINdjgkJ%2BRzjEY%3D HTTP/1.1");
}
@Test
void testFilterTwice() {
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector().getInstance(
QuerySigner.class);
HttpRequest request = HttpRequest.builder().method("GET").endpoint(
URI.create("http://localhost:8080/client/api?command=listZones")).build();
QuerySigner filter = RestContextFactory.createContextBuilder(DUMMY_SPEC).buildInjector()
.getInstance(QuerySigner.class);
HttpRequest request = HttpRequest.builder().method("GET")
.endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build();
for (int i = 0; i < 2; i++) {
request = filter.filter(request);
assertEquals(
request.getRequestLine(),
"GET http://localhost:8080/client/api?command=listZones&apiKey=apiKey&signature=2UG8AcnMaozL3BINdjgkJ%2BRzjEY%3D HTTP/1.1");
request.getRequestLine(),
"GET http://localhost:8080/client/api?command=listZones&apiKey=apiKey&signature=2UG8AcnMaozL3BINdjgkJ%2BRzjEY%3D HTTP/1.1");
}
}
}

View File

@ -58,12 +58,12 @@ public class ParseAsyncJobFromHttpResponseTest {
String input = "{ \"queryasyncjobresultresponse\" : {\"jobid\":860,\"jobstatus\":0,\"jobprocstatus\":0,\"jobresultcode\":0} }";
AsyncJob<PublicIPAddress> expects = AsyncJob.<PublicIPAddress> builder().id(860).status(0).progress(0)
.resultCode(0).build();
.resultCode(0).build();
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
@SuppressWarnings("unchecked")
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
Payloads.newStringPayload(input)));
Payloads.newStringPayload(input)));
assertEquals(response, expects);
}
@ -72,12 +72,12 @@ public class ParseAsyncJobFromHttpResponseTest {
String input = "{ \"queryasyncjobresultresponse\" : {\"jobid\":1138,\"jobstatus\":1,\"jobprocstatus\":0,\"jobresultcode\":0,\"jobresulttype\":\"object\",\"jobresult\":{\"success\":true}} }";
AsyncJob<PublicIPAddress> expects = AsyncJob.<PublicIPAddress> builder().id(1138).status(1).progress(0)
.resultType("object").resultCode(0).build();
.resultType("object").resultCode(0).build();
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
@SuppressWarnings("unchecked")
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
Payloads.newStringPayload(input)));
Payloads.newStringPayload(input)));
assertEquals(response, expects);
}
@ -85,16 +85,19 @@ public class ParseAsyncJobFromHttpResponseTest {
public void testWithErrorSetsResultNullSoToAvoidClassCastExceptions() {
String input = "{ \"queryasyncjobresultresponse\" : {\"jobid\":1103,\"jobstatus\":2,\"jobprocstatus\":0,\"jobresultcode\":530,\"jobresulttype\":\"object\",\"jobresult\":{\"errorcode\":530,\"errortext\":\"Internal error executing command, please contact your system administrator\"}} }";
AsyncJob<PublicIPAddress> expects = AsyncJob.<PublicIPAddress> builder().id(1103).status(2).progress(0)
.resultType("object").error(
new AsyncJobError(530,
"Internal error executing command, please contact your system administrator"))
.resultCode(530).build();
AsyncJob<PublicIPAddress> expects = AsyncJob
.<PublicIPAddress> builder()
.id(1103)
.status(2)
.progress(0)
.resultType("object")
.error(new AsyncJobError(530, "Internal error executing command, please contact your system administrator"))
.resultCode(530).build();
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
@SuppressWarnings("unchecked")
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
Payloads.newStringPayload(input)));
Payloads.newStringPayload(input)));
assertEquals(response, expects);
}
@ -103,66 +106,83 @@ public class ParseAsyncJobFromHttpResponseTest {
String input = "{ \"queryasyncjobresultresponse\" : {\"jobid\":860,\"jobstatus\":0,\"jobprocstatus\":0,\"jobresultcode\":0,\"jobresult\":{\"foo\":{\"bar\":1}}}}";
AsyncJob<?> expects = AsyncJob.builder().id(860).status(0).progress(0).resultCode(0).result("{\"bar\":1}")
.build();
.build();
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
@SuppressWarnings("unchecked")
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
Payloads.newStringPayload(input)));
Payloads.newStringPayload(input)));
assertEquals(response, expects);
}
public void testWithBadResultReturnsMap() {
// Not the best result object, but this is an unexpected error case. Cloud.com have verified
// that this case will not happen. This code is only here to prevent exceptions from being
// Not the best result object, but this is an unexpected error case.
// Cloud.com have verified
// that this case will not happen. This code is only here to prevent
// exceptions from being
// thrown in case they change their minds.
String input = "{ \"queryasyncjobresultresponse\" : {\"jobid\":860,\"jobstatus\":0,\"jobprocstatus\":0,\"jobresultcode\":0,\"jobresult\":{\"foo\":{\"bar\":1},\"foo2\":{\"bar2\":2}}}}";
AsyncJob<?> expects = AsyncJob.builder().id(860).status(0).progress(0).resultCode(0).result(
ImmutableMap.of("foo", new JsonBall("{\"bar\":1}"), "foo2", new JsonBall("{\"bar2\":2}"))).build();
AsyncJob<?> expects = AsyncJob.builder().id(860).status(0).progress(0).resultCode(0)
.result(ImmutableMap.of("foo", new JsonBall("{\"bar\":1}"), "foo2", new JsonBall("{\"bar2\":2}"))).build();
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
@SuppressWarnings("unchecked")
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
Payloads.newStringPayload(input)));
Payloads.newStringPayload(input)));
assertEquals(response, expects);
}
public void testPublicIPAddress() {
InputStream is = getClass().getResourceAsStream("/queryasyncjobresultresponse-ipaddress.json");
AsyncJob<PublicIPAddress> expects = AsyncJob.<PublicIPAddress> builder().id(860).status(1).progress(0)
.resultType("object").resultCode(0).result(
PublicIPAddress.builder().id(6).IPAddress("72.52.126.35").allocated(
new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-23T20:15:01-0800"))
.zoneId(1).zoneName("San Jose 1").isSourceNAT(false).account("adrian").domainId(1)
.domain("ROOT").usesVirtualNetwork(true).isStaticNAT(false).associatedNetworkId(204)
.networkId(200).state(PublicIPAddress.State.ALLOCATING).build()
AsyncJob<PublicIPAddress> expects = AsyncJob
.<PublicIPAddress> builder()
.id(860)
.status(1)
.progress(0)
.resultType("object")
.resultCode(0)
.result(
PublicIPAddress
.builder()
.id(6)
.IPAddress("72.52.126.35")
.allocated(
new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-02-23T20:15:01-0800"))
.zoneId(1).zoneName("San Jose 1").isSourceNAT(false).account("adrian").domainId(1)
.domain("ROOT").usesVirtualNetwork(true).isStaticNAT(false).associatedNetworkId(204)
.networkId(200).state(PublicIPAddress.State.ALLOCATING).build()
).build();
).build();
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
@SuppressWarnings("unchecked")
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
Payloads.newInputStreamPayload(is)));
Payloads.newInputStreamPayload(is)));
assertEquals(response, expects);
}
public void testIPForwardingRule() {
InputStream is = getClass().getResourceAsStream("/queryasyncjobresultresponse-ipforwardingrule.json");
AsyncJob<IPForwardingRule> expects = AsyncJob.<IPForwardingRule> builder().id(1133).status(1).progress(0)
.resultType("object").resultCode(0).result(
IPForwardingRule.builder().id(109).protocol("tcp").virtualMachineId(226).virtualMachineName(
"i-3-226-VM").IPAddressId(36).IPAddress("72.52.126.65").startPort(22).endPort(22)
.state("Active").build()
).build();
AsyncJob<IPForwardingRule> expects = AsyncJob
.<IPForwardingRule> builder()
.id(1133)
.status(1)
.progress(0)
.resultType("object")
.resultCode(0)
.result(
IPForwardingRule.builder().id(109).protocol("tcp").virtualMachineId(226)
.virtualMachineName("i-3-226-VM").IPAddressId(36).IPAddress("72.52.126.65").startPort(22)
.endPort(22).state("Active").build()).build();
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
@SuppressWarnings("unchecked")
AsyncJob<IPForwardingRule> response = (AsyncJob<IPForwardingRule>) parser.apply(new HttpResponse(200, "ok",
Payloads.newInputStreamPayload(is)));
Payloads.newInputStreamPayload(is)));
assertEquals(response, expects);
}

View File

@ -48,7 +48,7 @@ public class ReuseOrAssociateNewPublicIPAddressTest {
long zoneId = 100l;
// note that it is associated network, not networkId
PublicIPAddress address = PublicIPAddress.builder().id(200).state(PublicIPAddress.State.ALLOCATED)
.associatedNetworkId(networkId).zoneId(zoneId).build();
.associatedNetworkId(networkId).zoneId(zoneId).build();
public void testReuseWorks() throws SecurityException, NoSuchMethodException {
@ -60,15 +60,16 @@ public class ReuseOrAssociateNewPublicIPAddressTest {
// an address is available
expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
ImmutableSet.<PublicIPAddress> of(address));
ImmutableSet.<PublicIPAddress> of(address));
// replay mocks
replay(client);
replay(addressClient);
// run
assertEquals(new ReuseOrAssociateNewPublicIPAddress(client, jobComplete).apply(Network.builder().id(networkId)
.zoneId(zoneId).build()), address);
assertEquals(
new ReuseOrAssociateNewPublicIPAddress(client, jobComplete).apply(Network.builder().id(networkId)
.zoneId(zoneId).build()), address);
// verify mocks
verify(client);
@ -88,7 +89,7 @@ public class ReuseOrAssociateNewPublicIPAddressTest {
// no ip addresses available
expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
ImmutableSet.<PublicIPAddress> of());
ImmutableSet.<PublicIPAddress> of());
AsyncCreateResponse job = new AsyncCreateResponse(1, 2);
// make sure we created the job relating to a new ip
@ -105,8 +106,9 @@ public class ReuseOrAssociateNewPublicIPAddressTest {
replay(jobClient);
// run
assertEquals(new ReuseOrAssociateNewPublicIPAddress(client, jobComplete).apply(Network.builder().id(networkId)
.zoneId(zoneId).build()), address);
assertEquals(
new ReuseOrAssociateNewPublicIPAddress(client, jobComplete).apply(Network.builder().id(networkId)
.zoneId(zoneId).build()), address);
// verify mocks
verify(client);
@ -128,13 +130,14 @@ public class ReuseOrAssociateNewPublicIPAddressTest {
// no ip addresses available
expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
ImmutableSet.<PublicIPAddress> of());
ImmutableSet.<PublicIPAddress> of());
AsyncCreateResponse job = new AsyncCreateResponse(1, 2);
// make sure we created the job relating to a new ip
expect(addressClient.associateIPAddressInZone(zoneId, networkId(networkId))).andReturn(job);
// the alwaysfalse predicate above should blow up with IllegalStateException
// the alwaysfalse predicate above should blow up with
// IllegalStateException
// replay mocks
replay(client);
@ -142,7 +145,7 @@ public class ReuseOrAssociateNewPublicIPAddressTest {
// run
new ReuseOrAssociateNewPublicIPAddress(client, jobComplete).apply(Network.builder().id(networkId).zoneId(zoneId)
.build());
.build());
// verify mocks
verify(client);

View File

@ -58,7 +58,6 @@ public class ListAsyncJobsOptionsTest {
assertEquals(ImmutableList.of("6"), options.buildQueryParameters().get("domainid"));
}
public void testStartDateStatic() {
ListAsyncJobsOptions options = startDate(new Date(100000));
assertEquals(ImmutableList.of("1970-01-01T00:01:40Z"), options.buildQueryParameters().get("startdate"));

View File

@ -18,10 +18,10 @@
*/
package org.jclouds.cloudstack.options;
import static org.jclouds.cloudstack.options.ListIPForwardingRulesOptions.Builder.IPAddressId;
import static org.jclouds.cloudstack.options.ListIPForwardingRulesOptions.Builder.accountInDomain;
import static org.jclouds.cloudstack.options.ListIPForwardingRulesOptions.Builder.domainId;
import static org.jclouds.cloudstack.options.ListIPForwardingRulesOptions.Builder.id;
import static org.jclouds.cloudstack.options.ListIPForwardingRulesOptions.Builder.IPAddressId;
import static org.jclouds.cloudstack.options.ListIPForwardingRulesOptions.Builder.virtualMachineId;
import static org.testng.Assert.assertEquals;

View File

@ -18,13 +18,13 @@
*/
package org.jclouds.cloudstack.options;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.accountInDomain;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.domainId;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.IPAddress;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.VLANId;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.accountInDomain;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.allocatedOnly;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.domainId;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.id;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.networkId;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.VLANId;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.usesVirtualNetwork;
import static org.jclouds.cloudstack.options.ListPublicIPAddressesOptions.Builder.zoneId;
import static org.testng.Assert.assertEquals;

View File

@ -41,7 +41,7 @@ import com.google.inject.Injector;
*/
@Test(groups = "unit")
public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
@Override
protected Injector injector() {
return Guice.createInjector(new CloudStackParserModule(), new GsonModule() {
@ -93,20 +93,11 @@ public class ListAccountsResponseTest extends BaseSetParserTest<Account> {
.VMsRunning(1)
.state(State.ENABLED)
.users(
ImmutableSet.of(User.builder()
.id(505)
.name("jclouds")
.firstName("Adrian")
.lastName("Cole")
.email("adrian@jclouds.org")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-19T01:57:24+0000"))
.state("enabled")
.account("jclouds")
.accountType(Type.USER)
.domainId(457)
.domain("AA000062-jclouds-dev")
.apiKey("APIKEY")
.secretKey("SECRETKEY").build())).build());
ImmutableSet.of(User.builder().id(505).name("jclouds").firstName("Adrian").lastName("Cole")
.email("adrian@jclouds.org")
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-19T01:57:24+0000"))
.state("enabled").account("jclouds").accountType(Type.USER).domainId(457)
.domain("AA000062-jclouds-dev").apiKey("APIKEY").secretKey("SECRETKEY").build())).build());
}
}

View File

@ -43,9 +43,9 @@ public class ListOSCategoriesResponseTest extends BaseItemParserTest<Map<Long, S
@Override
public Map<Long, String> expected() {
return ImmutableMap.<Long, String> builder().put(1l, "CentOS").put(2l, "Debian").put(3l, "Oracle").put(4l,
"RedHat").put(5l, "SUSE").put(6l, "Windows").put(7l, "Other").put(8l, "Novel").put(9l, "Unix").put(10l,
"Ubuntu").build();
return ImmutableMap.<Long, String> builder().put(1l, "CentOS").put(2l, "Debian").put(3l, "Oracle")
.put(4l, "RedHat").put(5l, "SUSE").put(6l, "Windows").put(7l, "Other").put(8l, "Novel").put(9l, "Unix")
.put(10l, "Ubuntu").build();
}
@Override

View File

@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableSet;
*/
@Test(groups = "unit")
public class ListOSTypesResponseTest extends BaseSetParserTest<OSType> {
@Override
public String resource() {
return "/listostypesresponse.json";
@ -42,189 +42,157 @@ public class ListOSTypesResponseTest extends BaseSetParserTest<OSType> {
@Override
@SelectJson("ostype")
public Set<OSType> expected() {
return ImmutableSet.<OSType> builder().add(
OSType.builder().id(69).OSCategoryId(7).description("Asianux 3(32-bit)").build()).add(
OSType.builder().id(70).OSCategoryId(7).description("Asianux 3(64-bit)").build()).add(
OSType.builder().id(1).OSCategoryId(1).description("CentOS 4.5 (32-bit)").build()).add(
OSType.builder().id(2).OSCategoryId(1).description("CentOS 4.6 (32-bit)").build()).add(
OSType.builder().id(3).OSCategoryId(1).description("CentOS 4.7 (32-bit)").build()).add(
OSType.builder().id(4).OSCategoryId(1).description("CentOS 4.8 (32-bit)").build()).add(
OSType.builder().id(5).OSCategoryId(1).description("CentOS 5.0 (32-bit)").build()).add(
OSType.builder().id(6).OSCategoryId(1).description("CentOS 5.0 (64-bit)").build()).add(
OSType.builder().id(7).OSCategoryId(1).description("CentOS 5.1 (32-bit)").build()).add(
OSType.builder().id(8).OSCategoryId(1).description("CentOS 5.1 (64-bit)").build()).add(
OSType.builder().id(9).OSCategoryId(1).description("CentOS 5.2 (32-bit)").build()).add(
OSType.builder().id(10).OSCategoryId(1).description("CentOS 5.2 (64-bit)").build()).add(
OSType.builder().id(11).OSCategoryId(1).description("CentOS 5.3 (32-bit)").build()).add(
OSType.builder().id(12).OSCategoryId(1).description("CentOS 5.3 (64-bit)").build()).add(
OSType.builder().id(13).OSCategoryId(1).description("CentOS 5.4 (32-bit)").build()).add(
OSType.builder().id(14).OSCategoryId(1).description("CentOS 5.4 (64-bit)").build()).add(
OSType.builder().id(111).OSCategoryId(1).description("CentOS 5.5 (32-bit)").build()).add(
OSType.builder().id(112).OSCategoryId(1).description("CentOS 5.5 (64-bit)").build()).add(
OSType.builder().id(73).OSCategoryId(2).description("Debian GNU/Linux 4(32-bit)").build()).add(
OSType.builder().id(74).OSCategoryId(2).description("Debian GNU/Linux 4(64-bit)").build()).add(
OSType.builder().id(72).OSCategoryId(2).description("Debian GNU/Linux 5(64-bit)").build()).add(
OSType.builder().id(15).OSCategoryId(2).description("Debian GNU/Linux 5.0 (32-bit)").build()).add(
OSType.builder().id(132).OSCategoryId(2).description("Debian GNU/Linux 6(32-bit)").build()).add(
OSType.builder().id(133).OSCategoryId(2).description("Debian GNU/Linux 6(64-bit)").build()).add(
OSType.builder().id(102).OSCategoryId(6).description("DOS").build()).add(
OSType.builder().id(118).OSCategoryId(4).description("Fedora 10").build()).add(
OSType.builder().id(117).OSCategoryId(4).description("Fedora 11").build()).add(
OSType.builder().id(116).OSCategoryId(4).description("Fedora 12").build()).add(
OSType.builder().id(115).OSCategoryId(4).description("Fedora 13").build()).add(
OSType.builder().id(120).OSCategoryId(4).description("Fedora 8").build()).add(
OSType.builder().id(119).OSCategoryId(4).description("Fedora 9").build()).add(
OSType.builder().id(83).OSCategoryId(9).description("FreeBSD (32-bit)").build()).add(
OSType.builder().id(84).OSCategoryId(9).description("FreeBSD (64-bit)").build()).add(
OSType.builder().id(92).OSCategoryId(6).description("Microsoft Small Bussiness Server 2003").build())
.add(OSType.builder().id(78).OSCategoryId(8).description("Novell Netware 5.1").build()).add(
OSType.builder().id(77).OSCategoryId(8).description("Novell Netware 6.x").build()).add(
OSType.builder().id(68).OSCategoryId(7).description("Open Enterprise Server").build()).add(
OSType.builder().id(16).OSCategoryId(3).description("Oracle Enterprise Linux 5.0 (32-bit)")
.build()).add(
OSType.builder().id(17).OSCategoryId(3).description("Oracle Enterprise Linux 5.0 (64-bit)")
.build()).add(
OSType.builder().id(18).OSCategoryId(3).description("Oracle Enterprise Linux 5.1 (32-bit)")
.build()).add(
OSType.builder().id(19).OSCategoryId(3).description("Oracle Enterprise Linux 5.1 (64-bit)")
.build()).add(
OSType.builder().id(20).OSCategoryId(3).description("Oracle Enterprise Linux 5.2 (32-bit)")
.build()).add(
OSType.builder().id(21).OSCategoryId(3).description("Oracle Enterprise Linux 5.2 (64-bit)")
.build()).add(
OSType.builder().id(22).OSCategoryId(3).description("Oracle Enterprise Linux 5.3 (32-bit)")
.build()).add(
OSType.builder().id(23).OSCategoryId(3).description("Oracle Enterprise Linux 5.3 (64-bit)")
.build()).add(
OSType.builder().id(24).OSCategoryId(3).description("Oracle Enterprise Linux 5.4 (32-bit)")
.build()).add(
OSType.builder().id(25).OSCategoryId(3).description("Oracle Enterprise Linux 5.4 (64-bit)")
.build()).add(
OSType.builder().id(134).OSCategoryId(3).description("Oracle Enterprise Linux 5.5 (32-bit)")
.build()).add(
OSType.builder().id(135).OSCategoryId(3).description("Oracle Enterprise Linux 5.5 (64-bit)")
.build()).add(OSType.builder().id(104).OSCategoryId(7).description("OS/2").build())
.add(OSType.builder().id(60).OSCategoryId(7).description("Other (32-bit)").build()).add(
OSType.builder().id(103).OSCategoryId(7).description("Other (64-bit)").build()).add(
OSType.builder().id(75).OSCategoryId(7).description("Other 2.6x Linux (32-bit)").build()).add(
OSType.builder().id(76).OSCategoryId(7).description("Other 2.6x Linux (64-bit)").build()).add(
OSType.builder().id(98).OSCategoryId(7).description("Other Linux (32-bit)").build()).add(
OSType.builder().id(99).OSCategoryId(7).description("Other Linux (64-bit)").build()).add(
OSType.builder().id(59).OSCategoryId(10).description("Other Ubuntu (32-bit)").build()).add(
OSType.builder().id(100).OSCategoryId(10).description("Other Ubuntu (64-bit)").build()).add(
OSType.builder().id(131).OSCategoryId(10).description("Red Hat Enterprise Linux 2").build())
.add(OSType.builder().id(66).OSCategoryId(4).description("Red Hat Enterprise Linux 3(32-bit)").build())
.add(OSType.builder().id(67).OSCategoryId(4).description("Red Hat Enterprise Linux 3(64-bit)").build())
.add(OSType.builder().id(106).OSCategoryId(4).description("Red Hat Enterprise Linux 4(64-bit)").build())
.add(
OSType.builder().id(26).OSCategoryId(4).description("Red Hat Enterprise Linux 4.5 (32-bit)")
.build()).add(
OSType.builder().id(27).OSCategoryId(4).description("Red Hat Enterprise Linux 4.6 (32-bit)")
.build()).add(
OSType.builder().id(28).OSCategoryId(4).description("Red Hat Enterprise Linux 4.7 (32-bit)")
.build()).add(
OSType.builder().id(29).OSCategoryId(4).description("Red Hat Enterprise Linux 4.8 (32-bit)")
.build()).add(
OSType.builder().id(30).OSCategoryId(4).description("Red Hat Enterprise Linux 5.0 (32-bit)")
.build()).add(
OSType.builder().id(31).OSCategoryId(4).description("Red Hat Enterprise Linux 5.0 (64-bit)")
.build()).add(
OSType.builder().id(32).OSCategoryId(4).description("Red Hat Enterprise Linux 5.1 (32-bit)")
.build()).add(
OSType.builder().id(33).OSCategoryId(4).description("Red Hat Enterprise Linux 5.1 (64-bit)")
.build()).add(
OSType.builder().id(34).OSCategoryId(4).description("Red Hat Enterprise Linux 5.2 (32-bit)")
.build()).add(
OSType.builder().id(35).OSCategoryId(4).description("Red Hat Enterprise Linux 5.2 (64-bit)")
.build()).add(
OSType.builder().id(36).OSCategoryId(4).description("Red Hat Enterprise Linux 5.3 (32-bit)")
.build()).add(
OSType.builder().id(37).OSCategoryId(4).description("Red Hat Enterprise Linux 5.3 (64-bit)")
.build()).add(
OSType.builder().id(38).OSCategoryId(4).description("Red Hat Enterprise Linux 5.4 (32-bit)")
.build()).add(
OSType.builder().id(39).OSCategoryId(4).description("Red Hat Enterprise Linux 5.4 (64-bit)")
.build()).add(
OSType.builder().id(113).OSCategoryId(4).description("Red Hat Enterprise Linux 5.5 (32-bit)")
.build()).add(
OSType.builder().id(114).OSCategoryId(4).description("Red Hat Enterprise Linux 5.5 (64-bit)")
.build()).add(
OSType.builder().id(136).OSCategoryId(4).description("Red Hat Enterprise Linux 6.0 (32-bit)")
.build()).add(
OSType.builder().id(137).OSCategoryId(4).description("Red Hat Enterprise Linux 6.0 (64-bit)")
.build()).add(
OSType.builder().id(85).OSCategoryId(9).description("SCO OpenServer 5").build()).add(
OSType.builder().id(86).OSCategoryId(9).description("SCO UnixWare 7").build()).add(
OSType.builder().id(79).OSCategoryId(9).description("Sun Solaris 10(32-bit)").build()).add(
OSType.builder().id(80).OSCategoryId(9).description("Sun Solaris 10(64-bit)").build()).add(
OSType.builder().id(82).OSCategoryId(9).description("Sun Solaris 8(Experimental)").build())
.add(OSType.builder().id(81).OSCategoryId(9).description("Sun Solaris 9(Experimental)").build()).add(
OSType.builder().id(109).OSCategoryId(5).description("SUSE Linux Enterprise 10(32-bit)")
.build()).add(
OSType.builder().id(110).OSCategoryId(5).description("SUSE Linux Enterprise 10(64-bit)")
.build()).add(
OSType.builder().id(96).OSCategoryId(5).description("SUSE Linux Enterprise 8(32-bit)").build())
.add(OSType.builder().id(97).OSCategoryId(5).description("SUSE Linux Enterprise 8(64-bit)").build())
.add(OSType.builder().id(107).OSCategoryId(5).description("SUSE Linux Enterprise 9(32-bit)").build())
.add(OSType.builder().id(108).OSCategoryId(5).description("SUSE Linux Enterprise 9(64-bit)").build())
.add(
OSType.builder().id(41).OSCategoryId(5).description(
"SUSE Linux Enterprise Server 10 SP1 (32-bit)").build()).add(
OSType.builder().id(42).OSCategoryId(5).description(
"SUSE Linux Enterprise Server 10 SP1 (64-bit)").build()).add(
OSType.builder().id(43).OSCategoryId(5).description(
"SUSE Linux Enterprise Server 10 SP2 (32-bit)").build()).add(
OSType.builder().id(44).OSCategoryId(5).description(
"SUSE Linux Enterprise Server 10 SP2 (64-bit)").build()).add(
OSType.builder().id(45).OSCategoryId(5).description(
"SUSE Linux Enterprise Server 10 SP3 (64-bit)").build()).add(
OSType.builder().id(46).OSCategoryId(5).description("SUSE Linux Enterprise Server 11 (32-bit)")
.build()).add(
OSType.builder().id(47).OSCategoryId(5).description("SUSE Linux Enterprise Server 11 (64-bit)")
.build()).add(
OSType.builder().id(40).OSCategoryId(5).description(
"SUSE Linux Enterprise Server 9 SP4 (32-bit)").build()).add(
OSType.builder().id(121).OSCategoryId(10).description("Ubuntu 10.04 (32-bit)").build()).add(
OSType.builder().id(126).OSCategoryId(10).description("Ubuntu 10.04 (64-bit)").build()).add(
OSType.builder().id(125).OSCategoryId(10).description("Ubuntu 8.04 (32-bit)").build()).add(
OSType.builder().id(130).OSCategoryId(10).description("Ubuntu 8.04 (64-bit)").build()).add(
OSType.builder().id(124).OSCategoryId(10).description("Ubuntu 8.10 (32-bit)").build()).add(
OSType.builder().id(129).OSCategoryId(10).description("Ubuntu 8.10 (64-bit)").build()).add(
OSType.builder().id(123).OSCategoryId(10).description("Ubuntu 9.04 (32-bit)").build()).add(
OSType.builder().id(128).OSCategoryId(10).description("Ubuntu 9.04 (64-bit)").build()).add(
OSType.builder().id(122).OSCategoryId(10).description("Ubuntu 9.10 (32-bit)").build()).add(
OSType.builder().id(127).OSCategoryId(10).description("Ubuntu 9.10 (64-bit)").build()).add(
OSType.builder().id(95).OSCategoryId(6).description("Windows 2000 Advanced Server").build())
.add(OSType.builder().id(105).OSCategoryId(6).description("Windows 2000 Professional").build()).add(
OSType.builder().id(61).OSCategoryId(6).description("Windows 2000 Server").build())
.add(OSType.builder().id(55).OSCategoryId(6).description("Windows 2000 Server SP4 (32-bit)").build())
.add(OSType.builder().id(65).OSCategoryId(6).description("Windows 3.1").build()).add(
OSType.builder().id(48).OSCategoryId(6).description("Windows 7 (32-bit)").build()).add(
OSType.builder().id(49).OSCategoryId(6).description("Windows 7 (64-bit)").build()).add(
OSType.builder().id(63).OSCategoryId(6).description("Windows 95").build()).add(
OSType.builder().id(62).OSCategoryId(6).description("Windows 98").build()).add(
OSType.builder().id(64).OSCategoryId(6).description("Windows NT 4").build()).add(
OSType.builder().id(87).OSCategoryId(6).description(
"Windows Server 2003 DataCenter Edition(32-bit)").build()).add(
OSType.builder().id(88).OSCategoryId(6).description(
"Windows Server 2003 DataCenter Edition(64-bit)").build()).add(
OSType.builder().id(50).OSCategoryId(6).description(
"Windows Server 2003 Enterprise Edition(32-bit)").build()).add(
OSType.builder().id(51).OSCategoryId(6).description(
"Windows Server 2003 Enterprise Edition(64-bit)").build()).add(
OSType.builder().id(89).OSCategoryId(6).description(
"Windows Server 2003 Standard Edition(32-bit)").build()).add(
OSType.builder().id(90).OSCategoryId(6).description(
"Windows Server 2003 Standard Edition(64-bit)").build()).add(
OSType.builder().id(91).OSCategoryId(6).description("Windows Server 2003 Web Edition").build())
.add(OSType.builder().id(52).OSCategoryId(6).description("Windows Server 2008 (32-bit)").build()).add(
OSType.builder().id(53).OSCategoryId(6).description("Windows Server 2008 (64-bit)").build())
.add(OSType.builder().id(54).OSCategoryId(6).description("Windows Server 2008 R2 (64-bit)").build())
.add(OSType.builder().id(56).OSCategoryId(6).description("Windows Vista (32-bit)").build()).add(
OSType.builder().id(101).OSCategoryId(6).description("Windows Vista (64-bit)").build()).add(
OSType.builder().id(93).OSCategoryId(6).description("Windows XP (32-bit)").build()).add(
OSType.builder().id(94).OSCategoryId(6).description("Windows XP (64-bit)").build()).add(
OSType.builder().id(57).OSCategoryId(6).description("Windows XP SP2 (32-bit)").build()).add(
OSType.builder().id(58).OSCategoryId(6).description("Windows XP SP3 (32-bit)").build()).build();
return ImmutableSet
.<OSType> builder()
.add(OSType.builder().id(69).OSCategoryId(7).description("Asianux 3(32-bit)").build())
.add(OSType.builder().id(70).OSCategoryId(7).description("Asianux 3(64-bit)").build())
.add(OSType.builder().id(1).OSCategoryId(1).description("CentOS 4.5 (32-bit)").build())
.add(OSType.builder().id(2).OSCategoryId(1).description("CentOS 4.6 (32-bit)").build())
.add(OSType.builder().id(3).OSCategoryId(1).description("CentOS 4.7 (32-bit)").build())
.add(OSType.builder().id(4).OSCategoryId(1).description("CentOS 4.8 (32-bit)").build())
.add(OSType.builder().id(5).OSCategoryId(1).description("CentOS 5.0 (32-bit)").build())
.add(OSType.builder().id(6).OSCategoryId(1).description("CentOS 5.0 (64-bit)").build())
.add(OSType.builder().id(7).OSCategoryId(1).description("CentOS 5.1 (32-bit)").build())
.add(OSType.builder().id(8).OSCategoryId(1).description("CentOS 5.1 (64-bit)").build())
.add(OSType.builder().id(9).OSCategoryId(1).description("CentOS 5.2 (32-bit)").build())
.add(OSType.builder().id(10).OSCategoryId(1).description("CentOS 5.2 (64-bit)").build())
.add(OSType.builder().id(11).OSCategoryId(1).description("CentOS 5.3 (32-bit)").build())
.add(OSType.builder().id(12).OSCategoryId(1).description("CentOS 5.3 (64-bit)").build())
.add(OSType.builder().id(13).OSCategoryId(1).description("CentOS 5.4 (32-bit)").build())
.add(OSType.builder().id(14).OSCategoryId(1).description("CentOS 5.4 (64-bit)").build())
.add(OSType.builder().id(111).OSCategoryId(1).description("CentOS 5.5 (32-bit)").build())
.add(OSType.builder().id(112).OSCategoryId(1).description("CentOS 5.5 (64-bit)").build())
.add(OSType.builder().id(73).OSCategoryId(2).description("Debian GNU/Linux 4(32-bit)").build())
.add(OSType.builder().id(74).OSCategoryId(2).description("Debian GNU/Linux 4(64-bit)").build())
.add(OSType.builder().id(72).OSCategoryId(2).description("Debian GNU/Linux 5(64-bit)").build())
.add(OSType.builder().id(15).OSCategoryId(2).description("Debian GNU/Linux 5.0 (32-bit)").build())
.add(OSType.builder().id(132).OSCategoryId(2).description("Debian GNU/Linux 6(32-bit)").build())
.add(OSType.builder().id(133).OSCategoryId(2).description("Debian GNU/Linux 6(64-bit)").build())
.add(OSType.builder().id(102).OSCategoryId(6).description("DOS").build())
.add(OSType.builder().id(118).OSCategoryId(4).description("Fedora 10").build())
.add(OSType.builder().id(117).OSCategoryId(4).description("Fedora 11").build())
.add(OSType.builder().id(116).OSCategoryId(4).description("Fedora 12").build())
.add(OSType.builder().id(115).OSCategoryId(4).description("Fedora 13").build())
.add(OSType.builder().id(120).OSCategoryId(4).description("Fedora 8").build())
.add(OSType.builder().id(119).OSCategoryId(4).description("Fedora 9").build())
.add(OSType.builder().id(83).OSCategoryId(9).description("FreeBSD (32-bit)").build())
.add(OSType.builder().id(84).OSCategoryId(9).description("FreeBSD (64-bit)").build())
.add(OSType.builder().id(92).OSCategoryId(6).description("Microsoft Small Bussiness Server 2003").build())
.add(OSType.builder().id(78).OSCategoryId(8).description("Novell Netware 5.1").build())
.add(OSType.builder().id(77).OSCategoryId(8).description("Novell Netware 6.x").build())
.add(OSType.builder().id(68).OSCategoryId(7).description("Open Enterprise Server").build())
.add(OSType.builder().id(16).OSCategoryId(3).description("Oracle Enterprise Linux 5.0 (32-bit)").build())
.add(OSType.builder().id(17).OSCategoryId(3).description("Oracle Enterprise Linux 5.0 (64-bit)").build())
.add(OSType.builder().id(18).OSCategoryId(3).description("Oracle Enterprise Linux 5.1 (32-bit)").build())
.add(OSType.builder().id(19).OSCategoryId(3).description("Oracle Enterprise Linux 5.1 (64-bit)").build())
.add(OSType.builder().id(20).OSCategoryId(3).description("Oracle Enterprise Linux 5.2 (32-bit)").build())
.add(OSType.builder().id(21).OSCategoryId(3).description("Oracle Enterprise Linux 5.2 (64-bit)").build())
.add(OSType.builder().id(22).OSCategoryId(3).description("Oracle Enterprise Linux 5.3 (32-bit)").build())
.add(OSType.builder().id(23).OSCategoryId(3).description("Oracle Enterprise Linux 5.3 (64-bit)").build())
.add(OSType.builder().id(24).OSCategoryId(3).description("Oracle Enterprise Linux 5.4 (32-bit)").build())
.add(OSType.builder().id(25).OSCategoryId(3).description("Oracle Enterprise Linux 5.4 (64-bit)").build())
.add(OSType.builder().id(134).OSCategoryId(3).description("Oracle Enterprise Linux 5.5 (32-bit)").build())
.add(OSType.builder().id(135).OSCategoryId(3).description("Oracle Enterprise Linux 5.5 (64-bit)").build())
.add(OSType.builder().id(104).OSCategoryId(7).description("OS/2").build())
.add(OSType.builder().id(60).OSCategoryId(7).description("Other (32-bit)").build())
.add(OSType.builder().id(103).OSCategoryId(7).description("Other (64-bit)").build())
.add(OSType.builder().id(75).OSCategoryId(7).description("Other 2.6x Linux (32-bit)").build())
.add(OSType.builder().id(76).OSCategoryId(7).description("Other 2.6x Linux (64-bit)").build())
.add(OSType.builder().id(98).OSCategoryId(7).description("Other Linux (32-bit)").build())
.add(OSType.builder().id(99).OSCategoryId(7).description("Other Linux (64-bit)").build())
.add(OSType.builder().id(59).OSCategoryId(10).description("Other Ubuntu (32-bit)").build())
.add(OSType.builder().id(100).OSCategoryId(10).description("Other Ubuntu (64-bit)").build())
.add(OSType.builder().id(131).OSCategoryId(10).description("Red Hat Enterprise Linux 2").build())
.add(OSType.builder().id(66).OSCategoryId(4).description("Red Hat Enterprise Linux 3(32-bit)").build())
.add(OSType.builder().id(67).OSCategoryId(4).description("Red Hat Enterprise Linux 3(64-bit)").build())
.add(OSType.builder().id(106).OSCategoryId(4).description("Red Hat Enterprise Linux 4(64-bit)").build())
.add(OSType.builder().id(26).OSCategoryId(4).description("Red Hat Enterprise Linux 4.5 (32-bit)").build())
.add(OSType.builder().id(27).OSCategoryId(4).description("Red Hat Enterprise Linux 4.6 (32-bit)").build())
.add(OSType.builder().id(28).OSCategoryId(4).description("Red Hat Enterprise Linux 4.7 (32-bit)").build())
.add(OSType.builder().id(29).OSCategoryId(4).description("Red Hat Enterprise Linux 4.8 (32-bit)").build())
.add(OSType.builder().id(30).OSCategoryId(4).description("Red Hat Enterprise Linux 5.0 (32-bit)").build())
.add(OSType.builder().id(31).OSCategoryId(4).description("Red Hat Enterprise Linux 5.0 (64-bit)").build())
.add(OSType.builder().id(32).OSCategoryId(4).description("Red Hat Enterprise Linux 5.1 (32-bit)").build())
.add(OSType.builder().id(33).OSCategoryId(4).description("Red Hat Enterprise Linux 5.1 (64-bit)").build())
.add(OSType.builder().id(34).OSCategoryId(4).description("Red Hat Enterprise Linux 5.2 (32-bit)").build())
.add(OSType.builder().id(35).OSCategoryId(4).description("Red Hat Enterprise Linux 5.2 (64-bit)").build())
.add(OSType.builder().id(36).OSCategoryId(4).description("Red Hat Enterprise Linux 5.3 (32-bit)").build())
.add(OSType.builder().id(37).OSCategoryId(4).description("Red Hat Enterprise Linux 5.3 (64-bit)").build())
.add(OSType.builder().id(38).OSCategoryId(4).description("Red Hat Enterprise Linux 5.4 (32-bit)").build())
.add(OSType.builder().id(39).OSCategoryId(4).description("Red Hat Enterprise Linux 5.4 (64-bit)").build())
.add(OSType.builder().id(113).OSCategoryId(4).description("Red Hat Enterprise Linux 5.5 (32-bit)").build())
.add(OSType.builder().id(114).OSCategoryId(4).description("Red Hat Enterprise Linux 5.5 (64-bit)").build())
.add(OSType.builder().id(136).OSCategoryId(4).description("Red Hat Enterprise Linux 6.0 (32-bit)").build())
.add(OSType.builder().id(137).OSCategoryId(4).description("Red Hat Enterprise Linux 6.0 (64-bit)").build())
.add(OSType.builder().id(85).OSCategoryId(9).description("SCO OpenServer 5").build())
.add(OSType.builder().id(86).OSCategoryId(9).description("SCO UnixWare 7").build())
.add(OSType.builder().id(79).OSCategoryId(9).description("Sun Solaris 10(32-bit)").build())
.add(OSType.builder().id(80).OSCategoryId(9).description("Sun Solaris 10(64-bit)").build())
.add(OSType.builder().id(82).OSCategoryId(9).description("Sun Solaris 8(Experimental)").build())
.add(OSType.builder().id(81).OSCategoryId(9).description("Sun Solaris 9(Experimental)").build())
.add(OSType.builder().id(109).OSCategoryId(5).description("SUSE Linux Enterprise 10(32-bit)").build())
.add(OSType.builder().id(110).OSCategoryId(5).description("SUSE Linux Enterprise 10(64-bit)").build())
.add(OSType.builder().id(96).OSCategoryId(5).description("SUSE Linux Enterprise 8(32-bit)").build())
.add(OSType.builder().id(97).OSCategoryId(5).description("SUSE Linux Enterprise 8(64-bit)").build())
.add(OSType.builder().id(107).OSCategoryId(5).description("SUSE Linux Enterprise 9(32-bit)").build())
.add(OSType.builder().id(108).OSCategoryId(5).description("SUSE Linux Enterprise 9(64-bit)").build())
.add(OSType.builder().id(41).OSCategoryId(5).description("SUSE Linux Enterprise Server 10 SP1 (32-bit)")
.build())
.add(OSType.builder().id(42).OSCategoryId(5).description("SUSE Linux Enterprise Server 10 SP1 (64-bit)")
.build())
.add(OSType.builder().id(43).OSCategoryId(5).description("SUSE Linux Enterprise Server 10 SP2 (32-bit)")
.build())
.add(OSType.builder().id(44).OSCategoryId(5).description("SUSE Linux Enterprise Server 10 SP2 (64-bit)")
.build())
.add(OSType.builder().id(45).OSCategoryId(5).description("SUSE Linux Enterprise Server 10 SP3 (64-bit)")
.build())
.add(OSType.builder().id(46).OSCategoryId(5).description("SUSE Linux Enterprise Server 11 (32-bit)")
.build())
.add(OSType.builder().id(47).OSCategoryId(5).description("SUSE Linux Enterprise Server 11 (64-bit)")
.build())
.add(OSType.builder().id(40).OSCategoryId(5).description("SUSE Linux Enterprise Server 9 SP4 (32-bit)")
.build())
.add(OSType.builder().id(121).OSCategoryId(10).description("Ubuntu 10.04 (32-bit)").build())
.add(OSType.builder().id(126).OSCategoryId(10).description("Ubuntu 10.04 (64-bit)").build())
.add(OSType.builder().id(125).OSCategoryId(10).description("Ubuntu 8.04 (32-bit)").build())
.add(OSType.builder().id(130).OSCategoryId(10).description("Ubuntu 8.04 (64-bit)").build())
.add(OSType.builder().id(124).OSCategoryId(10).description("Ubuntu 8.10 (32-bit)").build())
.add(OSType.builder().id(129).OSCategoryId(10).description("Ubuntu 8.10 (64-bit)").build())
.add(OSType.builder().id(123).OSCategoryId(10).description("Ubuntu 9.04 (32-bit)").build())
.add(OSType.builder().id(128).OSCategoryId(10).description("Ubuntu 9.04 (64-bit)").build())
.add(OSType.builder().id(122).OSCategoryId(10).description("Ubuntu 9.10 (32-bit)").build())
.add(OSType.builder().id(127).OSCategoryId(10).description("Ubuntu 9.10 (64-bit)").build())
.add(OSType.builder().id(95).OSCategoryId(6).description("Windows 2000 Advanced Server").build())
.add(OSType.builder().id(105).OSCategoryId(6).description("Windows 2000 Professional").build())
.add(OSType.builder().id(61).OSCategoryId(6).description("Windows 2000 Server").build())
.add(OSType.builder().id(55).OSCategoryId(6).description("Windows 2000 Server SP4 (32-bit)").build())
.add(OSType.builder().id(65).OSCategoryId(6).description("Windows 3.1").build())
.add(OSType.builder().id(48).OSCategoryId(6).description("Windows 7 (32-bit)").build())
.add(OSType.builder().id(49).OSCategoryId(6).description("Windows 7 (64-bit)").build())
.add(OSType.builder().id(63).OSCategoryId(6).description("Windows 95").build())
.add(OSType.builder().id(62).OSCategoryId(6).description("Windows 98").build())
.add(OSType.builder().id(64).OSCategoryId(6).description("Windows NT 4").build())
.add(OSType.builder().id(87).OSCategoryId(6).description("Windows Server 2003 DataCenter Edition(32-bit)")
.build())
.add(OSType.builder().id(88).OSCategoryId(6).description("Windows Server 2003 DataCenter Edition(64-bit)")
.build())
.add(OSType.builder().id(50).OSCategoryId(6).description("Windows Server 2003 Enterprise Edition(32-bit)")
.build())
.add(OSType.builder().id(51).OSCategoryId(6).description("Windows Server 2003 Enterprise Edition(64-bit)")
.build())
.add(OSType.builder().id(89).OSCategoryId(6).description("Windows Server 2003 Standard Edition(32-bit)")
.build())
.add(OSType.builder().id(90).OSCategoryId(6).description("Windows Server 2003 Standard Edition(64-bit)")
.build())
.add(OSType.builder().id(91).OSCategoryId(6).description("Windows Server 2003 Web Edition").build())
.add(OSType.builder().id(52).OSCategoryId(6).description("Windows Server 2008 (32-bit)").build())
.add(OSType.builder().id(53).OSCategoryId(6).description("Windows Server 2008 (64-bit)").build())
.add(OSType.builder().id(54).OSCategoryId(6).description("Windows Server 2008 R2 (64-bit)").build())
.add(OSType.builder().id(56).OSCategoryId(6).description("Windows Vista (32-bit)").build())
.add(OSType.builder().id(101).OSCategoryId(6).description("Windows Vista (64-bit)").build())
.add(OSType.builder().id(93).OSCategoryId(6).description("Windows XP (32-bit)").build())
.add(OSType.builder().id(94).OSCategoryId(6).description("Windows XP (64-bit)").build())
.add(OSType.builder().id(57).OSCategoryId(6).description("Windows XP SP2 (32-bit)").build())
.add(OSType.builder().id(58).OSCategoryId(6).description("Windows XP SP3 (32-bit)").build()).build();
}
}

View File

@ -35,12 +35,11 @@ import com.google.common.collect.ImmutableSet;
@Test(groups = "unit")
public class ListPublicIPAddressesResponseTest extends BaseSetParserTest<PublicIPAddress> {
@Override
public String resource() {
return "/listpublicipaddressesresponse.json";
}
@Override
@SelectJson("publicipaddress")
public Set<PublicIPAddress> expected() {

View File

@ -47,9 +47,12 @@ public class NetworkPredicatesTest {
}
public void testSupportsStaticNATFindsWhenFirewallHasStaticNatFeature() {
Network network = Network.builder().id(204).services(
ImmutableSet.of(new NetworkService("Firewall", ImmutableMap.<String, String> of("StaticNat", "true"))))
.build();
Network network = Network
.builder()
.id(204)
.services(
ImmutableSet.of(new NetworkService("Firewall", ImmutableMap.<String, String> of("StaticNat", "true"))))
.build();
assert !hasLoadBalancerService().apply(network);
assert supportsStaticNAT().apply(network);
@ -57,8 +60,8 @@ public class NetworkPredicatesTest {
}
public void testNoSupport() {
Network network = Network.builder().id(204).services(
ImmutableSet.of(new NetworkService("Firewall", ImmutableMap.<String, String> of()))).build();
Network network = Network.builder().id(204)
.services(ImmutableSet.of(new NetworkService("Firewall", ImmutableMap.<String, String> of()))).build();
assert !hasLoadBalancerService().apply(network);
assert !supportsStaticNAT().apply(network);
@ -66,9 +69,12 @@ public class NetworkPredicatesTest {
}
public void testSupportsPortForwardingFindsWhenFirewallHasPortForwardingFeature() {
Network network = Network.builder().id(204).services(
ImmutableSet.of(new NetworkService("Firewall", ImmutableMap
.<String, String> of("PortForwarding", "true")))).build();
Network network = Network
.builder()
.id(204)
.services(
ImmutableSet.of(new NetworkService("Firewall", ImmutableMap.<String, String> of("PortForwarding",
"true")))).build();
assert !hasLoadBalancerService().apply(network);
assert !supportsStaticNAT().apply(network);
@ -76,8 +82,11 @@ public class NetworkPredicatesTest {
}
public void testSupportsPortForwardingAndStaticNATWhenFirewallHasFeatures() {
Network network = Network.builder().id(204).services(
ImmutableSet.of(new NetworkService("Firewall", ImmutableMap.<String, String> of("StaticNat", "true",
Network network = Network
.builder()
.id(204)
.services(
ImmutableSet.of(new NetworkService("Firewall", ImmutableMap.<String, String> of("StaticNat", "true",
"PortForwarding", "true")))).build();
assert Predicates.and(supportsPortForwarding(), supportsStaticNAT()).apply(network);

View File

@ -46,23 +46,23 @@ public class PublicIPAddressPredicatesTest {
public void testIsNotAvailableWhenAssignedToVM() {
PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).virtualMachineId(1)
.id(204).build();
.id(204).build();
assert !available().apply(address);
}
public void testIsNotAvailableWhenSourceNAT() {
PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).isSourceNAT(true).id(
204).build();
PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).isSourceNAT(true)
.id(204).build();
assert !available().apply(address);
}
public void testIsNotAvailableWhenStaticNAT() {
PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).isStaticNAT(true).id(
204).build();
PublicIPAddress address = PublicIPAddress.builder().state(PublicIPAddress.State.ALLOCATED).isStaticNAT(true)
.id(204).build();
assert !available().apply(address);