mirror of https://github.com/apache/jclouds.git
Merge pull request #1144 from jclouds/invokable-not-method
Invokable not method
This commit is contained in:
commit
253ce089bf
|
@ -21,8 +21,6 @@ package org.jclouds.atmos.blobstore;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -37,6 +35,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -47,24 +48,27 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner {
|
|||
private final BlobToObject blobToObject;
|
||||
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
||||
|
||||
private final Method getMethod;
|
||||
private final Method deleteMethod;
|
||||
private final Method createMethod;
|
||||
private final Invokable<?, ?> getMethod;
|
||||
private final Invokable<?, ?> deleteMethod;
|
||||
private final Invokable<?, ?> createMethod;
|
||||
|
||||
@Inject
|
||||
public AtmosBlobRequestSigner(RestAnnotationProcessor.Factory processor, BlobToObject blobToObject,
|
||||
BlobToHttpGetOptions blob2ObjectGetOptions) throws SecurityException, NoSuchMethodException {
|
||||
BlobToHttpGetOptions blob2ObjectGetOptions) throws SecurityException, NoSuchMethodException {
|
||||
this.processor = checkNotNull(processor, "processor").declaring(AtmosAsyncClient.class);
|
||||
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||
this.getMethod = AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class);
|
||||
this.deleteMethod = AtmosAsyncClient.class.getMethod("deletePath", String.class);
|
||||
this.createMethod = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, PutOptions[].class);
|
||||
this.getMethod = Invokable.from(AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class));
|
||||
this.deleteMethod = Invokable.from(AtmosAsyncClient.class.getMethod("deletePath", String.class));
|
||||
this.createMethod = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class,
|
||||
AtmosObject.class, PutOptions[].class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name) {
|
||||
return cleanRequest(processor.createRequest(getMethod, getPath(container, name)));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(getMethod, ImmutableList.<Object> of(getPath(container, name))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +78,10 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner {
|
|||
|
||||
@Override
|
||||
public HttpRequest signPutBlob(String container, Blob blob) {
|
||||
return cleanRequest(processor.createRequest(createMethod, container, blobToObject.apply(blob)));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(blob, "blob");
|
||||
return cleanRequest(processor.createRequest(createMethod,
|
||||
ImmutableList.<Object> of(container, blobToObject.apply(blob))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +91,9 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner {
|
|||
|
||||
@Override
|
||||
public HttpRequest signRemoveBlob(String container, String name) {
|
||||
return cleanRequest(processor.createRequest(deleteMethod, getPath(container, name)));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(deleteMethod, ImmutableList.<Object> of(getPath(container, name))));
|
||||
}
|
||||
|
||||
private String getPath(String container, String name) {
|
||||
|
@ -93,8 +102,10 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner {
|
|||
|
||||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
|
||||
return cleanRequest(processor.createRequest(getMethod, getPath(container, name), blob2ObjectGetOptions
|
||||
.apply(options)));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(getMethod,
|
||||
ImmutableList.of(getPath(container, name), blob2ObjectGetOptions.apply(checkNotNull(options, "options")))));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.atmos;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
|
||||
|
@ -54,6 +53,8 @@ import org.testng.annotations.BeforeClass;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
|
@ -68,8 +69,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
private BlobToObject blobToObject;
|
||||
|
||||
public void testListDirectories() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": text/xml\n");
|
||||
|
@ -83,8 +84,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testListDirectory() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "directory");
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("directory"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/directory/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": text/xml\n");
|
||||
|
@ -98,8 +99,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testListDirectoriesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, new ListOptions().limit(1).token("asda"));
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(new ListOptions().limit(1).token("asda")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": text/xml\nx-emc-limit: 1\nx-emc-token: asda\n");
|
||||
|
@ -113,8 +114,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testListDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "directory", new ListOptions().limit(1).token("asda"));
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("directory", new ListOptions().limit(1).token("asda")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/directory/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": text/xml\nx-emc-limit: 1\nx-emc-token: asda\n");
|
||||
|
@ -128,8 +129,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testCreateDirectory() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "dir");
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
|
@ -143,8 +144,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testCreateDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "dir", PutOptions.Builder.publicRead());
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", PutOptions.Builder.publicRead()));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT
|
||||
|
@ -159,10 +160,10 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testCreateFile() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class,
|
||||
PutOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "dir", blobToObject
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB));
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class,
|
||||
PutOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", blobToObject
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB)));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
|
@ -176,10 +177,10 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testCreateFileOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class,
|
||||
PutOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "dir", blobToObject
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead());
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class,
|
||||
PutOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", blobToObject
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead()));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT
|
||||
|
@ -194,10 +195,10 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testUpdateFile() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class,
|
||||
PutOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "dir", blobToObject
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB));
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class,
|
||||
PutOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", blobToObject
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB)));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
|
@ -211,10 +212,10 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testUpdateFileOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class,
|
||||
PutOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "dir", blobToObject
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead());
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class,
|
||||
PutOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", blobToObject
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT
|
||||
|
@ -229,8 +230,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testReadFile() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "dir/file");
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir/file"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
|
@ -244,8 +245,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testGetSystemMetadata() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("getSystemMetadata", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "dir/file");
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("getSystemMetadata", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir/file"));
|
||||
|
||||
assertRequestLineEquals(request, "HEAD https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
|
@ -259,8 +260,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testDeletePath() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("deletePath", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "dir/file");
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("deletePath", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir/file"));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
|
@ -274,8 +275,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testIsPublic() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("isPublic", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "dir/file");
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("isPublic", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir/file"));
|
||||
|
||||
assertRequestLineEquals(request, "HEAD https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
|
@ -289,8 +290,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
}
|
||||
|
||||
public void testNewObject() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AtmosAsyncClient.class.getMethod("newObject");
|
||||
assertEquals(method.getReturnType(), AtmosObject.class);
|
||||
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("newObject"));
|
||||
assertEquals(method.getReturnType().getRawType(), AtmosObject.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,6 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
@ -67,7 +66,9 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
|
@ -80,14 +81,11 @@ import com.google.inject.Provides;
|
|||
// surefire
|
||||
@Test(groups = "unit", singleThreaded = true, testName = "CloudServersAsyncClientTest")
|
||||
public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServersAsyncClient> {
|
||||
private static final Class<? extends ListOptions[]> listOptionsVarargsClass = new ListOptions[] {}.getClass();
|
||||
private static final Class<? extends CreateServerOptions[]> createServerOptionsVarargsClass = new CreateServerOptions[] {}
|
||||
.getClass();
|
||||
|
||||
public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
createServerOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", 2, 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
CreateServerOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -103,9 +101,9 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testCreateServerWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
createServerOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", 2, 1, withSharedIpGroup(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
CreateServerOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1, withSharedIpGroup(2)));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -121,10 +119,10 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testCreateServerWithFile() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
createServerOptionsVarargsClass);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
CreateServerOptions[].class));
|
||||
HttpRequest request = processor
|
||||
.createRequest(method, "ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes()));
|
||||
.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes())));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -142,10 +140,10 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testCreateServerWithMetadata() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
createServerOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", 2, 1,
|
||||
withMetadata(ImmutableMap.of("foo", "bar")));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
CreateServerOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1,
|
||||
withMetadata(ImmutableMap.of("foo", "bar"))));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -163,10 +161,10 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
|
||||
public void testCreateServerWithIpGroupAndSharedIp() throws IOException, SecurityException, NoSuchMethodException,
|
||||
UnknownHostException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
createServerOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", 2, 1,
|
||||
withSharedIpGroup(2).withSharedIp("127.0.0.1"));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
|
||||
CreateServerOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1,
|
||||
withSharedIpGroup(2).withSharedIp("127.0.0.1")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -183,8 +181,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testDeleteImage() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("deleteImage", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteImage", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -198,8 +196,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testLimits() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("getLimits");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getLimits"));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/limits?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -213,8 +211,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListServers() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -230,8 +228,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
Date now = new Date(10000000l);
|
||||
|
||||
public void testListServersOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
|
@ -246,8 +244,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListServersDetail() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listServers", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails());
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/detail?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -261,8 +259,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testGetServer() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("getServer", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getServer", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -276,8 +274,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListFlavors() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -291,8 +289,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListFlavorsOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
|
@ -307,8 +305,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListFlavorsDetail() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails());
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -322,8 +320,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListFlavorsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
|
@ -338,8 +336,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testGetFlavor() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("getFlavor", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getFlavor", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/2?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -353,8 +351,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListImages() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -368,8 +366,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListImagesDetail() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails());
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -383,8 +381,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListImagesOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
|
@ -399,8 +397,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListImagesDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listImages", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
|
@ -415,8 +413,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testGetImage() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("getImage", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getImage", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -430,8 +428,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testDeleteServer() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("deleteServer", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteServer", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -445,9 +443,9 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testShareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class,
|
||||
boolean.class);
|
||||
HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, false);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class,
|
||||
boolean.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, false));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -463,9 +461,9 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testShareIpConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class,
|
||||
boolean.class);
|
||||
HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, true);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class,
|
||||
boolean.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, true));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -482,8 +480,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
|
||||
public void testUnshareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException,
|
||||
UnknownHostException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("unshareIp", String.class, int.class);
|
||||
HttpRequest request = processor.createRequest(method, "127.0.0.1", 2, 3, false);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("unshareIp", String.class, int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, false));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -498,9 +496,9 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testReplaceBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("replaceBackupSchedule", int.class, BackupSchedule.class);
|
||||
HttpRequest request = processor.createRequest(method, 2, BackupSchedule.builder().weekly(WeeklyBackup.MONDAY)
|
||||
.daily(DailyBackup.H_0800_1000).enabled(true).build());
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("replaceBackupSchedule", int.class, BackupSchedule.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, BackupSchedule.builder().weekly(WeeklyBackup.MONDAY)
|
||||
.daily(DailyBackup.H_0800_1000).enabled(true).build()));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -517,8 +515,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testDeleteBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("deleteBackupSchedule", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteBackupSchedule", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -533,8 +531,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("changeAdminPass", int.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, 2, "foo");
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("changeAdminPass", int.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, "foo"));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -549,8 +547,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testChangeServerName() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("renameServer", int.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, 2, "foo");
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("renameServer", int.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, "foo"));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -565,8 +563,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListSharedIpGroups() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -580,8 +578,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListSharedIpGroupsOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, changesSince(now).maxResults(1).startAt(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
|
@ -596,8 +594,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListSharedIpGroupsDetail() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails());
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -611,8 +609,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListSharedIpGroupsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listSharedIpGroups", listOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, withDetails().changesSince(now).maxResults(1).startAt(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
|
||||
|
@ -627,8 +625,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testGetSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("getSharedIpGroup", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getSharedIpGroup", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -641,13 +639,10 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
private static final Class<? extends CreateSharedIpGroupOptions[]> createSharedIpGroupOptionsVarargsClass = new CreateSharedIpGroupOptions[] {}
|
||||
.getClass();
|
||||
|
||||
public void testCreateSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class,
|
||||
createSharedIpGroupOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie");
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class,
|
||||
CreateSharedIpGroupOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -662,9 +657,9 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testCreateSharedIpGroupWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class,
|
||||
createSharedIpGroupOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", withServer(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class,
|
||||
CreateSharedIpGroupOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", withServer(2)));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -679,8 +674,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testDeleteSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("deleteSharedIpGroup", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteSharedIpGroup", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -694,8 +689,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListAddresses() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("getAddresses", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getAddresses", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -709,8 +704,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListPublicAddresses() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listPublicAddresses", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listPublicAddresses", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -724,8 +719,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListPrivateAddresses() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("listPrivateAddresses", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listPrivateAddresses", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/private?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -739,8 +734,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testListBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("getBackupSchedule", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getBackupSchedule", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -754,8 +749,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testCreateImageWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("createImageFromServer", String.class, int.class);
|
||||
HttpRequest request = processor.createRequest(method, "ralphie", 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createImageFromServer", String.class, int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
|
||||
|
@ -770,13 +765,10 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
|
||||
}
|
||||
|
||||
private static final Class<? extends RebuildServerOptions[]> rebuildServerOptionsVarargsClass = new RebuildServerOptions[] {}
|
||||
.getClass();
|
||||
|
||||
public void testRebuildServer() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("rebuildServer", int.class,
|
||||
rebuildServerOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, 3);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebuildServer", int.class,
|
||||
RebuildServerOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(3));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -790,9 +782,9 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testRebuildServerWithImage() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("rebuildServer", int.class,
|
||||
rebuildServerOptionsVarargsClass);
|
||||
HttpRequest request = processor.createRequest(method, 3, withImage(2));
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebuildServer", int.class,
|
||||
RebuildServerOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(3, withImage(2)));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -806,8 +798,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testReboot() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("rebootServer", int.class, RebootType.class);
|
||||
HttpRequest request = processor.createRequest(method, 2, RebootType.HARD);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebootServer", int.class, RebootType.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, RebootType.HARD));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -821,8 +813,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testResize() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("resizeServer", int.class, int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2, 3);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("resizeServer", int.class, int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, 3));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -837,8 +829,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testConfirmResize() throws IOException, IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("confirmResizeServer", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("confirmResizeServer", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -852,8 +844,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
|||
}
|
||||
|
||||
public void testRevertResize() throws IOException, SecurityException, NoSuchMethodException {
|
||||
Method method = CloudServersAsyncClient.class.getMethod("revertResizeServer", int.class);
|
||||
HttpRequest request = processor.createRequest(method, 2);
|
||||
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("revertResizeServer", int.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudsigma;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||
|
@ -52,6 +51,7 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code CloudSigmaAsyncClient}
|
||||
|
@ -63,8 +63,8 @@ import com.google.common.collect.Iterables;
|
|||
public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsyncClient> {
|
||||
|
||||
public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("getProfileInfo");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getProfileInfo"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/profile/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -79,8 +79,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListStandardDrives() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listStandardDrives");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardDrives"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -94,8 +94,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListStandardCds() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listStandardCds");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardCds"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/cd/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -109,8 +109,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListStandardImages() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listStandardImages");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardImages"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/img/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -124,8 +124,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listDriveInfo");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listDriveInfo"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -139,8 +139,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("getDriveInfo", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getDriveInfo", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -155,10 +155,10 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("createDrive", Drive.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createDrive", Drive.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
new CreateDriveRequest.Builder().name("foo").use(ImmutableList.of("production", "candy")).size(10000l)
|
||||
.build());
|
||||
.build()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/create HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -173,9 +173,9 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testCloneDrive() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class,
|
||||
CloneDriveOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "sourceid", "newname");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class,
|
||||
CloneDriveOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -190,10 +190,10 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testCloneDriveOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class,
|
||||
CloneDriveOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "sourceid", "newname",
|
||||
new CloneDriveOptions().size(1024l));
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class,
|
||||
CloneDriveOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname",
|
||||
new CloneDriveOptions().size(1024l)));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -208,9 +208,9 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100", new DriveData.Builder().name("foo").size(10000l)
|
||||
.use(ImmutableList.of("production", "candy")).build());
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", new DriveData.Builder().name("foo").size(10000l)
|
||||
.use(ImmutableList.of("production", "candy")).build()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/100/set HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -225,8 +225,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listServers");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listServers"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -252,8 +252,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listServerInfo");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listServerInfo"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -267,8 +267,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("getServerInfo", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getServerInfo", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -283,8 +283,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("createServer", Server.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, BindServerToPlainTextStringTest.SERVER);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createServer", Server.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(BindServerToPlainTextStringTest.SERVER));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/create HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -299,8 +299,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100", BindServerToPlainTextStringTest.SERVER);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", BindServerToPlainTextStringTest.SERVER));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/100/set HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -315,8 +315,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("destroyServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -331,8 +331,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("startServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("startServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/start HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -347,8 +347,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("stopServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("stopServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/stop HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -363,8 +363,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("shutdownServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("shutdownServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/shutdown HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -379,8 +379,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("resetServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("resetServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/reset HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -395,8 +395,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listDrives");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listDrives"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -422,8 +422,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("destroyDrive", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyDrive", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -438,8 +438,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListVLANs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listVLANs");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listVLANs"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -465,8 +465,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listVLANInfo");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listVLANInfo"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -480,8 +480,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testGetVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("getVLANInfo", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getVLANInfo", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -496,8 +496,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testCreateVLAN() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("createVLAN", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "poohbear");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createVLAN", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("poohbear"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/create HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -512,8 +512,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testRenameVLAN() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("renameVLAN", String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100", "poohbear");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("renameVLAN", String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "poohbear"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/100/set HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -528,8 +528,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testDestroyVLAN() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("destroyVLAN", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyVLAN", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -544,8 +544,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListStaticIPs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listStaticIPs");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStaticIPs"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -571,8 +571,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testListStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("listStaticIPInfo");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStaticIPInfo"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -586,8 +586,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testGetStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("getStaticIPInfo", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getStaticIPInfo", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -602,8 +602,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testCreateStaticIP() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("createStaticIP");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createStaticIP"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/ip/create HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -618,8 +618,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
|||
}
|
||||
|
||||
public void testDestroyStaticIP() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudSigmaAsyncClient.class.getMethod("destroyStaticIP", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyStaticIP", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -31,6 +30,8 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code AccountAsyncClient}
|
||||
|
@ -43,8 +44,8 @@ import com.google.common.base.Functions;
|
|||
public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<AccountAsyncClient> {
|
||||
|
||||
public void testListAccounts() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listAccounts&listAll=true HTTP/1.1");
|
||||
|
@ -60,9 +61,9 @@ 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"));
|
||||
Invokable<?, ?> method = Invokable.from(AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
ListAccountsOptions.Builder.accountInDomain("jclouds", "123")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listAccounts&listAll=true&account=jclouds&domainid=123 HTTP/1.1");
|
||||
|
@ -78,8 +79,8 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
|
|||
}
|
||||
|
||||
public void testGetAccount() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AccountAsyncClient.class.getMethod("getAccount", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "3");
|
||||
Invokable<?, ?> method = Invokable.from(AccountAsyncClient.class.getMethod("getAccount", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("3"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listAccounts&listAll=true&id=3 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -36,6 +35,8 @@ import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code AddressAsyncClient}
|
||||
|
@ -47,8 +48,8 @@ import com.google.common.base.Functions;
|
|||
@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);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listPublicIpAddresses&listAll=true HTTP/1.1");
|
||||
|
@ -64,9 +65,9 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
|
|||
}
|
||||
|
||||
public void testListPublicIPAddressesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
ListPublicIPAddressesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true));
|
||||
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
ListPublicIPAddressesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true)));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -83,8 +84,8 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
|
|||
}
|
||||
|
||||
public void testGetPublicIPAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AddressAsyncClient.class.getMethod("getPublicIPAddress", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("getPublicIPAddress", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listPublicIpAddresses&listAll=true&id=5 HTTP/1.1");
|
||||
|
@ -101,9 +102,9 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
|
|||
}
|
||||
|
||||
public void testAssociateIPAddressInZone() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AddressAsyncClient.class.getMethod("associateIPAddressInZone", String.class,
|
||||
AssociateIPAddressOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 6);
|
||||
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("associateIPAddressInZone", String.class,
|
||||
AssociateIPAddressOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(6));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=associateIpAddress&zoneid=6 HTTP/1.1");
|
||||
|
@ -119,8 +120,8 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
|
|||
}
|
||||
|
||||
public void testDisassociateIPAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AddressAsyncClient.class.getMethod("disassociateIPAddress", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("disassociateIPAddress", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=disassociateIpAddress&id=5 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -30,6 +29,9 @@ import org.jclouds.cloudstack.options.ListAsyncJobsOptions;
|
|||
import org.jclouds.http.HttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code AsyncJobAsyncClient}
|
||||
*
|
||||
|
@ -41,8 +43,8 @@ import org.testng.annotations.Test;
|
|||
public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<AsyncJobAsyncClient> {
|
||||
|
||||
public void testGetAsyncJob() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AsyncJobAsyncClient.class.getMethod("getAsyncJob", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 11l);
|
||||
Invokable<?, ?> method = Invokable.from(AsyncJobAsyncClient.class.getMethod("getAsyncJob", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=queryAsyncJobResult&jobid=11 HTTP/1.1");
|
||||
|
@ -58,8 +60,8 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<Async
|
|||
}
|
||||
|
||||
public void testListAsyncJobs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listAsyncJobs&listAll=true HTTP/1.1");
|
||||
|
@ -75,9 +77,9 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<Async
|
|||
}
|
||||
|
||||
public void testListAsyncJobsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
ListAsyncJobsOptions.Builder.accountInDomain("adrian", "5"));
|
||||
Invokable<?, ?> method = Invokable.from(AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
ListAsyncJobsOptions.Builder.accountInDomain("adrian", "5")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listAsyncJobs&listAll=true&account=adrian&domainid=5 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||
|
@ -27,6 +26,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ConfigurationAsyncClient}
|
||||
*
|
||||
|
@ -38,8 +40,8 @@ import org.testng.annotations.Test;
|
|||
public class ConfigurationAsyncClientTest extends BaseCloudStackAsyncClientTest<ConfigurationAsyncClient> {
|
||||
|
||||
public void testListCapabilities() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigurationAsyncClient.class.getMethod("listCapabilities");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ConfigurationAsyncClient.class.getMethod("listCapabilities"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&listAll=true&command=listCapabilities HTTP/1.1");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -27,6 +25,9 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code DomainAccountAsyncClient}
|
||||
*
|
||||
|
@ -36,8 +37,8 @@ import org.testng.annotations.Test;
|
|||
public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<DomainAccountAsyncClient> {
|
||||
|
||||
public void testEnableAccount() throws Exception {
|
||||
Method method = DomainAccountAsyncClient.class.getMethod("enableAccount", String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "goo", "2");
|
||||
Invokable<?, ?> method = Invokable.from(DomainAccountAsyncClient.class.getMethod("enableAccount", String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo", "2"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=enableAccount&account=goo&domainid=2 HTTP/1.1");
|
||||
|
@ -52,8 +53,8 @@ public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
}
|
||||
|
||||
public void testDisableAccount() throws Exception {
|
||||
Method method = DomainAccountAsyncClient.class.getMethod("disableAccount", String.class, String.class, boolean.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "1", "2", true);
|
||||
Invokable<?, ?> method = Invokable.from(DomainAccountAsyncClient.class.getMethod("disableAccount", String.class, String.class, boolean.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("1", "2", true));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=disableAccount&account=1&domainid=2&lock=true HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.domain.ResourceLimit;
|
||||
import org.jclouds.cloudstack.domain.ResourceLimit.ResourceType;
|
||||
|
@ -29,6 +28,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code DomainLimitAsyncClient}
|
||||
*
|
||||
|
@ -38,9 +40,9 @@ import org.testng.annotations.Test;
|
|||
public class DomainLimitAsyncClientTest extends BaseCloudStackAsyncClientTest<DomainLimitAsyncClient> {
|
||||
|
||||
public void testUpdateResourceLimit() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = DomainLimitAsyncClient.class.getMethod("updateResourceLimit", ResourceLimit.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
ResourceLimit.builder().resourceType(ResourceType.SNAPSHOT).account("foo").domainId("100").max(101).build());
|
||||
Invokable<?, ?> method = Invokable.from(DomainLimitAsyncClient.class.getMethod("updateResourceLimit", ResourceLimit.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
ResourceLimit.builder().resourceType(ResourceType.SNAPSHOT).account("foo").domainId("100").max(101).build()));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse;
|
||||
|
@ -29,6 +28,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code EventAsyncClient}
|
||||
*
|
||||
|
@ -40,8 +42,8 @@ import org.testng.annotations.Test;
|
|||
public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest<EventAsyncClient> {
|
||||
|
||||
public void testListEventTypes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EventAsyncClient.class.getMethod("listEventTypes");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(EventAsyncClient.class.getMethod("listEventTypes"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&listAll=true&command=listEventTypes HTTP/1.1");
|
||||
|
@ -56,8 +58,8 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest<EventAsy
|
|||
}
|
||||
|
||||
public void testListEvents() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents HTTP/1.1");
|
||||
|
@ -73,8 +75,8 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest<EventAsy
|
|||
}
|
||||
|
||||
public void testEventsListOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListEventsOptions.Builder.account("jclouds"));
|
||||
Invokable<?, ?> method = Invokable.from(EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListEventsOptions.Builder.account("jclouds")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents&account=jclouds HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||
|
@ -33,6 +32,9 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code FirewallAsyncClient}
|
||||
*
|
||||
|
@ -43,9 +45,9 @@ import org.testng.annotations.Test;
|
|||
@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);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(FirewallAsyncClient.class.getMethod("listPortForwardingRules",
|
||||
ListPortForwardingRulesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true HTTP/1.1");
|
||||
|
@ -61,9 +63,9 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
|
|||
}
|
||||
|
||||
public void testListPortForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = FirewallAsyncClient.class.getMethod("listPortForwardingRules",
|
||||
ListPortForwardingRulesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListPortForwardingRulesOptions.Builder.ipAddressId("3"));
|
||||
Invokable<?, ?> method = Invokable.from(FirewallAsyncClient.class.getMethod("listPortForwardingRules",
|
||||
ListPortForwardingRulesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListPortForwardingRulesOptions.Builder.ipAddressId("3")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true&ipaddressid=3 HTTP/1.1");
|
||||
|
@ -80,9 +82,9 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
|
|||
|
||||
public void testCreatePortForwardingRuleForVirtualMachine() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = FirewallAsyncClient.class.getMethod("createPortForwardingRuleForVirtualMachine", String.class,
|
||||
PortForwardingRule.Protocol.class, int.class, String.class, int.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "6", PortForwardingRule.Protocol.TCP, 22, "7", 22);
|
||||
Invokable<?, ?> method = Invokable.from(FirewallAsyncClient.class.getMethod("createPortForwardingRuleForVirtualMachine", String.class,
|
||||
PortForwardingRule.Protocol.class, int.class, String.class, int.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("6", PortForwardingRule.Protocol.TCP, 22, "7", 22));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -99,8 +101,8 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
|
|||
}
|
||||
|
||||
public void testDeletePortForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = FirewallAsyncClient.class.getMethod("deletePortForwardingRule", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(FirewallAsyncClient.class.getMethod("deletePortForwardingRule", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deletePortForwardingRule&id=5 HTTP/1.1");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
|
@ -30,6 +28,9 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GlobalAccountAsyncClient}
|
||||
*
|
||||
|
@ -51,10 +52,10 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
.build();
|
||||
|
||||
public void testCreateAccount() throws Exception {
|
||||
Method method = GlobalAccountAsyncClient.class.getMethod("createAccount", String.class, Account.Type.class,
|
||||
String.class, String.class, String.class, String.class, CreateAccountOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "user", Account.Type.USER, "email@example.com",
|
||||
"FirstName", "LastName", "hashed-password");
|
||||
Invokable<?, ?> method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("createAccount", String.class, Account.Type.class,
|
||||
String.class, String.class, String.class, String.class, CreateAccountOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("user", Account.Type.USER, "email@example.com",
|
||||
"FirstName", "LastName", "hashed-password"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, create.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -77,9 +78,9 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
.build();
|
||||
|
||||
public void testUpdateAccount() throws Exception {
|
||||
Method method = GlobalAccountAsyncClient.class.getMethod("updateAccount", String.class, String.class,
|
||||
String.class, UpdateAccountOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "account", 42L, "new-account-name");
|
||||
Invokable<?, ?> method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("updateAccount", String.class, String.class,
|
||||
String.class, UpdateAccountOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("account", 42L, "new-account-name"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, update.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -93,8 +94,8 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
}
|
||||
|
||||
public void testDeleteAccount() throws Exception {
|
||||
Method method = GlobalAccountAsyncClient.class.getMethod("deleteAccount", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 42L);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("deleteAccount", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(42L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteAccount&id=42 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
|
@ -28,6 +27,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GlobalAlertsAsyncClient}
|
||||
*
|
||||
|
@ -39,8 +41,8 @@ import org.testng.annotations.Test;
|
|||
public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest<GlobalAlertAsyncClient> {
|
||||
|
||||
public void testListAlerts() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listAlerts&listAll=true HTTP/1.1");
|
||||
|
@ -56,8 +58,8 @@ public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
|
|||
}
|
||||
|
||||
public void testListAlertsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListAlertsOptions.Builder.id("42").keyword("jclouds").type("TEMPLATE"));
|
||||
Invokable<?, ?> method = Invokable.from(GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListAlertsOptions.Builder.id("42").keyword("jclouds").type("TEMPLATE")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listAlerts&listAll=true&id=42&keyword=jclouds&type=TEMPLATE HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.domain.Capacity;
|
||||
|
@ -29,6 +28,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GlobalCapacityAsyncClient}
|
||||
*
|
||||
|
@ -40,8 +42,8 @@ import org.testng.annotations.Test;
|
|||
public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest<GlobalCapacityAsyncClient> {
|
||||
|
||||
public void testListCapacity() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listCapacity&listAll=true HTTP/1.1");
|
||||
|
@ -56,8 +58,8 @@ public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testListCapacityOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListCapacityOptions.Builder.hostId("3").keyword("fred").podId("4").type(Capacity.Type.CPU_ALLOCATED_MHZ).zoneId("6"));
|
||||
Invokable<?, ?> method = Invokable.from(GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListCapacityOptions.Builder.hostId("3").keyword("fred").podId("4").type(Capacity.Type.CPU_ALLOCATED_MHZ).zoneId("6")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listCapacity&listAll=true&hostid=3&keyword=fred&podid=4&type=1&zoneid=6 HTTP/1.1");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListHostsOptions;
|
||||
|
@ -27,6 +25,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GlobalHostAsyncClient}
|
||||
*
|
||||
|
@ -36,8 +37,8 @@ import org.testng.annotations.Test;
|
|||
public class GlobalHostAsyncClientTest extends BaseCloudStackAsyncClientTest<GlobalHostAsyncClient> {
|
||||
|
||||
public void testListHosts() throws Exception {
|
||||
Method method =GlobalHostAsyncClient.class.getMethod("listHosts", ListHostsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalHostAsyncClient.class.getMethod("listHosts", ListHostsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listHosts&listAll=true HTTP/1.1");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.CreateDiskOfferingOptions;
|
||||
|
@ -32,6 +30,9 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GlobalOfferingAsyncClient}
|
||||
*
|
||||
|
@ -51,9 +52,9 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
.addQueryParam("memory", "3").build();
|
||||
|
||||
public void testCreateServiceOffering() throws Exception {
|
||||
Method method = GlobalOfferingAsyncClient.class.getMethod("createServiceOffering",
|
||||
String.class, String.class, int.class, int.class, int.class, CreateServiceOfferingOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "name", "displayText", 1, 2, 3);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("createServiceOffering",
|
||||
String.class, String.class, int.class, int.class, int.class, CreateServiceOfferingOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name", "displayText", 1, 2, 3));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createServiceOffering.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -67,9 +68,9 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testUpdateServiceOffering() throws Exception {
|
||||
Method method = GlobalOfferingAsyncClient.class.getMethod("updateServiceOffering",
|
||||
String.class, UpdateServiceOfferingOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 1L);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateServiceOffering",
|
||||
String.class, UpdateServiceOfferingOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateServiceOffering&id=1 HTTP/1.1");
|
||||
|
@ -84,8 +85,8 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testDeleteServiceOffering() throws Exception {
|
||||
Method method = GlobalOfferingAsyncClient.class.getMethod("deleteServiceOffering", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 1L);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("deleteServiceOffering", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteServiceOffering&id=1 HTTP/1.1");
|
||||
|
@ -100,9 +101,9 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testCreateDiskOffering() throws Exception {
|
||||
Method method = GlobalOfferingAsyncClient.class.getMethod("createDiskOffering",
|
||||
String.class, String.class, CreateDiskOfferingOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "name", "displayText");
|
||||
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("createDiskOffering",
|
||||
String.class, String.class, CreateDiskOfferingOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name", "displayText"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=createDiskOffering&name=name&displaytext=displayText HTTP/1.1");
|
||||
|
@ -117,9 +118,9 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testUpdateDiskOffering() throws Exception {
|
||||
Method method = GlobalOfferingAsyncClient.class.getMethod("updateDiskOffering",
|
||||
String.class, UpdateDiskOfferingOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 1L);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateDiskOffering",
|
||||
String.class, UpdateDiskOfferingOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateDiskOffering&id=1 HTTP/1.1");
|
||||
|
@ -134,8 +135,8 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testDeleteDiskOffering() throws Exception {
|
||||
Method method = GlobalOfferingAsyncClient.class.getMethod("deleteDiskOffering", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 1L);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("deleteDiskOffering", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteDiskOffering&id=1 HTTP/1.1");
|
||||
|
@ -150,9 +151,9 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testUpdateNetworkOffering() throws Exception {
|
||||
Method method = GlobalOfferingAsyncClient.class.getMethod("updateNetworkOffering",
|
||||
String.class, UpdateNetworkOfferingOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 1L);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateNetworkOffering",
|
||||
String.class, UpdateNetworkOfferingOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateNetworkOffering&id=1 HTTP/1.1");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListStoragePoolsOptions;
|
||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||
|
@ -27,6 +25,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GlobalStoragePoolAsyncClient}
|
||||
*
|
||||
|
@ -36,8 +37,8 @@ import org.testng.annotations.Test;
|
|||
public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientTest<GlobalStoragePoolAsyncClient> {
|
||||
|
||||
public void testListStoragePools() throws NoSuchMethodException {
|
||||
Method method = GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listStoragePools&listAll=true HTTP/1.1");
|
||||
|
@ -52,8 +53,8 @@ public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientT
|
|||
}
|
||||
|
||||
public void testListStoragePoolsOptions() throws NoSuchMethodException {
|
||||
Method method = GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListStoragePoolsOptions.Builder.clusterId("3").id("4").ipAddress("192.168.42.42").keyword("fred").name("bob").path("/mnt/store42").podId("4").zoneId("5"));
|
||||
Invokable<?, ?> method = Invokable.from(GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListStoragePoolsOptions.Builder.clusterId("3").id("4").ipAddress("192.168.42.42").keyword("fred").name("bob").path("/mnt/store42").podId("4").zoneId("5")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listStoragePools&listAll=true&clusterid=3&id=4&ipaddress=192.168.42.42&keyword=fred&name=bob&path=/mnt/store42&podid=4&zoneid=5 HTTP/1.1");
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -30,6 +29,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GlobalUsageAsyncClient}
|
||||
*
|
||||
|
@ -47,9 +49,9 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
|
|||
c.set(Calendar.DAY_OF_MONTH, 31);
|
||||
Date end = c.getTime();
|
||||
|
||||
Method method = GlobalUsageAsyncClient.class.getMethod("generateUsageRecords",
|
||||
Date.class, Date.class, GenerateUsageRecordsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, start, end);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("generateUsageRecords",
|
||||
Date.class, Date.class, GenerateUsageRecordsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=generateUsageRecords&startdate=2012-01-01&enddate=2012-01-31 HTTP/1.1");
|
||||
|
@ -72,9 +74,9 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
|
|||
c.set(Calendar.DAY_OF_MONTH, 31);
|
||||
Date end = c.getTime();
|
||||
|
||||
Method method = GlobalUsageAsyncClient.class.getMethod("generateUsageRecords",
|
||||
Date.class, Date.class, GenerateUsageRecordsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, start, end, GenerateUsageRecordsOptions.Builder.domainId("42"));
|
||||
Invokable<?, ?> method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("generateUsageRecords",
|
||||
Date.class, Date.class, GenerateUsageRecordsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end, GenerateUsageRecordsOptions.Builder.domainId("42")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=generateUsageRecords&startdate=2012-01-01&enddate=2012-01-31&domainid=42 HTTP/1.1");
|
||||
|
@ -97,9 +99,9 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
|
|||
c.set(Calendar.DAY_OF_MONTH, 31);
|
||||
Date end = c.getTime();
|
||||
|
||||
Method method = GlobalUsageAsyncClient.class.getMethod("listUsageRecords",
|
||||
Date.class, Date.class, ListUsageRecordsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, start, end);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("listUsageRecords",
|
||||
Date.class, Date.class, ListUsageRecordsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listUsageRecords&listAll=true&startdate=2012-01-01&enddate=2012-01-31 HTTP/1.1");
|
||||
|
@ -122,9 +124,9 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
|
|||
c.set(Calendar.DAY_OF_MONTH, 31);
|
||||
Date end = c.getTime();
|
||||
|
||||
Method method = GlobalUsageAsyncClient.class.getMethod("listUsageRecords",
|
||||
Date.class, Date.class, ListUsageRecordsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, start, end, ListUsageRecordsOptions.Builder.accountInDomain("fred", "42").accountId("41").keyword("bob"));
|
||||
Invokable<?, ?> method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("listUsageRecords",
|
||||
Date.class, Date.class, ListUsageRecordsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end, ListUsageRecordsOptions.Builder.accountInDomain("fred", "42").accountId("41").keyword("bob")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listUsageRecords&listAll=true&startdate=2012-01-01&enddate=2012-01-31&account=fred&domainid=42&accountid=41&keyword=bob HTTP/1.1");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.CreateUserOptions;
|
||||
|
@ -29,6 +27,9 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GlobalUserAsyncClient}
|
||||
*/
|
||||
|
@ -47,10 +48,10 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
|
|||
.addQueryParam("lastname", "LastName").build();
|
||||
|
||||
public void testCreateAccount() throws Exception {
|
||||
Method method = GlobalUserAsyncClient.class.getMethod("createUser", String.class, String.class,
|
||||
String.class, String.class, String.class, String.class, CreateUserOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "user", "account", "email@example.com",
|
||||
"hashed-password", "FirstName", "LastName");
|
||||
Invokable<?, ?> method = Invokable.from(GlobalUserAsyncClient.class.getMethod("createUser", String.class, String.class,
|
||||
String.class, String.class, String.class, String.class, CreateUserOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("user", "account", "email@example.com",
|
||||
"hashed-password", "FirstName", "LastName"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createUser.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -64,8 +65,8 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
|
|||
}
|
||||
|
||||
public void testUpdateUser() throws Exception {
|
||||
Method method = GlobalUserAsyncClient.class.getMethod("updateUser", String.class, UpdateUserOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 42L);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalUserAsyncClient.class.getMethod("updateUser", String.class, UpdateUserOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(42L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateUser&id=42 HTTP/1.1");
|
||||
|
@ -80,8 +81,8 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
|
|||
}
|
||||
|
||||
public void testDeleteUser() throws Exception {
|
||||
Method method = GlobalUserAsyncClient.class.getMethod("deleteUser", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 42L);
|
||||
Invokable<?, ?> method = Invokable.from(GlobalUserAsyncClient.class.getMethod("deleteUser", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(42L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteUser&id=42 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -33,6 +32,8 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GuestOSAsyncClient}
|
||||
|
@ -45,8 +46,8 @@ import com.google.common.base.Functions;
|
|||
public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestOSAsyncClient> {
|
||||
|
||||
public void testGetOSCategory() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GuestOSAsyncClient.class.getMethod("getOSCategory", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 11l);
|
||||
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("getOSCategory", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listOsCategories&listAll=true&id=11 HTTP/1.1");
|
||||
|
@ -62,8 +63,8 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
|
|||
}
|
||||
|
||||
public void testListOSCategories() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GuestOSAsyncClient.class.getMethod("listOSCategories");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSCategories"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listOsCategories&listAll=true HTTP/1.1");
|
||||
|
@ -79,8 +80,8 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
|
|||
}
|
||||
|
||||
public void testGetOSType() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GuestOSAsyncClient.class.getMethod("getOSType", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 11l);
|
||||
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("getOSType", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&listAll=true&id=11 HTTP/1.1");
|
||||
|
@ -97,8 +98,8 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
|
|||
}
|
||||
|
||||
public void testListOSTypes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&listAll=true HTTP/1.1");
|
||||
|
@ -114,8 +115,8 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
|
|||
}
|
||||
|
||||
public void testListOSTypesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListOSTypesOptions.Builder.OSCategoryId("11"));
|
||||
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListOSTypesOptions.Builder.OSCategoryId("11")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&listAll=true&oscategoryid=11 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse;
|
||||
|
@ -27,6 +26,9 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
|||
import org.jclouds.http.HttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code HypervisorAsyncClient}
|
||||
*
|
||||
|
@ -38,8 +40,8 @@ import org.testng.annotations.Test;
|
|||
public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest<HypervisorAsyncClient> {
|
||||
|
||||
public void testListHypervisors() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = HypervisorAsyncClient.class.getMethod("listHypervisors");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(HypervisorAsyncClient.class.getMethod("listHypervisors"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listHypervisors&listAll=true HTTP/1.1");
|
||||
|
@ -55,8 +57,8 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest<Hyp
|
|||
}
|
||||
|
||||
public void testListHypervisorsInZon() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = HypervisorAsyncClient.class.getMethod("listHypervisorsInZone", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 11);
|
||||
Invokable<?, ?> method = Invokable.from(HypervisorAsyncClient.class.getMethod("listHypervisorsInZone", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listHypervisors&listAll=true&zoneid=11 HTTP/1.1");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.domain.ExtractMode;
|
||||
import org.jclouds.cloudstack.domain.PermissionOperation;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
|
@ -35,7 +33,9 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.Invokable;
|
||||
/**
|
||||
* Tests the behaviour of ISOAsyncClient.
|
||||
*
|
||||
|
@ -47,8 +47,8 @@ import com.google.common.collect.ImmutableSet;
|
|||
public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncClient> {
|
||||
|
||||
public void testAttachISO() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("attachISO", String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "3", "5");
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("attachISO", String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("3", "5"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=attachIso&id=3&virtualmachineid=5 HTTP/1.1");
|
||||
|
@ -63,8 +63,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testDetachISO() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("detachISO", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3);
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("detachISO", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=detachIso&virtualmachineid=3 HTTP/1.1");
|
||||
|
@ -79,8 +79,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testUpdateISO() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3);
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateIso&id=3 HTTP/1.1");
|
||||
|
@ -95,8 +95,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testUpdateISOOptions() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, UpdateISOOptions.Builder.bootable(true).displayText("robert").format("format").name("bob").osTypeId("9").passwordEnabled(true));
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, UpdateISOOptions.Builder.bootable(true).displayText("robert").format("format").name("bob").osTypeId("9").passwordEnabled(true)));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateIso&id=3&bootable=true&displaytext=robert&format=format&name=bob&ostypeid=9&passwordenabled=true HTTP/1.1");
|
||||
|
@ -111,8 +111,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testDeleteISO() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3);
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteIso&id=3 HTTP/1.1");
|
||||
|
@ -127,8 +127,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testDeleteISOOptions() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, DeleteISOOptions.Builder.zoneId("5"));
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, DeleteISOOptions.Builder.zoneId("5")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteIso&id=3&zoneid=5 HTTP/1.1");
|
||||
|
@ -152,8 +152,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
.build();
|
||||
|
||||
public void testCopyISO() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("copyISO", String.class, String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, 5, 7);
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("copyISO", String.class, String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, 5, 7));
|
||||
|
||||
assertRequestLineEquals(httpRequest, copyIso.getRequestLine());
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
@ -166,8 +166,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testUpdateISOPermissions() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3);
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateIsoPermissions&id=3 HTTP/1.1");
|
||||
|
@ -182,8 +182,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testUpdateISOPermissionsOptions() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, UpdateISOPermissionsOptions.Builder.accounts(ImmutableSet.<String>of("fred", "bob")).isExtractable(true).isFeatured(true).isPublic(true).operation(PermissionOperation.add));
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, UpdateISOPermissionsOptions.Builder.accounts(ImmutableSet.<String>of("fred", "bob")).isExtractable(true).isFeatured(true).isPublic(true).operation(PermissionOperation.add)));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateIsoPermissions&id=3&accounts=fred,bob&isextractable=true&isfeatured=true&ispublic=true&op=add HTTP/1.1");
|
||||
|
@ -198,8 +198,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testListISOPermissions() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3);
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listIsoPermissions&listAll=true&id=3 HTTP/1.1");
|
||||
|
@ -214,8 +214,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
}
|
||||
|
||||
public void testListISOPermissionsOptions() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, AccountInDomainOptions.Builder.accountInDomain("fred", "5"));
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, AccountInDomainOptions.Builder.accountInDomain("fred", "5")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listIsoPermissions&listAll=true&id=3&account=fred&domainid=5 HTTP/1.1");
|
||||
|
@ -239,8 +239,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
.build();
|
||||
|
||||
public void testExtractISO() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, ExtractMode.HTTP_DOWNLOAD, 5);
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, ExtractMode.HTTP_DOWNLOAD, 5));
|
||||
|
||||
assertRequestLineEquals(httpRequest, extractIso.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -264,8 +264,8 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
|||
.build();
|
||||
|
||||
public void testExtractISOOptions() throws NoSuchMethodException {
|
||||
Method method = ISOAsyncClient.class.getMethod("extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractISOOptions.Builder.url("http://example.com/"));
|
||||
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractISOOptions.Builder.url("http://example.com/")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, extractIsoOptions.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
|
@ -28,6 +27,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code LimitAsyncClient}
|
||||
*
|
||||
|
@ -37,8 +39,8 @@ import org.testng.annotations.Test;
|
|||
public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest<LimitAsyncClient> {
|
||||
|
||||
public void testListResourceLimits() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listResourceLimits&listAll=true HTTP/1.1");
|
||||
|
@ -54,8 +56,8 @@ public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest<LimitAsy
|
|||
}
|
||||
|
||||
public void testListResourceLimitsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListResourceLimitsOptions.Builder.account("jclouds" , "23"));
|
||||
Invokable<?, ?> method = Invokable.from(LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListResourceLimitsOptions.Builder.account("jclouds" , "23")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listResourceLimits&listAll=true&account=jclouds&domainid=23 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -33,6 +32,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code LoadBalancerAsyncClient}
|
||||
*
|
||||
|
@ -43,9 +45,9 @@ import org.testng.annotations.Test;
|
|||
@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);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
|
||||
ListLoadBalancerRulesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules&listAll=true HTTP/1.1");
|
||||
|
@ -61,9 +63,9 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
|
|||
}
|
||||
|
||||
public void testListLoadBalancerRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
|
||||
ListLoadBalancerRulesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListLoadBalancerRulesOptions.Builder.publicIPId("3"));
|
||||
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
|
||||
ListLoadBalancerRulesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListLoadBalancerRulesOptions.Builder.publicIPId("3")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules&listAll=true&publicipid=3 HTTP/1.1");
|
||||
|
@ -89,9 +91,9 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
|
|||
.addQueryParam("publicport", "22").build();
|
||||
|
||||
public void testCreateLoadBalancerRuleForPublicIP() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("createLoadBalancerRuleForPublicIP", String.class,
|
||||
Algorithm.class, String.class, int.class, int.class, CreateLoadBalancerRuleOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 6, Algorithm.LEASTCONN, "tcp", 22, 22);
|
||||
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("createLoadBalancerRuleForPublicIP", String.class,
|
||||
Algorithm.class, String.class, int.class, int.class, CreateLoadBalancerRuleOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(6, Algorithm.LEASTCONN, "tcp", 22, 22));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createLoadBalancerRule.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -106,8 +108,8 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
|
|||
}
|
||||
|
||||
public void testUpdateLoadBalancerRule() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("updateLoadBalancerRule", String.class, UpdateLoadBalancerRuleOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("updateLoadBalancerRule", String.class, UpdateLoadBalancerRuleOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateLoadBalancerRule&id=5 HTTP/1.1");
|
||||
|
@ -122,8 +124,8 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
|
|||
}
|
||||
|
||||
public void testDeleteLoadBalancerRule() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("deleteLoadBalancerRule", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("deleteLoadBalancerRule", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteLoadBalancerRule&id=5 HTTP/1.1");
|
||||
|
@ -140,9 +142,9 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
|
|||
|
||||
public void testListVirtualMachinesAssignedToLoadBalancerRule() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = LoadBalancerAsyncClient.class.getMethod("listVirtualMachinesAssignedToLoadBalancerRule",
|
||||
String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listVirtualMachinesAssignedToLoadBalancerRule",
|
||||
String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRuleInstances&listAll=true&id=5 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -33,6 +32,9 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code NATAsyncClient}
|
||||
*
|
||||
|
@ -43,8 +45,8 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit", testName = "NATAsyncClientTest")
|
||||
public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncClient> {
|
||||
public void testListIPForwardingRules() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&listAll=true HTTP/1.1");
|
||||
|
@ -60,9 +62,9 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
|||
}
|
||||
|
||||
public void testListIPForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
ListIPForwardingRulesOptions.Builder.virtualMachineId("3"));
|
||||
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
ListIPForwardingRulesOptions.Builder.virtualMachineId("3")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&listAll=true&virtualmachineid=3 HTTP/1.1");
|
||||
|
@ -78,8 +80,8 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
|||
}
|
||||
|
||||
public void testGetIPForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NATAsyncClient.class.getMethod("getIPForwardingRule", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("getIPForwardingRule", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&listAll=true&id=5 HTTP/1.1");
|
||||
|
@ -103,9 +105,9 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
|||
|
||||
public void testCreateIPForwardingRuleForVirtualMachine() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = NATAsyncClient.class.getMethod("createIPForwardingRule", String.class, String.class, int.class,
|
||||
CreateIPForwardingRuleOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 7, "tcp", 22);
|
||||
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("createIPForwardingRule", String.class, String.class, int.class,
|
||||
CreateIPForwardingRuleOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(7, "tcp", 22));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createIpForwardingRule.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -130,10 +132,10 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
|||
|
||||
public void testCreateIPForwardingRuleForVirtualMachineOptions() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = NATAsyncClient.class.getMethod("createIPForwardingRule", String.class, String.class, int.class,
|
||||
CreateIPForwardingRuleOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 7, "tcp", 22,
|
||||
CreateIPForwardingRuleOptions.Builder.endPort(22));
|
||||
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("createIPForwardingRule", String.class, String.class, int.class,
|
||||
CreateIPForwardingRuleOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(7, "tcp", 22,
|
||||
CreateIPForwardingRuleOptions.Builder.endPort(22)));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createIpForwardingRuleOptions.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -148,8 +150,8 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
|||
}
|
||||
|
||||
public void testEnableStaticNATForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NATAsyncClient.class.getMethod("enableStaticNATForVirtualMachine", String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5, 6);
|
||||
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("enableStaticNATForVirtualMachine", String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, 6));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=enableStaticNat&virtualmachineid=5&ipaddressid=6 HTTP/1.1");
|
||||
|
@ -165,8 +167,8 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
|||
}
|
||||
|
||||
public void testDisableStaticNATOnPublicIP() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NATAsyncClient.class.getMethod("disableStaticNATOnPublicIP", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("disableStaticNATOnPublicIP", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=disableStaticNat&ipaddressid=5 HTTP/1.1");
|
||||
|
@ -182,8 +184,8 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
|||
}
|
||||
|
||||
public void testDeleteIPForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NATAsyncClient.class.getMethod("deleteIPForwardingRule", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("deleteIPForwardingRule", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteIpForwardingRule&id=5 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -34,6 +33,8 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code NetworkAsyncClient}
|
||||
|
@ -45,8 +46,8 @@ import com.google.common.base.Functions;
|
|||
@Test(groups = "unit", testName = "NetworkAsyncClientTest")
|
||||
public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<NetworkAsyncClient> {
|
||||
public void testListNetworks() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listNetworks&listAll=true HTTP/1.1");
|
||||
|
@ -62,9 +63,9 @@ 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"));
|
||||
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListNetworksOptions.Builder.type(NetworkType.ADVANCED)
|
||||
.domainId("6").id("5")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listNetworks&listAll=true&type=Advanced&domainid=6&id=5 HTTP/1.1");
|
||||
|
@ -80,8 +81,8 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
|||
}
|
||||
|
||||
public void testGetNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NetworkAsyncClient.class.getMethod("getNetwork", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "id");
|
||||
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("getNetwork", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("id"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listNetworks&listAll=true&id=id HTTP/1.1");
|
||||
|
@ -107,9 +108,9 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
|||
.addQueryParam("displaytext", "lovely").build();
|
||||
|
||||
public void testCreateNetworkInZone() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NetworkAsyncClient.class.getMethod("createNetworkInZone", String.class, String.class, String.class,
|
||||
String.class, CreateNetworkOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 1, 2, "named", "lovely");
|
||||
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("createNetworkInZone", String.class, String.class, String.class,
|
||||
String.class, CreateNetworkOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1, 2, "named", "lovely"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createNetwork.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -135,11 +136,11 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
|||
.addQueryParam("domainid", "6").build();
|
||||
|
||||
public void testCreateNetworkInZoneOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NetworkAsyncClient.class.getMethod("createNetworkInZone", String.class, String.class, String.class,
|
||||
String.class, CreateNetworkOptions[].class);
|
||||
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("createNetworkInZone", String.class, String.class, String.class,
|
||||
String.class, CreateNetworkOptions[].class));
|
||||
|
||||
HttpRequest httpRequest = processor.createRequest(method, 1, 2, "named", "lovely", CreateNetworkOptions.Builder
|
||||
.netmask("255.255.255.0").domainId("6"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1, 2, "named", "lovely", CreateNetworkOptions.Builder
|
||||
.netmask("255.255.255.0").domainId("6")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createNetworkOptions.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -154,8 +155,8 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
|||
}
|
||||
|
||||
public void testDeleteNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NetworkAsyncClient.class.getMethod("deleteNetwork", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("deleteNetwork", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteNetwork&id=5 HTTP/1.1");
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudstack.features;
|
|||
import static org.jclouds.cloudstack.domain.NetworkOfferingAvailabilityType.DEFAULT;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -35,6 +34,8 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code OfferingAsyncClient}
|
||||
|
@ -46,8 +47,8 @@ import com.google.common.base.Functions;
|
|||
@Test(groups = "unit", testName = "OfferingAsyncClientTest")
|
||||
public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<OfferingAsyncClient> {
|
||||
public void testListDiskOfferings() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listDiskOfferings&listAll=true HTTP/1.1");
|
||||
|
@ -63,8 +64,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
|||
}
|
||||
|
||||
public void testListDiskOfferingsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListDiskOfferingsOptions.Builder.domainId("6").id("5"));
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListDiskOfferingsOptions.Builder.domainId("6").id("5")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listDiskOfferings&listAll=true&domainid=6&id=5 HTTP/1.1");
|
||||
|
@ -80,8 +81,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
|||
}
|
||||
|
||||
public void testGetDiskOffering() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("getDiskOffering", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "5");
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("getDiskOffering", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("5"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listDiskOfferings&listAll=true&id=5 HTTP/1.1");
|
||||
|
@ -98,8 +99,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
|||
}
|
||||
|
||||
public void testListNetworkOfferings() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listNetworkOfferings&listAll=true HTTP/1.1");
|
||||
|
@ -115,9 +116,9 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
|||
}
|
||||
|
||||
public void testListNetworkOfferingsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
ListNetworkOfferingsOptions.Builder.availability(DEFAULT).isShared(true).id("6"));
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
ListNetworkOfferingsOptions.Builder.availability(DEFAULT).isShared(true).id("6")));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -134,8 +135,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
|||
}
|
||||
|
||||
public void testGetNetworkOffering() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("getNetworkOffering", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "5");
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("getNetworkOffering", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("5"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listNetworkOfferings&listAll=true&id=5 HTTP/1.1");
|
||||
|
@ -152,8 +153,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
|||
}
|
||||
|
||||
public void testListServiceOfferings() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listServiceOfferings&listAll=true HTTP/1.1");
|
||||
|
@ -169,9 +170,9 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
|||
}
|
||||
|
||||
public void testListServiceOfferingsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListServiceOfferingsOptions.Builder.virtualMachineId("4")
|
||||
.domainId("5").id("6"));
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListServiceOfferingsOptions.Builder.virtualMachineId("4")
|
||||
.domainId("5").id("6")));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -188,8 +189,8 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
|||
}
|
||||
|
||||
public void testGetServiceOffering() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OfferingAsyncClient.class.getMethod("getServiceOffering", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "5");
|
||||
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("getServiceOffering", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("5"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listServiceOfferings&listAll=true&id=5 HTTP/1.1");
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudstack.features;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
|
@ -39,6 +38,8 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code SSHKeyPairAsyncClient}
|
||||
|
@ -49,8 +50,8 @@ import com.google.common.base.Functions;
|
|||
public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSHKeyPairAsyncClient> {
|
||||
|
||||
public void testListSSHKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true HTTP/1.1");
|
||||
|
@ -66,8 +67,8 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
|
|||
}
|
||||
|
||||
public void testListSSHKeyPairsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListSSHKeyPairsOptions.Builder.name("jclouds"));
|
||||
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSSHKeyPairsOptions.Builder.name("jclouds")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&name=jclouds HTTP/1.1");
|
||||
|
@ -83,8 +84,8 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
|
|||
}
|
||||
|
||||
public void testGetSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SSHKeyPairAsyncClient.class.getMethod("getSSHKeyPair", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "jclouds-keypair");
|
||||
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("getSSHKeyPair", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&name=jclouds-keypair HTTP/1.1");
|
||||
|
@ -101,9 +102,9 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
|
|||
}
|
||||
|
||||
public void testRegisterSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SSHKeyPairAsyncClient.class.getMethod("registerSSHKeyPair", String.class, String.class);
|
||||
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("registerSSHKeyPair", String.class, String.class));
|
||||
String publicKey = URLEncoder.encode(SshKeys.generate().get("public"), "UTF-8");
|
||||
HttpRequest httpRequest = processor.createRequest(method, "jclouds-keypair", publicKey);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair", publicKey));
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=registerSSHKeyPair&name=jclouds-keypair&publickey="
|
||||
+ publicKey
|
||||
|
@ -121,8 +122,8 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
|
|||
|
||||
|
||||
public void testDeleteSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SSHKeyPairAsyncClient.class.getMethod("deleteSSHKeyPair", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "jclouds-keypair");
|
||||
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("deleteSSHKeyPair", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteSSHKeyPair&name=jclouds-keypair HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -35,9 +34,11 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code SecurityGroupAsyncClient}
|
||||
|
@ -50,8 +51,8 @@ import com.google.common.collect.Multimap;
|
|||
public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<SecurityGroupAsyncClient> {
|
||||
|
||||
public void testListSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true HTTP/1.1");
|
||||
|
@ -67,9 +68,9 @@ 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"));
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSecurityGroupsOptions.Builder.virtualMachineId("4")
|
||||
.domainId("5").id("6")));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -86,8 +87,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
}
|
||||
|
||||
public void testGetSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("getSecurityGroup", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("getSecurityGroup", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true&id=5 HTTP/1.1");
|
||||
|
@ -104,8 +105,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
}
|
||||
|
||||
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("createSecurityGroup", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "goo");
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("createSecurityGroup", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=createSecurityGroup&name=goo HTTP/1.1");
|
||||
|
@ -131,10 +132,10 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
.addQueryParam("cidrlist", "1.1.1.1/24,1.2.2.2/16").build();
|
||||
|
||||
public void testAuthorizeIngressPortsToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToCIDRs", String.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"));
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToCIDRs", String.class,
|
||||
String.class, int.class, int.class, Iterable.class, AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "tcp", 22, 22,
|
||||
ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress3.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -164,10 +165,10 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
.addQueryParam("usersecuritygrouplist%5B2%5D.group", "group1").build();
|
||||
|
||||
public void testAuthorizeIngressPortsToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToSecurityGroups", String.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"));
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToSecurityGroups", String.class,
|
||||
String.class, int.class, int.class, Multimap.class, AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "tcp", 22, 22,
|
||||
ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress4.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -192,9 +193,9 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
.addQueryParam("cidrlist", "1.1.1.1/24,1.2.2.2/16").build();
|
||||
|
||||
public void testAuthorizeIngressICMPToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToCIDRs", String.class , int.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"));
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToCIDRs", String.class , int.class,
|
||||
int.class, Iterable.class, AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress1.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -224,10 +225,10 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
.addQueryParam("usersecuritygrouplist%5B2%5D.group", "group1").build();
|
||||
|
||||
public void testAuthorizeIngressICMPToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToSecurityGroups", String.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"));
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToSecurityGroups", String.class,
|
||||
int.class, int.class, Multimap.class, AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, 22, 22,
|
||||
ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress2.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -242,10 +243,10 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
}
|
||||
|
||||
public void testRevokeIngressRule() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("revokeIngressRule", String.class,
|
||||
AccountInDomainOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5,
|
||||
AccountInDomainOptions.Builder.accountInDomain("adrian", "1"));
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeIngressRule", String.class,
|
||||
AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5,
|
||||
AccountInDomainOptions.Builder.accountInDomain("adrian", "1")));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -262,8 +263,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
|||
}
|
||||
|
||||
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroup", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroup", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteSecurityGroup&id=5 HTTP/1.1");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||
|
@ -39,7 +37,9 @@ import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests the behaviour of SnapshotAsyncClient.
|
||||
|
@ -53,8 +53,8 @@ import com.google.common.collect.ImmutableSet;
|
|||
public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<SnapshotAsyncClient> {
|
||||
|
||||
public void testCreateSnapshot() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=createSnapshot&volumeid=5 HTTP/1.1");
|
||||
|
@ -69,8 +69,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testCreateSnapshotOptions() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5, CreateSnapshotOptions.Builder.accountInDomain("acc", "7").policyId("9"));
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, CreateSnapshotOptions.Builder.accountInDomain("acc", "7").policyId("9")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=createSnapshot&volumeid=5&account=acc&domainid=7&policyid=9 HTTP/1.1");
|
||||
|
@ -85,8 +85,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testListSnapshots() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSnapshots&listAll=true HTTP/1.1");
|
||||
|
@ -101,8 +101,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testGetSnapshot() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("getSnapshot", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("getSnapshot", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSnapshots&listAll=true&id=5 HTTP/1.1");
|
||||
|
@ -118,8 +118,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testListSnapshotsOptions() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListSnapshotsOptions.Builder.accountInDomain("acc", "7").id("5").interval(Snapshot.Interval.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.Type.RECURRING).volumeId("11"));
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSnapshotsOptions.Builder.accountInDomain("acc", "7").id("5").interval(Snapshot.Interval.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.Type.RECURRING).volumeId("11")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSnapshots&listAll=true&account=acc&domainid=7&id=5&intervaltype=MONTHLY&isrecursive=true&keyword=fred&name=fred%27s%20snapshot&snapshottype=RECURRING&volumeid=11 HTTP/1.1");
|
||||
|
@ -134,8 +134,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testDeleteSnapshot() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("deleteSnapshot", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 14);
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshot", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(14));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteSnapshot&id=14 HTTP/1.1");
|
||||
|
@ -160,8 +160,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
.addQueryParam("schedule", "07%3A06%3A05").build();
|
||||
|
||||
public void testCreateSnapshotPolicy() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("createSnapshotPolicy", SnapshotPolicySchedule.class, String.class, String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, SnapshotPolicySchedules.monthly(5, 6, 7), 10, "UTC", 12);
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshotPolicy", SnapshotPolicySchedule.class, String.class, String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(SnapshotPolicySchedules.monthly(5, 6, 7), 10, "UTC", 12));
|
||||
|
||||
assertRequestLineEquals(httpRequest,extractIso.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -175,8 +175,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testDeleteSnapshotPolicy() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicy", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 7);
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicy", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(7));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteSnapshotPolicies&id=7 HTTP/1.1");
|
||||
|
@ -191,9 +191,9 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testDeleteSnapshotPolicies() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicies", Iterable.class);
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicies", Iterable.class));
|
||||
Iterable<String> ids = ImmutableSet.of("3", "5", "7");
|
||||
HttpRequest httpRequest = processor.createRequest(method, ids);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ids));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteSnapshotPolicies&ids=3,5,7 HTTP/1.1");
|
||||
|
@ -208,8 +208,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testListSnapshotPolicies() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 10);
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(10));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSnapshotPolicies&listAll=true&volumeid=10 HTTP/1.1");
|
||||
|
@ -224,8 +224,8 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
}
|
||||
|
||||
public void testListSnapshotPoliciesOptions() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 10, ListSnapshotPoliciesOptions.Builder.accountInDomain("fred", "4").keyword("bob"));
|
||||
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(10, ListSnapshotPoliciesOptions.Builder.accountInDomain("fred", "4").keyword("bob")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listSnapshotPolicies&listAll=true&volumeid=10&account=fred&domainid=4&keyword=bob HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -45,7 +44,9 @@ import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code TemplateAsyncClient}
|
||||
|
@ -58,8 +59,8 @@ import com.google.common.collect.ImmutableSet;
|
|||
public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<TemplateAsyncClient> {
|
||||
|
||||
public void testCreateTemplate() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build());
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createTemplate&name=thename&ostypeid=10&displaytext=description HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -73,8 +74,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testCreateTemplateOptions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), CreateTemplateOptions.Builder.bits(32).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true).snapshotId("11").volumeId("12"));
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), CreateTemplateOptions.Builder.bits(32).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true).snapshotId("11").volumeId("12")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createTemplate&bits=32&isfeatured=true&ispublic=true&passwordenabled=true&requireshvm=true&snapshotid=11&volumeid=12&name=thename&ostypeid=10&displaytext=description HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -100,8 +101,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
.addQueryParam("displaytext", "description").build();
|
||||
|
||||
public void testRegisterTemplate() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20));
|
||||
|
||||
assertRequestLineEquals(httpRequest, registerTemplate.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -136,9 +137,9 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
.addQueryParam("displaytext", "description").build();
|
||||
|
||||
public void testRegisterTemplateOptions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20,
|
||||
RegisterTemplateOptions.Builder.accountInDomain("mydomain", "3").bits(32).checksum("ABC").isExtractable(true).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true));
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20,
|
||||
RegisterTemplateOptions.Builder.accountInDomain("mydomain", "3").bits(32).checksum("ABC").isExtractable(true).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true)));
|
||||
|
||||
assertRequestLineEquals(httpRequest, registerTemplateOptions.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -152,8 +153,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testUpdateTemplate() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplate&id=17 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -167,8 +168,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testUpdateTemplateOptions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17, UpdateTemplateOptions.Builder.bootable(true).displayText("description").format(Template.Format.VHD).name("thename").osTypeId("12").passwordEnabled(true));
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17, UpdateTemplateOptions.Builder.bootable(true).displayText("description").format(Template.Format.VHD).name("thename").osTypeId("12").passwordEnabled(true)));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplate&id=17&bootable=true&displaytext=description&format=VHD&name=thename&ostypeid=12&passwordenabled=true HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -190,8 +191,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
.addQueryParam("destzoneid", "19").build();
|
||||
|
||||
public void testCopyTemplate() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("copyTemplateToZone", String.class, String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17, 18, 19);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("copyTemplateToZone", String.class, String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17, 18, 19));
|
||||
|
||||
assertRequestLineEquals(httpRequest,copyTemplate.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -205,8 +206,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testDeleteTemplate() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteTemplate&id=17 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -220,8 +221,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testDeleteTemplateOptions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17, DeleteTemplateOptions.Builder.zoneId("8"));
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17, DeleteTemplateOptions.Builder.zoneId("8")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteTemplate&id=17&zoneid=8 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -235,8 +236,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testListTemplates() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("listTemplates");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplates"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listTemplates&listAll=true&templatefilter=executable HTTP/1.1");
|
||||
|
@ -252,12 +253,12 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testListTemplatesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("listTemplates", ListTemplatesOptions.class);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplates", ListTemplatesOptions.class));
|
||||
HttpRequest httpRequest = processor
|
||||
.createRequest(
|
||||
method,
|
||||
method, ImmutableList.<Object> of(
|
||||
ListTemplatesOptions.Builder.accountInDomain("adrian", "6").hypervisor("xen")
|
||||
.filter(TemplateFilter.FEATURED));
|
||||
.filter(TemplateFilter.FEATURED)));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -274,8 +275,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testGetTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("getTemplateInZone", String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5, 1);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("getTemplateInZone", String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, 1));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -293,8 +294,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testUpdateTemplatePermissions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplatePermissions&id=17 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
|
@ -308,8 +309,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testUpdateTemplatePermissionsOptions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17, UpdateTemplatePermissionsOptions.Builder.accounts(ImmutableSet.of("5", "6")).isExtractable(true).isFeatured(true).isPublic(true).op(UpdateTemplatePermissionsOptions.Operation.add));
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17, UpdateTemplatePermissionsOptions.Builder.accounts(ImmutableSet.of("5", "6")).isExtractable(true).isFeatured(true).isPublic(true).op(UpdateTemplatePermissionsOptions.Operation.add)));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplatePermissions&id=17&accounts=5,6&isextractable=true&isfeatured=true&ispublic=true&op=add HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "");
|
||||
|
@ -323,8 +324,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testListTemplatePermissions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listTemplatePermissions&listAll=true&id=17 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -338,8 +339,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
}
|
||||
|
||||
public void testListTemplatePermissionsOptions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 17, AccountInDomainOptions.Builder.accountInDomain("fred", "8"));
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17, AccountInDomainOptions.Builder.accountInDomain("fred", "8")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listTemplatePermissions&listAll=true&id=17&account=fred&domainid=8 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -361,8 +362,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
.addQueryParam("zoneid", "5").build();
|
||||
|
||||
public void testExtractTemplate() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, ExtractMode.HTTP_DOWNLOAD, 5);
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, ExtractMode.HTTP_DOWNLOAD, 5));
|
||||
|
||||
assertRequestLineEquals(httpRequest, extractTemplate.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -385,8 +386,8 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
|||
.addQueryParam("url", "http%3A//example.com/").build();
|
||||
|
||||
public void testExtractTemplateOptions() throws NoSuchMethodException {
|
||||
Method method = TemplateAsyncClient.class.getMethod("extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractTemplateOptions.Builder.url("http://example.com/"));
|
||||
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractTemplateOptions.Builder.url("http://example.com/")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, extractTemplateOptions.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -36,6 +35,8 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VMGroupAsyncClient}
|
||||
|
@ -48,8 +49,8 @@ import com.google.common.base.Functions;
|
|||
public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGroupAsyncClient> {
|
||||
|
||||
public void testListVMGroups() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listInstanceGroups&listAll=true HTTP/1.1");
|
||||
|
@ -65,9 +66,9 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
|
|||
}
|
||||
|
||||
public void testListVMGroupsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListVMGroupsOptions.Builder.account("fred")
|
||||
.domainId("5").id("6"));
|
||||
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListVMGroupsOptions.Builder.account("fred")
|
||||
.domainId("5").id("6")));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -84,8 +85,8 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
|
|||
}
|
||||
|
||||
public void testGetVMGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VMGroupAsyncClient.class.getMethod("getInstanceGroup", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("getInstanceGroup", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listInstanceGroups&listAll=true&id=5 HTTP/1.1");
|
||||
|
@ -102,8 +103,8 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
|
|||
}
|
||||
|
||||
public void testCreateVMGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "goo");
|
||||
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=createInstanceGroup&name=goo HTTP/1.1");
|
||||
|
@ -119,8 +120,8 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
|
|||
}
|
||||
|
||||
public void testCreateVMGroupOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "goo", CreateVMGroupOptions.Builder.account("foo").domainId("42"));
|
||||
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo", CreateVMGroupOptions.Builder.account("foo").domainId("42")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=createInstanceGroup&name=goo&account=foo&domainid=42 HTTP/1.1");
|
||||
|
@ -136,8 +137,8 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
|
|||
}
|
||||
|
||||
public void testUpdateVMGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VMGroupAsyncClient.class.getMethod("updateInstanceGroup", String.class, UpdateVMGroupOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5, UpdateVMGroupOptions.Builder.name("fred"));
|
||||
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("updateInstanceGroup", String.class, UpdateVMGroupOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, UpdateVMGroupOptions.Builder.name("fred")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateInstanceGroup&id=5&name=fred HTTP/1.1");
|
||||
|
@ -153,8 +154,8 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
|
|||
}
|
||||
|
||||
public void testDeleteVMGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VMGroupAsyncClient.class.getMethod("deleteInstanceGroup", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("deleteInstanceGroup", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteInstanceGroup&id=5 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -35,6 +34,8 @@ import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VirtualMachineAsyncClient}
|
||||
|
@ -46,9 +47,9 @@ import com.google.common.base.Functions;
|
|||
@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);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
|
||||
ListVirtualMachinesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&listAll=true HTTP/1.1");
|
||||
|
@ -64,10 +65,10 @@ 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));
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
|
||||
ListVirtualMachinesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
ListVirtualMachinesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true)));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
@ -84,8 +85,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("getVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("getVirtualMachine", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&listAll=true&id=5 HTTP/1.1");
|
||||
|
@ -110,9 +111,9 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
.addQueryParam("templateid", "5").build();
|
||||
|
||||
public void testDeployVirtualMachineInZone() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("deployVirtualMachineInZone", String.class, String.class,
|
||||
String.class, DeployVirtualMachineOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 6, 4, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("deployVirtualMachineInZone", String.class, String.class,
|
||||
String.class, DeployVirtualMachineOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(6, 4, 5));
|
||||
|
||||
assertRequestLineEquals(httpRequest, deployVirtualMachine.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -127,8 +128,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("rebootVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("rebootVirtualMachine", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=rebootVirtualMachine&id=5 HTTP/1.1");
|
||||
|
@ -144,8 +145,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testStartVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("startVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("startVirtualMachine", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=startVirtualMachine&id=5 HTTP/1.1");
|
||||
|
@ -161,8 +162,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testStopVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("stopVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("stopVirtualMachine", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=stopVirtualMachine&id=5 HTTP/1.1");
|
||||
|
@ -178,8 +179,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testResetPasswordForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("resetPasswordForVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("resetPasswordForVirtualMachine", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=resetPasswordForVirtualMachine&id=5 HTTP/1.1");
|
||||
|
@ -195,8 +196,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testChangeServiceForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("changeServiceForVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("changeServiceForVirtualMachine", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=changeServiceForVirtualMachine&id=5 HTTP/1.1");
|
||||
|
@ -212,8 +213,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("updateVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("updateVirtualMachine", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=updateVirtualMachine&id=5 HTTP/1.1");
|
||||
|
@ -229,8 +230,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testDestroyVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("destroyVirtualMachine", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("destroyVirtualMachine", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=destroyVirtualMachine&id=5 HTTP/1.1");
|
||||
|
@ -246,10 +247,10 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
|||
}
|
||||
|
||||
public void testAssignVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VirtualMachineAsyncClient.class.getMethod("assignVirtualMachine", String.class,
|
||||
AssignVirtualMachineOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "abcd",
|
||||
AssignVirtualMachineOptions.Builder.accountInDomain("adrian", "6"));
|
||||
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("assignVirtualMachine", String.class,
|
||||
AssignVirtualMachineOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("abcd",
|
||||
AssignVirtualMachineOptions.Builder.accountInDomain("adrian", "6")));
|
||||
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -29,6 +28,9 @@ import org.jclouds.cloudstack.options.ListVolumesOptions;
|
|||
import org.jclouds.http.HttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code EventAsyncClient}
|
||||
*
|
||||
|
@ -40,8 +42,8 @@ import org.testng.annotations.Test;
|
|||
public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeAsyncClient> {
|
||||
|
||||
public void testListVolumes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VolumeAsyncClient.class.getMethod("listVolumes", ListVolumesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("listVolumes", ListVolumesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listVolumes&listAll=true HTTP/1.1");
|
||||
|
@ -56,8 +58,8 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
|
|||
}
|
||||
|
||||
public void testGetVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VolumeAsyncClient.class.getMethod("getVolume", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 111L);
|
||||
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("getVolume", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(111L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listVolumes&listAll=true&id=111 HTTP/1.1");
|
||||
|
@ -80,9 +82,9 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
|
|||
.addQueryParam("zoneid", "111").build();
|
||||
|
||||
public void testCreateVolumeWithSnapshot() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VolumeAsyncClient.class.getMethod("createVolumeFromSnapshotInZone", String.class, String.class,
|
||||
String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "jclouds-volume", 999L, 111l);
|
||||
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("createVolumeFromSnapshotInZone", String.class, String.class,
|
||||
String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-volume", 999L, 111l));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createVolumeFromSnapshot.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -102,10 +104,10 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
|
|||
.addQueryParam("zoneid", "111").build();
|
||||
|
||||
public void testCreateVolumeFromDiskOffering() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VolumeAsyncClient.class.getMethod("createVolumeFromDiskOfferingInZone", String.class, String.class,
|
||||
String.class);
|
||||
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("createVolumeFromDiskOfferingInZone", String.class, String.class,
|
||||
String.class));
|
||||
|
||||
HttpRequest httpRequest = processor.createRequest(method, "jclouds-volume", 999L, 111L);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-volume", 999L, 111L));
|
||||
|
||||
assertRequestLineEquals(httpRequest, createVolumeFromDiskOffering.getRequestLine());
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
|
@ -117,9 +119,9 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
|
|||
}
|
||||
|
||||
public void testAttachVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VolumeAsyncClient.class.getMethod("attachVolume", String.class, String.class);
|
||||
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("attachVolume", String.class, String.class));
|
||||
|
||||
HttpRequest httpRequest = processor.createRequest(method, 111L, 999L);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(111L, 999L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=attachVolume&id=111&virtualmachineid=999 HTTP/1.1");
|
||||
|
@ -132,9 +134,9 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
|
|||
}
|
||||
|
||||
public void testDetachVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VolumeAsyncClient.class.getMethod("detachVolume", String.class);
|
||||
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("detachVolume", String.class));
|
||||
|
||||
HttpRequest httpRequest = processor.createRequest(method, 111L);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(111L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=detachVolume&id=111 HTTP/1.1");
|
||||
|
@ -147,8 +149,8 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
|
|||
}
|
||||
|
||||
public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VolumeAsyncClient.class.getMethod("deleteVolume", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 111L);
|
||||
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("deleteVolume", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(111L));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=deleteVolume&id=111 HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -31,7 +30,9 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ZoneAsyncClient}
|
||||
|
@ -43,8 +44,8 @@ import com.google.common.collect.Iterables;
|
|||
@Test(groups = "unit", testName = "ZoneAsyncClientTest")
|
||||
public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsyncClient> {
|
||||
public void testListZones() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listZones&listAll=true HTTP/1.1");
|
||||
|
@ -70,9 +71,9 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
|
|||
}
|
||||
|
||||
public void testListZonesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, ListZonesOptions.Builder.available(true).domainId("5")
|
||||
.id("6"));
|
||||
Invokable<?, ?> method = Invokable.from(ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListZonesOptions.Builder.available(true).domainId("5")
|
||||
.id("6")));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listZones&listAll=true&available=true&domainid=5&id=6 HTTP/1.1");
|
||||
|
@ -88,8 +89,8 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
|
|||
}
|
||||
|
||||
public void testGetZone() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ZoneAsyncClient.class.getMethod("getZone", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, 6);
|
||||
Invokable<?, ?> method = Invokable.from(ZoneAsyncClient.class.getMethod("getZone", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(6));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=listZones&listAll=true&id=6 HTTP/1.1");
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.ec2.compute;
|
||||
|
||||
import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getJavaArgsForRequestAtIndex;
|
||||
import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getJavaMethodForRequest;
|
||||
import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getJavaMethodForRequestAtIndex;
|
||||
import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getArgsForRequestAtIndex;
|
||||
import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getInvokerOfRequest;
|
||||
import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getInvokerOfRequestAtIndex;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -73,14 +73,14 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive
|
|||
AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class));
|
||||
@Override
|
||||
public boolean apply(HttpCommand input) {
|
||||
return !ignored.contains(getJavaMethodForRequest(input));
|
||||
return !ignored.contains(getInvokerOfRequest(input));
|
||||
}
|
||||
});
|
||||
|
||||
assert filteredCommandsInvoked.size() == 1 : commandsInvoked;
|
||||
assertEquals(getJavaMethodForRequestAtIndex(filteredCommandsInvoked, 0), AMIAsyncClient.class
|
||||
assertEquals(getInvokerOfRequestAtIndex(filteredCommandsInvoked, 0), AMIAsyncClient.class
|
||||
.getMethod("describeImagesInRegion", String.class, DescribeImagesOptions[].class));
|
||||
assertDescribeImagesOptionsEquals((DescribeImagesOptions[])getJavaArgsForRequestAtIndex(filteredCommandsInvoked, 0).get(1),
|
||||
assertDescribeImagesOptionsEquals((DescribeImagesOptions[])getArgsForRequestAtIndex(filteredCommandsInvoked, 0).get(1),
|
||||
defaultImageProviderId);
|
||||
|
||||
} finally {
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.ec2.services;
|
|||
import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.executableBy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.ec2.options.CreateImageOptions;
|
||||
|
@ -39,6 +37,8 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code AMIAsyncClient}
|
||||
|
@ -63,9 +63,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class,
|
||||
Array.newInstance(CreateImageOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "name", "instanceId");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class,
|
||||
CreateImageOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "instanceId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -96,10 +96,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testCreateImageOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class,
|
||||
Array.newInstance(CreateImageOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "name", "instanceId", new CreateImageOptions()
|
||||
.withDescription("description").noReboot());
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class,
|
||||
CreateImageOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "instanceId", new CreateImageOptions()
|
||||
.withDescription("description").noReboot()));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -127,9 +127,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, Array.newInstance(
|
||||
DescribeImagesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class,
|
||||
DescribeImagesOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -162,10 +162,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, Array.newInstance(
|
||||
DescribeImagesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, executableBy("me").ownedBy("fred", "nancy").imageIds(
|
||||
"1", "2"));
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class,
|
||||
DescribeImagesOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds(
|
||||
"1", "2")));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -194,8 +194,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("deregisterImageInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "imageId");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("deregisterImageInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -225,9 +225,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class,
|
||||
String.class, Array.newInstance(RegisterImageOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "name", "pathToManifest");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class,
|
||||
String.class, RegisterImageOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "pathToManifest"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -257,10 +257,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testRegisterImageFromManifestOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class,
|
||||
String.class, Array.newInstance(RegisterImageOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "name", "pathToManifest", new RegisterImageOptions()
|
||||
.withDescription("description"));
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class,
|
||||
String.class, RegisterImageOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "pathToManifest", new RegisterImageOptions()
|
||||
.withDescription("description")));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -292,9 +292,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class,
|
||||
String.class, String.class, Array.newInstance(RegisterImageBackedByEbsOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "imageName", "snapshotId");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class,
|
||||
String.class, String.class, RegisterImageBackedByEbsOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageName", "snapshotId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -333,11 +333,11 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class,
|
||||
String.class, String.class, Array.newInstance(RegisterImageBackedByEbsOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "imageName", "snapshotId",
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class,
|
||||
String.class, String.class, RegisterImageBackedByEbsOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageName", "snapshotId",
|
||||
new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot(
|
||||
"/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100));
|
||||
"/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100)));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -367,9 +367,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testGetBlockDeviceMappingsForImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "imageId");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion", String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -399,8 +399,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "imageId");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -434,10 +434,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion", String.class,
|
||||
Iterable.class, Iterable.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, ImmutableList.of("bob", "sue"), ImmutableList
|
||||
.of("all"), "imageId");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion", String.class,
|
||||
Iterable.class, Iterable.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
|
||||
.of("all"), "imageId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -471,10 +471,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testRemoveLaunchPermissionsFromImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion", String.class,
|
||||
Iterable.class, Iterable.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, ImmutableList.of("bob", "sue"), ImmutableList
|
||||
.of("all"), "imageId");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion", String.class,
|
||||
Iterable.class, Iterable.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
|
||||
.of("all"), "imageId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -503,9 +503,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "imageId");
|
||||
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion", String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ import static org.jclouds.ec2.options.DescribeAvailabilityZonesOptions.Builder.a
|
|||
import static org.jclouds.ec2.options.DescribeRegionsOptions.Builder.regions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
@ -35,6 +33,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code AvailabilityZoneAndRegionAsyncClient}
|
||||
*
|
||||
|
@ -46,9 +47,9 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
|||
BaseEC2AsyncClientTest<AvailabilityZoneAndRegionAsyncClient> {
|
||||
|
||||
public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
|
||||
String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, Region.US_WEST_1);
|
||||
Invokable<?, ?> method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
|
||||
String.class, DescribeAvailabilityZonesOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(Region.US_WEST_1));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n");
|
||||
|
@ -63,9 +64,9 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
|||
}
|
||||
|
||||
public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
|
||||
String.class, Array.newInstance(DescribeAvailabilityZonesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "us-east-1", availabilityZones("us-east-1a", "us-east-1b"));
|
||||
Invokable<?, ?> method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
|
||||
String.class, DescribeAvailabilityZonesOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("us-east-1", availabilityZones("us-east-1a", "us-east-1b")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -81,9 +82,9 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
|||
}
|
||||
|
||||
public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
|
||||
Array.newInstance(DescribeRegionsOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
|
||||
DescribeRegionsOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -98,9 +99,9 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
|||
}
|
||||
|
||||
public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
|
||||
Array.newInstance(DescribeRegionsOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, regions(Region.US_EAST_1, Region.US_WEST_1));
|
||||
Invokable<?, ?> method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
|
||||
DescribeRegionsOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(regions(Region.US_EAST_1, Region.US_WEST_1)));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
|
|
@ -22,8 +22,6 @@ import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.ownedBy;
|
|||
import static org.jclouds.ec2.options.DetachVolumeOptions.Builder.fromInstance;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.ec2.EC2Fallbacks.VoidOnVolumeAvailable;
|
||||
|
@ -41,6 +39,8 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ElasticBlockStoreAsyncClient}
|
||||
|
@ -52,8 +52,8 @@ import com.google.common.collect.ImmutableList;
|
|||
public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<ElasticBlockStoreAsyncClient> {
|
||||
|
||||
public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "id");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -79,9 +79,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testDescribeVolumes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class,
|
||||
String[].class);
|
||||
HttpRequest request = processor.createRequest(method, null);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class,
|
||||
String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -98,9 +98,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
}
|
||||
|
||||
public void testDescribeVolumesArgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class, Array
|
||||
.newInstance(String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class,
|
||||
String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -129,9 +129,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testAttachVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("attachVolumeInRegion", String.class, String.class,
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "id", "instanceId", "/device");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("attachVolumeInRegion", String.class, String.class,
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id", "instanceId", "/device"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -161,9 +161,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testDetachVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion", String.class, String.class,
|
||||
boolean.class, Array.newInstance(DetachVolumeOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "id", false);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion", String.class, String.class,
|
||||
boolean.class, DetachVolumeOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id", false));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -195,10 +195,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testDetachVolumeOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion", String.class, String.class,
|
||||
boolean.class, Array.newInstance(DetachVolumeOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "id", true, fromInstance("instanceId").fromDevice(
|
||||
"/device"));
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion", String.class, String.class,
|
||||
boolean.class, DetachVolumeOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id", true, fromInstance("instanceId").fromDevice(
|
||||
"/device")));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -215,9 +215,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
}
|
||||
|
||||
public void testCreateSnapshot() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class,
|
||||
String.class, Array.newInstance(CreateSnapshotOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "volumeId");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class,
|
||||
String.class, CreateSnapshotOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "volumeId"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -232,10 +232,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
}
|
||||
|
||||
public void testCreateSnapshotOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class,
|
||||
String.class, Array.newInstance(CreateSnapshotOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "volumeId", CreateSnapshotOptions.Builder
|
||||
.withDescription("description"));
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class,
|
||||
String.class, CreateSnapshotOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "volumeId", CreateSnapshotOptions.Builder
|
||||
.withDescription("description")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -251,9 +251,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
}
|
||||
|
||||
public void testDescribeSnapshots() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class, Array
|
||||
.newInstance(DescribeSnapshotsOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class,
|
||||
DescribeSnapshotsOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -268,10 +268,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
}
|
||||
|
||||
public void testDescribeSnapshotsArgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class, Array
|
||||
.newInstance(DescribeSnapshotsOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, ownedBy("o1", "o2").restorableBy("r1", "r2")
|
||||
.snapshotIds("s1", "s2"));
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class,
|
||||
DescribeSnapshotsOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ownedBy("o1", "o2").restorableBy("r1", "r2")
|
||||
.snapshotIds("s1", "s2")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -288,9 +288,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
}
|
||||
|
||||
public void testGetCreateVolumePermissionForSnapshot() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("getCreateVolumePermissionForSnapshotInRegion",
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "snapshotId");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("getCreateVolumePermissionForSnapshotInRegion",
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "snapshotId"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -324,10 +324,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testAddCreateVolumePermissionsToSnapshot() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("addCreateVolumePermissionsToSnapshotInRegion",
|
||||
String.class, Iterable.class, Iterable.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, ImmutableList.of("bob", "sue"), ImmutableList
|
||||
.of("all"), "snapshotId");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("addCreateVolumePermissionsToSnapshotInRegion",
|
||||
String.class, Iterable.class, Iterable.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
|
||||
.of("all"), "snapshotId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -362,10 +362,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
|
||||
public void testRemoveCreateVolumePermissionsFromSnapshot() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("removeCreateVolumePermissionsFromSnapshotInRegion",
|
||||
String.class, Iterable.class, Iterable.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, ImmutableList.of("bob", "sue"), ImmutableList
|
||||
.of("all"), "snapshotId");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("removeCreateVolumePermissionsFromSnapshotInRegion",
|
||||
String.class, Iterable.class, Iterable.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
|
||||
.of("all"), "snapshotId"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -383,9 +383,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
|||
|
||||
public void testResetCreateVolumePermissionsOnSnapshot() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod("resetCreateVolumePermissionsOnSnapshotInRegion",
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "snapshotId");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("resetCreateVolumePermissionsOnSnapshotInRegion",
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "snapshotId"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package org.jclouds.ec2.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.ec2.xml.AllocateAddressResponseHandler;
|
||||
|
@ -30,6 +28,9 @@ import org.jclouds.http.functions.ParseSax;
|
|||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ElasticIPAddressAsyncClient}
|
||||
*
|
||||
|
@ -40,9 +41,9 @@ import org.testng.annotations.Test;
|
|||
public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<ElasticIPAddressAsyncClient> {
|
||||
|
||||
public void testDisassociateAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("disassociateAddressInRegion", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "127.0.0.1");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("disassociateAddressInRegion", String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "127.0.0.1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -70,9 +71,9 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testAssociateAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("associateAddressInRegion", String.class,
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "127.0.0.1", "me");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("associateAddressInRegion", String.class,
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "127.0.0.1", "me"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -89,8 +90,8 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
|
|||
}
|
||||
|
||||
public void testReleaseAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("releaseAddressInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "127.0.0.1");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("releaseAddressInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "127.0.0.1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -105,9 +106,9 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
|
|||
}
|
||||
|
||||
public void testDescribeAddresses() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("describeAddressesInRegion", String.class, Array
|
||||
.newInstance(String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "127.0.0.1");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("describeAddressesInRegion", String.class,
|
||||
String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "127.0.0.1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -122,8 +123,8 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
|
|||
}
|
||||
|
||||
public void testAllocateAddress() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticIPAddressAsyncClient.class.getMethod("allocateAddressInRegion", String.class);
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("allocateAddressInRegion", String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package org.jclouds.ec2.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
|
@ -43,7 +41,10 @@ import org.jclouds.http.functions.ParseSax;
|
|||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code InstanceAsyncClient}
|
||||
|
@ -54,8 +55,8 @@ import com.google.common.collect.Maps;
|
|||
@Test(groups = "unit", testName = "InstanceAsyncClientTest")
|
||||
public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyncClient> {
|
||||
public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class);
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -70,8 +71,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testDescribeInstancesArgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -86,9 +87,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testTerminateInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("terminateInstancesInRegion", String.class, Array
|
||||
.newInstance(String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("terminateInstancesInRegion", String.class,
|
||||
String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -103,9 +104,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testRunInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
||||
String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, null, "ami-voo", 1, 1);
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
||||
String.class, int.class, int.class, RunInstancesOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, null, "ami-voo", 1, 1));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -125,10 +126,10 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
||||
String.class, int.class, int.class, Array.newInstance(RunInstancesOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "eu-west-1", "eu-west-1a", "ami-voo",
|
||||
1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2"));
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class,
|
||||
String.class, int.class, int.class, RunInstancesOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("eu-west-1", "eu-west-1a", "ami-voo",
|
||||
1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.eu-west-1.amazonaws.com\n");
|
||||
|
@ -152,9 +153,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testStopInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("stopInstancesInRegion", String.class, boolean.class, Array
|
||||
.newInstance(String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, true, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("stopInstancesInRegion", String.class, boolean.class,
|
||||
String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, true, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -169,9 +170,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testRebootInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("rebootInstancesInRegion", String.class, Array.newInstance(
|
||||
String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("rebootInstancesInRegion", String.class, String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -186,9 +186,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testStartInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("startInstancesInRegion", String.class, Array.newInstance(
|
||||
String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("startInstancesInRegion", String.class, String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -203,8 +202,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testGetUserDataForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -220,9 +219,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testGetRootDeviceNameForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion", String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -238,8 +237,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testGetRamdiskForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -256,9 +255,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
|
||||
public void testGetDisableApiTerminationForInstanceInRegion() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("isApiTerminationDisabledForInstanceInRegion", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("isApiTerminationDisabledForInstanceInRegion", String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -274,8 +273,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testGetKernelForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("getKernelForInstanceInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getKernelForInstanceInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -290,9 +289,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testGetInstanceTypeForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion", String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -309,9 +308,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
|
||||
public void testGetInstanceInitiatedShutdownBehaviorForInstanceInRegion() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("getInstanceInitiatedShutdownBehaviorForInstanceInRegion",
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getInstanceInitiatedShutdownBehaviorForInstanceInRegion",
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -329,9 +328,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
|
||||
public void testGetBlockDeviceMappingForInstanceInRegion() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("getBlockDeviceMappingForInstanceInRegion", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getBlockDeviceMappingForInstanceInRegion", String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -361,9 +360,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testSetUserDataForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("setUserDataForInstanceInRegion", String.class, String.class,
|
||||
Array.newInstance(byte.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "test".getBytes());
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("setUserDataForInstanceInRegion", String.class, String.class,
|
||||
byte[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test".getBytes()));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -394,9 +393,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testSetRamdiskForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("setRamdiskForInstanceInRegion", String.class, String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "test");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("setRamdiskForInstanceInRegion", String.class, String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -427,9 +426,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testSetKernelForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("setKernelForInstanceInRegion", String.class, String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "test");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("setKernelForInstanceInRegion", String.class, String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -461,9 +460,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
|
||||
public void testSetApiTerminationDisabledForInstanceInRegion() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("setApiTerminationDisabledForInstanceInRegion", String.class,
|
||||
String.class, boolean.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1", true);
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("setApiTerminationDisabledForInstanceInRegion", String.class,
|
||||
String.class, boolean.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", true));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -494,9 +493,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testSetInstanceTypeForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("setInstanceTypeForInstanceInRegion", String.class,
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1", InstanceType.C1_MEDIUM);
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("setInstanceTypeForInstanceInRegion", String.class,
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", InstanceType.C1_MEDIUM));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -528,9 +527,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
|
||||
public void testSetInstanceInitiatedShutdownBehaviorForInstanceInRegion() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("setInstanceInitiatedShutdownBehaviorForInstanceInRegion",
|
||||
String.class, String.class, InstanceInitiatedShutdownBehavior.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1", InstanceInitiatedShutdownBehavior.TERMINATE);
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("setInstanceInitiatedShutdownBehaviorForInstanceInRegion",
|
||||
String.class, String.class, InstanceInitiatedShutdownBehavior.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -548,12 +547,12 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
|
||||
public void testSetBlockDeviceMappingForInstanceInRegion() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("setBlockDeviceMappingForInstanceInRegion", String.class,
|
||||
String.class, Map.class);
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("setBlockDeviceMappingForInstanceInRegion", String.class,
|
||||
String.class, Map.class));
|
||||
|
||||
Map<String, BlockDevice> mapping = Maps.newLinkedHashMap();
|
||||
mapping.put("/dev/sda1", new BlockDevice("vol-test1", true));
|
||||
HttpRequest request = processor.createRequest(method, null, "1", mapping);
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", mapping));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -574,8 +573,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
|||
}
|
||||
|
||||
public void testGetConsoleOutputForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = InstanceAsyncClient.class.getMethod("getConsoleOutputForInstanceInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1");
|
||||
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getConsoleOutputForInstanceInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package org.jclouds.ec2.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.ec2.xml.DescribeKeyPairsResponseHandler;
|
||||
|
@ -29,6 +27,9 @@ import org.jclouds.http.functions.ParseSax;
|
|||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code KeyPairAsyncClient}
|
||||
*
|
||||
|
@ -39,8 +40,8 @@ import org.testng.annotations.Test;
|
|||
public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncClient> {
|
||||
|
||||
public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = KeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "mykey");
|
||||
Invokable<?, ?> method = Invokable.from(KeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "mykey"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -55,9 +56,8 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
|
|||
}
|
||||
|
||||
public void testDescribeKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, Array.newInstance(
|
||||
String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
Invokable<?, ?> method = Invokable.from(KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -72,9 +72,8 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
|
|||
}
|
||||
|
||||
public void testDescribeKeyPairsArgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, Array.newInstance(
|
||||
String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package org.jclouds.ec2.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||
|
@ -32,6 +30,9 @@ import org.jclouds.http.functions.ParseSax;
|
|||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code SecurityGroupAsyncClient}
|
||||
*
|
||||
|
@ -42,9 +43,9 @@ import org.testng.annotations.Test;
|
|||
public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<SecurityGroupAsyncClient> {
|
||||
|
||||
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegion", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "name");
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegion", String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -72,9 +73,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion", String.class,
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "name", "description");
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion", String.class,
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "description"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -91,9 +92,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
|
|||
}
|
||||
|
||||
public void testDescribeSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class, Array
|
||||
.newInstance(String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class,
|
||||
String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -108,9 +109,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
|
|||
}
|
||||
|
||||
public void testDescribeSecurityGroupsArgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class, Array
|
||||
.newInstance(String.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class,
|
||||
String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -125,10 +126,10 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
|
|||
}
|
||||
|
||||
public void testAuthorizeSecurityGroupIngressGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, UserIdGroupPair.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "group", new UserIdGroupPair("sourceUser",
|
||||
"sourceGroup"));
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, UserIdGroupPair.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", new UserIdGroupPair("sourceUser",
|
||||
"sourceGroup")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -161,9 +162,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testAuthorizeSecurityGroupIngressCidr() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, IpProtocol.class, int.class, int.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, IpProtocol.class, int.class, int.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -179,10 +180,10 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
|
|||
}
|
||||
|
||||
public void testRevokeSecurityGroupIngressGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, UserIdGroupPair.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "group", new UserIdGroupPair("sourceUser",
|
||||
"sourceGroup"));
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, UserIdGroupPair.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", new UserIdGroupPair("sourceUser",
|
||||
"sourceGroup")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -215,9 +216,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testRevokeSecurityGroupIngressCidr() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, IpProtocol.class, int.class, int.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0");
|
||||
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, IpProtocol.class, int.class, int.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.ec2.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||
import org.jclouds.ec2.options.BundleInstanceS3StorageOptions;
|
||||
|
@ -29,6 +28,9 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code WindowsAsyncClient}
|
||||
*
|
||||
|
@ -55,16 +57,17 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testBundleInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class,
|
||||
String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class);
|
||||
Invokable<?, ?> method = Invokable.from(WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class,
|
||||
String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class));
|
||||
HttpRequest request = processor
|
||||
.createRequest(
|
||||
method,
|
||||
Lists.<Object> newArrayList(
|
||||
null,
|
||||
"i-e468cd8d",
|
||||
"winami",
|
||||
"my-bucket",
|
||||
"{\"expiration\": \"2008-08-30T08:49:09Z\",\"conditions\": [{\"bucket\": \"my-bucket\"},[\"starts-with\", \"$key\", \"my-new-image\"]]}");
|
||||
"{\"expiration\": \"2008-08-30T08:49:09Z\",\"conditions\": [{\"bucket\": \"my-bucket\"},[\"starts-with\", \"$key\", \"my-new-image\"]]}"));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
|
@ -98,22 +101,22 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
|
|||
.addFormParam("AWSAccessKeyId", "identity").build();
|
||||
|
||||
public void testBundleInstanceInRegionOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class,
|
||||
String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class);
|
||||
Invokable<?, ?> method = Invokable.from(WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class,
|
||||
String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class));
|
||||
HttpRequest request = processor
|
||||
.createRequest(
|
||||
method,
|
||||
Lists.<Object> newArrayList(
|
||||
null,
|
||||
"i-e468cd8d",
|
||||
"winami",
|
||||
"my-bucket",
|
||||
"{\"expiration\": \"2008-08-30T08:49:09Z\",\"conditions\": [{\"bucket\": \"my-bucket\"},[\"starts-with\", \"$key\", \"my-new-image\"]]}",
|
||||
BundleInstanceS3StorageOptions.Builder.bucketOwnedBy("10QMXFEV71ZS32XQFTR2"));
|
||||
BundleInstanceS3StorageOptions.Builder.bucketOwnedBy("10QMXFEV71ZS32XQFTR2")));
|
||||
|
||||
request = request.getFilters().get(0).filter(request);
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
String payload = "Action=BundleInstance&Storage.S3.Prefix=winami&InstanceId=i-e468cd8d&Storage.S3.Bucket=my-bucket&Storage.S3.AWSAccessKeyId=10QMXFEV71ZS32XQFTR2&Storage.S3.UploadPolicy=eyJleHBpcmF0aW9uIjogIjIwMDgtMDgtMzBUMDg6NDk6MDlaIiwiY29uZGl0aW9ucyI6IFt7ImJ1Y2tldCI6ICJteS1idWNrZXQifSxbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAibXktbmV3LWltYWdlIl1dfQ%3D%3D&Storage.S3.UploadPolicySignature=ih/iohGe0A7y4QVRbKaq6BZShzUsmBEJEa9AdFbxM6Y%3D";
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, bundleInstanceInRegionOptions.getPayload().getRawContent().toString(),
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
@ -126,8 +129,8 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
|
|||
}
|
||||
|
||||
public void testDescribeBundleTasks() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class);
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
Invokable<?, ?> method = Invokable.from(WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
@ -142,8 +145,8 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
|
|||
}
|
||||
|
||||
public void testDescribeBundleTasksArgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
Invokable<?, ?> method = Invokable.from(WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.elasticstack;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
|
@ -51,6 +50,7 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ElasticStackAsyncClient}
|
||||
|
@ -61,8 +61,8 @@ import com.google.common.collect.Iterables;
|
|||
@Test(groups = "unit", testName = "ElasticStackAsyncClientTest")
|
||||
public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStackAsyncClient> {
|
||||
public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("listServers");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listServers"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -88,8 +88,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("listServerInfo");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listServerInfo"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -103,8 +103,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("getServerInfo", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("getServerInfo", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/uuid/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -119,9 +119,9 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testCreateAndStartServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("createAndStartServer", Server.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
BindServerToPlainTextStringTest.SERVER);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createAndStartServer", Server.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
BindServerToPlainTextStringTest.SERVER));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -136,9 +136,9 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("createServer", Server.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
BindServerToPlainTextStringTest.SERVER);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createServer", Server.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
BindServerToPlainTextStringTest.SERVER));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create/stopped HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -153,9 +153,9 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100",
|
||||
BindServerToPlainTextStringTest.SERVER);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
|
||||
BindServerToPlainTextStringTest.SERVER));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/100/set HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -170,8 +170,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("destroyServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("destroyServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/destroy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -186,8 +186,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("startServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("startServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/start HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -202,8 +202,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("stopServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("stopServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/stop HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -218,8 +218,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("shutdownServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("shutdownServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/shutdown HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -234,8 +234,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("resetServer", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("resetServer", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/reset HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -250,8 +250,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("listDrives");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listDrives"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -277,8 +277,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("listDriveInfo");
|
||||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listDriveInfo"));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -292,8 +292,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("getDriveInfo", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("getDriveInfo", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/uuid/info HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -308,9 +308,9 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("createDrive", Drive.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
new CreateDriveRequest.Builder().name("foo").size(10000l).build());
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createDrive", Drive.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
|
||||
new CreateDriveRequest.Builder().name("foo").size(10000l).build()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/create HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -325,9 +325,9 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100",
|
||||
new DriveData.Builder().name("foo").size(10000l).tags(ImmutableList.of("production", "candy")).build());
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
|
||||
new DriveData.Builder().name("foo").size(10000l).tags(ImmutableList.of("production", "candy")).build()));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/set HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -342,8 +342,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("destroyDrive", String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "uuid");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("destroyDrive", String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/uuid/destroy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -358,8 +358,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testImageDrive() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100", "200");
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "200"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -374,10 +374,10 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testImageDriveWithConversion() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class,
|
||||
ImageConversionType.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100", "200",
|
||||
ImageConversionType.GUNZIP);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class,
|
||||
ImageConversionType.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "200",
|
||||
ImageConversionType.GUNZIP));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100/gunzip HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -392,8 +392,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testReadDrive() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("readDrive", String.class, long.class, long.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100", 1024, 2048);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("readDrive", String.class, long.class, long.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", 1024, 2048));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/read/1024/2048 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/octet-stream\n");
|
||||
|
@ -407,9 +407,9 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testWriteDrive() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100",
|
||||
Payloads.newStringPayload("foo"));
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
|
||||
Payloads.newStringPayload("foo")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/write HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
@ -423,9 +423,9 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
|||
}
|
||||
|
||||
public void testWriteDriveOffset() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class, long.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "100",
|
||||
Payloads.newStringPayload("foo"), 2048);
|
||||
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class, long.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
|
||||
Payloads.newStringPayload("foo"), 2048));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/write/2048 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.s3.blobstore;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -37,6 +35,9 @@ import org.jclouds.s3.blobstore.functions.BlobToObject;
|
|||
import org.jclouds.s3.domain.S3Object;
|
||||
import org.jclouds.s3.options.PutObjectOptions;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -47,26 +48,29 @@ public class S3BlobRequestSigner implements BlobRequestSigner {
|
|||
private final BlobToObject blobToObject;
|
||||
private final BlobToHttpGetOptions blob2HttpGetOptions;
|
||||
|
||||
private final Method getMethod;
|
||||
private final Method deleteMethod;
|
||||
private final Method createMethod;
|
||||
private final Invokable<?, ?> getMethod;
|
||||
private final Invokable<?, ?> deleteMethod;
|
||||
private final Invokable<?, ?> createMethod;
|
||||
|
||||
@Inject
|
||||
public S3BlobRequestSigner(RestAnnotationProcessor.Factory processor, BlobToObject blobToObject,
|
||||
BlobToHttpGetOptions blob2HttpGetOptions) throws SecurityException, NoSuchMethodException {
|
||||
BlobToHttpGetOptions blob2HttpGetOptions) throws SecurityException, NoSuchMethodException {
|
||||
this.processor = checkNotNull(processor, "processor").declaring(S3AsyncClient.class);
|
||||
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
||||
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
|
||||
this.getMethod = S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class);
|
||||
this.deleteMethod = S3AsyncClient.class.getMethod("deleteObject", String.class, String.class);
|
||||
this.createMethod = S3AsyncClient.class.getMethod("putObject", String.class, S3Object.class,
|
||||
PutObjectOptions[].class);
|
||||
this.getMethod = Invokable.from(S3AsyncClient.class.getMethod("getObject", String.class, String.class,
|
||||
GetOptions[].class));
|
||||
this.deleteMethod = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class));
|
||||
this.createMethod = Invokable.from(S3AsyncClient.class.getMethod("putObject", String.class, S3Object.class,
|
||||
PutObjectOptions[].class));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name) {
|
||||
return cleanRequest(processor.createRequest(getMethod, container, name));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(getMethod, ImmutableList.<Object> of(container, name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +80,10 @@ public class S3BlobRequestSigner implements BlobRequestSigner {
|
|||
|
||||
@Override
|
||||
public HttpRequest signPutBlob(String container, Blob blob) {
|
||||
return cleanRequest(processor.createRequest(createMethod, container, blobToObject.apply(blob)));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(blob, "blob");
|
||||
return cleanRequest(processor.createRequest(createMethod,
|
||||
ImmutableList.<Object> of(container, blobToObject.apply(blob))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,11 +93,16 @@ public class S3BlobRequestSigner implements BlobRequestSigner {
|
|||
|
||||
@Override
|
||||
public HttpRequest signRemoveBlob(String container, String name) {
|
||||
return cleanRequest(processor.createRequest(deleteMethod, container, name));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(deleteMethod, ImmutableList.<Object> of(container, name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
|
||||
return cleanRequest(processor.createRequest(getMethod, container, name, blob2HttpGetOptions.apply(options)));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(getMethod,
|
||||
ImmutableList.of(container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options")))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,8 +78,8 @@ public class S3Utils {
|
|||
|
||||
String bucketName = null;
|
||||
|
||||
for (int i = 0; i < request.getJavaMethod().getParameterAnnotations().length; i++) {
|
||||
if (any(Arrays.asList(request.getJavaMethod().getParameterAnnotations()[i]), ANNOTATIONTYPE_BUCKET)) {
|
||||
for (int i = 0; i < request.getInvoker().getParameters().size(); i++) {
|
||||
if (any(Arrays.asList(request.getInvoker().getParameters().get(i).getAnnotations()), ANNOTATIONTYPE_BUCKET)) {
|
||||
bucketName = (String) request.getArgs().get(i);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.s3;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
@ -69,7 +67,10 @@ import org.jclouds.util.Strings2;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
|
@ -79,21 +80,21 @@ import com.google.inject.Module;
|
|||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "S3AsyncClientTest")
|
||||
public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClientTest<T> {
|
||||
public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClientTest<T> {
|
||||
|
||||
protected String url = "s3.amazonaws.com";
|
||||
|
||||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
|
||||
PutBucketOptions.class, 0).getClass());
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class,
|
||||
PutBucketOptions[].class));
|
||||
for (String region : Region.DEFAULT_S3) {
|
||||
processor.createRequest(method, region, "bucket-" + region);
|
||||
processor.createRequest(method, ImmutableList.<Object> of(region, "bucket-" + region));
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetBucketLocation() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("getBucketLocation", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://bucket." + url + "/?location HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -115,8 +116,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testGetBucketPayer() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("getBucketPayer", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getBucketPayer", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://bucket." + url + "/?requestPayment HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -130,8 +131,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testSetBucketPayerOwner() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", Payer.BUCKET_OWNER);
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", Payer.BUCKET_OWNER));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?requestPayment HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -146,8 +147,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testSetBucketPayerRequester() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", Payer.REQUESTER);
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", Payer.REQUESTER));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?requestPayment HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -162,9 +163,9 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testListBucket() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("listBucket", String.class, Array.newInstance(
|
||||
ListBucketOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("listBucket", String.class,
|
||||
ListBucketOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://bucket." + url + "/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -178,8 +179,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testBucketExists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("bucketExists", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("bucketExists", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://bucket." + url + "/?max-keys=0 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -195,18 +196,18 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testCopyObjectInvalidName() throws ArrayIndexOutOfBoundsException, SecurityException,
|
||||
IllegalArgumentException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class,
|
||||
String.class, Array.newInstance(CopyObjectOptions.class, 0).getClass());
|
||||
processor.createRequest(method, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class,
|
||||
String.class, CopyObjectOptions[].class));
|
||||
processor.createRequest(method, ImmutableList.<Object> of("sourceBucket", "sourceObject", "destinationBucket", "destinationObject"));
|
||||
|
||||
}
|
||||
|
||||
public void testCopyObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class,
|
||||
String.class, Array.newInstance(CopyObjectOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "sourceBucket", "sourceObject", "destinationbucket",
|
||||
"destinationObject");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class,
|
||||
String.class, CopyObjectOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("sourceBucket", "sourceObject", "destinationbucket",
|
||||
"destinationObject"));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://destinationbucket." + url + "/destinationObject HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: destinationbucket." + url
|
||||
|
@ -221,8 +222,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testDeleteBucketIfEmpty() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("deleteBucketIfEmpty", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("deleteBucketIfEmpty", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://bucket." + url + "/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -236,8 +237,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testDeleteObject() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("deleteObject", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "object");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://bucket." + url + "/object HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -252,8 +253,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
|
||||
public void testGetBucketACL() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
||||
Method method = S3AsyncClient.class.getMethod("getBucketACL", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getBucketACL", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://bucket." + url + "/?acl HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -268,8 +269,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
|
||||
public void testGetObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "object");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://bucket." + url + "/object HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -284,8 +285,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
|
||||
public void testGetObjectACL() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
||||
Method method = S3AsyncClient.class.getMethod("getObjectACL", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "object");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getObjectACL", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://bucket." + url + "/object?acl HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -300,8 +301,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
|
||||
public void testObjectExists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
||||
Method method = S3AsyncClient.class.getMethod("objectExists", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "object");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("objectExists", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
|
||||
|
||||
assertRequestLineEquals(request, "HEAD https://bucket." + url + "/object HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -316,8 +317,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
|
||||
public void testHeadObject() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
||||
Method method = S3AsyncClient.class.getMethod("headObject", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "object");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("headObject", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
|
||||
|
||||
assertRequestLineEquals(request, "HEAD https://bucket." + url + "/object HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -331,8 +332,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testListOwnedBuckets() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("listOwnedBuckets");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("listOwnedBuckets"));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET https://" + url + "/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: " + url + "\n");
|
||||
|
@ -346,14 +347,14 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testNewS3Object() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("newS3Object");
|
||||
assertEquals(method.getReturnType(), S3Object.class);
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("newS3Object"));
|
||||
assertEquals(method.getReturnType().getRawType(), S3Object.class);
|
||||
}
|
||||
|
||||
public void testPutBucketACL() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("putBucketACL", String.class, AccessControlList.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", AccessControlList.fromCannedAccessPolicy(
|
||||
CannedAccessPolicy.PRIVATE, "1234"));
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("putBucketACL", String.class, AccessControlList.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", AccessControlList.fromCannedAccessPolicy(
|
||||
CannedAccessPolicy.PRIVATE, "1234")));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?acl HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -373,9 +374,9 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
|
||||
public void testPutBucketDefault() throws ArrayIndexOutOfBoundsException, SecurityException,
|
||||
IllegalArgumentException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
|
||||
PutBucketOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, (String) null, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class,
|
||||
PutBucketOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null, "bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -391,10 +392,10 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
public void testPutObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
|
||||
NoSuchMethodException, IOException {
|
||||
|
||||
Method method = S3AsyncClient.class
|
||||
.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", blobToS3Object
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB));
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class
|
||||
.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", blobToS3Object
|
||||
.apply(BindBlobToMultipartFormTest.TEST_BLOB)));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -408,10 +409,10 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testPutObjectACL() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class
|
||||
.getMethod("putObjectACL", String.class, String.class, AccessControlList.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "key", AccessControlList.fromCannedAccessPolicy(
|
||||
CannedAccessPolicy.PRIVATE, "1234"));
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class
|
||||
.getMethod("putObjectACL", String.class, String.class, AccessControlList.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "key", AccessControlList.fromCannedAccessPolicy(
|
||||
CannedAccessPolicy.PRIVATE, "1234")));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/key?acl HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -430,8 +431,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testGetBucketLogging() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("getBucketLogging", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getBucketLogging", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://bucket." + url + "/?logging HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -445,8 +446,8 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testDisableBucketLogging() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("disableBucketLogging", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("disableBucketLogging", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -461,10 +462,10 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
}
|
||||
|
||||
public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("enableBucketLogging", String.class, BucketLogging.class);
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("enableBucketLogging", String.class, BucketLogging.class));
|
||||
HttpRequest request = processor
|
||||
.createRequest(method, "bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet
|
||||
.<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL))));
|
||||
.createRequest(method, ImmutableList.<Object> of("bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet
|
||||
.<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL)))));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.s3.binders;
|
|||
import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
@ -29,6 +28,9 @@ import org.jclouds.s3.S3AsyncClient;
|
|||
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindAsHostPrefixIfConfigured}
|
||||
*
|
||||
|
@ -40,8 +42,8 @@ public class BindAsHostPrefixIfConfiguredNoPathTest extends BaseS3AsyncClientTes
|
|||
|
||||
public void testBucketWithHostnameStyle() throws IOException, SecurityException, NoSuchMethodException {
|
||||
|
||||
Method method = S3AsyncClient.class.getMethod("deleteObject", String.class, String.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, "testbucket.example.com", "test.jpg");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("testbucket.example.com", "test.jpg"));
|
||||
assertRequestLineEquals(request, "DELETE https://s3.amazonaws.com/testbucket.example.com/test.jpg HTTP/1.1");
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCK
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -32,6 +31,9 @@ import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
|||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindAsHostPrefixIfConfigured}
|
||||
*
|
||||
|
@ -59,8 +61,8 @@ public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest<S3As
|
|||
request = binder.bindToRequest(request, "testbucket.example.com");
|
||||
assertEquals(request.getRequestLine(), "GET http://euc/services/Walrus/testbucket.example.com HTTP/1.1");
|
||||
|
||||
Method method = S3AsyncClient.class.getMethod("deleteObject", String.class, String.class);
|
||||
request = processor.createRequest(method, "testbucket.example.com", "test.jpg");
|
||||
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class));
|
||||
request = processor.createRequest(method, ImmutableList.<Object> of("testbucket.example.com", "test.jpg"));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://euc/services/Walrus/testbucket.example.com/test.jpg HTTP/1.1");
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ import org.jclouds.s3.options.PutBucketOptions;
|
|||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -48,8 +50,8 @@ public class FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTes
|
|||
.method("PUT")
|
||||
.endpoint("https://adriancole-blobstore113.s3.amazonaws.com/")
|
||||
.declaring(S3Client.class)
|
||||
.javaMethod(
|
||||
S3Client.class.getMethod("putBucketInRegion", String.class, String.class, PutBucketOptions[].class))
|
||||
.invoker(Invokable.from(
|
||||
S3Client.class.getMethod("putBucketInRegion", String.class, String.class, PutBucketOptions[].class)))
|
||||
.args(new Object[] { null, "bucket" }).build();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,10 @@ import org.jclouds.s3.reference.S3Headers;
|
|||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.SortedSetMultimap;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code RequestAuthorizeSignature}
|
||||
|
@ -85,8 +87,9 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3Async
|
|||
|
||||
@Test
|
||||
void testAppendBucketNameHostHeader() throws SecurityException, NoSuchMethodException {
|
||||
HttpRequest request = processor.createRequest(S3AsyncClient.class.getMethod("getBucketLocation", String.class),
|
||||
"bucket");
|
||||
HttpRequest request = processor.createRequest(
|
||||
Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class)),
|
||||
ImmutableList.<Object> of("bucket"));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
filter.appendBucketName(request, builder);
|
||||
assertEquals(builder.toString(), "/bucket");
|
||||
|
@ -101,9 +104,10 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3Async
|
|||
}
|
||||
|
||||
private GeneratedHttpRequest putBucketAcl() throws NoSuchMethodException {
|
||||
return processor.createRequest(S3AsyncClient.class.getMethod("putBucketACL", String.class,
|
||||
AccessControlList.class), "bucket", AccessControlList.fromCannedAccessPolicy(CannedAccessPolicy.PRIVATE,
|
||||
"1234"));
|
||||
return processor.createRequest(
|
||||
Invokable.from(S3AsyncClient.class.getMethod("putBucketACL", String.class, AccessControlList.class)),
|
||||
ImmutableList.<Object> of("bucket",
|
||||
AccessControlList.fromCannedAccessPolicy(CannedAccessPolicy.PRIVATE, "1234")));
|
||||
}
|
||||
|
||||
// "?acl", "?location", "?logging", "?uploads", or "?torrent"
|
||||
|
@ -117,7 +121,8 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3Async
|
|||
}
|
||||
|
||||
private GeneratedHttpRequest listOwnedBuckets() throws NoSuchMethodException {
|
||||
return processor.createRequest(S3AsyncClient.class.getMethod("listOwnedBuckets"));
|
||||
return processor.createRequest(Invokable.from(S3AsyncClient.class.getMethod("listOwnedBuckets")),
|
||||
ImmutableList.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -132,17 +137,16 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3Async
|
|||
|
||||
private HttpRequest putObject() throws NoSuchMethodException {
|
||||
S3Object object = blobToS3Object.apply(BindBlobToMultipartFormTest.TEST_BLOB);
|
||||
|
||||
object.getMetadata().getUserMetadata().put("Adrian", "foo");
|
||||
HttpRequest request = processor.createRequest(S3AsyncClient.class.getMethod("putObject", String.class,
|
||||
S3Object.class, PutObjectOptions[].class), "bucket", object);
|
||||
return request;
|
||||
return processor.createRequest(Invokable.from(S3AsyncClient.class.getMethod("putObject", String.class,
|
||||
S3Object.class, PutObjectOptions[].class)), ImmutableList.<Object> of("bucket", object));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAppendBucketNameURIHost() throws SecurityException, NoSuchMethodException {
|
||||
HttpRequest request = processor.createRequest(S3AsyncClient.class.getMethod("getBucketLocation", String.class),
|
||||
"bucket");
|
||||
HttpRequest request = processor.createRequest(
|
||||
Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class)),
|
||||
ImmutableList.<Object> of("bucket"));
|
||||
assertEquals(request.getEndpoint().getHost(), "bucket.s3.amazonaws.com");
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import static org.jclouds.crypto.Macs.asByteProcessor;
|
|||
import static org.jclouds.util.Strings2.toInputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.InvalidKeyException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -50,8 +49,10 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.io.ByteProcessor;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
/**
|
||||
|
@ -69,22 +70,21 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
|
|||
private final BlobToObject blobToObject;
|
||||
private final BlobToHttpGetOptions blob2HttpGetOptions;
|
||||
|
||||
private final Method getMethod;
|
||||
private final Method deleteMethod;
|
||||
private final Method createMethod;
|
||||
private final Invokable<?, ?> getMethod;
|
||||
private final Invokable<?, ?> deleteMethod;
|
||||
private final Invokable<?, ?> createMethod;
|
||||
|
||||
/**
|
||||
* create a signer for this subtype of swift
|
||||
*
|
||||
*
|
||||
* @param processor
|
||||
* bound to the current subclass of {@link CommonSwiftAsyncClient}
|
||||
*/
|
||||
@Inject
|
||||
protected SwiftBlobSigner(BlobToObject blobToObject, BlobToHttpGetOptions blob2HttpGetOptions, Crypto crypto,
|
||||
@TimeStamp Provider<Long> unixEpochTimestampProvider,
|
||||
@TemporaryUrlKey Supplier<String> temporaryUrlKeySupplier,
|
||||
RestAnnotationProcessor.Factory processor, Class<T> clazz)
|
||||
throws SecurityException, NoSuchMethodException {
|
||||
@TemporaryUrlKey Supplier<String> temporaryUrlKeySupplier, RestAnnotationProcessor.Factory processor,
|
||||
Class<T> clazz) throws SecurityException, NoSuchMethodException {
|
||||
this.processor = checkNotNull(processor, "processor").declaring(clazz);
|
||||
this.crypto = checkNotNull(crypto, "crypto");
|
||||
|
||||
|
@ -94,45 +94,60 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
|
|||
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
||||
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
|
||||
|
||||
this.getMethod = clazz.getMethod("getObject", String.class, String.class, GetOptions[].class);
|
||||
this.deleteMethod = clazz.getMethod("removeObject", String.class, String.class);
|
||||
this.createMethod = clazz.getMethod("putObject", String.class, SwiftObject.class);
|
||||
this.getMethod = Invokable.from(clazz.getMethod("getObject", String.class, String.class, GetOptions[].class));
|
||||
this.deleteMethod = Invokable.from(clazz.getMethod("removeObject", String.class, String.class));
|
||||
this.createMethod = Invokable.from(clazz.getMethod("putObject", String.class, SwiftObject.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name) {
|
||||
return cleanRequest(processor.createRequest(getMethod, container, name));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(getMethod, ImmutableList.<Object> of(container, name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name, long timeInSeconds) {
|
||||
HttpRequest request = processor.createRequest(getMethod, container, name);
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
HttpRequest request = processor.createRequest(getMethod, ImmutableList.<Object> of(container, name));
|
||||
return cleanRequest(signForTemporaryAccess(request, timeInSeconds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
|
||||
return cleanRequest(processor.createRequest(getMethod, container, name, blob2HttpGetOptions.apply(options)));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(getMethod,
|
||||
ImmutableList.of(container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options")))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signPutBlob(String container, Blob blob) {
|
||||
return cleanRequest(processor.createRequest(createMethod, container, blobToObject.apply(blob)));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(blob, "blob");
|
||||
return cleanRequest(processor.createRequest(createMethod,
|
||||
ImmutableList.<Object> of(container, blobToObject.apply(blob))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signPutBlob(String container, Blob blob, long timeInSeconds) {
|
||||
HttpRequest request = processor.createRequest(createMethod, container, blobToObject.apply(blob));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(blob, "blob");
|
||||
HttpRequest request = processor.createRequest(createMethod,
|
||||
ImmutableList.<Object> of(container, blobToObject.apply(blob)));
|
||||
return cleanRequest(signForTemporaryAccess(request, timeInSeconds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequest signRemoveBlob(String container, String name) {
|
||||
return cleanRequest(processor.createRequest(deleteMethod, container, name));
|
||||
checkNotNull(container, "container");
|
||||
checkNotNull(name, "name");
|
||||
return cleanRequest(processor.createRequest(deleteMethod, ImmutableList.<Object> of(container, name)));
|
||||
}
|
||||
|
||||
private HttpRequest signForTemporaryAccess(HttpRequest request, long timeInSeconds) {
|
||||
HttpRequest.Builder<?> builder = request.toBuilder().filters(ImmutableSet.<HttpRequestFilter>of());
|
||||
HttpRequest.Builder<?> builder = request.toBuilder().filters(ImmutableSet.<HttpRequestFilter> of());
|
||||
|
||||
String key = temporaryUrlKeySupplier.get();
|
||||
if (key == null) {
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.vcloud;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
@ -31,6 +30,9 @@ import org.jclouds.rest.internal.BaseAsyncClientTest;
|
|||
import org.jclouds.vcloud.xml.SupportedVersionsHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudVersionsAsyncClient}
|
||||
*
|
||||
|
@ -41,8 +43,8 @@ import org.testng.annotations.Test;
|
|||
public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest<VCloudVersionsAsyncClient> {
|
||||
|
||||
public void testVersions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudVersionsAsyncClient.class.getMethod("getSupportedVersions");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(VCloudVersionsAsyncClient.class.getMethod("getSupportedVersions"));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
@ -59,7 +60,7 @@ public class BindCloneVAppParamsToXmlPayloadTest {
|
|||
CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().description(
|
||||
"The description of the new vApp");
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().method("POST").endpoint("http://localhost/key")
|
||||
.declaring(String.class).javaMethod(String.class.getDeclaredMethod("toString")).arg(options).build();
|
||||
.declaring(String.class).invoker(Invokable.from(String.class.getDeclaredMethod("toString"))).arg(options).build();
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
|
||||
|
@ -75,7 +76,7 @@ public class BindCloneVAppParamsToXmlPayloadTest {
|
|||
CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().description(
|
||||
"The description of the new vApp");
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().method("POST").endpoint("http://localhost/key")
|
||||
.declaring(String.class).javaMethod(String.class.getDeclaredMethod("toString")).arg(options).build();
|
||||
.declaring(String.class).invoker(Invokable.from(String.class.getDeclaredMethod("toString"))).arg(options).build();
|
||||
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
|
@ -91,7 +92,7 @@ public class BindCloneVAppParamsToXmlPayloadTest {
|
|||
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml"));
|
||||
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().method("POST").endpoint("http://localhost/key")
|
||||
.declaring(String.class).javaMethod(String.class.getDeclaredMethod("toString")).build();
|
||||
.declaring(String.class).invoker(Invokable.from(String.class.getDeclaredMethod("toString"))).build();
|
||||
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.vcloud.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -31,6 +30,9 @@ import org.jclouds.vcloud.xml.CatalogHandler;
|
|||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code CatalogAsyncClient}
|
||||
*
|
||||
|
@ -42,9 +44,9 @@ import org.testng.annotations.Test;
|
|||
public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsyncClient> {
|
||||
|
||||
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CatalogAsyncClient.class.getMethod("getCatalog", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"));
|
||||
Invokable<?, ?> method = Invokable.from(CatalogAsyncClient.class.getMethod("getCatalog", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||
|
@ -58,8 +60,8 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
|
|||
}
|
||||
|
||||
public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CatalogAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "catalog");
|
||||
Invokable<?, ?> method = Invokable.from(CatalogAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||
|
@ -73,9 +75,9 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
|
|||
}
|
||||
|
||||
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CatalogAsyncClient.class.getMethod("getCatalogItem", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"));
|
||||
Invokable<?, ?> method = Invokable.from(CatalogAsyncClient.class.getMethod("getCatalogItem", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
||||
|
@ -89,9 +91,9 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
|
|||
}
|
||||
|
||||
public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CatalogAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class,
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "catalog", "item");
|
||||
Invokable<?, ?> method = Invokable.from(CatalogAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class,
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog", "item"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
||||
|
@ -106,11 +108,11 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
|
|||
|
||||
public void testAddVAppTemplateOrMediaImageToCatalogAndNameItem() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = CatalogAsyncClient.class.getMethod("addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class,
|
||||
URI.class, String.class, CatalogItemOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI.create("http://fooentity"), URI
|
||||
Invokable<?, ?> method = Invokable.from(CatalogAsyncClient.class.getMethod("addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class,
|
||||
URI.class, String.class, CatalogItemOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI.create("http://fooentity"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", CatalogItemOptions.Builder
|
||||
.description("mydescription"));
|
||||
.description("mydescription")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/catalog/1/catalogItems HTTP/1.1");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.vcloud.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -29,6 +28,9 @@ import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
|||
import org.jclouds.vcloud.xml.OrgNetworkHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code NetworkAsyncClient}
|
||||
*
|
||||
|
@ -40,9 +42,9 @@ import org.testng.annotations.Test;
|
|||
public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest<NetworkAsyncClient> {
|
||||
|
||||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NetworkAsyncClient.class.getMethod("getNetwork", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/2"));
|
||||
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("getNetwork", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/2")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
||||
|
@ -56,9 +58,9 @@ public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest<NetworkAsy
|
|||
}
|
||||
|
||||
public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = NetworkAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc", "network");
|
||||
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, String.class,
|
||||
String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "vdc", "network"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/network/1990 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.vcloud.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -31,6 +30,9 @@ import org.jclouds.vcloud.xml.OrgHandler;
|
|||
import org.jclouds.vcloud.xml.OrgListHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code OrgAsyncClient}
|
||||
*
|
||||
|
@ -42,8 +44,8 @@ import org.testng.annotations.Test;
|
|||
public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest<OrgAsyncClient> {
|
||||
|
||||
public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OrgAsyncClient.class.getMethod("listOrgs");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(OrgAsyncClient.class.getMethod("listOrgs"));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.orgList+xml\n");
|
||||
|
@ -57,9 +59,9 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest<OrgAsyncClient
|
|||
}
|
||||
|
||||
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OrgAsyncClient.class.getMethod("getOrg", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"));
|
||||
Invokable<?, ?> method = Invokable.from(OrgAsyncClient.class.getMethod("getOrg", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
||||
|
@ -73,8 +75,8 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest<OrgAsyncClient
|
|||
}
|
||||
|
||||
public void testFindOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OrgAsyncClient.class.getMethod("findOrgNamed", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org");
|
||||
Invokable<?, ?> method = Invokable.from(OrgAsyncClient.class.getMethod("findOrgNamed", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.vcloud.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -31,6 +30,9 @@ import org.jclouds.vcloud.xml.TaskHandler;
|
|||
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code TaskAsyncClient}
|
||||
*
|
||||
|
@ -42,9 +44,9 @@ import org.testng.annotations.Test;
|
|||
public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClient> {
|
||||
|
||||
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TaskAsyncClient.class.getMethod("getTasksList", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"));
|
||||
Invokable<?, ?> method = Invokable.from(TaskAsyncClient.class.getMethod("getTasksList", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
||||
|
@ -58,8 +60,8 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClie
|
|||
}
|
||||
|
||||
public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TaskAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org");
|
||||
Invokable<?, ?> method = Invokable.from(TaskAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
||||
|
@ -73,9 +75,9 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClie
|
|||
}
|
||||
|
||||
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TaskAsyncClient.class.getMethod("getTask", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
||||
Invokable<?, ?> method = Invokable.from(TaskAsyncClient.class.getMethod("getTask", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -89,9 +91,9 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClie
|
|||
}
|
||||
|
||||
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TaskAsyncClient.class.getMethod("cancelTask", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1"));
|
||||
Invokable<?, ?> method = Invokable.from(TaskAsyncClient.class.getMethod("cancelTask", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/task/1")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.vcloud.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -34,6 +33,9 @@ import org.jclouds.vcloud.xml.TaskHandler;
|
|||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VAppAsyncClient}
|
||||
*
|
||||
|
@ -45,11 +47,11 @@ import org.testng.annotations.Test;
|
|||
public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClient> {
|
||||
|
||||
public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapp");
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapp"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
|
@ -65,12 +67,12 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testCopyVAppToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions()
|
||||
.deploy().powerOn().description("The description of the new vApp"));
|
||||
.deploy().powerOn().description("The description of the new vApp")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
|
@ -86,12 +88,12 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testMoveVAppToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("moveVAppToVDCAndRename", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("moveVAppToVDCAndRename", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions()
|
||||
.deploy().powerOn().description("The description of the new vApp"));
|
||||
.deploy().powerOn().description("The description of the new vApp")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
|
@ -107,9 +109,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("deployVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("deployVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -124,9 +126,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testDeployAndPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("deployAndPowerOnVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("deployAndPowerOnVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -141,9 +143,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("getVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("getVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
|
@ -157,9 +159,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testRebootVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("rebootVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("rebootVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1");
|
||||
|
@ -174,9 +176,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("undeployVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("undeployVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
||||
|
@ -192,9 +194,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testUndeployAndSaveStateOfVAppSaveState() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("undeployAndSaveStateOfVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("undeployAndSaveStateOfVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
||||
|
@ -211,9 +213,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("deleteVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("deleteVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -227,9 +229,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("powerOnVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("powerOnVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
|
||||
|
@ -244,9 +246,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testPowerOffVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("powerOffVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("powerOffVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
|
||||
|
@ -261,9 +263,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testResetVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("resetVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("resetVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
|
||||
|
@ -278,9 +280,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testSuspendVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("suspendVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("suspendVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
|
||||
|
@ -295,9 +297,9 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
|
|||
}
|
||||
|
||||
public void testShutdownVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppAsyncClient.class.getMethod("shutdownVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("shutdownVApp", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.vcloud.features;
|
|||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -40,6 +39,9 @@ import org.jclouds.vcloud.xml.VAppHandler;
|
|||
import org.jclouds.vcloud.xml.VAppTemplateHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VAppTemplateAsyncClient}
|
||||
*
|
||||
|
@ -52,13 +54,13 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
|
||||
public void testCreateVAppInVDCByInstantiatingTemplate() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class,
|
||||
URI.class, URI.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "my-vapp", URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class,
|
||||
URI.class, URI.class, InstantiateVAppTemplateOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("my-vapp", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"),
|
||||
addNetworkConfig(new NetworkConfig("aloha", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED)));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED))));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
|
@ -77,19 +79,19 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testCreateVAppInVDCByInstantiatingTemplateOptionsIllegalName() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class,
|
||||
URI.class, URI.class, InstantiateVAppTemplateOptions[].class);
|
||||
processor.createRequest(method, "CentOS 01", URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class,
|
||||
URI.class, URI.class, InstantiateVAppTemplateOptions[].class));
|
||||
processor.createRequest(method, ImmutableList.<Object> of("CentOS 01", URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), addNetworkConfig(new NetworkConfig(null,
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null)));
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null))));
|
||||
}
|
||||
|
||||
public void testcopyVAppTemplateToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class,
|
||||
String.class, CloneVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class,
|
||||
String.class, CloneVAppTemplateOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapptemplate");
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapptemplate"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
|
||||
|
@ -105,12 +107,12 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
}
|
||||
|
||||
public void testcopyVAppTemplateToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class,
|
||||
String.class, CloneVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class,
|
||||
String.class, CloneVAppTemplateOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server",
|
||||
new CloneVAppTemplateOptions().description("The description of the new vAppTemplate"));
|
||||
new CloneVAppTemplateOptions().description("The description of the new vAppTemplate")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
|
||||
|
@ -126,12 +128,12 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
}
|
||||
|
||||
public void testmoveVAppTemplateToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("moveVAppTemplateToVDCAndRename", URI.class, URI.class,
|
||||
String.class, CloneVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("moveVAppTemplateToVDCAndRename", URI.class, URI.class,
|
||||
String.class, CloneVAppTemplateOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server",
|
||||
new CloneVAppTemplateOptions().description("The description of the new vAppTemplate"));
|
||||
new CloneVAppTemplateOptions().description("The description of the new vAppTemplate")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
|
||||
|
@ -147,11 +149,11 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
}
|
||||
|
||||
public void testcaptureVAppAsTemplateInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class,
|
||||
URI.class, CaptureVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class,
|
||||
URI.class, CaptureVAppOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
|
||||
|
@ -168,12 +170,12 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
}
|
||||
|
||||
public void testcaptureVAppAsTemplateInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class,
|
||||
URI.class, CaptureVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class,
|
||||
URI.class, CaptureVAppOptions[].class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), new CaptureVAppOptions()
|
||||
.withDescription("The description of the new vApp Template"));
|
||||
.withDescription("The description of the new vApp Template")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
|
||||
|
@ -189,9 +191,9 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
}
|
||||
|
||||
public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class,
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "catalog", "template");
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class,
|
||||
String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog", "template"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
||||
|
@ -205,9 +207,9 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
}
|
||||
|
||||
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("getVAppTemplate", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("getVAppTemplate", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
||||
|
@ -221,9 +223,9 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
|
|||
}
|
||||
|
||||
public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VAppTemplateAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
|
||||
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: text/xml\n");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.vcloud.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
@ -30,6 +29,10 @@ import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
|||
import org.jclouds.vcloud.xml.VDCHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VDCAsyncClient}
|
||||
*
|
||||
|
@ -42,19 +45,19 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient
|
|||
|
||||
@Test(expectedExceptions = NoSuchElementException.class)
|
||||
public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
||||
processor.createRequest(method, "org", "vdc1");
|
||||
Invokable<?, ?> method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class));
|
||||
processor.createRequest(method, ImmutableList.<Object> of("org", "vdc1"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NoSuchElementException.class)
|
||||
public void testFindVDCInOrgNamedBadOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
||||
processor.createRequest(method, "org1", "vdc");
|
||||
Invokable<?, ?> method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class));
|
||||
processor.createRequest(method, ImmutableList.<Object> of("org1", "vdc"));
|
||||
}
|
||||
|
||||
public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "vdc");
|
||||
Invokable<?, ?> method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "vdc"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
|
@ -68,8 +71,8 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient
|
|||
}
|
||||
|
||||
public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, new Object[] { null, null });
|
||||
Invokable<?, ?> method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class));
|
||||
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, null));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
|
@ -83,9 +86,9 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient
|
|||
}
|
||||
|
||||
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VDCAsyncClient.class.getMethod("getVDC", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VDCAsyncClient.class.getMethod("getVDC", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.vcloud.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
|
@ -36,6 +35,9 @@ import org.jclouds.vcloud.xml.VmHandler;
|
|||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VmAsyncClient}
|
||||
*
|
||||
|
@ -47,9 +49,9 @@ import org.testng.annotations.Test;
|
|||
public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient> {
|
||||
|
||||
public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("getScreenThumbnailForVm", URI.class);
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("getScreenThumbnailForVm", URI.class));
|
||||
HttpRequest request = processor
|
||||
.createRequest(method, URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"));
|
||||
.createRequest(method, ImmutableList.<Object> of(URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://vcloud.example.com/api/v1.0/vApp/vm-12/screen HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: image/png\n");
|
||||
|
@ -64,13 +66,13 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
|
||||
@Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=402")
|
||||
public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("updateGuestCustomizationOfVm", GuestCustomizationSection.class,
|
||||
URI.class);
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("updateGuestCustomizationOfVm", GuestCustomizationSection.class,
|
||||
URI.class));
|
||||
GuestCustomizationSection guest = new GuestCustomizationSection(URI
|
||||
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection"));
|
||||
guest.setCustomizationScript("cat > /tmp/foo.txt<<EOF\nI love candy\nEOF");
|
||||
HttpRequest request = processor.createRequest(method, guest, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(guest, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection HTTP/1.1");
|
||||
|
@ -86,9 +88,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testUpdateCPUCountOfVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("updateCPUCountOfVm", int.class, URI.class);
|
||||
HttpRequest request = processor.createRequest(method, 2, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("updateCPUCountOfVm", int.class, URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/cpu HTTP/1.1");
|
||||
|
@ -104,9 +106,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testUpdateMemoryMBOfVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("updateMemoryMBOfVm", int.class, URI.class);
|
||||
HttpRequest request = processor.createRequest(method, 512, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("updateMemoryMBOfVm", int.class, URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(512, URI
|
||||
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/memory HTTP/1.1");
|
||||
|
@ -122,9 +124,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testDeployVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("deployVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("deployVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -139,9 +141,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testDeployAndPowerOnVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("deployAndPowerOnVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("deployAndPowerOnVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -156,9 +158,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testGetVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("getVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vm/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("getVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vm/1")));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vm/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vm+xml\n");
|
||||
|
@ -172,9 +174,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testRebootVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("rebootVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("rebootVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1");
|
||||
|
@ -189,9 +191,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testUndeployVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("undeployVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("undeployVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
||||
|
@ -207,9 +209,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testUndeployAndSaveStateOfVmSaveState() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("undeployAndSaveStateOfVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("undeployAndSaveStateOfVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
|
||||
|
@ -226,9 +228,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testPowerOnVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("powerOnVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("powerOnVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
|
||||
|
@ -243,9 +245,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testPowerOffVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("powerOffVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("powerOffVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
|
||||
|
@ -260,9 +262,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testResetVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("resetVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("resetVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
|
||||
|
@ -277,9 +279,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testSuspendVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("suspendVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("suspendVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
|
||||
|
@ -294,9 +296,9 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
|
|||
}
|
||||
|
||||
public void testShutdownVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VmAsyncClient.class.getMethod("shutdownVm", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"));
|
||||
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("shutdownVm", URI.class));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.vcloud.internal;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
|
@ -37,6 +36,8 @@ import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
@ -51,8 +52,8 @@ import com.google.inject.Provides;
|
|||
public class VCloudLoginAsyncClientTest extends BaseAsyncClientTest<VCloudLoginAsyncClient> {
|
||||
|
||||
public void testLogin() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudLoginAsyncClient.class.getMethod("login");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(VCloudLoginAsyncClient.class.getMethod("login"));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.orgList+xml\n");
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.openstack.internal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||
|
@ -31,6 +30,9 @@ import org.jclouds.rest.AnonymousRestApiMetadata;
|
|||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code OpenStackAuthAsyncClient}
|
||||
*
|
||||
|
@ -41,8 +43,8 @@ import org.testng.annotations.Test;
|
|||
public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest<OpenStackAuthAsyncClient> {
|
||||
|
||||
public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OpenStackAuthAsyncClient.class.getMethod("authenticate", String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "foo", "bar");
|
||||
Invokable<?, ?> method = Invokable.from(OpenStackAuthAsyncClient.class.getMethod("authenticate", String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("foo", "bar"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\nHost: localhost:8080\nX-Auth-Key: bar\nX-Auth-User: foo\n");
|
||||
|
@ -55,8 +57,8 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest<OpenStackA
|
|||
}
|
||||
|
||||
public void testAuthenticateStorage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = OpenStackAuthAsyncClient.class.getMethod("authenticateStorage", String.class, String.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, "foo", "bar");
|
||||
Invokable<?, ?> method = Invokable.from(OpenStackAuthAsyncClient.class.getMethod("authenticateStorage", String.class, String.class));
|
||||
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("foo", "bar"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\nHost: localhost:8080\nX-Storage-Pass: bar\nX-Storage-User: foo\n");
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.jclouds.util.Strings2;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
@ -59,7 +60,7 @@ public class BindCloneVAppParamsToXmlPayloadTest {
|
|||
CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().withDescription(
|
||||
"The description of the new vApp");
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().method("POST").endpoint("http://localhost/key")
|
||||
.declaring(String.class).javaMethod(String.class.getDeclaredMethod("toString")).arg(options).build();
|
||||
.declaring(String.class).invoker(Invokable.from(String.class.getDeclaredMethod("toString"))).arg(options).build();
|
||||
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
|
@ -74,7 +75,7 @@ public class BindCloneVAppParamsToXmlPayloadTest {
|
|||
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml"));
|
||||
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().method("POST").endpoint("http://localhost/key")
|
||||
.declaring(String.class).javaMethod(String.class.getDeclaredMethod("toString")).build();
|
||||
.declaring(String.class).invoker(Invokable.from(String.class.getDeclaredMethod("toString"))).build();
|
||||
|
||||
BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.trmk.vcloud_0_8.internal;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
|
@ -37,6 +36,8 @@ import org.jclouds.trmk.vcloud_0_8.functions.ParseLoginResponseFromHeaders;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
@ -52,8 +53,8 @@ import com.google.inject.Provides;
|
|||
public class TerremarkVCloudLoginAsyncClientTest extends BaseAsyncClientTest<TerremarkVCloudLoginAsyncClient> {
|
||||
|
||||
public void testLogin() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudLoginAsyncClient.class.getMethod("login");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(TerremarkVCloudLoginAsyncClient.class.getMethod("login"));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.orgList+xml\n");
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.trmk.vcloud_0_8.internal;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
@ -31,6 +30,9 @@ import org.jclouds.rest.internal.BaseAsyncClientTest;
|
|||
import org.jclouds.trmk.vcloud_0_8.xml.SupportedVersionsHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudVersionsAsyncClient}
|
||||
*
|
||||
|
@ -41,8 +43,8 @@ import org.testng.annotations.Test;
|
|||
public class TerremarkVCloudVersionsAsyncClientTest extends BaseAsyncClientTest<TerremarkVCloudVersionsAsyncClient> {
|
||||
|
||||
public void testVersions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudVersionsAsyncClient.class.getMethod("getSupportedVersions");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(TerremarkVCloudVersionsAsyncClient.class.getMethod("getSupportedVersions"));
|
||||
HttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -36,6 +37,7 @@ import javax.inject.Named;
|
|||
import org.jclouds.internal.ClassInvokerArgs;
|
||||
import org.jclouds.internal.ClassInvokerArgsAndReturnVal;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.reflect.AbstractInvocationHandler;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.util.Optionals2;
|
||||
import org.jclouds.util.Throwables2;
|
||||
|
@ -47,7 +49,7 @@ import com.google.common.base.Throwables;
|
|||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.AbstractInvocationHandler;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.inject.ProvisionException;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
@ -77,13 +79,14 @@ public final class SyncProxy extends AbstractInvocationHandler {
|
|||
private final Function<ClassInvokerArgsAndReturnVal, Optional<Object>> optionalConverter;
|
||||
private final Object delegate;
|
||||
private final Class<?> declaring;
|
||||
private final Map<Method, Method> methodMap;
|
||||
private final Map<Method, Method> syncMethodMap;
|
||||
private final Map<Method, Optional<Long>> timeoutMap;
|
||||
private final Map<Invokable<?, ?>, Invokable<Object, ListenableFuture<?>>> methodMap;
|
||||
private final Map<Invokable<?, ?>, Invokable<Object, ?>> syncMethodMap;
|
||||
private final Map<Invokable<?, ?>, Optional<Long>> timeoutMap;
|
||||
private final LoadingCache<ClassInvokerArgs, Object> delegateMap;
|
||||
private final Map<Class<?>, Class<?>> sync2Async;
|
||||
private static final Set<Method> objectMethods = ImmutableSet.copyOf(Object.class.getMethods());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Inject
|
||||
@VisibleForTesting
|
||||
SyncProxy(Function<ClassInvokerArgsAndReturnVal, Optional<Object>> optionalConverter,
|
||||
|
@ -96,8 +99,8 @@ public final class SyncProxy extends AbstractInvocationHandler {
|
|||
this.declaring = declaring;
|
||||
this.sync2Async = ImmutableMap.copyOf(sync2Async);
|
||||
|
||||
ImmutableMap.Builder<Method, Method> methodMapBuilder = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<Method, Method> syncMethodMapBuilder = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<Invokable<?, ?>, Invokable<Object, ListenableFuture<?>>> methodMapBuilder = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<Invokable<?, ?>, Invokable<Object, ?>> syncMethodMapBuilder = ImmutableMap.builder();
|
||||
|
||||
for (Method method : declaring.getMethods()) {
|
||||
if (!objectMethods.contains(method)) {
|
||||
|
@ -106,17 +109,17 @@ public final class SyncProxy extends AbstractInvocationHandler {
|
|||
throw new IllegalArgumentException(String.format(
|
||||
"method %s has different typed exceptions than delegated method %s", method, delegatedMethod));
|
||||
if (delegatedMethod.getReturnType().isAssignableFrom(ListenableFuture.class)) {
|
||||
methodMapBuilder.put(method, delegatedMethod);
|
||||
methodMapBuilder.put(Invokable.from(method), Invokable.class.cast(Invokable.from(delegatedMethod)));
|
||||
} else {
|
||||
syncMethodMapBuilder.put(method, delegatedMethod);
|
||||
syncMethodMapBuilder.put(Invokable.from(method), Invokable.class.cast(Invokable.from(delegatedMethod)));
|
||||
}
|
||||
}
|
||||
}
|
||||
methodMap = methodMapBuilder.build();
|
||||
syncMethodMap = syncMethodMapBuilder.build();
|
||||
|
||||
ImmutableMap.Builder<Method, Optional<Long>> timeoutMapBuilder = ImmutableMap.builder();
|
||||
for (Method method : methodMap.keySet()) {
|
||||
ImmutableMap.Builder<Invokable<?, ?>, Optional<Long>> timeoutMapBuilder = ImmutableMap.builder();
|
||||
for (Invokable<?, ?> method : methodMap.keySet()) {
|
||||
timeoutMapBuilder.put(method, timeoutInNanos(method, timeouts));
|
||||
}
|
||||
timeoutMap = timeoutMapBuilder.build();
|
||||
|
@ -127,7 +130,7 @@ public final class SyncProxy extends AbstractInvocationHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Object handleInvocation(Object o, Method method, Object[] args) throws Exception {
|
||||
protected Object handleInvocation(Object proxy, Invokable<?, ?> method, List<Object> args) throws Throwable {
|
||||
if (method.isAnnotationPresent(Delegate.class)) {
|
||||
Class<?> syncClass = Optionals2.returnTypeOrTypeOfOptional(method);
|
||||
// get the return type of the asynchronous class associated with this client
|
||||
|
@ -148,16 +151,16 @@ public final class SyncProxy extends AbstractInvocationHandler {
|
|||
return returnVal;
|
||||
} else if (syncMethodMap.containsKey(method)) {
|
||||
try {
|
||||
return syncMethodMap.get(method).invoke(delegate, args);
|
||||
return syncMethodMap.get(method).invoke(delegate, args.toArray());
|
||||
} catch (InvocationTargetException e) {
|
||||
throw Throwables.propagate(e.getCause());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Optional<Long> timeoutNanos = timeoutMap.get(method);
|
||||
Method asyncMethod = methodMap.get(method);
|
||||
Invokable<Object, ListenableFuture<?>> asyncMethod = methodMap.get(method);
|
||||
String name = asyncMethod.getDeclaringClass().getSimpleName() + "." + asyncMethod.getName();
|
||||
ListenableFuture<?> future = ((ListenableFuture<?>) asyncMethod.invoke(delegate, args));
|
||||
ListenableFuture<?> future = asyncMethod.invoke(delegate, args.toArray());
|
||||
if (timeoutNanos.isPresent()) {
|
||||
logger.debug(">> blocking on %s for %s", name, timeoutNanos);
|
||||
return future.get(timeoutNanos.get(), TimeUnit.NANOSECONDS);
|
||||
|
@ -175,7 +178,7 @@ public final class SyncProxy extends AbstractInvocationHandler {
|
|||
}
|
||||
|
||||
// override timeout by values configured in properties(in ms)
|
||||
private Optional<Long> timeoutInNanos(Method method, Map<String, Long> timeouts) {
|
||||
private Optional<Long> timeoutInNanos(Invokable<?, ?> method, Map<String, Long> timeouts) {
|
||||
String className = declaring.getSimpleName();
|
||||
Optional<Long> timeoutMillis = fromNullable(timeouts.get(className + "." + method.getName()))
|
||||
.or(fromNullable(timeouts.get(className)))
|
||||
|
|
|
@ -133,7 +133,7 @@ public class HttpCommand {
|
|||
public String toString() {
|
||||
if (request instanceof GeneratedHttpRequest)
|
||||
return String.format("[method=%s.%s, request=%s]", GeneratedHttpRequest.class.cast(request).getDeclaring()
|
||||
.getSimpleName(), GeneratedHttpRequest.class.cast(request).getJavaMethod().getName(), request
|
||||
.getSimpleName(), GeneratedHttpRequest.class.cast(request).getInvoker().getName(), request
|
||||
.getRequestLine());
|
||||
else
|
||||
return "[request=" + request.getRequestLine() + "]";
|
||||
|
|
|
@ -21,13 +21,11 @@ package org.jclouds.internal;
|
|||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
|
@ -71,22 +69,6 @@ public class ClassInvokerArgs {
|
|||
this.invoker = invoker;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ClassInvokerArgs#getInvoker()
|
||||
*/
|
||||
@Deprecated
|
||||
public B invoker(Method method) {
|
||||
return invoker(Invokable.from(method));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ClassInvokerArgs#getArgs()
|
||||
*/
|
||||
@Deprecated
|
||||
public B args(Object[] args) {
|
||||
return args(args == null ? Lists.newArrayList(new Object[] { null }) : Lists.newArrayList(args));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ClassInvokerArgs#getArgs()
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.reflect;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Like {@link com.google.common.reflect.AbstractInvocationHandler}, except you process {@link Invokable} and
|
||||
* {@link List} as opposed to {@link Method} and arg arrays.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @since 1.6
|
||||
*/
|
||||
@Beta
|
||||
public abstract class AbstractInvocationHandler extends com.google.common.reflect.AbstractInvocationHandler {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* note that this can contain nulls, as method arguments can be null.
|
||||
* @see com.google.common.reflect.AbstractInvocationHandler#invoke(Object, Method, Object[])
|
||||
*/
|
||||
protected abstract Object handleInvocation(Object proxy, Invokable<?, ?> method, List<Object> args) throws Throwable;
|
||||
|
||||
@Override
|
||||
protected Object handleInvocation(Object proxy, Method method, Object[] argv) throws Throwable {
|
||||
List<Object> args = Arrays.asList(argv);
|
||||
if (Iterables.all(args, Predicates.notNull()))
|
||||
args = ImmutableList.copyOf(args);
|
||||
else
|
||||
args = Collections.unmodifiableList(args);
|
||||
return handleInvocation(proxy, Invokable.from(method), args);
|
||||
}
|
||||
}
|
|
@ -21,12 +21,10 @@ package org.jclouds.rest;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Collections2.filter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.predicates.Validator;
|
||||
import org.jclouds.rest.annotations.ParamValidators;
|
||||
|
||||
|
@ -72,12 +70,6 @@ public class InputParamValidator {
|
|||
* @throws IllegalStateException
|
||||
* if validation failed
|
||||
*/
|
||||
@Deprecated
|
||||
public void validateMethodParametersOrThrow(Method method, @Nullable Object... args) {
|
||||
validateMethodParametersOrThrow(Invokable.from(checkNotNull(method, "method")),
|
||||
Lists.newArrayList(args));
|
||||
}
|
||||
|
||||
public void validateMethodParametersOrThrow(Invokable<?, ?> method, List<Object> args) {
|
||||
try {
|
||||
performMethodValidation(checkNotNull(method, "method"), args);
|
||||
|
|
|
@ -44,9 +44,9 @@ public class BindMapToStringPayload implements MapBinder {
|
|||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
|
||||
checkNotNull(postParams, "postParams");
|
||||
GeneratedHttpRequest r = GeneratedHttpRequest.class.cast(checkNotNull(request, "request"));
|
||||
checkArgument(r.getJavaMethod().isAnnotationPresent(Payload.class),
|
||||
"method %s must have @Payload annotation to use this binder", r.getJavaMethod());
|
||||
String payload = r.getJavaMethod().getAnnotation(Payload.class).value();
|
||||
checkArgument(r.getInvoker().isAnnotationPresent(Payload.class),
|
||||
"method %s must have @Payload annotation to use this binder", r.getInvoker());
|
||||
String payload = r.getInvoker().getAnnotation(Payload.class).value();
|
||||
if (postParams.size() > 0) {
|
||||
payload = urlDecode(expand(payload, postParams));
|
||||
}
|
||||
|
|
|
@ -22,9 +22,6 @@ import static com.google.common.base.Functions.compose;
|
|||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.collect.Iterables.any;
|
||||
import static com.google.common.collect.Iterables.find;
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.util.concurrent.Callables.returning;
|
||||
import static com.google.common.util.concurrent.Futures.immediateFailedFuture;
|
||||
import static com.google.common.util.concurrent.Futures.transform;
|
||||
import static com.google.common.util.concurrent.Futures.withFallback;
|
||||
|
@ -80,6 +77,7 @@ import org.jclouds.internal.ClassInvokerArgs;
|
|||
import org.jclouds.internal.ClassInvokerArgsAndReturnVal;
|
||||
import org.jclouds.json.internal.GsonWrapper;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.reflect.AbstractInvocationHandler;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.InvocationContext;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
@ -91,20 +89,21 @@ import org.jclouds.rest.annotations.SelectJson;
|
|||
import org.jclouds.rest.annotations.Transform;
|
||||
import org.jclouds.rest.annotations.Unwrap;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor.InvokerKey;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.AbstractInvocationHandler;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.common.reflect.Parameter;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
@ -141,6 +140,7 @@ import com.google.inject.assistedinject.Assisted;
|
|||
*/
|
||||
@Singleton
|
||||
public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
||||
|
||||
public static interface Factory {
|
||||
Declaring declaring(Class<?> declaring);
|
||||
|
||||
|
@ -180,38 +180,52 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
private final RestAnnotationProcessor annotationProcessor;
|
||||
private final ParseSax.Factory parserFactory;
|
||||
private final Class<?> declaring;
|
||||
|
||||
private static final LoadingCache<Class<?>, Set<Integer>> delegationMapCache = CacheBuilder.newBuilder().build(
|
||||
new CacheLoader<Class<?>, Set<Integer>>() {
|
||||
public Set<Integer> load(Class<?> declaring) throws ExecutionException {
|
||||
FluentIterable<Invokable<?, ?>> methodsToProcess = FluentIterable
|
||||
.from(ImmutableSet.copyOf(declaring.getMethods()))
|
||||
.filter(Predicates.not(Predicates.in(ImmutableSet.copyOf(Object.class.getMethods()))))
|
||||
.transform(new Function<Method, Invokable<?, ?>>() {
|
||||
public Invokable<?, ?> apply(Method in) {
|
||||
return Invokable.from(in);
|
||||
}
|
||||
}).filter(new Predicate<Invokable<?, ?>>() {
|
||||
public boolean apply(Invokable<?, ?> in) {
|
||||
return in.isAnnotationPresent(Path.class) || tryFindHttpMethod(in).isPresent()
|
||||
|| any(in.getParameters(), new Predicate<Parameter>(){
|
||||
public boolean apply(Parameter in) {
|
||||
return in.getType().getRawType().isAssignableFrom(HttpRequest.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).filter(new Predicate<Invokable<?, ?>>() {
|
||||
public boolean apply(Invokable<?, ?> in) {
|
||||
return in.getReturnType().getRawType().isAssignableFrom(ListenableFuture.class);
|
||||
}
|
||||
|
||||
private static final LoadingCache<Class<?>, Cache<InvokerKey, Invokable<?, ?>>> delegationMapCache = CacheBuilder
|
||||
.newBuilder().build(new CacheLoader<Class<?>, Cache<InvokerKey, Invokable<?, ?>>>() {
|
||||
public Cache<InvokerKey, Invokable<?, ?>> load(Class<?> declaring) throws ExecutionException {
|
||||
Cache<InvokerKey, Invokable<?, ?>> delegationMap = CacheBuilder.newBuilder()
|
||||
.<InvokerKey, Invokable<?, ?>> build();
|
||||
for (Method method : difference(ImmutableSet.copyOf(declaring.getMethods()),
|
||||
ImmutableSet.copyOf(Object.class.getMethods()))) {
|
||||
Invokable<?, ?> invoker = Invokable.from(method);
|
||||
if (isHttpMethod(invoker) || method.isAnnotationPresent(Delegate.class)) {
|
||||
delegationMap.get(new InvokerKey(invoker), returning(invoker));
|
||||
} else if (!method.getDeclaringClass().equals(declaring)) { // potentially overridden
|
||||
} else if (method.isAnnotationPresent(Provides.class)) {
|
||||
}
|
||||
}
|
||||
return delegationMap;
|
||||
});
|
||||
return Maps.uniqueIndex(methodsToProcess, HashSignatureExceptReturnVal.INSTANCE).keySet();
|
||||
}
|
||||
});
|
||||
|
||||
private Invokable<?, ?> getDelegateOrNull(Invokable<?, ?> in) {
|
||||
return delegationMapCache.getUnchecked(declaring).getIfPresent(new InvokerKey(in));
|
||||
private static enum HashSignatureExceptReturnVal implements Function<Invokable<?, ?>, Integer> {
|
||||
INSTANCE;
|
||||
public Integer apply(Invokable<?, ?> in) {
|
||||
int parametersTypeHashCode = hashParameterTypes(in);
|
||||
return Objects.hashCode(in.getDeclaringClass(), in.getName(), parametersTypeHashCode);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isHttpMethod(Invokable<?, ?> invoker) {
|
||||
return invoker.isAnnotationPresent(Path.class) || tryFindHttpMethod(invoker).isPresent()
|
||||
|| any(invoker.getParameters(), new Predicate<Parameter>() {
|
||||
public boolean apply(Parameter in) {
|
||||
return in.getType().isAssignableFrom(HttpRequest.class);
|
||||
}
|
||||
});
|
||||
private static int hashParameterTypes(Invokable<?, ?> in) {
|
||||
int parametersTypeHashCode = 0;
|
||||
for (Parameter param : in.getParameters())
|
||||
parametersTypeHashCode += param.getType().hashCode();
|
||||
return parametersTypeHashCode;
|
||||
}
|
||||
|
||||
|
||||
private AsyncRestClientProxy(Injector injector,
|
||||
Function<ClassInvokerArgsAndReturnVal, Optional<Object>> optionalConverter, HttpCommandExecutorService http,
|
||||
ExecutorService userThreads, LoadingCache<ClassInvokerArgs, Object> delegateMap,
|
||||
|
@ -236,12 +250,12 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
};
|
||||
|
||||
@Override
|
||||
protected Object handleInvocation(Object proxy, Method method, Object[] args) throws ExecutionException {
|
||||
protected Object handleInvocation(Object proxy, Invokable<?, ?> method, List<Object> args) throws Throwable {
|
||||
if (method.isAnnotationPresent(Provides.class)) {
|
||||
return lookupValueFromGuice(method);
|
||||
} else if (method.isAnnotationPresent(Delegate.class)) {
|
||||
return propagateContextToDelegate(method, args);
|
||||
} else if (isRestCall(method)) {
|
||||
} else if (isAsyncOrDelegate(method)) {
|
||||
return createListenableFutureForHttpRequestMappedToMethodAndArgs(method, args);
|
||||
} else {
|
||||
throw new RuntimeException(String.format("Method is not annotated as either http or provider method: %s",
|
||||
|
@ -249,12 +263,11 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isRestCall(Method method) {
|
||||
return getDelegateOrNull(Invokable.from(method)) != null
|
||||
&& ListenableFuture.class.isAssignableFrom(method.getReturnType());
|
||||
private boolean isAsyncOrDelegate(Invokable<?, ?> method) {
|
||||
return delegationMapCache.getUnchecked(declaring).contains(HashSignatureExceptReturnVal.INSTANCE.apply(method));
|
||||
}
|
||||
|
||||
private Object propagateContextToDelegate(Method method, Object[] args) throws ExecutionException {
|
||||
private Object propagateContextToDelegate(Invokable<?, ?> method, List<Object> args) throws ExecutionException {
|
||||
Class<?> asyncClass = returnTypeOrTypeOfOptional(method);
|
||||
ClassInvokerArgs cma = ClassInvokerArgs.builder().clazz(asyncClass).invoker(method).args(args).build();
|
||||
Object returnVal = delegateMap.get(cma);
|
||||
|
@ -266,9 +279,9 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
return returnVal;
|
||||
}
|
||||
|
||||
private Object lookupValueFromGuice(Method method) {
|
||||
private Object lookupValueFromGuice(Invokable<?, ?> method) {
|
||||
try {
|
||||
Type genericReturnType = method.getGenericReturnType();
|
||||
Type genericReturnType = method.getReturnType().getType();
|
||||
try {
|
||||
Annotation qualifier = find(ImmutableList.copyOf(method.getAnnotations()), isQualifierPresent);
|
||||
return getInstanceOfTypeWithQualifier(genericReturnType, qualifier);
|
||||
|
@ -320,15 +333,9 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
return injector.getInstance(Key.get(genericReturnType, qualifier));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static Function<HttpResponse, ?> createResponseParser(ParseSax.Factory parserFactory, Injector injector,
|
||||
Method method, HttpRequest request) {
|
||||
return createResponseParser(parserFactory, injector, Invokable.from(method), request);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@VisibleForTesting
|
||||
private static Function<HttpResponse, ?> createResponseParser(ParseSax.Factory parserFactory, Injector injector,
|
||||
static Function<HttpResponse, ?> createResponseParser(ParseSax.Factory parserFactory, Injector injector,
|
||||
Invokable<?, ?> method, HttpRequest request) {
|
||||
Function<HttpResponse, ?> transformer;
|
||||
Class<? extends HandlerWithResult<?>> handler = getSaxResponseParserClassOrNull(method);
|
||||
|
@ -377,14 +384,8 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
return transformer;
|
||||
}
|
||||
|
||||
private ListenableFuture<?> createListenableFutureForHttpRequestMappedToMethodAndArgs(Method method, Object[] args)
|
||||
throws ExecutionException {
|
||||
return createListenableFutureForHttpRequestMappedToMethodAndArgs(method, Invokable.from(method),
|
||||
args == null ? newArrayList(new Object[] { null }) : newArrayList(args));
|
||||
}
|
||||
|
||||
private ListenableFuture<?> createListenableFutureForHttpRequestMappedToMethodAndArgs(Method method,
|
||||
Invokable<?, ?> invoker, List<Object> args) throws ExecutionException {
|
||||
private ListenableFuture<?> createListenableFutureForHttpRequestMappedToMethodAndArgs(Invokable<?, ?> invoker,
|
||||
List<Object> args) {
|
||||
String name = invoker.getDeclaringClass().getSimpleName() + "." + invoker.getName();
|
||||
logger.trace(">> converting %s", name);
|
||||
FutureFallback<?> fallback = fallbacks.getUnchecked(invoker);
|
||||
|
@ -394,7 +395,7 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
}
|
||||
ListenableFuture<?> result;
|
||||
try {
|
||||
GeneratedHttpRequest request = annotationProcessor.createRequest(method, invoker, newArrayList(args));
|
||||
GeneratedHttpRequest request = annotationProcessor.createRequest(invoker, args);
|
||||
if (fallback instanceof InvocationContext) {
|
||||
InvocationContext.class.cast(fallback).setContext(request);
|
||||
}
|
||||
|
@ -457,13 +458,9 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
private static final long serialVersionUID = 1L;
|
||||
};
|
||||
|
||||
@Deprecated
|
||||
static Key<? extends Function<HttpResponse, ?>> getParserOrThrowException(Method method) {
|
||||
return getParserOrThrowException(Invokable.from(method));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Key<? extends Function<HttpResponse, ?>> getParserOrThrowException(Invokable<?, ?> method) {
|
||||
@VisibleForTesting
|
||||
static Key<? extends Function<HttpResponse, ?>> getParserOrThrowException(Invokable<?, ?> method) {
|
||||
|
||||
ResponseParser annotation = method.getAnnotation(ResponseParser.class);
|
||||
if (annotation == null) {
|
||||
|
@ -478,9 +475,9 @@ public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
|||
} else if (method.getReturnType().equals(HttpResponse.class)
|
||||
|| method.getReturnType().equals(futureHttpResponseLiteral)) {
|
||||
return Key.get(Class.class.cast(IdentityFunction.class));
|
||||
} else if (RestAnnotationProcessor.getAcceptHeadersOrNull(method).contains(APPLICATION_JSON)) {
|
||||
} else if (RestAnnotationProcessor.getAcceptHeaders(method).contains(APPLICATION_JSON)) {
|
||||
return getJsonParserKeyForMethod(method);
|
||||
} else if (RestAnnotationProcessor.getAcceptHeadersOrNull(method).contains(APPLICATION_XML)
|
||||
} else if (RestAnnotationProcessor.getAcceptHeaders(method).contains(APPLICATION_XML)
|
||||
|| method.isAnnotationPresent(JAXBResponseParser.class)) {
|
||||
return getJAXBParserKeyForMethod(method);
|
||||
} else if (method.getReturnType().equals(String.class) || method.getReturnType().equals(futureStringLiteral)) {
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.rest.internal;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -54,7 +53,6 @@ public class GeneratedHttpRequest extends HttpRequest {
|
|||
|
||||
public static class Builder extends HttpRequest.Builder<Builder> {
|
||||
protected Class<?> declaring;
|
||||
protected Method javaMethod;
|
||||
protected Invokable<?, ?> invoker;
|
||||
// args can be null, so cannot use immutable list
|
||||
protected List<Object> args = Lists.newArrayList();
|
||||
|
@ -68,16 +66,6 @@ public class GeneratedHttpRequest extends HttpRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see GeneratedHttpRequest#getJavaMethod()
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder javaMethod(Method javaMethod) {
|
||||
this.javaMethod = checkNotNull(javaMethod, "javaMethod");
|
||||
this.invoker(Invokable.from(javaMethod));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see GeneratedHttpRequest#getInvoker()
|
||||
*/
|
||||
|
@ -116,16 +104,15 @@ public class GeneratedHttpRequest extends HttpRequest {
|
|||
this.caller = Optional.fromNullable(caller);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public GeneratedHttpRequest build() {
|
||||
return new GeneratedHttpRequest(method, endpoint, headers.build(), payload, declaring, javaMethod, invoker,
|
||||
args, filters.build(), caller);
|
||||
return new GeneratedHttpRequest(method, endpoint, headers.build(), payload, declaring, invoker, args,
|
||||
filters.build(), caller);
|
||||
}
|
||||
|
||||
public Builder fromGeneratedHttpRequest(GeneratedHttpRequest in) {
|
||||
return super.fromHttpRequest(in)
|
||||
.declaring(in.getDeclaring())
|
||||
.javaMethod(in.getJavaMethod())
|
||||
.invoker(in.invoker)
|
||||
.args(in.getArgs())
|
||||
.caller(in.getCaller().orNull());
|
||||
|
@ -138,20 +125,18 @@ public class GeneratedHttpRequest extends HttpRequest {
|
|||
}
|
||||
|
||||
private final Class<?> declaring;
|
||||
private final Method javaMethod;
|
||||
private final Invokable<?, ?> invoker;
|
||||
private final List<Object> args;
|
||||
private final Optional<ClassInvokerArgs> caller;
|
||||
|
||||
protected GeneratedHttpRequest(String method, URI endpoint, Multimap<String, String> headers,
|
||||
@Nullable Payload payload, Class<?> declaring, Method javaMethod, Invokable<?, ?> invoker,
|
||||
Iterable<Object> args, Iterable<HttpRequestFilter> filters, Optional<ClassInvokerArgs> caller) {
|
||||
@Nullable Payload payload, Class<?> declaring, Invokable<?, ?> invoker,
|
||||
List<Object> args, Iterable<HttpRequestFilter> filters, Optional<ClassInvokerArgs> caller) {
|
||||
super(method, endpoint, headers, payload, filters);
|
||||
this.declaring = checkNotNull(declaring, "declaring");
|
||||
this.javaMethod = checkNotNull(javaMethod, "javaMethod");
|
||||
this.invoker = checkNotNull(invoker, "invoker");
|
||||
// TODO make immutable. ImmutableList.of() doesn't accept nulls
|
||||
this.args = Lists.newArrayList(checkNotNull(args, "args"));
|
||||
this.args = Collections.unmodifiableList(checkNotNull(args, "args"));
|
||||
this.caller = checkNotNull(caller, "caller");
|
||||
}
|
||||
|
||||
|
@ -159,20 +144,12 @@ public class GeneratedHttpRequest extends HttpRequest {
|
|||
return declaring;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated see {@link #getInvoker()}
|
||||
*/
|
||||
@Deprecated
|
||||
public Method getJavaMethod() {
|
||||
return javaMethod;
|
||||
}
|
||||
|
||||
public Invokable<?,?> getInvoker() {
|
||||
return invoker;
|
||||
}
|
||||
|
||||
public List<Object> getArgs() {
|
||||
return Collections.unmodifiableList(args);
|
||||
return args;
|
||||
}
|
||||
|
||||
public Optional<ClassInvokerArgs> getCaller() {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.rest.internal;
|
||||
import static com.google.common.base.Functions.toStringFunction;
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
@ -44,7 +43,6 @@ import static org.jclouds.util.Strings2.replaceTokens;
|
|||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -104,7 +102,6 @@ import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith;
|
|||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -118,7 +115,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.LinkedListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.primitives.Chars;
|
||||
|
@ -194,15 +190,6 @@ public abstract class RestAnnotationProcessor {
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
static final LoadingCache<Method, Invokable<?, ?>> methods = CacheBuilder.newBuilder().build(
|
||||
new CacheLoader<Method, Invokable<?, ?>>() {
|
||||
@Override
|
||||
public Invokable<?, ?> load(Method method) {
|
||||
return Invokable.from(method);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
private static final Function<? super Entry<String, Object>, ? extends Part> ENTRY_TO_PART = new Function<Entry<String, Object>, Part>() {
|
||||
@Override
|
||||
public Part apply(Entry<String, Object> from) {
|
||||
|
@ -229,45 +216,8 @@ public abstract class RestAnnotationProcessor {
|
|||
this.inputParamValidator = inputParamValidator;
|
||||
this.declaring = declaring;
|
||||
}
|
||||
|
||||
public static class InvokerKey {
|
||||
private final String name;
|
||||
private final int parametersTypeHashCode;
|
||||
private final Class<?> declaringClass;
|
||||
|
||||
public InvokerKey(Invokable<?, ?> invoker) {
|
||||
this.name = invoker.getName();
|
||||
this.declaringClass = invoker.getDeclaringClass();
|
||||
int parametersTypeHashCode = 0;
|
||||
for (Parameter param : invoker.getParameters())
|
||||
parametersTypeHashCode += param.getType().hashCode();
|
||||
this.parametersTypeHashCode = parametersTypeHashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(declaringClass, name, parametersTypeHashCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
InvokerKey that = InvokerKey.class.cast(obj);
|
||||
return equal(this.declaringClass, that.declaringClass)
|
||||
&& equal(this.name, that.name)
|
||||
&& equal(this.parametersTypeHashCode, that.parametersTypeHashCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public GeneratedHttpRequest createRequest(Method method, @Nullable Object... args) {
|
||||
List<Object> list = args == null ? Lists.newArrayList(new Object[] { null }) : Lists.newArrayList(args);
|
||||
return createRequest(method, methods.getUnchecked(method), list);
|
||||
}
|
||||
|
||||
public GeneratedHttpRequest createRequest(Method method, Invokable<?, ?> invoker, List<Object> args) {
|
||||
checkNotNull(method, "method");
|
||||
public GeneratedHttpRequest createRequest(Invokable<?, ?> invoker, List<Object> args) {
|
||||
checkNotNull(invoker, "invoker");
|
||||
checkNotNull(args, "args");
|
||||
inputParamValidator.validateMethodParametersOrThrow(invoker, args);
|
||||
|
@ -293,7 +243,6 @@ public abstract class RestAnnotationProcessor {
|
|||
}
|
||||
|
||||
requestBuilder.declaring(declaring)
|
||||
.javaMethod(method)
|
||||
.invoker(invoker)
|
||||
.args(args)
|
||||
.filters(getFiltersIfAnnotated(invoker));
|
||||
|
@ -549,14 +498,9 @@ public abstract class RestAnnotationProcessor {
|
|||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static URI getEndpointInParametersOrNull(Method method, @Deprecated Object[] args, Injector injector) {
|
||||
return getEndpointInParametersOrNull(methods.getUnchecked(method), args != null ? Lists.newArrayList(args)
|
||||
: ImmutableList.of(), injector);
|
||||
}
|
||||
|
||||
private static URI getEndpointInParametersOrNull(Invokable<?,?> method, List<Object> args, Injector injector) {
|
||||
@VisibleForTesting
|
||||
static URI getEndpointInParametersOrNull(Invokable<?,?> method, List<Object> args, Injector injector) {
|
||||
Collection<Parameter> endpointParams = parametersWithAnnotation(method, EndpointParam.class);
|
||||
if (endpointParams.isEmpty())
|
||||
return null;
|
||||
|
@ -603,7 +547,6 @@ public abstract class RestAnnotationProcessor {
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Deprecated
|
||||
static URI addHostIfMissing(URI original, URI withHost) {
|
||||
checkNotNull(withHost, "URI withHost cannot be null");
|
||||
checkArgument(withHost.getHost() != null, "URI withHost must have host:" + withHost);
|
||||
|
@ -740,12 +683,6 @@ public abstract class RestAnnotationProcessor {
|
|||
return result.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Multimap<String, String> buildHeaders(Multimap<String, ?> tokenValues, Method method, Object... args) {
|
||||
return buildHeaders(tokenValues, methods.getUnchecked(method), args != null ? Lists.newArrayList(args)
|
||||
: ImmutableList.of());
|
||||
}
|
||||
|
||||
private Multimap<String, String> buildHeaders(Multimap<String, ?> tokenValues, Invokable<?, ?> method,
|
||||
List<Object> args) {
|
||||
Multimap<String, String> headers = LinkedHashMultimap.create();
|
||||
|
@ -762,24 +699,16 @@ public abstract class RestAnnotationProcessor {
|
|||
}
|
||||
|
||||
private void addConsumesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invokable<?,?> method) {
|
||||
List<String> accept = getAcceptHeadersOrNull(method);
|
||||
if (accept.size() > 0)
|
||||
Set<String> accept = getAcceptHeaders(method);
|
||||
if (!accept.isEmpty())
|
||||
headers.replaceValues(ACCEPT, accept);
|
||||
}
|
||||
|
||||
// TODO: refactor this out
|
||||
@VisibleForTesting
|
||||
static List<String> getAcceptHeadersOrNull(Invokable<?,?> method) {
|
||||
List<String> accept = ImmutableList.of();
|
||||
if (method.getDeclaringClass().isAnnotationPresent(Consumes.class)) {
|
||||
Consumes header = method.getDeclaringClass().getAnnotation(Consumes.class);
|
||||
accept = asList(header.value());
|
||||
}
|
||||
if (method.isAnnotationPresent(Consumes.class)) {
|
||||
Consumes header = method.getAnnotation(Consumes.class);
|
||||
accept = asList(header.value());
|
||||
}
|
||||
return accept;
|
||||
static Set<String> getAcceptHeaders(Invokable<?, ?> method) {
|
||||
Optional<Consumes> accept = Optional.fromNullable(method.getAnnotation(Consumes.class)).or(
|
||||
Optional.fromNullable(method.getDeclaringClass().getAnnotation(Consumes.class)));
|
||||
return (accept.isPresent()) ? ImmutableSet.copyOf(accept.get().value()) : ImmutableSet.<String> of();
|
||||
}
|
||||
|
||||
private void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invokable<?,?> method) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.WildcardType;
|
||||
|
@ -37,12 +36,6 @@ public class Optionals2 {
|
|||
return returnTypeOrTypeOfOptional(type.getRawType(), type.getType());
|
||||
}
|
||||
|
||||
public static Class<?> returnTypeOrTypeOfOptional(Method method) {
|
||||
Class<?> syncClass = method.getReturnType();
|
||||
Type genericType = method.getGenericReturnType();
|
||||
return returnTypeOrTypeOfOptional(syncClass, genericType);
|
||||
}
|
||||
|
||||
private static Class<?> returnTypeOrTypeOfOptional(Class<?> syncClass, Type genericType) {
|
||||
if (syncClass.isAssignableFrom(Optional.class)) {
|
||||
ParameterizedType futureType = ParameterizedType.class.cast(genericType);
|
||||
|
@ -57,8 +50,7 @@ public class Optionals2 {
|
|||
return syncClass;
|
||||
}
|
||||
|
||||
public static boolean isReturnTypeOptional(Method method) {
|
||||
return method.getReturnType().isAssignableFrom(Optional.class);
|
||||
public static boolean isReturnTypeOptional(Invokable<?, ?> method) {
|
||||
return method.getReturnType().getRawType().isAssignableFrom(Optional.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.jclouds.rest.ResourceNotFoundException;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.CreationException;
|
||||
import com.google.inject.ProvisionException;
|
||||
import com.google.inject.spi.Message;
|
||||
|
@ -120,10 +121,10 @@ public class Throwables2 {
|
|||
|
||||
// Note this needs to be kept up-to-date with all top-level exceptions jclouds works against
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||
public static Exception returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(Class[] exceptionTypes,
|
||||
public static Exception returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(Iterable<TypeToken<? extends Throwable>> throwables,
|
||||
Exception exception) throws Exception {
|
||||
for (Class type : exceptionTypes) {
|
||||
Throwable throwable = getFirstThrowableOfType(exception, type);
|
||||
for (TypeToken<? extends Throwable> type : throwables) {
|
||||
Throwable throwable = getFirstThrowableOfType(exception, (Class<Throwable>) type.getRawType());
|
||||
if (throwable != null) {
|
||||
return (Exception) throwable;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import static org.testng.Assert.assertTrue;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -50,6 +49,8 @@ import org.testng.annotations.BeforeTest;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
@Test(groups = "unit", testName = "BackoffLimitedRetryHandlerTest")
|
||||
public class BackoffLimitedRetryHandlerTest {
|
||||
|
@ -169,9 +170,9 @@ public class BackoffLimitedRetryHandlerTest {
|
|||
.getInstance(RestAnnotationProcessor.Factory.class).declaring(IntegrationTestAsyncClient.class);
|
||||
|
||||
private HttpCommand createCommand() throws SecurityException, NoSuchMethodException {
|
||||
Method method = IntegrationTestAsyncClient.class.getMethod("download", String.class);
|
||||
Invokable<?, Object> method = Invokable.from(IntegrationTestAsyncClient.class.getMethod("download", String.class));
|
||||
|
||||
return new HttpCommand(processor.createRequest(method, "1"));
|
||||
return new HttpCommand(processor.createRequest(method, ImmutableList.<Object> of("1")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.http.internal;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -42,6 +41,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
|||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
@ -73,16 +73,15 @@ public class TrackingJavaUrlHttpCommandExecutorService extends JavaUrlHttpComman
|
|||
};
|
||||
}
|
||||
|
||||
public static Method getJavaMethodForRequestAtIndex(final Collection<HttpCommand> commandsInvoked, int index) {
|
||||
return getJavaMethodForRequest(Iterables.get(commandsInvoked, index));
|
||||
public static Invokable<?, ?> getInvokerOfRequestAtIndex(final Collection<HttpCommand> commandsInvoked, int index) {
|
||||
return getInvokerOfRequest(Iterables.get(commandsInvoked, index));
|
||||
}
|
||||
|
||||
public static Method getJavaMethodForRequest(HttpCommand commandInvoked) {
|
||||
return GeneratedHttpRequest.class.cast(commandInvoked.getCurrentRequest()).getJavaMethod();
|
||||
public static Invokable<?, ?> getInvokerOfRequest(HttpCommand commandInvoked) {
|
||||
return GeneratedHttpRequest.class.cast(commandInvoked.getCurrentRequest()).getInvoker();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Object> getJavaArgsForRequestAtIndex(final Collection<HttpCommand> commandsInvoked, int index) {
|
||||
public static List<Object> getArgsForRequestAtIndex(final Collection<HttpCommand> commandsInvoked, int index) {
|
||||
return GeneratedHttpRequest.class.cast(Iterables.get(commandsInvoked, index).getCurrentRequest()).getArgs();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.reflect;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.common.reflect.Reflection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test
|
||||
public class AbstractInvocationHandlerTest {
|
||||
|
||||
@Test(expectedExceptions = UnsupportedOperationException.class)
|
||||
public void testNullArgsAreAllowedAndUnmodifiable() throws IOException {
|
||||
Reflection.newProxy(Appendable.class, new AbstractInvocationHandler() {
|
||||
protected Object handleInvocation(Object proxy, Invokable<?, ?> method, List<Object> args) throws Throwable {
|
||||
assertNotNull(args);
|
||||
assertNull(args.get(0));
|
||||
args.add("foo");
|
||||
throw new AssertionError("shouldn't be able to mutate the list!");
|
||||
}
|
||||
}).append(null);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = UnsupportedOperationException.class)
|
||||
public void testImmutableListWhenArgsAreNotNull() throws IOException {
|
||||
Reflection.newProxy(Appendable.class, new AbstractInvocationHandler() {
|
||||
protected Object handleInvocation(Object proxy, Invokable<?, ?> method, List<Object> args) throws Throwable {
|
||||
assertNotNull(args);
|
||||
assertTrue(args instanceof ImmutableList);
|
||||
assertEquals(args.get(0), "foo");
|
||||
args.add("bar");
|
||||
throw new AssertionError("shouldn't be able to mutate the list!");
|
||||
}
|
||||
}).append("foo");
|
||||
}
|
||||
}
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.rest;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PathParam;
|
||||
|
||||
|
@ -34,6 +32,8 @@ import org.testng.TestException;
|
|||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
@Test(groups = "unit")
|
||||
|
@ -58,26 +58,26 @@ public class InputParamValidatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void testInputParamsValidation() throws Exception {
|
||||
Method allParamsValidatedMethod = InputParamValidatorForm.class.getMethod("allParamsValidated", String.class,
|
||||
String.class);
|
||||
Method oneParamValidatedMethod = InputParamValidatorForm.class.getMethod("oneParamValidated", String.class,
|
||||
String.class);
|
||||
Invokable<?, ?> allParamsValidatedMethod = Invokable.from(InputParamValidatorForm.class.getMethod(
|
||||
"allParamsValidated", String.class, String.class));
|
||||
Invokable<?, ?> oneParamValidatedMethod = Invokable.from(InputParamValidatorForm.class.getMethod(
|
||||
"oneParamValidated", String.class, String.class));
|
||||
RestAnnotationProcessor restAnnotationProcessor = factory(InputParamValidatorForm.class);
|
||||
restAnnotationProcessor.createRequest(allParamsValidatedMethod, "blah", "blah");
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, "blah", "blah");
|
||||
restAnnotationProcessor.createRequest(allParamsValidatedMethod, ImmutableList.<Object> of("blah", "blah"));
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, ImmutableList.<Object> of("blah", "blah"));
|
||||
|
||||
try {
|
||||
restAnnotationProcessor.createRequest(allParamsValidatedMethod, "BLAH", "blah");
|
||||
restAnnotationProcessor.createRequest(allParamsValidatedMethod, ImmutableList.<Object> of("BLAH", "blah"));
|
||||
throw new TestException(
|
||||
"AllLowerCaseValidator shouldn't have passed 'BLAH' as a parameter because it's uppercase.");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// supposed to happen - continue
|
||||
}
|
||||
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, "BLAH", "blah");
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, ImmutableList.<Object> of("BLAH", "blah"));
|
||||
|
||||
try {
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, "blah", "BLAH");
|
||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, ImmutableList.<Object> of("blah", "BLAH"));
|
||||
throw new TestException(
|
||||
"AllLowerCaseValidator shouldn't have passed 'BLAH' as the second parameter because it's uppercase.");
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -98,8 +98,8 @@ public class InputParamValidatorTest {
|
|||
|
||||
@Test(expectedExceptions = ClassCastException.class)
|
||||
public void testWrongPredicateTypeLiteral() throws Exception {
|
||||
Method method = WrongValidator.class.getMethod("method", Integer.class);
|
||||
new InputParamValidator(injector).validateMethodParametersOrThrow(method, 55);
|
||||
Invokable<?, ?> method = Invokable.from(WrongValidator.class.getMethod("method", Integer.class));
|
||||
new InputParamValidator(injector).validateMethodParametersOrThrow(method, ImmutableList.<Object> of(55));
|
||||
}
|
||||
|
||||
private RestAnnotationProcessor factory(Class<?> clazz) {
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.rest.binders;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.ws.rs.PathParam;
|
||||
|
||||
|
@ -33,6 +32,7 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindMapToStringPayload}
|
||||
|
@ -53,9 +53,9 @@ public class BindMapToStringPayloadTest {
|
|||
|
||||
@Test
|
||||
public void testCorrect() throws SecurityException, NoSuchMethodException {
|
||||
Method testPayload = TestPayload.class.getMethod("testPayload", String.class);
|
||||
Invokable<?, Object> testPayload = Invokable.from(TestPayload.class.getMethod("testPayload", String.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder()
|
||||
.declaring(TestPayload.class).javaMethod(testPayload).args(ImmutableList.<Object> of("robot"))
|
||||
.declaring(TestPayload.class).invoker(testPayload).args(ImmutableList.<Object> of("robot"))
|
||||
.method("POST").endpoint("http://localhost").build();
|
||||
|
||||
GeneratedHttpRequest newRequest = binder()
|
||||
|
@ -67,9 +67,9 @@ public class BindMapToStringPayloadTest {
|
|||
|
||||
@Test
|
||||
public void testDecodes() throws SecurityException, NoSuchMethodException {
|
||||
Method testPayload = TestPayload.class.getMethod("changeAdminPass", String.class);
|
||||
Invokable<?, Object> testPayload = Invokable.from(TestPayload.class.getMethod("changeAdminPass", String.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder()
|
||||
.declaring(TestPayload.class).javaMethod(testPayload).args(ImmutableList.<Object> of("foo"))
|
||||
.declaring(TestPayload.class).invoker(testPayload).args(ImmutableList.<Object> of("foo"))
|
||||
.method("POST").endpoint("http://localhost").build();
|
||||
|
||||
GeneratedHttpRequest newRequest = binder()
|
||||
|
@ -81,9 +81,9 @@ public class BindMapToStringPayloadTest {
|
|||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testMustHavePayloadAnnotation() throws SecurityException, NoSuchMethodException {
|
||||
Method noPayload = TestPayload.class.getMethod("noPayload", String.class);
|
||||
Invokable<?, Object> noPayload = Invokable.from(TestPayload.class.getMethod("noPayload", String.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder()
|
||||
.declaring(TestPayload.class).javaMethod(noPayload).args(ImmutableList.<Object> of("robot"))
|
||||
.declaring(TestPayload.class).invoker(noPayload).args(ImmutableList.<Object> of("robot"))
|
||||
.method("POST").endpoint("http://localhost").build();
|
||||
binder().bindToRequest(request, ImmutableMap.<String,Object>of("fooble", "robot"));
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Allows you to use simple api version comparison to determine if a feature is
|
||||
|
@ -163,8 +165,8 @@ public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest
|
|||
ClassInvokerArgsAndReturnVal getApi(String name, Class<?> type) {
|
||||
try {
|
||||
return ClassInvokerArgsAndReturnVal.builder().clazz(type)
|
||||
.invoker(EC2AsyncApi.class.getDeclaredMethod("get" + name + "ApiForRegion", String.class))
|
||||
.args(new Object[] { "region" }).returnVal("present").build();
|
||||
.invoker(Invokable.from(EC2AsyncApi.class.getDeclaredMethod("get" + name + "ApiForRegion", String.class)))
|
||||
.args(ImmutableList.<Object> of("region")).returnVal("present").build();
|
||||
} catch (Exception e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -49,6 +48,7 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SortedSetMultimap;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
@ -160,7 +160,7 @@ public abstract class BaseRestApiTest {
|
|||
assertEquals(request.getRequestLine(), toMatch);
|
||||
}
|
||||
|
||||
protected void assertFallbackClassEquals(Method method, @Nullable Class<?> expected) {
|
||||
protected void assertFallbackClassEquals(Invokable<?, ?> method, @Nullable Class<?> expected) {
|
||||
Fallback fallbackAnnotation = method.getAnnotation(Fallback.class);
|
||||
Class<?> assigned = fallbackAnnotation != null ? fallbackAnnotation.value() : MapHttp4xxCodesToExceptions.class;
|
||||
if (expected == null)
|
||||
|
@ -169,13 +169,13 @@ public abstract class BaseRestApiTest {
|
|||
assertEquals(assigned, expected);
|
||||
}
|
||||
|
||||
protected void assertSaxResponseParserClassEquals(Method method, @Nullable Class<?> parserClass) {
|
||||
protected void assertSaxResponseParserClassEquals(Invokable<?, ?> method, @Nullable Class<?> parserClass) {
|
||||
XMLResponseParser annotation = method.getAnnotation(XMLResponseParser.class);
|
||||
Class<?> expected = (annotation != null) ? annotation.value() :null;
|
||||
assertEquals(expected, parserClass);
|
||||
}
|
||||
|
||||
protected void assertResponseParserClassEquals(Method method, HttpRequest request, @Nullable Class<?> parserClass) {
|
||||
protected void assertResponseParserClassEquals(Invokable<?, ?> method, HttpRequest request, @Nullable Class<?> parserClass) {
|
||||
assertEquals(AsyncRestClientProxy.createResponseParser(parserFactory, injector, method, request).getClass(), parserClass);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,11 +22,10 @@ import static org.testng.Assert.assertEquals;
|
|||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -41,25 +40,25 @@ public class Optionals2Test {
|
|||
}
|
||||
|
||||
public void testReturnTypeOrTypeOfOptionalWhenOptional() throws SecurityException, NoSuchMethodException {
|
||||
Method method = Test.class.getMethod("getOptional");
|
||||
Invokable<?, ?> method = Invokable.from(Test.class.getMethod("getOptional"));
|
||||
|
||||
assertEquals(Optionals2.returnTypeOrTypeOfOptional(method), String.class);
|
||||
}
|
||||
|
||||
public void testReturnTypeOrTypeOfOptionalWhenNotOptional() throws SecurityException, NoSuchMethodException {
|
||||
Method method = Test.class.getMethod("getNotOptional");
|
||||
Invokable<?, ?> method = Invokable.from(Test.class.getMethod("getNotOptional"));
|
||||
|
||||
assertEquals(Optionals2.returnTypeOrTypeOfOptional(method), String.class);
|
||||
}
|
||||
|
||||
public void testIsReturnTypeOptionalWhenOptional() throws SecurityException, NoSuchMethodException {
|
||||
Method method = Test.class.getMethod("getOptional");
|
||||
Invokable<?, ?> method = Invokable.from(Test.class.getMethod("getOptional"));
|
||||
|
||||
assertTrue(Optionals2.isReturnTypeOptional(method));
|
||||
}
|
||||
|
||||
public void testIsReturnTypeOptionalWhenNotOptional() throws SecurityException, NoSuchMethodException {
|
||||
Method method = Test.class.getMethod("getNotOptional");
|
||||
Invokable<?, ?> method = Invokable.from(Test.class.getMethod("getNotOptional"));
|
||||
|
||||
assertFalse(Optionals2.isReturnTypeOptional(method));
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jclouds.concurrent.TransformParallelException;
|
||||
|
@ -41,6 +41,7 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.CreationException;
|
||||
import com.google.inject.ProvisionException;
|
||||
import com.google.inject.spi.Message;
|
||||
|
@ -117,153 +118,160 @@ public class Throwables2Test {
|
|||
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetCauseTransformParallel() {
|
||||
Exception aex = createMock(AuthorizationException.class);
|
||||
TransformParallelException pex = new TransformParallelException((Map) ImmutableMap.of(), ImmutableMap.of("bad",
|
||||
aex), "test");
|
||||
TransformParallelException pex = new TransformParallelException(ImmutableMap.<Object, Future<?>> of(),
|
||||
ImmutableMap.of("bad", aex), "test");
|
||||
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetFirstThrowableOfTypeInnerTransformParallel() {
|
||||
Exception aex = createMock(AuthorizationException.class);
|
||||
TransformParallelException pex = new TransformParallelException((Map) ImmutableMap.of(), ImmutableMap.of("bad",
|
||||
(Exception) new ExecutionException(aex)), "test");
|
||||
TransformParallelException pex = new TransformParallelException(ImmutableMap.<Object, Future<?>> of(),
|
||||
ImmutableMap.of("bad", (Exception) new ExecutionException(aex)), "test");
|
||||
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetFirstThrowableOfTypeOuterTransformParallel() {
|
||||
Exception aex = createMock(AuthorizationException.class);
|
||||
TransformParallelException pex = new TransformParallelException((Map) ImmutableMap.of(), ImmutableMap.of("bad",
|
||||
(Exception) aex), "test");
|
||||
TransformParallelException pex = new TransformParallelException(ImmutableMap.<Object, Future<?>> of(),
|
||||
ImmutableMap.of("bad", (Exception) aex), "test");
|
||||
assertEquals(getFirstThrowableOfType(new ExecutionException(pex), AuthorizationException.class), aex);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetFirstThrowableOfTypeFailTransformParallel() {
|
||||
Exception aex = createMock(TimeoutException.class);
|
||||
TransformParallelException pex = new TransformParallelException((Map) ImmutableMap.of(), ImmutableMap.of("bad",
|
||||
aex), "test");
|
||||
TransformParallelException pex = new TransformParallelException(ImmutableMap.<Object, Future<?>> of(),
|
||||
ImmutableMap.of("bad", aex), "test");
|
||||
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnExceptionThatsInList() throws Exception {
|
||||
Exception e = new TestException();
|
||||
assertEquals(returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] { TestException.class }, e),
|
||||
e);
|
||||
assertEquals(returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] { TestException.class },
|
||||
new RuntimeException(e)), e);
|
||||
assertEquals(
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(
|
||||
ImmutableSet.<TypeToken<? extends Throwable>> of(TypeToken.of(TestException.class)), e), e);
|
||||
assertEquals(
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(
|
||||
ImmutableSet.<TypeToken<? extends Throwable>> of(TypeToken.of(TestException.class)),
|
||||
new RuntimeException(e)), e);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = TestException.class)
|
||||
public void testThrowExceptionNotInList() throws Exception {
|
||||
Exception e = new TestException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, e);
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(), e);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalStateException.class)
|
||||
public void testPropagateStandardExceptionIllegalStateException() throws Exception {
|
||||
Exception e = new IllegalStateException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new RuntimeException(e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new RuntimeException(e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testPropagateStandardExceptionIllegalArgumentException() throws Exception {
|
||||
Exception e = new IllegalArgumentException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new RuntimeException(e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new RuntimeException(e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = UnsupportedOperationException.class)
|
||||
public void testPropagateStandardExceptionUnsupportedOperationException() throws Exception {
|
||||
Exception e = new UnsupportedOperationException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new RuntimeException(e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new RuntimeException(e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AssertionError.class)
|
||||
public void testPropagateStandardExceptionAssertionError() throws Exception {
|
||||
AssertionError e = new AssertionError();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new RuntimeException(e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new RuntimeException(e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testPropagateStandardExceptionAuthorizationException() throws Exception {
|
||||
Exception e = new AuthorizationException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new RuntimeException(e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new RuntimeException(e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testPropagateProvisionExceptionAuthorizationException() throws Exception {
|
||||
Exception e = new AuthorizationException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new ProvisionException(ImmutableSet.of(new Message(
|
||||
ImmutableList.of(), "Error in custom provider",e))));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new ProvisionException(ImmutableSet.of(new Message(ImmutableList.of(), "Error in custom provider", e))));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testPropagateCreationExceptionAuthorizationException() throws Exception {
|
||||
Exception e = new AuthorizationException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new CreationException(ImmutableSet.of(new Message(
|
||||
ImmutableList.of(), "Error in custom provider",e))));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new CreationException(ImmutableSet.of(new Message(ImmutableList.of(), "Error in custom provider", e))));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = InsufficientResourcesException.class)
|
||||
public void testPropagateStandardExceptionInsufficientResourcesException() throws Exception {
|
||||
Exception e = new InsufficientResourcesException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new RuntimeException(e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new RuntimeException(e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testPropagateStandardExceptionResourceNotFoundException() throws Exception {
|
||||
Exception e = new ResourceNotFoundException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new RuntimeException(e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new RuntimeException(e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalStateException.class)
|
||||
public void testPropagateStandardExceptionIllegalStateExceptionNestedInHttpResponseException() throws Exception {
|
||||
Exception e = new IllegalStateException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new HttpResponseException("goo",
|
||||
createNiceMock(HttpCommand.class), null, e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new HttpResponseException("goo", createNiceMock(HttpCommand.class), null, e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testPropagateStandardExceptionIllegalArgumentExceptionNestedInHttpResponseException() throws Exception {
|
||||
Exception e = new IllegalArgumentException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new HttpResponseException("goo",
|
||||
createNiceMock(HttpCommand.class), null, e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new HttpResponseException("goo", createNiceMock(HttpCommand.class), null, e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = UnsupportedOperationException.class)
|
||||
public void testPropagateStandardExceptionUnsupportedOperationExceptionNestedInHttpResponseException()
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
Exception e = new UnsupportedOperationException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new HttpResponseException("goo",
|
||||
createNiceMock(HttpCommand.class), null, e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new HttpResponseException("goo", createNiceMock(HttpCommand.class), null, e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testPropagateStandardExceptionAuthorizationExceptionNestedInHttpResponseException() throws Exception {
|
||||
Exception e = new AuthorizationException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new HttpResponseException("goo",
|
||||
createNiceMock(HttpCommand.class), null, e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new HttpResponseException("goo", createNiceMock(HttpCommand.class), null, e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testPropagateStandardExceptionResourceNotFoundExceptionNestedInHttpResponseException() throws Exception {
|
||||
Exception e = new ResourceNotFoundException();
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new HttpResponseException("goo",
|
||||
createNiceMock(HttpCommand.class), null, e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new HttpResponseException("goo", createNiceMock(HttpCommand.class), null, e));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = HttpResponseException.class)
|
||||
public void testPropagateStandardExceptionHttpResponseException() throws Exception {
|
||||
Exception e = new HttpResponseException("goo", createNiceMock(HttpCommand.class), null);
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(new Class[] {}, new RuntimeException(e));
|
||||
returnFirstExceptionIfInListOrThrowStandardExceptionOrCause(ImmutableSet.<TypeToken<? extends Throwable>> of(),
|
||||
new RuntimeException(e));
|
||||
}
|
||||
|
||||
static class TestException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class BindToPath implements Binder {
|
|||
*/
|
||||
static RESTLink getLinkToUse(final GeneratedHttpRequest request, final SingleResourceTransportDto payload) {
|
||||
int argIndex = request.getArgs().indexOf(payload);
|
||||
Annotation[] annotations = request.getJavaMethod().getParameterAnnotations()[argIndex];
|
||||
Annotation[] annotations = request.getInvoker().getParameters().get(argIndex).getAnnotations();
|
||||
|
||||
EndpointLink linkName = (EndpointLink) Iterables.find(Arrays.asList(annotations),
|
||||
Predicates.instanceOf(EndpointLink.class), null);
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.abiquo.binders;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
|
@ -37,6 +36,7 @@ import org.testng.annotations.Test;
|
|||
import com.abiquo.model.rest.RESTLink;
|
||||
import com.abiquo.model.transport.SingleResourceTransportDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link BindToPath} binder.
|
||||
|
@ -59,9 +59,9 @@ public class BindToPathTest {
|
|||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testInvalidNullInput() throws SecurityException, NoSuchMethodException {
|
||||
Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class);
|
||||
Invokable<?, ?> withEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class)
|
||||
.javaMethod(withEndpointLink).args(ImmutableList.<Object> of(new TestDto())).method(HttpMethod.GET)
|
||||
.invoker(withEndpointLink).args(ImmutableList.<Object> of(new TestDto())).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindToPath binder = new BindToPath();
|
||||
|
@ -70,9 +70,9 @@ public class BindToPathTest {
|
|||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testInvalidInputType() throws SecurityException, NoSuchMethodException {
|
||||
Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class);
|
||||
Invokable<?, ?> withEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class)
|
||||
.javaMethod(withEndpointLink).args(ImmutableList.<Object> of(new TestDto())).method(HttpMethod.GET)
|
||||
.invoker(withEndpointLink).args(ImmutableList.<Object> of(new TestDto())).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindToPath binder = new BindToPath();
|
||||
|
@ -82,9 +82,9 @@ public class BindToPathTest {
|
|||
@Test(expectedExceptions = BindException.class)
|
||||
public void testAnnotationNotPresent() throws SecurityException, NoSuchMethodException {
|
||||
TestDto dto = new TestDto();
|
||||
Method withoutEndpointLink = TestEndpointLink.class.getMethod("withoutEndpointLink", TestDto.class);
|
||||
Invokable<?, ?> withoutEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withoutEndpointLink", TestDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class)
|
||||
.javaMethod(withoutEndpointLink).args(ImmutableList.<Object> of(dto)).method(HttpMethod.GET)
|
||||
.invoker(withoutEndpointLink).args(ImmutableList.<Object> of(dto)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindToPath binder = new BindToPath();
|
||||
|
@ -94,9 +94,9 @@ public class BindToPathTest {
|
|||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testLinkNotPresent() throws SecurityException, NoSuchMethodException {
|
||||
TestDto dto = new TestDto();
|
||||
Method withUnexistingLink = TestEndpointLink.class.getMethod("withUnexistingLink", TestDto.class);
|
||||
Invokable<?, ?> withUnexistingLink = Invokable.from(TestEndpointLink.class.getMethod("withUnexistingLink", TestDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class)
|
||||
.javaMethod(withUnexistingLink).args(ImmutableList.<Object> of(dto)).method(HttpMethod.GET)
|
||||
.invoker(withUnexistingLink).args(ImmutableList.<Object> of(dto)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindToPath binder = new BindToPath();
|
||||
|
@ -105,9 +105,9 @@ public class BindToPathTest {
|
|||
|
||||
public void testBindWithoutParameters() throws SecurityException, NoSuchMethodException {
|
||||
TestDto dto = new TestDto();
|
||||
Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class);
|
||||
Invokable<?, ?> withEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class)
|
||||
.javaMethod(withEndpointLink).args(ImmutableList.<Object> of(dto)).method(HttpMethod.GET)
|
||||
.invoker(withEndpointLink).args(ImmutableList.<Object> of(dto)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindToPath binder = new BindToPath();
|
||||
|
@ -117,9 +117,9 @@ public class BindToPathTest {
|
|||
|
||||
public void testBindWithQueryParameters() throws SecurityException, NoSuchMethodException {
|
||||
TestDto dto = new TestDto();
|
||||
Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class);
|
||||
Invokable<?, ?> withEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class)
|
||||
.javaMethod(withEndpointLink).args(ImmutableList.<Object> of(dto)).method(HttpMethod.GET)
|
||||
.invoker(withEndpointLink).args(ImmutableList.<Object> of(dto)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost?param=value")).build();
|
||||
|
||||
BindToPath binder = new BindToPath();
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.abiquo.binders.cloud;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
@ -34,6 +33,7 @@ import org.testng.annotations.Test;
|
|||
import com.abiquo.server.core.cloud.VirtualDatacenterDto;
|
||||
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link BindMoveVolumeToPath} binder.
|
||||
|
@ -61,9 +61,9 @@ public class BindMoveVolumeToPathTest {
|
|||
}
|
||||
|
||||
private static GeneratedHttpRequest generatedHttpRequest() throws SecurityException, NoSuchMethodException {
|
||||
Method withEndpointLink = CloudAsyncApi.class.getMethod("moveVolume", VolumeManagementDto.class,
|
||||
VirtualDatacenterDto.class);
|
||||
return GeneratedHttpRequest.builder().declaring(CloudAsyncApi.class).javaMethod(withEndpointLink)
|
||||
Invokable<?, ?> withEndpointLink = Invokable.from(CloudAsyncApi.class.getMethod("moveVolume", VolumeManagementDto.class,
|
||||
VirtualDatacenterDto.class));
|
||||
return GeneratedHttpRequest.builder().declaring(CloudAsyncApi.class).invoker(withEndpointLink)
|
||||
.args(ImmutableList.<Object> of(CloudResources.volumePut(), CloudResources.virtualDatacenterPut()))
|
||||
.method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import static org.jclouds.abiquo.domain.DomainUtils.withHeader;
|
|||
import static org.jclouds.abiquo.util.Assert.assertPayloadEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
@ -41,6 +40,8 @@ import com.abiquo.model.transport.LinksDto;
|
|||
import com.abiquo.server.core.cloud.VirtualMachineDto;
|
||||
import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link BindNetworkConfigurationRefToPayload} binder.
|
||||
|
@ -66,9 +67,10 @@ public class BindNetworkConfigurationRefToPayloadTest {
|
|||
public void testInvalidNullInput() throws SecurityException, NoSuchMethodException {
|
||||
VirtualMachineDto vm = CloudResources.virtualMachinePut();
|
||||
|
||||
Method method = TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, VLANNetworkDto.class);
|
||||
Invokable<?, ?> method = Invokable.from(TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class,
|
||||
VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class)
|
||||
.javaMethod(method).args(ImmutableList.<Object> of(vm, null)).method(HttpMethod.GET)
|
||||
.invoker(method).args(Lists.<Object> newArrayList(vm, null)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
|
||||
|
@ -80,9 +82,10 @@ public class BindNetworkConfigurationRefToPayloadTest {
|
|||
VirtualMachineDto vm = CloudResources.virtualMachinePut();
|
||||
Object network = new Object();
|
||||
|
||||
Method method = TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, VLANNetworkDto.class);
|
||||
Invokable<?, ?> method = Invokable.from(TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class,
|
||||
VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class)
|
||||
.javaMethod(method).args(ImmutableList.<Object> of(vm, network)).method(HttpMethod.GET)
|
||||
.invoker(method).args(ImmutableList.<Object> of(vm, network)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
|
||||
|
@ -93,9 +96,10 @@ public class BindNetworkConfigurationRefToPayloadTest {
|
|||
public void testBindNetworkConfigurationRefWithoutVirtualMachine() throws SecurityException, NoSuchMethodException {
|
||||
VLANNetworkDto network = NetworkResources.privateNetworkPut();
|
||||
|
||||
Method method = TestNetworkConfig.class.getMethod("withoutVirtualMachine", VLANNetworkDto.class);
|
||||
Invokable<?, ?> method = Invokable.from(TestNetworkConfig.class.getMethod("withoutVirtualMachine",
|
||||
VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class)
|
||||
.javaMethod(method).args(ImmutableList.<Object> of(network)).method(HttpMethod.GET)
|
||||
.invoker(method).args(ImmutableList.<Object> of(network)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
|
||||
|
@ -106,9 +110,10 @@ public class BindNetworkConfigurationRefToPayloadTest {
|
|||
VirtualMachineDto vm = CloudResources.virtualMachinePut();
|
||||
VLANNetworkDto network = NetworkResources.privateNetworkPut();
|
||||
|
||||
Method method = TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, VLANNetworkDto.class);
|
||||
Invokable<?, ?> method = Invokable.from(TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class,
|
||||
VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class)
|
||||
.javaMethod(method).args(ImmutableList.<Object> of(vm, network)).method(HttpMethod.GET)
|
||||
.invoker(method).args(ImmutableList.<Object> of(vm, network)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://localhost")).build();
|
||||
|
||||
BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.abiquo.binders.infrastructure;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
@ -33,6 +32,7 @@ import org.testng.annotations.Test;
|
|||
import com.abiquo.model.rest.RESTLink;
|
||||
import com.abiquo.server.core.infrastructure.DatacenterDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link BindSupportedDevicesLinkToPath} class.
|
||||
|
@ -59,11 +59,11 @@ public class BindSupportedDevicesLinkToPathTest {
|
|||
|
||||
BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath();
|
||||
|
||||
Method withEndpointLink = InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices",
|
||||
DatacenterDto.class);
|
||||
Invokable<?, ?> withEndpointLink = Invokable.from(InfrastructureAsyncApi.class.getMethod(
|
||||
"listSupportedStorageDevices", DatacenterDto.class));
|
||||
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(InfrastructureAsyncApi.class)
|
||||
.javaMethod(withEndpointLink).args(ImmutableList.<Object> of(datacenter)).method(HttpMethod.GET)
|
||||
.invoker(withEndpointLink).args(ImmutableList.<Object> of(datacenter)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://foo/bar")).build();
|
||||
|
||||
assertEquals(binder.getNewEndpoint(request, datacenter), "http://foo/bar/action/supported");
|
||||
|
@ -75,11 +75,11 @@ public class BindSupportedDevicesLinkToPathTest {
|
|||
|
||||
BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath();
|
||||
|
||||
Method withEndpointLink = InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices",
|
||||
DatacenterDto.class);
|
||||
Invokable<?, ?> withEndpointLink = Invokable.from(InfrastructureAsyncApi.class.getMethod(
|
||||
"listSupportedStorageDevices", DatacenterDto.class));
|
||||
|
||||
GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(InfrastructureAsyncApi.class)
|
||||
.javaMethod(withEndpointLink).args(ImmutableList.<Object> of(datacenter)).method(HttpMethod.GET)
|
||||
.invoker(withEndpointLink).args(ImmutableList.<Object> of(datacenter)).method(HttpMethod.GET)
|
||||
.endpoint(URI.create("http://foo/bar")).build();
|
||||
|
||||
assertEquals(binder.getNewEndpoint(request, datacenter), "http://foo/bar/action/supported");
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.jclouds.abiquo.features;
|
|||
import static org.jclouds.abiquo.domain.DomainUtils.withHeader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.abiquo.domain.AdminResources;
|
||||
|
@ -36,6 +35,8 @@ import com.abiquo.server.core.enterprise.PrivilegesDto;
|
|||
import com.abiquo.server.core.enterprise.RoleDto;
|
||||
import com.abiquo.server.core.enterprise.RolesDto;
|
||||
import com.abiquo.server.core.enterprise.UserDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code AdminAsyncApi}
|
||||
|
@ -48,8 +49,8 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest<AdminAsyncApi> {
|
|||
/*********************** Role ***********************/
|
||||
|
||||
public void testListRoles() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AdminAsyncApi.class.getMethod("listRoles");
|
||||
GeneratedHttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(AdminAsyncApi.class.getMethod("listRoles"));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/roles HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + RolesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -63,8 +64,8 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest<AdminAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetRoleFromUser() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AdminAsyncApi.class.getMethod("getRole", UserDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.userPut());
|
||||
Invokable<?, ?> method = Invokable.from(AdminAsyncApi.class.getMethod("getRole", UserDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.userPut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -78,8 +79,8 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest<AdminAsyncApi> {
|
|||
}
|
||||
|
||||
public void testCreateRole() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AdminAsyncApi.class.getMethod("createRole", RoleDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePost());
|
||||
Invokable<?, ?> method = Invokable.from(AdminAsyncApi.class.getMethod("createRole", RoleDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(AdminResources.rolePost()));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://localhost/api/admin/roles HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -94,8 +95,8 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest<AdminAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeleteRole() throws SecurityException, NoSuchMethodException {
|
||||
Method method = AdminAsyncApi.class.getMethod("deleteRole", RoleDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut());
|
||||
Invokable<?, ?> method = Invokable.from(AdminAsyncApi.class.getMethod("deleteRole", RoleDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(AdminResources.rolePut()));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/admin/roles/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -109,8 +110,8 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest<AdminAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdateRole() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AdminAsyncApi.class.getMethod("updateRole", RoleDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut());
|
||||
Invokable<?, ?> method = Invokable.from(AdminAsyncApi.class.getMethod("updateRole", RoleDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(AdminResources.rolePut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/admin/roles/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -125,8 +126,8 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest<AdminAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetRoleById() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AdminAsyncApi.class.getMethod("getRole", Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, 1);
|
||||
Invokable<?, ?> method = Invokable.from(AdminAsyncApi.class.getMethod("getRole", Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -140,8 +141,8 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest<AdminAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListPrivilegesByRoles() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AdminAsyncApi.class.getMethod("listPrivileges", RoleDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut());
|
||||
Invokable<?, ?> method = Invokable.from(AdminAsyncApi.class.getMethod("listPrivileges", RoleDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(AdminResources.rolePut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1/action/privileges HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -157,8 +158,8 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest<AdminAsyncApi> {
|
|||
/*********************** Current User **********************/
|
||||
|
||||
public void testGetCurrentUser() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AdminAsyncApi.class.getMethod("getCurrentUser");
|
||||
GeneratedHttpRequest request = processor.createRequest(method, 1);
|
||||
Invokable<?, ?> method = Invokable.from(AdminAsyncApi.class.getMethod("getCurrentUser"));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/login HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.jclouds.abiquo.features;
|
|||
import static org.jclouds.abiquo.domain.DomainUtils.withHeader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
|
@ -77,6 +76,8 @@ import com.abiquo.server.core.infrastructure.storage.TierDto;
|
|||
import com.abiquo.server.core.infrastructure.storage.TiersDto;
|
||||
import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
|
||||
import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code CloudAsyncApi}
|
||||
|
@ -89,9 +90,9 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Virtual Datacenter ***********************/
|
||||
|
||||
public void testListVirtualDatacentersParams() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, VirtualDatacenterOptions.builder().datacenterId(1)
|
||||
.enterpriseId(1).build());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(VirtualDatacenterOptions.builder().datacenterId(1)
|
||||
.enterpriseId(1).build()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters?datacenter=1&enterprise=1 HTTP/1.1");
|
||||
|
@ -106,8 +107,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListVirtualDatacentersNoParams() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, VirtualDatacenterOptions.builder().build());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(VirtualDatacenterOptions.builder().build()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacentersDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -121,10 +122,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testCreateVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("createVirtualDatacenter", VirtualDatacenterDto.class,
|
||||
DatacenterDto.class, EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPost(),
|
||||
InfrastructureResources.datacenterPut(), EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("createVirtualDatacenter", VirtualDatacenterDto.class,
|
||||
DatacenterDto.class, EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPost(),
|
||||
InfrastructureResources.datacenterPut(), EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters?datacenter=1&enterprise=1 HTTP/1.1");
|
||||
|
@ -140,8 +141,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getVirtualDatacenter", Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualDatacenter", Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacenterDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -155,8 +156,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdateVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("updateVirtualDatacenter", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("updateVirtualDatacenter", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacenterDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -171,8 +172,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeleteVirtualDatacenter() throws SecurityException, NoSuchMethodException {
|
||||
Method method = CloudAsyncApi.class.getMethod("deleteVirtualDatacenter", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("deleteVirtualDatacenter", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -189,9 +190,9 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
|
||||
public void testListAvailablePublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
IpOptions options = IpOptions.builder().limit(5).build();
|
||||
Method method = CloudAsyncApi.class.getMethod("listAvailablePublicIps", VirtualDatacenterDto.class,
|
||||
IpOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), options);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listAvailablePublicIps", VirtualDatacenterDto.class,
|
||||
IpOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(), options));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/publicips/topurchase?limit=5 HTTP/1.1");
|
||||
|
@ -207,9 +208,9 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
|
||||
public void testListPurchasedPublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
IpOptions options = IpOptions.builder().limit(5).build();
|
||||
Method method = CloudAsyncApi.class.getMethod("listPurchasedPublicIps", VirtualDatacenterDto.class,
|
||||
IpOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), options);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listPurchasedPublicIps", VirtualDatacenterDto.class,
|
||||
IpOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(), options));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/publicips/purchased?limit=5 HTTP/1.1");
|
||||
|
@ -224,8 +225,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testPurchasePublicIp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("purchasePublicIp", PublicIpDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicIpToPurchase());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("purchasePublicIp", PublicIpDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(NetworkResources.publicIpToPurchase()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://localhost/api/cloud/virtualdatacenters/5/publicips/purchased/1 HTTP/1.1");
|
||||
|
@ -240,8 +241,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testReleasePublicIp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("releasePublicIp", PublicIpDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicIpToRelease());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("releasePublicIp", PublicIpDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(NetworkResources.publicIpToRelease()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://localhost/api/cloud/virtualdatacenters/5/publicips/topurchase/1 HTTP/1.1");
|
||||
|
@ -258,8 +259,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Available templates ***********************/
|
||||
|
||||
public void testListAvailableTemplates() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/action/templates HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -273,11 +274,11 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListAvailableTemplatesWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class,
|
||||
VirtualMachineTemplateOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class,
|
||||
VirtualMachineTemplateOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
VirtualMachineTemplateOptions.builder().hypervisorType(HypervisorType.XENSERVER).categoryName("Firewalls")
|
||||
.idTemplate(1).build());
|
||||
.idTemplate(1).build()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/action/templates"
|
||||
+ "?hypervisorTypeName=XENSERVER&categoryName=Firewalls&idTemplate=1 HTTP/1.1");
|
||||
|
@ -294,8 +295,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Storage Tiers ***********************/
|
||||
|
||||
public void testListStorageTiers() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listStorageTiers", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listStorageTiers", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/tiers HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + TiersDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -309,8 +310,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetStorageTier() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getStorageTier", VirtualDatacenterDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getStorageTier", VirtualDatacenterDto.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(), 1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/tiers/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + TierDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -324,8 +325,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetDefaultNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getDefaultNetwork", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getDefaultNetwork", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -339,10 +340,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testSetDefaultNetworkInternal() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class,
|
||||
VLANNetworkDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
NetworkResources.privateNetworkPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class,
|
||||
VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
NetworkResources.privateNetworkPut()));
|
||||
|
||||
RESTLink netLink = NetworkResources.privateNetworkPut().getEditLink();
|
||||
|
||||
|
@ -360,10 +361,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testSetDefaultNetworkExternal() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class,
|
||||
VLANNetworkDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
NetworkResources.externalNetworkPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class,
|
||||
VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
NetworkResources.externalNetworkPut()));
|
||||
|
||||
RESTLink netLink = NetworkResources.externalNetworkPut().getEditLink();
|
||||
|
||||
|
@ -383,8 +384,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Private Network ***********************/
|
||||
|
||||
public void testListPrivateNetworks() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listPrivateNetworks", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listPrivateNetworks", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -398,8 +399,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetPrivateNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getPrivateNetwork", VirtualDatacenterDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getPrivateNetwork", VirtualDatacenterDto.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(), 1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -413,10 +414,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testCreatePrivateNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("createPrivateNetwork", VirtualDatacenterDto.class,
|
||||
VLANNetworkDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
NetworkResources.vlanPost());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("createPrivateNetwork", VirtualDatacenterDto.class,
|
||||
VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
NetworkResources.vlanPost()));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/privatenetworks HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -431,8 +432,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdatePrivateNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("updatePrivateNetwork", VLANNetworkDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("updatePrivateNetwork", VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(NetworkResources.privateNetworkPut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -447,8 +448,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeletePrivateNetwork() throws SecurityException, NoSuchMethodException {
|
||||
Method method = CloudAsyncApi.class.getMethod("deletePrivateNetwork", VLANNetworkDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("deletePrivateNetwork", VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(NetworkResources.privateNetworkPut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"DELETE http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1");
|
||||
|
@ -465,8 +466,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Private Network IPs ***********************/
|
||||
|
||||
public void testListPrivateNetworkIps() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(NetworkResources.privateNetworkPut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips HTTP/1.1");
|
||||
|
@ -482,8 +483,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
|
||||
public void testListPrivateNetworkIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
IpOptions options = IpOptions.builder().startWith(10).build();
|
||||
Method method = CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class, IpOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut(), options);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class, IpOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(NetworkResources.privateNetworkPut(), options));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips?startwith=10 HTTP/1.1");
|
||||
|
@ -498,8 +499,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetPrivateNetworkIp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getPrivateNetworkIp", VLANNetworkDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getPrivateNetworkIp", VLANNetworkDto.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(NetworkResources.privateNetworkPut(), 1));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips/1 HTTP/1.1");
|
||||
|
@ -516,8 +517,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Virtual Appliance ***********************/
|
||||
|
||||
public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listVirtualAppliances", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualAppliances", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VirtualAppliancesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -531,8 +532,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getVirtualAppliance", VirtualDatacenterDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualAppliance", VirtualDatacenterDto.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(), 1));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1 HTTP/1.1");
|
||||
|
@ -547,8 +548,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetVirtualApplianceState() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getVirtualApplianceState", VirtualApplianceDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualApplianceState", VirtualApplianceDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/state HTTP/1.1");
|
||||
|
@ -563,10 +564,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testCreateVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("createVirtualAppliance", VirtualDatacenterDto.class,
|
||||
VirtualApplianceDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
CloudResources.virtualAppliancePost());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("createVirtualAppliance", VirtualDatacenterDto.class,
|
||||
VirtualApplianceDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
CloudResources.virtualAppliancePost()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances HTTP/1.1");
|
||||
|
@ -582,8 +583,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdateVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("updateVirtualAppliance", VirtualApplianceDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("updateVirtualAppliance", VirtualApplianceDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1 HTTP/1.1");
|
||||
|
@ -599,8 +600,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeleteVirtualAppliance() throws SecurityException, NoSuchMethodException {
|
||||
Method method = CloudAsyncApi.class.getMethod("deleteVirtualAppliance", VirtualApplianceDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("deleteVirtualAppliance", VirtualApplianceDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1 HTTP/1.1");
|
||||
|
@ -615,10 +616,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeployVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("deployVirtualAppliance", VirtualApplianceDto.class,
|
||||
VirtualMachineTaskDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(),
|
||||
CloudResources.deployOptions());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("deployVirtualAppliance", VirtualApplianceDto.class,
|
||||
VirtualMachineTaskDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut(),
|
||||
CloudResources.deployOptions()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/deploy HTTP/1.1");
|
||||
|
@ -634,10 +635,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUndeployVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("undeployVirtualAppliance", VirtualApplianceDto.class,
|
||||
VirtualMachineTaskDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(),
|
||||
CloudResources.undeployOptions());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("undeployVirtualAppliance", VirtualApplianceDto.class,
|
||||
VirtualMachineTaskDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut(),
|
||||
CloudResources.undeployOptions()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/undeploy HTTP/1.1");
|
||||
|
@ -653,8 +654,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetVirtualAppliancePrice() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getVirtualAppliancePrice", VirtualApplianceDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualAppliancePrice", VirtualApplianceDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/price HTTP/1.1");
|
||||
|
@ -671,8 +672,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Virtual Machine ***********************/
|
||||
|
||||
public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines HTTP/1.1");
|
||||
|
@ -687,10 +688,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListVirtualMachinesWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class,
|
||||
VirtualMachineOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(),
|
||||
VirtualMachineOptions.builder().disablePagination().build());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class,
|
||||
VirtualMachineOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut(),
|
||||
VirtualMachineOptions.builder().disablePagination().build()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines?limit=0 HTTP/1.1");
|
||||
|
@ -705,8 +706,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getVirtualMachine", VirtualApplianceDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualMachine", VirtualApplianceDto.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut(), 1));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1 HTTP/1.1");
|
||||
|
@ -721,10 +722,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testCreateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("createVirtualMachine", VirtualApplianceDto.class,
|
||||
VirtualMachineWithNodeExtendedDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(),
|
||||
CloudResources.virtualMachinePost());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("createVirtualMachine", VirtualApplianceDto.class,
|
||||
VirtualMachineWithNodeExtendedDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualAppliancePut(),
|
||||
CloudResources.virtualMachinePost()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines HTTP/1.1");
|
||||
|
@ -740,8 +741,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1 HTTP/1.1");
|
||||
|
@ -757,10 +758,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdateVirtualMachineWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class,
|
||||
VirtualMachineOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(),
|
||||
VirtualMachineOptions.builder().force(true).build());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class,
|
||||
VirtualMachineOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut(),
|
||||
VirtualMachineOptions.builder().force(true).build()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1?force=true HTTP/1.1");
|
||||
|
@ -776,10 +777,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testChangeVirtualMachineState() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("changeVirtualMachineState", VirtualMachineDto.class,
|
||||
VirtualMachineStateDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(),
|
||||
CloudResources.virtualMachineState());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("changeVirtualMachineState", VirtualMachineDto.class,
|
||||
VirtualMachineStateDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut(),
|
||||
CloudResources.virtualMachineState()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state HTTP/1.1");
|
||||
|
@ -795,8 +796,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeleteVirtualMachine() throws SecurityException, NoSuchMethodException {
|
||||
Method method = CloudAsyncApi.class.getMethod("deleteVirtualMachine", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("deleteVirtualMachine", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1 HTTP/1.1");
|
||||
|
@ -811,8 +812,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetVirtualMachineState() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getVirtualMachineState", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualMachineState", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state HTTP/1.1");
|
||||
|
@ -827,10 +828,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("deployVirtualMachine", VirtualMachineDto.class,
|
||||
VirtualMachineTaskDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(),
|
||||
CloudResources.deployOptions());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("deployVirtualMachine", VirtualMachineDto.class,
|
||||
VirtualMachineTaskDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut(),
|
||||
CloudResources.deployOptions()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/deploy HTTP/1.1");
|
||||
|
@ -846,10 +847,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUndeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("undeployVirtualMachine", VirtualMachineDto.class,
|
||||
VirtualMachineTaskDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(),
|
||||
CloudResources.undeployOptions());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("undeployVirtualMachine", VirtualMachineDto.class,
|
||||
VirtualMachineTaskDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut(),
|
||||
CloudResources.undeployOptions()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/undeploy HTTP/1.1");
|
||||
|
@ -865,8 +866,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("rebootVirtualMachine", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("rebootVirtualMachine", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/reset HTTP/1.1");
|
||||
|
@ -881,8 +882,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListNetworkConfigurations() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listNetworkConfigurations", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listNetworkConfigurations", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(
|
||||
request,
|
||||
|
@ -898,12 +899,12 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testSetGatewayNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("setGatewayNetwork", VirtualMachineDto.class, VLANNetworkDto.class);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("setGatewayNetwork", VirtualMachineDto.class, VLANNetworkDto.class));
|
||||
|
||||
VirtualMachineDto vm = CloudResources.virtualMachinePut();
|
||||
VLANNetworkDto network = NetworkResources.privateNetworkPut();
|
||||
|
||||
GeneratedHttpRequest request = processor.createRequest(method, vm, network);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(vm, network));
|
||||
|
||||
String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId();
|
||||
|
||||
|
@ -924,8 +925,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Virtual Machine Template ***********************/
|
||||
|
||||
public void testGetVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getVirtualMachineTemplate", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualMachineTemplate", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1 HTTP/1.1");
|
||||
|
@ -940,8 +941,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListAttachedVolumes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listAttachedVolumes", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listAttachedVolumes", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes HTTP/1.1");
|
||||
|
@ -956,8 +957,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDetachAllVolumes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("detachAllVolumes", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("detachAllVolumes", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes HTTP/1.1");
|
||||
|
@ -976,10 +977,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
VolumeManagementDto second = CloudResources.volumePut();
|
||||
second.getEditLink().setHref(second.getEditLink().getHref() + "second");
|
||||
|
||||
Method method = CloudAsyncApi.class.getMethod("replaceVolumes", VirtualMachineDto.class,
|
||||
VirtualMachineOptions.class, VolumeManagementDto[].class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(),
|
||||
VirtualMachineOptions.builder().force(true).build(), new VolumeManagementDto[] { first, second });
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("replaceVolumes", VirtualMachineDto.class,
|
||||
VirtualMachineOptions.class, VolumeManagementDto[].class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut(),
|
||||
VirtualMachineOptions.builder().force(true).build(), new VolumeManagementDto[] { first, second }));
|
||||
|
||||
String editLink = CloudResources.volumePut().getEditLink().getHref();
|
||||
assertRequestLineEquals(
|
||||
|
@ -997,8 +998,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListAttachedHardDisks() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listAttachedHardDisks", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listAttachedHardDisks", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks HTTP/1.1");
|
||||
|
@ -1013,8 +1014,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDetachAllHardDisks() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("detachAllHardDisks", VirtualMachineDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("detachAllHardDisks", VirtualMachineDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks HTTP/1.1");
|
||||
|
@ -1033,10 +1034,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
DiskManagementDto second = CloudResources.hardDiskPut();
|
||||
second.getEditLink().setHref(second.getEditLink().getHref() + "second");
|
||||
|
||||
Method method = CloudAsyncApi.class.getMethod("replaceHardDisks", VirtualMachineDto.class,
|
||||
DiskManagementDto[].class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(),
|
||||
new DiskManagementDto[] { first, second });
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("replaceHardDisks", VirtualMachineDto.class,
|
||||
DiskManagementDto[].class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualMachinePut(),
|
||||
new DiskManagementDto[] { first, second }));
|
||||
|
||||
String editLink = CloudResources.hardDiskPut().getEditLink().getHref();
|
||||
assertRequestLineEquals(request,
|
||||
|
@ -1055,8 +1056,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Hard disks ***********************/
|
||||
|
||||
public void testListHardDisks() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listHardDisks", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listHardDisks", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/disks HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + DisksManagementDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -1070,8 +1071,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetHardDisk() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getHardDisk", VirtualDatacenterDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getHardDisk", VirtualDatacenterDto.class, Integer.class));;
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(), 1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/disks/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + DiskManagementDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -1085,10 +1086,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testCreateHardDisk() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("createHardDisk", VirtualDatacenterDto.class,
|
||||
DiskManagementDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
CloudResources.hardDiskPost());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("createHardDisk", VirtualDatacenterDto.class,
|
||||
DiskManagementDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
CloudResources.hardDiskPost()));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/disks HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + DiskManagementDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -1103,8 +1104,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeleteHardDisk() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("deleteHardDisk", DiskManagementDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.hardDiskPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("deleteHardDisk", DiskManagementDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.hardDiskPut()));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/disks/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -1120,8 +1121,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
/*********************** Volumes ***********************/
|
||||
|
||||
public void testListVolumes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/volumes HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -1135,9 +1136,9 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListVolumesWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, VolumeOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
VolumeOptions.builder().onlyAvailable(true).build());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, VolumeOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
VolumeOptions.builder().onlyAvailable(true).build()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/volumes?available=true HTTP/1.1");
|
||||
|
@ -1152,10 +1153,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListVolumesWithFilterOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, VolumeOptions.class);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, VolumeOptions.class));
|
||||
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
VolumeOptions.builder().has("vol").orderBy(OrderBy.NAME).ascendant(true).build());
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
VolumeOptions.builder().has("vol").orderBy(OrderBy.NAME).ascendant(true).build()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/cloud/virtualdatacenters/1/volumes?has=vol&by=name&asc=true HTTP/1.1");
|
||||
|
@ -1170,8 +1171,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("getVolume", VirtualDatacenterDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("getVolume", VirtualDatacenterDto.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(), 1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VolumeManagementDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -1185,10 +1186,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("createVolume", VirtualDatacenterDto.class,
|
||||
VolumeManagementDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(),
|
||||
CloudResources.volumePost());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("createVolume", VirtualDatacenterDto.class,
|
||||
VolumeManagementDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.virtualDatacenterPut(),
|
||||
CloudResources.volumePost()));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/volumes HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VolumeManagementDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -1203,8 +1204,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdateVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("updateVolume", VolumeManagementDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.volumePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("updateVolume", VolumeManagementDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.volumePut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -1219,8 +1220,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class.getMethod("deleteVolume", VolumeManagementDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.volumePut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class.getMethod("deleteVolume", VolumeManagementDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.volumePut()));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -1234,10 +1235,10 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest<CloudAsyncApi> {
|
|||
}
|
||||
|
||||
public void testMoveVolume() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = CloudAsyncApi.class
|
||||
.getMethod("moveVolume", VolumeManagementDto.class, VirtualDatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, CloudResources.volumePut(),
|
||||
CloudResources.virtualDatacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(CloudAsyncApi.class
|
||||
.getMethod("moveVolume", VolumeManagementDto.class, VirtualDatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(CloudResources.volumePut(),
|
||||
CloudResources.virtualDatacenterPut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/cloud/virtualdatacenters/1/volumes/1/action/move HTTP/1.1");
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.jclouds.abiquo.features;
|
|||
import static org.jclouds.abiquo.domain.DomainUtils.withHeader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.abiquo.domain.ConfigResources;
|
||||
|
@ -41,6 +40,8 @@ import com.abiquo.server.core.config.SystemPropertiesDto;
|
|||
import com.abiquo.server.core.config.SystemPropertyDto;
|
||||
import com.abiquo.server.core.enterprise.PrivilegeDto;
|
||||
import com.abiquo.server.core.enterprise.PrivilegesDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code AdminAsyncApi}.
|
||||
|
@ -53,8 +54,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
/*********************** License ***********************/
|
||||
|
||||
public void testListLicenses() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("listLicenses");
|
||||
GeneratedHttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("listLicenses"));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/config/licenses HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + LicensesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -68,8 +69,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListLicenseWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("listLicenses", LicenseOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, LicenseOptions.builder().active(true).build());
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("listLicenses", LicenseOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(LicenseOptions.builder().active(true).build()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/config/licenses?active=true HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + LicensesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -83,8 +84,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testAddLicense() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("addLicense", LicenseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.licensePost());
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("addLicense", LicenseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(ConfigResources.licensePost()));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://localhost/api/config/licenses HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + LicenseDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -99,8 +100,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testRemoveLicense() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("removeLicense", LicenseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.licensePut());
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("removeLicense", LicenseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(ConfigResources.licensePut()));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/config/licenses/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -116,8 +117,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
/*********************** Privilege ***********************/
|
||||
|
||||
public void testListPrivileges() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("listPrivileges");
|
||||
GeneratedHttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("listPrivileges"));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/config/privileges HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -131,8 +132,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetPrivilege() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("getPrivilege", Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, 1);
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("getPrivilege", Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/config/privileges/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegeDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -148,8 +149,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
/*********************** System Properties ***********************/
|
||||
|
||||
public void testListSystemProperties() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("listSystemProperties");
|
||||
GeneratedHttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("listSystemProperties"));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/config/properties HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertiesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -163,9 +164,9 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testListSystemPropertiesWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("listSystemProperties", PropertyOptions.class);
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("listSystemProperties", PropertyOptions.class));
|
||||
GeneratedHttpRequest request = processor
|
||||
.createRequest(method, PropertyOptions.builder().component("api").build());
|
||||
.createRequest(method, ImmutableList.<Object> of(PropertyOptions.builder().component("api").build()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/config/properties?component=api HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertiesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -179,8 +180,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdateSystemProperty() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("updateSystemProperty", SystemPropertyDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.propertyPut());
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("updateSystemProperty", SystemPropertyDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(ConfigResources.propertyPut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/config/properties/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertyDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -197,8 +198,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
/*********************** Category ***********************/
|
||||
|
||||
public void testListCategories() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("listCategories");
|
||||
GeneratedHttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("listCategories"));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/config/categories HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + CategoriesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -212,8 +213,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testGetCategory() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("getCategory", Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, 1);
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("getCategory", Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/config/categories/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -227,8 +228,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testCreateCategory() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("createCategory", CategoryDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.categoryPost());
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("createCategory", CategoryDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(ConfigResources.categoryPost()));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://localhost/api/config/categories HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -243,8 +244,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testUpdateCategory() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("updateCategory", CategoryDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.categoryPut());
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("updateCategory", CategoryDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(ConfigResources.categoryPut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/config/categories/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -259,8 +260,8 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest<ConfigAsyncApi> {
|
|||
}
|
||||
|
||||
public void testDeleteCategory() throws SecurityException, NoSuchMethodException {
|
||||
Method method = ConfigAsyncApi.class.getMethod("deleteCategory", CategoryDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.categoryPut());
|
||||
Invokable<?, ?> method = Invokable.from(ConfigAsyncApi.class.getMethod("deleteCategory", CategoryDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(ConfigResources.categoryPut()));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/config/categories/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.jclouds.abiquo.features;
|
|||
import static org.jclouds.abiquo.domain.DomainUtils.withHeader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.abiquo.domain.EnterpriseResources;
|
||||
|
@ -53,6 +52,8 @@ import com.abiquo.server.core.infrastructure.DatacenterDto;
|
|||
import com.abiquo.server.core.infrastructure.DatacentersDto;
|
||||
import com.abiquo.server.core.infrastructure.MachinesDto;
|
||||
import com.abiquo.server.core.infrastructure.network.VLANNetworksDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code EnterpriseAsyncApi}
|
||||
|
@ -65,8 +66,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
/*********************** Enterprise ********************** */
|
||||
|
||||
public void testListEnterprises() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listEnterprises");
|
||||
GeneratedHttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listEnterprises"));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -82,8 +83,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
public void testListEnterprisesWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
EnterpriseOptions options = EnterpriseOptions.builder().has("abi").orderBy(OrderBy.NAME).ascendant(true).build();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listEnterprises", EnterpriseOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, options);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listEnterprises", EnterpriseOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(options));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises?has=abi&by=name&asc=true HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -99,9 +100,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
public void testListEnterprisesByDatacenter() throws SecurityException, NoSuchMethodException, IOException {
|
||||
EnterpriseOptions options = EnterpriseOptions.builder().startWith(0).limit(25).network(true).build();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listEnterprises", DatacenterDto.class,
|
||||
EnterpriseOptions.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), options);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listEnterprises", DatacenterDto.class,
|
||||
EnterpriseOptions.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(InfrastructureResources.datacenterPut(), options));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/admin/datacenters/1/action/enterprises?network=true&startwith=0&limit=25 HTTP/1.1");
|
||||
|
@ -116,8 +117,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testCreateEnterprise() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("createEnterprise", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePost());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("createEnterprise", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePost()));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -132,8 +133,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testGetEnterprise() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("getEnterprise", Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, 1);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getEnterprise", Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -147,8 +148,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testUpdateEnterprise() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("updateEnterprise", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateEnterprise", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -163,8 +164,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testDeleteEnterprise() throws SecurityException, NoSuchMethodException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("deleteEnterprise", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("deleteEnterprise", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -178,8 +179,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testListAllowedDatacenters() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listAllowedDatacenters", Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, 1);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listAllowedDatacenters", Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters?idEnterprise=1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -193,8 +194,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testListVirtualDatacentersFromEnterprise() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listVirtualDatacenters", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listVirtualDatacenters", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/admin/enterprises/1/action/virtualdatacenters HTTP/1.1");
|
||||
|
@ -211,8 +212,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
/*********************** Enterprise Properties ********************** */
|
||||
|
||||
public void testGetEnterpriseProperties() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("getEnterpriseProperties", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getEnterpriseProperties", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/properties HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisePropertiesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -226,8 +227,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testUpdateEnterpriseProperties() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("updateEnterpriseProperties", EnterprisePropertiesDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePropertiesPut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateEnterpriseProperties", EnterprisePropertiesDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePropertiesPut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/properties HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisePropertiesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -248,9 +249,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
DatacenterDto datacenter = InfrastructureResources.datacenterPut();
|
||||
DatacenterLimitsDto limits = EnterpriseResources.datacenterLimitsPost();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("createLimits", EnterpriseDto.class, DatacenterDto.class,
|
||||
DatacenterLimitsDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, enterprise, datacenter, limits);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("createLimits", EnterpriseDto.class, DatacenterDto.class,
|
||||
DatacenterLimitsDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(enterprise, datacenter, limits));
|
||||
|
||||
String limitsUri = enterprise.searchLink("limits").getHref();
|
||||
String requestURI = String.format("POST %s?datacenter=%d HTTP/1.1", limitsUri, datacenter.getId());
|
||||
|
@ -271,8 +272,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
EnterpriseDto enterprise = EnterpriseResources.enterprisePut();
|
||||
DatacenterDto datacenter = InfrastructureResources.datacenterPut();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("getLimits", EnterpriseDto.class, DatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, enterprise, datacenter);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getLimits", EnterpriseDto.class, DatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(enterprise, datacenter));
|
||||
|
||||
String limitsUri = enterprise.searchLink("limits").getHref();
|
||||
String requestURI = String.format("GET %s?datacenter=%d HTTP/1.1", limitsUri, datacenter.getId());
|
||||
|
@ -291,9 +292,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
public void testUpdateLimits() throws SecurityException, NoSuchMethodException, IOException {
|
||||
EnterpriseDto enterprise = EnterpriseResources.enterprisePut();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("updateLimits", DatacenterLimitsDto.class);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateLimits", DatacenterLimitsDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method,
|
||||
EnterpriseResources.datacenterLimitsPut(enterprise));
|
||||
ImmutableList.<Object> of(EnterpriseResources.datacenterLimitsPut(enterprise)));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/limits/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterLimitsDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -310,9 +311,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
public void testDeleteLimits() throws SecurityException, NoSuchMethodException {
|
||||
EnterpriseDto enterprise = EnterpriseResources.enterprisePut();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("deleteLimits", DatacenterLimitsDto.class);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("deleteLimits", DatacenterLimitsDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method,
|
||||
EnterpriseResources.datacenterLimitsPut(enterprise));
|
||||
ImmutableList.<Object> of(EnterpriseResources.datacenterLimitsPut(enterprise)));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/limits/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -326,8 +327,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testListLimitsEnterprise() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listLimits", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listLimits", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersLimitsDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -343,8 +344,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
/*********************** User ***********************/
|
||||
|
||||
public void testGetUser() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("getUser", EnterpriseDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getUser", EnterpriseDto.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut(), 1));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -358,8 +359,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testListUsers() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listUsers", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listUsers", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/users HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + UsersDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -376,8 +377,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
EnterpriseDto enterprise = EnterpriseResources.enterprisePut();
|
||||
UserDto user = EnterpriseResources.userPost();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("createUser", EnterpriseDto.class, UserDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, enterprise, user);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("createUser", EnterpriseDto.class, UserDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(enterprise, user));
|
||||
|
||||
assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises/1/users HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -392,8 +393,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testUpdateUser() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("updateUser", UserDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.userPut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateUser", UserDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.userPut()));
|
||||
|
||||
assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -408,8 +409,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testDeleteUser() throws SecurityException, NoSuchMethodException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("deleteUser", UserDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.userPut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("deleteUser", UserDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.userPut()));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -423,8 +424,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testListVirtualMachinesByUser() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listVirtualMachines", UserDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.userPut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listVirtualMachines", UserDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.userPut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/admin/enterprises/1/users/1/action/virtualmachines HTTP/1.1");
|
||||
|
@ -441,9 +442,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
/*********************** Datacenter Repository ********************** */
|
||||
|
||||
public void testGetDatacenterRepository() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("getDatacenterRepository", EnterpriseDto.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut(),
|
||||
InfrastructureResources.datacenterPut().getId());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getDatacenterRepository", EnterpriseDto.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut(),
|
||||
InfrastructureResources.datacenterPut().getId()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterRepositoryDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -457,9 +458,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testRefreshTemplateRepository() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("refreshTemplateRepository", Integer.class, Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut().getId(),
|
||||
InfrastructureResources.datacenterPut().getId());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("refreshTemplateRepository", Integer.class, Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut().getId(),
|
||||
InfrastructureResources.datacenterPut().getId()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://localhost/api/admin/enterprises/1/datacenterrepositories/1/actions/refresh HTTP/1.1");
|
||||
|
@ -476,8 +477,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
/*********************** External Network ********************** */
|
||||
|
||||
public void testListExternalNetworks() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listExternalNetworks", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listExternalNetworks", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/externalnetworks HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -493,8 +494,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
/*********************** Cloud ********************** */
|
||||
|
||||
public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listVirtualMachines", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listVirtualMachines", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/virtualmachines HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -508,8 +509,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listVirtualAppliances", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listVirtualAppliances", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/virtualappliances HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + VirtualAppliancesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -525,8 +526,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
/*********************** Machine ********************** */
|
||||
|
||||
public void testListReservedMachines() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listReservedMachines", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listReservedMachines", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/reservedmachines HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
@ -542,8 +543,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
/*********************** Template definition list ***********************/
|
||||
|
||||
public void testListTemplateDefinitionLists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listTemplateDefinitionLists", EnterpriseDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listTemplateDefinitionLists", EnterpriseDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists HTTP/1.1");
|
||||
|
@ -561,9 +562,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
EnterpriseDto enterprise = EnterpriseResources.enterprisePut();
|
||||
TemplateDefinitionListDto template = EnterpriseResources.templateListPost();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("createTemplateDefinitionList", EnterpriseDto.class,
|
||||
TemplateDefinitionListDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, enterprise, template);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("createTemplateDefinitionList", EnterpriseDto.class,
|
||||
TemplateDefinitionListDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(enterprise, template));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists HTTP/1.1");
|
||||
|
@ -581,9 +582,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
public void testUpdateTemplateDefinitionList() throws SecurityException, NoSuchMethodException, IOException {
|
||||
TemplateDefinitionListDto template = EnterpriseResources.templateListPut();
|
||||
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("updateTemplateDefinitionList",
|
||||
TemplateDefinitionListDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, template);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateTemplateDefinitionList",
|
||||
TemplateDefinitionListDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(template));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"PUT http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1 HTTP/1.1");
|
||||
|
@ -599,9 +600,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testDeleteTemplateDefinitionList() throws SecurityException, NoSuchMethodException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("deleteTemplateDefinitionList",
|
||||
TemplateDefinitionListDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.templateListPut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("deleteTemplateDefinitionList",
|
||||
TemplateDefinitionListDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.templateListPut()));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"DELETE http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1 HTTP/1.1");
|
||||
|
@ -616,9 +617,9 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testGetTemplateDefinitionList() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("getTemplateDefinitionList", EnterpriseDto.class,
|
||||
Integer.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut(), 1);
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getTemplateDefinitionList", EnterpriseDto.class,
|
||||
Integer.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.enterprisePut(), 1));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"GET http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1 HTTP/1.1");
|
||||
|
@ -633,10 +634,10 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest<EnterpriseAsy
|
|||
}
|
||||
|
||||
public void testListTemplateListStatus() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EnterpriseAsyncApi.class.getMethod("listTemplateListStatus", TemplateDefinitionListDto.class,
|
||||
DatacenterDto.class);
|
||||
GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.templateListPut(),
|
||||
InfrastructureResources.datacenterPut());
|
||||
Invokable<?, ?> method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listTemplateListStatus", TemplateDefinitionListDto.class,
|
||||
DatacenterDto.class));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(EnterpriseResources.templateListPut(),
|
||||
InfrastructureResources.datacenterPut()));
|
||||
|
||||
assertRequestLineEquals(
|
||||
request,
|
||||
|
|
|
@ -20,13 +20,14 @@
|
|||
package org.jclouds.abiquo.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.abiquo.server.core.event.EventsDto;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.reflect.Invokable;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code EventAsyncApi}
|
||||
|
@ -37,8 +38,8 @@ import com.abiquo.server.core.event.EventsDto;
|
|||
@Test(groups = "unit", testName = "EventAsyncApiTest")
|
||||
public class EventAsyncApiTest extends BaseAbiquoAsyncApiTest<EventAsyncApi> {
|
||||
public void testListEvents() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = EventAsyncApi.class.getMethod("listEvents");
|
||||
GeneratedHttpRequest request = processor.createRequest(method);
|
||||
Invokable<?, ?> method = Invokable.from(EventAsyncApi.class.getMethod("listEvents"));
|
||||
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
|
||||
|
||||
assertRequestLineEquals(request, "GET http://localhost/api/events HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: " + EventsDto.BASE_MEDIA_TYPE + "\n");
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue