Merge pull request #1153 from jclouds/invokable-with-enclosing

Invokable with enclosing
This commit is contained in:
Adrian Cole 2013-01-08 01:16:21 -08:00
commit f170c8d669
169 changed files with 3337 additions and 2240 deletions

View File

@ -37,7 +37,9 @@ import org.jclouds.reflect.Invocation;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
import com.google.common.reflect.TypeToken;
import org.jclouds.reflect.Invokable;
/**
*
@ -59,10 +61,12 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner {
this.processor = checkNotNull(processor, "processor");
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
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));
this.getMethod = Invokable.from(TypeToken.of(AtmosAsyncClient.class),
AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class));
this.deleteMethod = Invokable.from(TypeToken.of(AtmosAsyncClient.class),
AtmosAsyncClient.class.getMethod("deletePath", String.class));
this.createMethod = Invokable.from(TypeToken.of(AtmosAsyncClient.class),
AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, PutOptions[].class));
}
@Override

View File

@ -47,14 +47,15 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.options.GetOptions;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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;
/**
@ -70,7 +71,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testListDirectories() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -85,7 +86,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testListDirectory() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("directory"));
GeneratedHttpRequest 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");
@ -100,7 +101,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testListDirectoriesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(new ListOptions().limit(1).token("asda")));
GeneratedHttpRequest 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");
@ -115,7 +116,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testListDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException {
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")));
GeneratedHttpRequest 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");
@ -130,7 +131,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testCreateDirectory() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir"));
GeneratedHttpRequest 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");
@ -145,7 +146,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testCreateDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", PutOptions.Builder.publicRead()));
GeneratedHttpRequest 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
@ -162,7 +163,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testCreateFile() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class,
PutOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", blobToObject
GeneratedHttpRequest 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");
@ -179,7 +180,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testCreateFileOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class,
PutOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", blobToObject
GeneratedHttpRequest 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");
@ -197,7 +198,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testUpdateFile() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class,
PutOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", blobToObject
GeneratedHttpRequest 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");
@ -214,7 +215,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testUpdateFileOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class,
PutOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir", blobToObject
GeneratedHttpRequest 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");
@ -231,7 +232,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testReadFile() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir/file"));
GeneratedHttpRequest 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");
@ -246,7 +247,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testGetSystemMetadata() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("getSystemMetadata", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir/file"));
GeneratedHttpRequest 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");
@ -261,7 +262,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testDeletePath() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("deletePath", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir/file"));
GeneratedHttpRequest 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");
@ -276,7 +277,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
public void testIsPublic() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AtmosAsyncClient.class.getMethod("isPublic", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("dir/file"));
GeneratedHttpRequest 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");

View File

@ -62,13 +62,14 @@ import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.GetAuth;
import org.jclouds.openstack.keystone.v1_1.domain.Auth;
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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;
@ -85,7 +86,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException {
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));
GeneratedHttpRequest 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,7 +104,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testCreateServerWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
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)));
GeneratedHttpRequest 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,7 +122,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testCreateServerWithFile() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
CreateServerOptions[].class));
HttpRequest request = processor
GeneratedHttpRequest request = processor
.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");
@ -142,7 +143,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testCreateServerWithMetadata() throws IOException, SecurityException, NoSuchMethodException {
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,
GeneratedHttpRequest 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");
@ -163,7 +164,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
UnknownHostException {
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,
GeneratedHttpRequest 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");
@ -182,7 +183,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testDeleteImage() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteImage", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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, "");
@ -197,7 +198,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testLimits() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getLimits"));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -212,7 +213,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListServers() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -229,7 +230,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListServersOptions() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
GeneratedHttpRequest 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");
@ -245,7 +246,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListServersDetail() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
GeneratedHttpRequest 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");
@ -260,7 +261,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testGetServer() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getServer", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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");
@ -275,7 +276,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListFlavors() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -290,7 +291,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListFlavorsOptions() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
GeneratedHttpRequest 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");
@ -306,7 +307,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListFlavorsDetail() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
GeneratedHttpRequest 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");
@ -321,7 +322,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListFlavorsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
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)));
GeneratedHttpRequest 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");
@ -337,7 +338,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testGetFlavor() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getFlavor", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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");
@ -352,7 +353,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListImages() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -367,7 +368,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListImagesDetail() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
GeneratedHttpRequest 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");
@ -382,7 +383,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListImagesOptions() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
GeneratedHttpRequest 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");
@ -398,7 +399,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListImagesDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
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)));
GeneratedHttpRequest 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");
@ -414,7 +415,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testGetImage() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getImage", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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");
@ -429,7 +430,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testDeleteServer() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteServer", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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,7 +446,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testShareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
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));
GeneratedHttpRequest 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,7 +464,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testShareIpConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
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));
GeneratedHttpRequest 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, "");
@ -481,7 +482,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testUnshareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException,
UnknownHostException {
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));
GeneratedHttpRequest 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, "");
@ -497,7 +498,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testReplaceBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
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)
GeneratedHttpRequest 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");
@ -516,7 +517,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testDeleteBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteBackupSchedule", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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, "");
@ -532,7 +533,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("changeAdminPass", int.class, String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, "foo"));
GeneratedHttpRequest 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, "");
@ -548,7 +549,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testChangeServerName() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("renameServer", int.class, String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, "foo"));
GeneratedHttpRequest 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, "");
@ -564,7 +565,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListSharedIpGroups() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -579,7 +580,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListSharedIpGroupsOptions() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
GeneratedHttpRequest 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");
@ -595,7 +596,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListSharedIpGroupsDetail() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
GeneratedHttpRequest 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");
@ -610,7 +611,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListSharedIpGroupsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
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)));
GeneratedHttpRequest 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");
@ -626,7 +627,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testGetSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getSharedIpGroup", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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");
@ -642,7 +643,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testCreateSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class,
CreateSharedIpGroupOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie"));
GeneratedHttpRequest 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");
@ -659,7 +660,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testCreateSharedIpGroupWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class,
CreateSharedIpGroupOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", withServer(2)));
GeneratedHttpRequest 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");
@ -675,7 +676,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testDeleteSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteSharedIpGroup", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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, "");
@ -690,7 +691,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListAddresses() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getAddresses", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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");
@ -705,7 +706,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListPublicAddresses() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listPublicAddresses", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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");
@ -720,7 +721,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListPrivateAddresses() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("listPrivateAddresses", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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");
@ -735,7 +736,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testListBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("getBackupSchedule", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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");
@ -750,7 +751,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testCreateImageWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("createImageFromServer", String.class, int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2));
GeneratedHttpRequest 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");
@ -768,7 +769,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testRebuildServer() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebuildServer", int.class,
RebuildServerOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(3));
GeneratedHttpRequest 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, "");
@ -784,7 +785,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testRebuildServerWithImage() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebuildServer", int.class,
RebuildServerOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(3, withImage(2)));
GeneratedHttpRequest 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, "");
@ -799,7 +800,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testReboot() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebootServer", int.class, RebootType.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, RebootType.HARD));
GeneratedHttpRequest 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, "");
@ -814,7 +815,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testResize() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("resizeServer", int.class, int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, 3));
GeneratedHttpRequest 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, "");
@ -830,7 +831,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testConfirmResize() throws IOException, IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("confirmResizeServer", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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, "");
@ -845,7 +846,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
public void testRevertResize() throws IOException, SecurityException, NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(CloudServersAsyncClient.class.getMethod("revertResizeServer", int.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
GeneratedHttpRequest 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, "");

View File

@ -19,6 +19,7 @@
package org.jclouds.cloudsigma;
import java.util.Set;
import org.jclouds.cloudsigma.domain.Drive;
import org.jclouds.cloudsigma.domain.DriveData;
import org.jclouds.cloudsigma.domain.DriveInfo;

View File

@ -33,11 +33,11 @@ import org.jclouds.cloudsigma.domain.ServerMetrics;
import org.jclouds.cloudsigma.functions.BaseDriveToMap;
import org.jclouds.cloudsigma.functions.DriveDataToMap;
import org.jclouds.cloudsigma.functions.MapToDevices;
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
import org.jclouds.cloudsigma.functions.MapToDriveMetrics;
import org.jclouds.cloudsigma.functions.MapToNICs;
import org.jclouds.cloudsigma.functions.MapToServerMetrics;
import org.jclouds.cloudsigma.functions.ServerToMap;
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.annotation.ClientError;

View File

@ -31,8 +31,8 @@ import org.jclouds.cloudsigma.domain.SCSIDevice;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Maps;
/**
*

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.cloudsigma.util;
import org.jclouds.cloudsigma.CloudSigmaClient;
import org.jclouds.cloudsigma.domain.IDEDevice;
import org.jclouds.cloudsigma.domain.Model;
import org.jclouds.cloudsigma.domain.NIC;

View File

@ -46,12 +46,13 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code CloudSigmaAsyncClient}
@ -64,7 +65,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getProfileInfo"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/profile/info HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
@ -80,7 +81,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListStandardDrives() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardDrives"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -95,7 +96,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListStandardCds() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardCds"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -110,7 +111,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListStandardImages() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardImages"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -125,7 +126,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listDriveInfo"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/info HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
@ -140,7 +141,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getDriveInfo", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -156,7 +157,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createDrive", Drive.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
new CreateDriveRequest.Builder().name("foo").use(ImmutableList.of("production", "candy")).size(10000l)
.build()));
@ -175,7 +176,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testCloneDrive() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class,
CloneDriveOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname"));
GeneratedHttpRequest 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");
@ -192,7 +193,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testCloneDriveOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class,
CloneDriveOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname",
GeneratedHttpRequest 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");
@ -209,7 +210,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
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)
GeneratedHttpRequest 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");
@ -226,15 +227,15 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listServers"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
assertPayloadEquals(httpRequest, null, null, false);
// now make sure request filters apply by replaying
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
// for example, using basic authentication, we should get "only one"
@ -253,7 +254,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listServerInfo"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/info HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
@ -268,7 +269,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getServerInfo", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -284,7 +285,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createServer", Server.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(BindServerToPlainTextStringTest.SERVER));
GeneratedHttpRequest 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");
@ -300,7 +301,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", BindServerToPlainTextStringTest.SERVER));
GeneratedHttpRequest 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");
@ -316,7 +317,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -332,7 +333,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("startServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -348,7 +349,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("stopServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -364,7 +365,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("shutdownServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -380,7 +381,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("resetServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -396,15 +397,15 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listDrives"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
assertPayloadEquals(httpRequest, null, null, false);
// now make sure request filters apply by replaying
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
// for example, using basic authentication, we should get "only one"
@ -423,7 +424,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyDrive", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -439,15 +440,15 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListVLANs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listVLANs"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
assertPayloadEquals(httpRequest, null, null, false);
// now make sure request filters apply by replaying
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
// for example, using basic authentication, we should get "only one"
@ -466,7 +467,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listVLANInfo"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -481,7 +482,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testGetVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getVLANInfo", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -497,7 +498,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testCreateVLAN() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createVLAN", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("poohbear"));
GeneratedHttpRequest 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");
@ -513,7 +514,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testRenameVLAN() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("renameVLAN", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "poohbear"));
GeneratedHttpRequest 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");
@ -529,7 +530,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testDestroyVLAN() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyVLAN", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -545,15 +546,15 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListStaticIPs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStaticIPs"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
assertPayloadEquals(httpRequest, null, null, false);
// now make sure request filters apply by replaying
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
// for example, using basic authentication, we should get "only one"
@ -572,7 +573,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testListStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStaticIPInfo"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -587,7 +588,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testGetStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getStaticIPInfo", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -603,7 +604,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testCreateStaticIP() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createStaticIP"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -619,7 +620,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
public void testDestroyStaticIP() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyStaticIP", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");

View File

@ -27,13 +27,13 @@ import java.util.Map;
import org.jclouds.cloudsigma.options.CloneDriveOptions;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.reflect.Invokable;
import com.google.inject.Guice;
/**

View File

@ -25,13 +25,13 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListAccountsOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -45,7 +45,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
public void testListAccounts() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listAccounts&listAll=true HTTP/1.1");
@ -62,7 +62,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
public void testListAccountsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
ListAccountsOptions.Builder.accountInDomain("jclouds", "123")));
assertRequestLineEquals(httpRequest,
@ -80,7 +80,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
public void testGetAccount() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AccountAsyncClient.class.getMethod("getAccount", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("3"));
GeneratedHttpRequest 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");

View File

@ -28,15 +28,15 @@ import org.jclouds.cloudstack.options.AssociateIPAddressOptions;
import org.jclouds.cloudstack.options.ListPublicIPAddressesOptions;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -49,7 +49,7 @@ import com.google.common.reflect.Invokable;
public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<AddressAsyncClient> {
public void testListPublicIPAddresses() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listPublicIpAddresses&listAll=true HTTP/1.1");
@ -66,7 +66,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
public void testListPublicIPAddressesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
ListPublicIPAddressesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true)));
assertRequestLineEquals(
@ -85,7 +85,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
public void testGetPublicIPAddress() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("getPublicIPAddress", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -104,7 +104,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
public void testAssociateIPAddressInZone() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("associateIPAddressInZone", String.class,
AssociateIPAddressOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(6));
GeneratedHttpRequest 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");
@ -121,7 +121,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
public void testDisassociateIPAddress() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AddressAsyncClient.class.getMethod("disassociateIPAddress", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");

View File

@ -26,11 +26,11 @@ import org.jclouds.cloudstack.functions.ParseAsyncJobFromHttpResponse;
import org.jclouds.cloudstack.functions.ParseAsyncJobsFromHttpResponse;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListAsyncJobsOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code AsyncJobAsyncClient}
@ -44,7 +44,7 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<Async
public void testGetAsyncJob() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AsyncJobAsyncClient.class.getMethod("getAsyncJob", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
GeneratedHttpRequest 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");
@ -61,7 +61,7 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<Async
public void testListAsyncJobs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listAsyncJobs&listAll=true HTTP/1.1");
@ -78,7 +78,7 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<Async
public void testListAsyncJobsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
ListAsyncJobsOptions.Builder.accountInDomain("adrian", "5")));
assertRequestLineEquals(httpRequest,

View File

@ -22,12 +22,12 @@ import java.io.IOException;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code ConfigurationAsyncClient}
@ -41,7 +41,7 @@ public class ConfigurationAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testListCapabilities() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ConfigurationAsyncClient.class.getMethod("listCapabilities"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&listAll=true&command=listCapabilities HTTP/1.1");

View File

@ -20,13 +20,13 @@ package org.jclouds.cloudstack.features;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code DomainAccountAsyncClient}
@ -38,7 +38,7 @@ public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testEnableAccount() throws Exception {
Invokable<?, ?> method = Invokable.from(DomainAccountAsyncClient.class.getMethod("enableAccount", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo", "2"));
GeneratedHttpRequest 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");
@ -54,7 +54,7 @@ public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testDisableAccount() throws Exception {
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));
GeneratedHttpRequest 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");

View File

@ -24,12 +24,12 @@ import org.jclouds.cloudstack.domain.ResourceLimit;
import org.jclouds.cloudstack.domain.ResourceLimit.ResourceType;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code DomainLimitAsyncClient}
@ -41,7 +41,7 @@ public class DomainLimitAsyncClientTest extends BaseCloudStackAsyncClientTest<Do
public void testUpdateResourceLimit() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(DomainLimitAsyncClient.class.getMethod("updateResourceLimit", ResourceLimit.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
ResourceLimit.builder().resourceType(ResourceType.SNAPSHOT).account("foo").domainId("100").max(101).build()));
assertRequestLineEquals(

View File

@ -24,12 +24,12 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListEventsOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code EventAsyncClient}
@ -43,7 +43,7 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest<EventAsy
public void testListEventTypes() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(EventAsyncClient.class.getMethod("listEventTypes"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&listAll=true&command=listEventTypes HTTP/1.1");
@ -59,7 +59,7 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest<EventAsy
public void testListEvents() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents HTTP/1.1");
@ -76,7 +76,7 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest<EventAsy
public void testEventsListOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListEventsOptions.Builder.account("jclouds")));
GeneratedHttpRequest 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");

View File

@ -26,14 +26,14 @@ import org.jclouds.cloudstack.domain.PortForwardingRule;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code FirewallAsyncClient}
@ -47,7 +47,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
public void testListPortForwardingRules() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(FirewallAsyncClient.class.getMethod("listPortForwardingRules",
ListPortForwardingRulesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true HTTP/1.1");
@ -65,7 +65,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
public void testListPortForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(FirewallAsyncClient.class.getMethod("listPortForwardingRules",
ListPortForwardingRulesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListPortForwardingRulesOptions.Builder.ipAddressId("3")));
GeneratedHttpRequest 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");
@ -84,7 +84,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
IOException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("6", PortForwardingRule.Protocol.TCP, 22, "7", 22));
assertRequestLineEquals(
httpRequest,
@ -102,7 +102,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
public void testDeletePortForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(FirewallAsyncClient.class.getMethod("deletePortForwardingRule", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");

View File

@ -26,10 +26,11 @@ import org.jclouds.cloudstack.options.UpdateAccountOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GlobalAccountAsyncClient}
@ -54,7 +55,7 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testCreateAccount() throws Exception {
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",
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("user", Account.Type.USER, "email@example.com",
"FirstName", "LastName", "hashed-password"));
assertRequestLineEquals(httpRequest, create.getRequestLine());
@ -80,7 +81,7 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testUpdateAccount() throws Exception {
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"));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("account", 42L, "new-account-name"));
assertRequestLineEquals(httpRequest, update.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -95,7 +96,7 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testDeleteAccount() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("deleteAccount", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(42L));
GeneratedHttpRequest 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");

View File

@ -23,12 +23,12 @@ import java.io.IOException;
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListAlertsOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GlobalAlertsAsyncClient}
@ -42,7 +42,7 @@ public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
public void testListAlerts() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listAlerts&listAll=true HTTP/1.1");
@ -59,7 +59,7 @@ public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
public void testListAlertsOptions() throws SecurityException, NoSuchMethodException, IOException {
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")));
GeneratedHttpRequest 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");

View File

@ -24,12 +24,12 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.cloudstack.domain.Capacity;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListCapacityOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GlobalCapacityAsyncClient}
@ -43,7 +43,7 @@ public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testListCapacity() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listCapacity&listAll=true HTTP/1.1");
@ -59,7 +59,7 @@ public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testListCapacityOptions() throws SecurityException, NoSuchMethodException, IOException {
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")));
GeneratedHttpRequest 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");

View File

@ -21,12 +21,12 @@ package org.jclouds.cloudstack.features;
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListHostsOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GlobalHostAsyncClient}
@ -38,7 +38,7 @@ public class GlobalHostAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
public void testListHosts() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalHostAsyncClient.class.getMethod("listHosts", ListHostsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listHosts&listAll=true HTTP/1.1");

View File

@ -28,10 +28,11 @@ import org.jclouds.cloudstack.options.UpdateServiceOfferingOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GlobalOfferingAsyncClient}
@ -54,7 +55,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testCreateServiceOffering() throws Exception {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name", "displayText", 1, 2, 3));
assertRequestLineEquals(httpRequest, createServiceOffering.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -70,7 +71,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testUpdateServiceOffering() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateServiceOffering",
String.class, UpdateServiceOfferingOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=updateServiceOffering&id=1 HTTP/1.1");
@ -86,7 +87,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testDeleteServiceOffering() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("deleteServiceOffering", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteServiceOffering&id=1 HTTP/1.1");
@ -103,7 +104,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testCreateDiskOffering() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("createDiskOffering",
String.class, String.class, CreateDiskOfferingOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name", "displayText"));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name", "displayText"));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=createDiskOffering&name=name&displaytext=displayText HTTP/1.1");
@ -120,7 +121,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testUpdateDiskOffering() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateDiskOffering",
String.class, UpdateDiskOfferingOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=updateDiskOffering&id=1 HTTP/1.1");
@ -136,7 +137,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testDeleteDiskOffering() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("deleteDiskOffering", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=deleteDiskOffering&id=1 HTTP/1.1");
@ -153,7 +154,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testUpdateNetworkOffering() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateNetworkOffering",
String.class, UpdateNetworkOfferingOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1L));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=updateNetworkOffering&id=1 HTTP/1.1");

View File

@ -21,12 +21,12 @@ package org.jclouds.cloudstack.features;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListStoragePoolsOptions;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GlobalStoragePoolAsyncClient}
@ -38,7 +38,7 @@ public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientT
public void testListStoragePools() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listStoragePools&listAll=true HTTP/1.1");
@ -54,7 +54,7 @@ public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientT
public void testListStoragePoolsOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListStoragePoolsOptions.Builder.clusterId("3").id("4").ipAddress("192.168.42.42").keyword("fred").name("bob").path("/mnt/store42").podId("4").zoneId("5")));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listStoragePools&listAll=true&clusterid=3&id=4&ipaddress=192.168.42.42&keyword=fred&name=bob&path=/mnt/store42&podid=4&zoneid=5 HTTP/1.1");

View File

@ -25,12 +25,12 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.GenerateUsageRecordsOptions;
import org.jclouds.cloudstack.options.ListUsageRecordsOptions;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GlobalUsageAsyncClient}
@ -51,7 +51,7 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
Invokable<?, ?> method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("generateUsageRecords",
Date.class, Date.class, GenerateUsageRecordsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=generateUsageRecords&startdate=2012-01-01&enddate=2012-01-31 HTTP/1.1");
@ -76,7 +76,7 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
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")));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end, GenerateUsageRecordsOptions.Builder.domainId("42")));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=generateUsageRecords&startdate=2012-01-01&enddate=2012-01-31&domainid=42 HTTP/1.1");
@ -101,7 +101,7 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
Invokable<?, ?> method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("listUsageRecords",
Date.class, Date.class, ListUsageRecordsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listUsageRecords&listAll=true&startdate=2012-01-01&enddate=2012-01-31 HTTP/1.1");
@ -126,7 +126,7 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
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")));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(start, end, ListUsageRecordsOptions.Builder.accountInDomain("fred", "42").accountId("41").keyword("bob")));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listUsageRecords&listAll=true&startdate=2012-01-01&enddate=2012-01-31&account=fred&domainid=42&accountid=41&keyword=bob HTTP/1.1");

View File

@ -25,10 +25,11 @@ import org.jclouds.cloudstack.options.UpdateUserOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GlobalUserAsyncClient}
@ -50,7 +51,7 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
public void testCreateAccount() throws Exception {
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",
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("user", "account", "email@example.com",
"hashed-password", "FirstName", "LastName"));
assertRequestLineEquals(httpRequest, createUser.getRequestLine());
@ -66,7 +67,7 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
public void testUpdateUser() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalUserAsyncClient.class.getMethod("updateUser", String.class, UpdateUserOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(42L));
GeneratedHttpRequest 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");
@ -82,7 +83,7 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
public void testDeleteUser() throws Exception {
Invokable<?, ?> method = Invokable.from(GlobalUserAsyncClient.class.getMethod("deleteUser", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(42L));
GeneratedHttpRequest 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");

View File

@ -27,13 +27,13 @@ import org.jclouds.cloudstack.functions.ParseIdToNameFromHttpResponse;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListOSTypesOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -47,7 +47,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
public void testGetOSCategory() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("getOSCategory", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
GeneratedHttpRequest 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");
@ -64,7 +64,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
public void testListOSCategories() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSCategories"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listOsCategories&listAll=true HTTP/1.1");
@ -81,7 +81,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
public void testGetOSType() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("getOSType", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
GeneratedHttpRequest 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");
@ -99,7 +99,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
public void testListOSTypes() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listOsTypes&listAll=true HTTP/1.1");
@ -116,7 +116,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
public void testListOSTypesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListOSTypesOptions.Builder.OSCategoryId("11")));
GeneratedHttpRequest 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");

View File

@ -23,11 +23,11 @@ import java.io.IOException;
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code HypervisorAsyncClient}
@ -41,7 +41,7 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest<Hyp
public void testListHypervisors() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(HypervisorAsyncClient.class.getMethod("listHypervisors"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listHypervisors&listAll=true HTTP/1.1");
@ -58,7 +58,7 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest<Hyp
public void testListHypervisorsInZon() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(HypervisorAsyncClient.class.getMethod("listHypervisorsInZone", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11));
GeneratedHttpRequest 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");

View File

@ -31,11 +31,12 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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.
*
@ -48,7 +49,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testAttachISO() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("attachISO", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("3", "5"));
GeneratedHttpRequest 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");
@ -64,7 +65,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testDetachISO() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("detachISO", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
GeneratedHttpRequest 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");
@ -80,7 +81,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testUpdateISO() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
GeneratedHttpRequest 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");
@ -96,7 +97,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testUpdateISOOptions() throws NoSuchMethodException {
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)));
GeneratedHttpRequest 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");
@ -112,7 +113,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testDeleteISO() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
GeneratedHttpRequest 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");
@ -128,7 +129,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testDeleteISOOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest 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");
@ -153,7 +154,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testCopyISO() throws NoSuchMethodException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, 5, 7));
assertRequestLineEquals(httpRequest, copyIso.getRequestLine());
assertPayloadEquals(httpRequest, null, null, false);
@ -167,7 +168,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testUpdateISOPermissions() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
GeneratedHttpRequest 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");
@ -183,7 +184,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testUpdateISOPermissionsOptions() throws NoSuchMethodException {
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)));
GeneratedHttpRequest 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");
@ -199,7 +200,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testListISOPermissions() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3));
GeneratedHttpRequest 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");
@ -215,7 +216,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testListISOPermissionsOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest 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");
@ -240,7 +241,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testExtractISO() throws NoSuchMethodException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, ExtractMode.HTTP_DOWNLOAD, 5));
assertRequestLineEquals(httpRequest, extractIso.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -265,7 +266,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
public void testExtractISOOptions() throws NoSuchMethodException {
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/")));
GeneratedHttpRequest 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");

View File

@ -23,12 +23,12 @@ import java.io.IOException;
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListResourceLimitsOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code LimitAsyncClient}
@ -40,7 +40,7 @@ public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest<LimitAsy
public void testListResourceLimits() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listResourceLimits&listAll=true HTTP/1.1");
@ -57,7 +57,7 @@ public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest<LimitAsy
public void testListResourceLimitsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListResourceLimitsOptions.Builder.account("jclouds" , "23")));
GeneratedHttpRequest 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");

View File

@ -30,10 +30,11 @@ import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code LoadBalancerAsyncClient}
@ -47,7 +48,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
public void testListLoadBalancerRules() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
ListLoadBalancerRulesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules&listAll=true HTTP/1.1");
@ -65,7 +66,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
public void testListLoadBalancerRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules",
ListLoadBalancerRulesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListLoadBalancerRulesOptions.Builder.publicIPId("3")));
GeneratedHttpRequest 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");
@ -93,7 +94,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
public void testCreateLoadBalancerRuleForPublicIP() throws SecurityException, NoSuchMethodException, IOException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(6, Algorithm.LEASTCONN, "tcp", 22, 22));
assertRequestLineEquals(httpRequest, createLoadBalancerRule.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -109,7 +110,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
public void testUpdateLoadBalancerRule() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("updateLoadBalancerRule", String.class, UpdateLoadBalancerRuleOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -125,7 +126,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
public void testDeleteLoadBalancerRule() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("deleteLoadBalancerRule", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -144,7 +145,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
IOException {
Invokable<?, ?> method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listVirtualMachinesAssignedToLoadBalancerRule",
String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");

View File

@ -30,10 +30,11 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code NATAsyncClient}
@ -46,7 +47,7 @@ import com.google.common.reflect.Invokable;
public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncClient> {
public void testListIPForwardingRules() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&listAll=true HTTP/1.1");
@ -63,7 +64,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
public void testListIPForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
ListIPForwardingRulesOptions.Builder.virtualMachineId("3")));
assertRequestLineEquals(httpRequest,
@ -81,7 +82,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
public void testGetIPForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("getIPForwardingRule", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -107,7 +108,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
IOException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(7, "tcp", 22));
assertRequestLineEquals(httpRequest, createIpForwardingRule.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -134,7 +135,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
IOException {
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,
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(7, "tcp", 22,
CreateIPForwardingRuleOptions.Builder.endPort(22)));
assertRequestLineEquals(httpRequest, createIpForwardingRuleOptions.getRequestLine());
@ -151,7 +152,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
public void testEnableStaticNATForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("enableStaticNATForVirtualMachine", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, 6));
GeneratedHttpRequest 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");
@ -168,7 +169,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
public void testDisableStaticNATOnPublicIP() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("disableStaticNATOnPublicIP", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -185,7 +186,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
public void testDeleteIPForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NATAsyncClient.class.getMethod("deleteIPForwardingRule", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");

View File

@ -30,11 +30,12 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -47,7 +48,7 @@ import com.google.common.reflect.Invokable;
public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<NetworkAsyncClient> {
public void testListNetworks() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listNetworks&listAll=true HTTP/1.1");
@ -64,7 +65,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
public void testListNetworksOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListNetworksOptions.Builder.type(NetworkType.ADVANCED)
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListNetworksOptions.Builder.type(NetworkType.ADVANCED)
.domainId("6").id("5")));
assertRequestLineEquals(httpRequest,
@ -82,7 +83,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
public void testGetNetwork() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("getNetwork", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("id"));
GeneratedHttpRequest 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");
@ -110,7 +111,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
public void testCreateNetworkInZone() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1, 2, "named", "lovely"));
assertRequestLineEquals(httpRequest, createNetwork.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -139,7 +140,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
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", CreateNetworkOptions.Builder
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1, 2, "named", "lovely", CreateNetworkOptions.Builder
.netmask("255.255.255.0").domainId("6")));
assertRequestLineEquals(httpRequest, createNetworkOptions.getRequestLine());
@ -156,7 +157,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
public void testDeleteNetwork() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("deleteNetwork", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");

View File

@ -29,13 +29,13 @@ import org.jclouds.cloudstack.options.ListDiskOfferingsOptions;
import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions;
import org.jclouds.cloudstack.options.ListServiceOfferingsOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -48,7 +48,7 @@ import com.google.common.reflect.Invokable;
public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<OfferingAsyncClient> {
public void testListDiskOfferings() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listDiskOfferings&listAll=true HTTP/1.1");
@ -65,7 +65,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
public void testListDiskOfferingsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListDiskOfferingsOptions.Builder.domainId("6").id("5")));
GeneratedHttpRequest 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");
@ -82,7 +82,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
public void testGetDiskOffering() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("getDiskOffering", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("5"));
GeneratedHttpRequest 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");
@ -100,7 +100,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
public void testListNetworkOfferings() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listNetworkOfferings&listAll=true HTTP/1.1");
@ -117,7 +117,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
public void testListNetworkOfferingsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
ListNetworkOfferingsOptions.Builder.availability(DEFAULT).isShared(true).id("6")));
assertRequestLineEquals(
@ -136,7 +136,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
public void testGetNetworkOffering() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("getNetworkOffering", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("5"));
GeneratedHttpRequest 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");
@ -154,7 +154,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
public void testListServiceOfferings() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listServiceOfferings&listAll=true HTTP/1.1");
@ -171,7 +171,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
public void testListServiceOfferingsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListServiceOfferingsOptions.Builder.virtualMachineId("4")
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListServiceOfferingsOptions.Builder.virtualMachineId("4")
.domainId("5").id("6")));
assertRequestLineEquals(
@ -190,7 +190,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
public void testGetServiceOffering() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OfferingAsyncClient.class.getMethod("getServiceOffering", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("5"));
GeneratedHttpRequest 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");

View File

@ -32,14 +32,14 @@ import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
import org.jclouds.crypto.SshKeys;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -51,7 +51,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
public void testListSSHKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true HTTP/1.1");
@ -68,7 +68,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
public void testListSSHKeyPairsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSSHKeyPairsOptions.Builder.name("jclouds")));
GeneratedHttpRequest 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");
@ -85,7 +85,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
public void testGetSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("getSSHKeyPair", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair"));
GeneratedHttpRequest 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");
@ -104,7 +104,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
public void testRegisterSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
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, ImmutableList.<Object> of("jclouds-keypair", publicKey));
GeneratedHttpRequest 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
@ -123,7 +123,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
public void testDeleteSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("deleteSSHKeyPair", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair"));
GeneratedHttpRequest 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");

View File

@ -31,6 +31,8 @@ import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.base.Functions;
@ -38,7 +40,6 @@ 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}
@ -52,7 +53,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testListSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true HTTP/1.1");
@ -69,7 +70,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testListSecurityGroupsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSecurityGroupsOptions.Builder.virtualMachineId("4")
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSecurityGroupsOptions.Builder.virtualMachineId("4")
.domainId("5").id("6")));
assertRequestLineEquals(
@ -88,7 +89,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testGetSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("getSecurityGroup", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -106,7 +107,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("createSecurityGroup", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo"));
GeneratedHttpRequest 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");
@ -134,7 +135,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testAuthorizeIngressPortsToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
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,
GeneratedHttpRequest 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());
@ -167,7 +168,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testAuthorizeIngressPortsToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
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,
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "tcp", 22, 22,
ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1")));
assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress4.getRequestLine());
@ -195,7 +196,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testAuthorizeIngressICMPToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
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")));
GeneratedHttpRequest 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");
@ -227,7 +228,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testAuthorizeIngressICMPToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
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,
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, 22, 22,
ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1")));
assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress2.getRequestLine());
@ -245,7 +246,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testRevokeIngressRule() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeIngressRule", String.class,
AccountInDomainOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5,
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5,
AccountInDomainOptions.Builder.accountInDomain("adrian", "1")));
assertRequestLineEquals(
@ -264,7 +265,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroup", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");

View File

@ -34,12 +34,13 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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.
@ -54,7 +55,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testCreateSnapshot() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -70,7 +71,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testCreateSnapshotOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest 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");
@ -86,7 +87,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testListSnapshots() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSnapshots&listAll=true HTTP/1.1");
@ -102,7 +103,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testGetSnapshot() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("getSnapshot", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -119,7 +120,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testListSnapshotsOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest 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");
@ -135,7 +136,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testDeleteSnapshot() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshot", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(14));
GeneratedHttpRequest 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");
@ -161,7 +162,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testCreateSnapshotPolicy() throws NoSuchMethodException {
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));
GeneratedHttpRequest 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");
@ -176,7 +177,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testDeleteSnapshotPolicy() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicy", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(7));
GeneratedHttpRequest 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");
@ -193,7 +194,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testDeleteSnapshotPolicies() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicies", Iterable.class));
Iterable<String> ids = ImmutableSet.of("3", "5", "7");
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ids));
GeneratedHttpRequest 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");
@ -209,7 +210,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testListSnapshotPolicies() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(10));
GeneratedHttpRequest 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");
@ -225,7 +226,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testListSnapshotPoliciesOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest 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");

View File

@ -41,12 +41,13 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -60,7 +61,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testCreateTemplate() throws NoSuchMethodException {
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()));
GeneratedHttpRequest 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");
@ -75,7 +76,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testCreateTemplateOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest 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");
@ -102,7 +103,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testRegisterTemplate() throws NoSuchMethodException {
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));
GeneratedHttpRequest 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");
@ -138,7 +139,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testRegisterTemplateOptions() throws NoSuchMethodException {
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,
GeneratedHttpRequest 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());
@ -154,7 +155,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testUpdateTemplate() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17));
GeneratedHttpRequest 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");
@ -169,7 +170,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testUpdateTemplateOptions() throws NoSuchMethodException {
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)));
GeneratedHttpRequest 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");
@ -192,7 +193,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testCopyTemplate() throws NoSuchMethodException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17, 18, 19));
assertRequestLineEquals(httpRequest,copyTemplate.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -207,7 +208,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testDeleteTemplate() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17));
GeneratedHttpRequest 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");
@ -222,7 +223,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testDeleteTemplateOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest 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");
@ -237,7 +238,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testListTemplates() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplates"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -254,7 +255,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testListTemplatesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplates", ListTemplatesOptions.class));
HttpRequest httpRequest = processor
GeneratedHttpRequest httpRequest = processor
.createRequest(
method, ImmutableList.<Object> of(
ListTemplatesOptions.Builder.accountInDomain("adrian", "6").hypervisor("xen")
@ -276,7 +277,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testGetTemplate() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("getTemplateInZone", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, 1));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, 1));
assertRequestLineEquals(
httpRequest,
@ -295,7 +296,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testUpdateTemplatePermissions() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17));
GeneratedHttpRequest 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, "");
@ -310,7 +311,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testUpdateTemplatePermissionsOptions() throws NoSuchMethodException {
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)));
GeneratedHttpRequest 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, "");
@ -325,7 +326,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testListTemplatePermissions() throws NoSuchMethodException {
Invokable<?, ?> method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(17));
GeneratedHttpRequest 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");
@ -340,7 +341,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testListTemplatePermissionsOptions() throws NoSuchMethodException {
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")));
GeneratedHttpRequest 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");
@ -363,7 +364,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testExtractTemplate() throws NoSuchMethodException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(3, ExtractMode.HTTP_DOWNLOAD, 5));
assertRequestLineEquals(httpRequest, extractTemplate.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -387,7 +388,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
public void testExtractTemplateOptions() throws NoSuchMethodException {
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/")));
GeneratedHttpRequest 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");

View File

@ -29,14 +29,14 @@ import org.jclouds.cloudstack.options.ListVMGroupsOptions;
import org.jclouds.cloudstack.options.UpdateVMGroupOptions;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -50,7 +50,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
public void testListVMGroups() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listInstanceGroups&listAll=true HTTP/1.1");
@ -67,7 +67,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
public void testListVMGroupsOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListVMGroupsOptions.Builder.account("fred")
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListVMGroupsOptions.Builder.account("fred")
.domainId("5").id("6")));
assertRequestLineEquals(
@ -86,7 +86,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
public void testGetVMGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("getInstanceGroup", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -104,7 +104,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
public void testCreateVMGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo"));
GeneratedHttpRequest 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");
@ -121,7 +121,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
public void testCreateVMGroupOptions() throws SecurityException, NoSuchMethodException, IOException {
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")));
GeneratedHttpRequest 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");
@ -138,7 +138,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
public void testUpdateVMGroup() throws SecurityException, NoSuchMethodException, IOException {
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")));
GeneratedHttpRequest 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");
@ -155,7 +155,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
public void testDeleteVMGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VMGroupAsyncClient.class.getMethod("deleteInstanceGroup", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");

View File

@ -31,11 +31,12 @@ import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -49,7 +50,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
ListVirtualMachinesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&listAll=true HTTP/1.1");
@ -67,7 +68,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testListVirtualMachinesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("listVirtualMachines",
ListVirtualMachinesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
ListVirtualMachinesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true)));
assertRequestLineEquals(
@ -86,7 +87,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("getVirtualMachine", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -113,7 +114,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testDeployVirtualMachineInZone() throws SecurityException, NoSuchMethodException, IOException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(6, 4, 5));
assertRequestLineEquals(httpRequest, deployVirtualMachine.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -129,7 +130,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("rebootVirtualMachine", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -146,7 +147,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testStartVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("startVirtualMachine", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -163,7 +164,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testStopVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("stopVirtualMachine", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -180,7 +181,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testResetPasswordForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("resetPasswordForVirtualMachine", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -197,7 +198,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testChangeServiceForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("changeServiceForVirtualMachine", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -214,7 +215,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("updateVirtualMachine", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -231,7 +232,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testDestroyVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("destroyVirtualMachine", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
GeneratedHttpRequest 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");
@ -249,7 +250,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
public void testAssignVirtualMachine() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("assignVirtualMachine", String.class,
AssignVirtualMachineOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("abcd",
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("abcd",
AssignVirtualMachineOptions.Builder.accountInDomain("adrian", "6")));
assertRequestLineEquals(

View File

@ -26,10 +26,11 @@ import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListVolumesOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code EventAsyncClient}
@ -43,7 +44,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
public void testListVolumes() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("listVolumes", ListVolumesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listVolumes&listAll=true HTTP/1.1");
@ -59,7 +60,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
public void testGetVolume() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("getVolume", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(111L));
GeneratedHttpRequest 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");
@ -84,7 +85,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
public void testCreateVolumeWithSnapshot() throws SecurityException, NoSuchMethodException, IOException {
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));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-volume", 999L, 111l));
assertRequestLineEquals(httpRequest, createVolumeFromSnapshot.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -107,7 +108,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("createVolumeFromDiskOfferingInZone", String.class, String.class,
String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-volume", 999L, 111L));
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-volume", 999L, 111L));
assertRequestLineEquals(httpRequest, createVolumeFromDiskOffering.getRequestLine());
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
@ -121,7 +122,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
public void testAttachVolume() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("attachVolume", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(111L, 999L));
GeneratedHttpRequest 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");
@ -136,7 +137,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
public void testDetachVolume() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("detachVolume", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(111L));
GeneratedHttpRequest 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");
@ -150,7 +151,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VolumeAsyncClient.class.getMethod("deleteVolume", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(111L));
GeneratedHttpRequest 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");

View File

@ -25,14 +25,14 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
import org.jclouds.cloudstack.options.ListZonesOptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -45,7 +45,7 @@ import com.google.common.reflect.Invokable;
public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsyncClient> {
public void testListZones() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listZones&listAll=true HTTP/1.1");
@ -53,8 +53,8 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
assertPayloadEquals(httpRequest, null, null, false);
// now make sure request filters apply by replaying
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(
httpRequest,
@ -72,7 +72,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
public void testListZonesOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListZonesOptions.Builder.available(true).domainId("5")
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListZonesOptions.Builder.available(true).domainId("5")
.id("6")));
assertRequestLineEquals(httpRequest,
@ -90,7 +90,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
public void testGetZone() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ZoneAsyncClient.class.getMethod("getZone", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(6));
GeneratedHttpRequest 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");

View File

@ -34,11 +34,12 @@ import org.jclouds.ec2.xml.PermissionHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -65,9 +66,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "instanceId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -98,10 +99,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testCreateImageOptions() throws SecurityException, NoSuchMethodException, IOException {
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()
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "instanceId", new CreateImageOptions()
.withDescription("description").noReboot()));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
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 +130,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class,
DescribeImagesOptions[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -164,10 +165,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException, IOException {
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(
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds(
"1", "2")));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -195,9 +196,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("deregisterImageInRegion", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -227,9 +228,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "pathToManifest"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -259,10 +260,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testRegisterImageFromManifestOptions() throws SecurityException, NoSuchMethodException, IOException {
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()
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "pathToManifest", new RegisterImageOptions()
.withDescription("description")));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -294,9 +295,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageName", "snapshotId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -335,11 +336,11 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException {
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",
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageName", "snapshotId",
new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot(
"/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100)));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -369,9 +370,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testGetBlockDeviceMappingsForImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion", String.class,
String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -400,9 +401,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -436,10 +437,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
.of("all"), "imageId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -473,10 +474,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testRemoveLaunchPermissionsFromImage() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
.of("all"), "imageId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -505,9 +506,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion", String.class,
String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "imageId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");

View File

@ -29,12 +29,12 @@ import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
import org.jclouds.ec2.options.DescribeRegionsOptions;
import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler;
import org.jclouds.ec2.xml.DescribeRegionsResponseHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code AvailabilityZoneAndRegionAsyncClient}
@ -49,7 +49,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion",
String.class, DescribeAvailabilityZonesOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(Region.US_WEST_1));
GeneratedHttpRequest 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");
@ -66,7 +66,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException {
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")));
GeneratedHttpRequest 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");
@ -84,7 +84,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions",
DescribeRegionsOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -101,7 +101,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException {
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)));
GeneratedHttpRequest 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");

View File

@ -36,11 +36,12 @@ import org.jclouds.ec2.xml.SnapshotHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -53,7 +54,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id"));
GeneratedHttpRequest 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");
@ -81,9 +82,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testDescribeVolumes() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class,
String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -100,7 +101,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testDescribeVolumesArgs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class,
String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
GeneratedHttpRequest 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");
@ -131,9 +132,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testAttachVolume() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id", "instanceId", "/device"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -163,9 +164,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testDetachVolume() throws SecurityException, NoSuchMethodException, IOException {
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));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id", false));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -197,10 +198,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testDetachVolumeOptions() throws SecurityException, NoSuchMethodException, IOException {
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(
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "id", true, fromInstance("instanceId").fromDevice(
"/device")));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -217,7 +218,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testCreateSnapshot() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class,
String.class, CreateSnapshotOptions[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "volumeId"));
GeneratedHttpRequest 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");
@ -234,7 +235,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testCreateSnapshotOptions() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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");
@ -253,7 +254,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testDescribeSnapshots() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class,
DescribeSnapshotsOptions[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
GeneratedHttpRequest 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");
@ -270,7 +271,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testDescribeSnapshotsArgs() throws SecurityException, NoSuchMethodException, IOException {
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")
GeneratedHttpRequest 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");
@ -290,7 +291,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testGetCreateVolumePermissionForSnapshot() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("getCreateVolumePermissionForSnapshotInRegion",
String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "snapshotId"));
GeneratedHttpRequest 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");
@ -326,10 +327,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
public void testAddCreateVolumePermissionsToSnapshot() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
.of("all"), "snapshotId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -364,10 +365,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
IOException {
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
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList
.of("all"), "snapshotId"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -385,7 +386,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
IOException {
Invokable<?, ?> method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("resetCreateVolumePermissionsOnSnapshotInRegion",
String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "snapshotId"));
GeneratedHttpRequest 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");

View File

@ -26,10 +26,11 @@ import org.jclouds.ec2.xml.DescribeAddressesResponseHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.Lists;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code ElasticIPAddressAsyncClient}
@ -43,7 +44,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
public void testDisassociateAddress() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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");
@ -73,9 +74,9 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
public void testAssociateAddress() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "127.0.0.1", "me"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -91,7 +92,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
public void testReleaseAddress() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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");
@ -108,7 +109,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
public void testDescribeAddresses() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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");
@ -124,7 +125,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
public void testAllocateAddress() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("allocateAddressInRegion", String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
GeneratedHttpRequest 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");

View File

@ -39,12 +39,13 @@ import org.jclouds.ec2.xml.UnencodeStringValueHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -56,7 +57,7 @@ import com.google.common.reflect.Invokable;
public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyncClient> {
public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
GeneratedHttpRequest 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,7 +73,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testDescribeInstancesArgs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
GeneratedHttpRequest 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");
@ -89,7 +90,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testTerminateInstances() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("terminateInstancesInRegion", String.class,
String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
GeneratedHttpRequest 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");
@ -106,7 +107,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testRunInstances() throws SecurityException, NoSuchMethodException, IOException {
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));
GeneratedHttpRequest 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");
@ -128,7 +129,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testRunInstancesOptions() throws SecurityException, NoSuchMethodException, IOException {
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",
GeneratedHttpRequest 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");
@ -155,7 +156,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testStopInstances() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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");
@ -171,7 +172,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testRebootInstances() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("rebootInstancesInRegion", String.class, String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
GeneratedHttpRequest 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");
@ -187,7 +188,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testStartInstances() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("startInstancesInRegion", String.class, String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
GeneratedHttpRequest 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,7 +204,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testGetUserDataForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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");
@ -221,7 +222,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testGetRootDeviceNameForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion", String.class,
String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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,7 +239,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testGetRamdiskForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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");
@ -257,7 +258,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("isApiTerminationDisabledForInstanceInRegion", String.class,
String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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,7 +275,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testGetKernelForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getKernelForInstanceInRegion", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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");
@ -291,7 +292,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testGetInstanceTypeForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion", String.class,
String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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");
@ -310,7 +311,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getInstanceInitiatedShutdownBehaviorForInstanceInRegion",
String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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");
@ -330,7 +331,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getBlockDeviceMappingForInstanceInRegion", String.class,
String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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");
@ -362,9 +363,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testSetUserDataForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
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()));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test".getBytes()));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -395,9 +396,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testSetRamdiskForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -428,9 +429,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testSetKernelForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "test"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -462,9 +463,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
IOException {
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));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", true));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -495,9 +496,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testSetInstanceTypeForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
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));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", InstanceType.C1_MEDIUM));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -529,9 +530,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
NoSuchMethodException, IOException {
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));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -552,7 +553,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
Map<String, BlockDevice> mapping = Maps.newLinkedHashMap();
mapping.put("/dev/sda1", new BlockDevice("vol-test1", true));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", mapping));
GeneratedHttpRequest 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,7 +575,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
public void testGetConsoleOutputForInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(InstanceAsyncClient.class.getMethod("getConsoleOutputForInstanceInRegion", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1"));
GeneratedHttpRequest 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");

View File

@ -22,13 +22,13 @@ import java.io.IOException;
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.ec2.xml.DescribeKeyPairsResponseHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.Lists;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code KeyPairAsyncClient}
@ -41,7 +41,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(KeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "mykey"));
GeneratedHttpRequest 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");
@ -57,7 +57,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
public void testDescribeKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
GeneratedHttpRequest 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");
@ -73,7 +73,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
public void testDescribeKeyPairsArgs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
GeneratedHttpRequest 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");

View File

@ -28,10 +28,11 @@ import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.Lists;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code SecurityGroupAsyncClient}
@ -45,7 +46,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegion", String.class,
String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name"));
GeneratedHttpRequest 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");
@ -75,9 +76,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "name", "description"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -94,7 +95,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
public void testDescribeSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class,
String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
GeneratedHttpRequest 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");
@ -111,7 +112,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
public void testDescribeSecurityGroupsArgs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class,
String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
GeneratedHttpRequest 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");
@ -128,7 +129,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
public void testAuthorizeSecurityGroupIngressGroup() throws SecurityException, NoSuchMethodException, IOException {
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",
GeneratedHttpRequest 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");
@ -164,9 +165,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
public void testAuthorizeSecurityGroupIngressCidr() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertPayloadEquals(request, authorizeSecurityGroupIngressCidr.getPayload().getRawContent().toString(),
@ -182,7 +183,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
public void testRevokeSecurityGroupIngressGroup() throws SecurityException, NoSuchMethodException, IOException {
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",
GeneratedHttpRequest 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");
@ -218,9 +219,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
public void testRevokeSecurityGroupIngressCidr() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");

View File

@ -26,10 +26,11 @@ import org.jclouds.ec2.xml.BundleTaskHandler;
import org.jclouds.ec2.xml.DescribeBundleTasksResponseHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.Lists;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code WindowsAsyncClient}
@ -59,7 +60,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
public void testBundleInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class,
String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class));
HttpRequest request = processor
GeneratedHttpRequest request = processor
.createRequest(
method,
Lists.<Object> newArrayList(
@ -69,7 +70,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
"my-bucket",
"{\"expiration\": \"2008-08-30T08:49:09Z\",\"conditions\": [{\"bucket\": \"my-bucket\"},[\"starts-with\", \"$key\", \"my-new-image\"]]}"));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -103,7 +104,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
public void testBundleInstanceInRegionOptions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class,
String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class));
HttpRequest request = processor
GeneratedHttpRequest request = processor
.createRequest(
method,
Lists.<Object> newArrayList(
@ -114,7 +115,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
"{\"expiration\": \"2008-08-30T08:49:09Z\",\"conditions\": [{\"bucket\": \"my-bucket\"},[\"starts-with\", \"$key\", \"my-new-image\"]]}",
BundleInstanceS3StorageOptions.Builder.bucketOwnedBy("10QMXFEV71ZS32XQFTR2")));
request = request.getFilters().get(0).filter(request);
request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
@ -130,7 +131,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
public void testDescribeBundleTasks() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
GeneratedHttpRequest 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");
@ -146,7 +147,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
public void testDescribeBundleTasksArgs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "1", "2"));
GeneratedHttpRequest 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");

View File

@ -45,12 +45,13 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code ElasticStackAsyncClient}
@ -62,15 +63,15 @@ import com.google.common.reflect.Invokable;
public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStackAsyncClient> {
public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listServers"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
assertPayloadEquals(httpRequest, null, null, false);
// now make sure request filters apply by replaying
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1");
// for example, using basic authentication, we should get "only one"
@ -89,7 +90,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listServerInfo"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -104,7 +105,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("getServerInfo", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -120,7 +121,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testCreateAndStartServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createAndStartServer", Server.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
BindServerToPlainTextStringTest.SERVER));
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create HTTP/1.1");
@ -137,7 +138,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createServer", Server.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
BindServerToPlainTextStringTest.SERVER));
assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create/stopped HTTP/1.1");
@ -154,7 +155,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
GeneratedHttpRequest 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");
@ -171,7 +172,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("destroyServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -187,7 +188,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("startServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -203,7 +204,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("stopServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -219,7 +220,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("shutdownServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -235,7 +236,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("resetServer", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -251,15 +252,15 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listDrives"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
assertPayloadEquals(httpRequest, null, null, false);
// now make sure request filters apply by replaying
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1");
// for example, using basic authentication, we should get "only one"
@ -278,7 +279,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listDriveInfo"));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -293,7 +294,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("getDriveInfo", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -309,7 +310,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createDrive", Drive.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
GeneratedHttpRequest 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");
@ -326,7 +327,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
GeneratedHttpRequest 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");
@ -343,7 +344,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("destroyDrive", String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
GeneratedHttpRequest 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");
@ -359,7 +360,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testImageDrive() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "200"));
GeneratedHttpRequest 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");
@ -376,7 +377,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testImageDriveWithConversion() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class,
ImageConversionType.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "200",
GeneratedHttpRequest 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");
@ -393,7 +394,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testReadDrive() throws SecurityException, NoSuchMethodException, IOException {
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));
GeneratedHttpRequest 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");
@ -408,7 +409,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testWriteDrive() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
GeneratedHttpRequest 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");
@ -424,7 +425,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
public void testWriteDriveOffset() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class, long.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
GeneratedHttpRequest 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");

View File

@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Provides;

View File

@ -30,6 +30,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.options.GetOptions;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.blobstore.functions.BlobToObject;
@ -37,7 +38,6 @@ import org.jclouds.s3.domain.S3Object;
import org.jclouds.s3.options.PutObjectOptions;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
import com.google.common.reflect.TypeToken;
/**
@ -53,21 +53,19 @@ public class S3BlobRequestSigner<T extends S3AsyncClient> implements BlobRequest
private final Invokable<?, ?> getMethod;
private final Invokable<?, ?> deleteMethod;
private final Invokable<?, ?> createMethod;
private final Class<T> interfaceType;
@Inject
public S3BlobRequestSigner(RestAnnotationProcessor processor, BlobToObject blobToObject,
BlobToHttpGetOptions blob2HttpGetOptions, Class<T> interfaceType) throws SecurityException,
NoSuchMethodException {
this.processor = checkNotNull(processor, "processor");
this.interfaceType = checkNotNull(interfaceType, "interfaceType");
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
this.getMethod = TypeToken.of(interfaceType).method(
this.getMethod = Invokable.from(TypeToken.of(interfaceType),
interfaceType.getMethod("getObject", String.class, String.class, GetOptions[].class));
this.deleteMethod = TypeToken.of(interfaceType).method(
this.deleteMethod = Invokable.from(TypeToken.of(interfaceType),
interfaceType.getMethod("deleteObject", String.class, String.class));
this.createMethod = TypeToken.of(interfaceType).method(
this.createMethod = Invokable.from(TypeToken.of(interfaceType),
interfaceType.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class));
}
@ -75,7 +73,7 @@ public class S3BlobRequestSigner<T extends S3AsyncClient> implements BlobRequest
public HttpRequest signGetBlob(String container, String name) {
checkNotNull(container, "container");
checkNotNull(name, "name");
return cleanRequest(processor.apply(Invocation.create(interfaceType, getMethod,
return cleanRequest(processor.apply(Invocation.create( getMethod,
ImmutableList.<Object> of(container, name))));
}
@ -88,7 +86,7 @@ public class S3BlobRequestSigner<T extends S3AsyncClient> implements BlobRequest
public HttpRequest signPutBlob(String container, Blob blob) {
checkNotNull(container, "container");
checkNotNull(blob, "blob");
return cleanRequest(processor.apply(Invocation.create(interfaceType, createMethod,
return cleanRequest(processor.apply(Invocation.create( createMethod,
ImmutableList.<Object> of(container, blobToObject.apply(blob)))));
}
@ -101,7 +99,7 @@ public class S3BlobRequestSigner<T extends S3AsyncClient> implements BlobRequest
public HttpRequest signRemoveBlob(String container, String name) {
checkNotNull(container, "container");
checkNotNull(name, "name");
return cleanRequest(processor.apply(Invocation.create(interfaceType, deleteMethod,
return cleanRequest(processor.apply(Invocation.create( deleteMethod,
ImmutableList.<Object> of(container, name))));
}
@ -109,7 +107,7 @@ public class S3BlobRequestSigner<T extends S3AsyncClient> implements BlobRequest
public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
checkNotNull(container, "container");
checkNotNull(name, "name");
return cleanRequest(processor.apply(Invocation.create(interfaceType, getMethod,
return cleanRequest(processor.apply(Invocation.create( getMethod,
ImmutableList.of(container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options"))))));
}
}

View File

@ -31,13 +31,14 @@ import org.jclouds.blobstore.BlobStoreFallbacks.ThrowContainerNotFoundOn404;
import org.jclouds.blobstore.BlobStoreFallbacks.ThrowKeyNotFoundOn404;
import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseETagHeader;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.http.options.GetOptions;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.s3.S3Fallbacks.TrueOn404OrNotFoundFalseOnIllegalState;
import org.jclouds.s3.config.S3RestClientModule;
import org.jclouds.s3.domain.AccessControlList;
@ -70,7 +71,6 @@ 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;
/**
@ -94,13 +94,13 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testGetBucketLocation() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
assertRequestLineEquals(request, "GET https://bucket." + url + "/?location HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
assertPayloadEquals(request, null, null, false);
request = filter.filter(request);
request = (GeneratedHttpRequest) filter.filter(request);
assertRequestLineEquals(request, "GET https://bucket." + url + "/?location HTTP/1.1");
assertNonPayloadHeadersEqual(request,
@ -117,7 +117,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testGetBucketPayer() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getBucketPayer", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
assertRequestLineEquals(request, "GET https://bucket." + url + "/?requestPayment HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -132,7 +132,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testSetBucketPayerOwner() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", Payer.BUCKET_OWNER));
GeneratedHttpRequest 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");
@ -148,7 +148,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testSetBucketPayerRequester() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", Payer.REQUESTER));
GeneratedHttpRequest 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");
@ -165,7 +165,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testListBucket() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("listBucket", String.class,
ListBucketOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
assertRequestLineEquals(request, "GET https://bucket." + url + "/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -180,7 +180,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testBucketExists() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("bucketExists", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
GeneratedHttpRequest 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");
@ -206,7 +206,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
NoSuchMethodException, IOException {
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",
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("sourceBucket", "sourceObject", "destinationbucket",
"destinationObject"));
assertRequestLineEquals(request, "PUT https://destinationbucket." + url + "/destinationObject HTTP/1.1");
@ -223,7 +223,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testDeleteBucketIfEmpty() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("deleteBucketIfEmpty", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
assertRequestLineEquals(request, "DELETE https://bucket." + url + "/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -238,7 +238,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testDeleteObject() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
GeneratedHttpRequest 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");
@ -254,7 +254,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testGetBucketACL() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getBucketACL", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
assertRequestLineEquals(request, "GET https://bucket." + url + "/?acl HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -270,7 +270,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testGetObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
GeneratedHttpRequest 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");
@ -286,7 +286,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testGetObjectACL() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getObjectACL", String.class, String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
GeneratedHttpRequest 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");
@ -302,7 +302,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testObjectExists() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("objectExists", String.class, String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
GeneratedHttpRequest 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");
@ -318,7 +318,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testHeadObject() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("headObject", String.class, String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", "object"));
GeneratedHttpRequest 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");
@ -333,7 +333,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testListOwnedBuckets() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("listOwnedBuckets"));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(request, "GET https://" + url + "/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: " + url + "\n");
@ -353,7 +353,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testPutBucketACL() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("putBucketACL", String.class, AccessControlList.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", AccessControlList.fromCannedAccessPolicy(
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", AccessControlList.fromCannedAccessPolicy(
CannedAccessPolicy.PRIVATE, "1234")));
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?acl HTTP/1.1");
@ -376,7 +376,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
IllegalArgumentException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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");
@ -394,7 +394,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class
.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", blobToS3Object
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket", blobToS3Object
.apply(BindBlobToMultipartFormTest.TEST_BLOB)));
assertRequestLineEquals(request, "PUT https://bucket." + url + "/hello HTTP/1.1");
@ -411,7 +411,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testPutObjectACL() throws SecurityException, NoSuchMethodException, IOException {
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(
GeneratedHttpRequest 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");
@ -432,7 +432,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testGetBucketLogging() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("getBucketLogging", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
assertRequestLineEquals(request, "GET https://bucket." + url + "/?logging HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -447,7 +447,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testDisableBucketLogging() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("disableBucketLogging", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("bucket"));
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -463,7 +463,7 @@ public class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3AsyncClien
public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(S3AsyncClient.class.getMethod("enableBucketLogging", String.class, BucketLogging.class));
HttpRequest request = processor
GeneratedHttpRequest request = processor
.createRequest(method, ImmutableList.<Object> of("bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet
.<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL)))));

View File

@ -29,7 +29,7 @@ import org.jclouds.s3.internal.BaseS3AsyncClientTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
/**
* Tests behavior of {@code BindAsHostPrefixIfConfigured}

View File

@ -32,7 +32,7 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
/**
* Tests behavior of {@code BindAsHostPrefixIfConfigured}

View File

@ -35,7 +35,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.collect.Lists;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
/**
* @author Adrian Cole

View File

@ -41,7 +41,7 @@ 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;
import org.jclouds.reflect.Invokable;
/**
* Tests behavior of {@code RequestAuthorizeSignature}
@ -87,7 +87,7 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3Async
@Test
void testAppendBucketNameHostHeader() throws SecurityException, NoSuchMethodException {
HttpRequest request = processor.createRequest(
GeneratedHttpRequest request = processor.createRequest(
Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class)),
ImmutableList.<Object> of("bucket"));
StringBuilder builder = new StringBuilder();
@ -144,7 +144,7 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3Async
@Test
void testAppendBucketNameURIHost() throws SecurityException, NoSuchMethodException {
HttpRequest request = processor.createRequest(
GeneratedHttpRequest request = processor.createRequest(
Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class)),
ImmutableList.<Object> of("bucket"));
assertEquals(request.getEndpoint().getHost(), "bucket.s3.amazonaws.com");

View File

@ -46,6 +46,8 @@ import org.jclouds.openstack.swift.TemporaryUrlKey;
import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;
import org.jclouds.openstack.swift.domain.SwiftObject;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import com.google.common.base.Supplier;
@ -53,7 +55,6 @@ 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.common.reflect.TypeToken;
import com.google.inject.Provider;
@ -75,7 +76,6 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
private final Invokable<?, ?> getMethod;
private final Invokable<?, ?> deleteMethod;
private final Invokable<?, ?> createMethod;
private final Class<T> interfaceType;
/**
* create a signer for this subtype of swift
@ -89,7 +89,6 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
@TemporaryUrlKey Supplier<String> temporaryUrlKeySupplier, RestAnnotationProcessor processor,
Class<T> interfaceType) throws SecurityException, NoSuchMethodException {
this.processor = checkNotNull(processor, "processor");
this.interfaceType = checkNotNull(interfaceType, "interfaceType");
this.crypto = checkNotNull(crypto, "crypto");
this.unixEpochTimestampProvider = checkNotNull(unixEpochTimestampProvider, "unixEpochTimestampProvider");
@ -98,11 +97,11 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
this.getMethod = TypeToken.of(interfaceType).method(
this.getMethod = Invokable.from(TypeToken.of(interfaceType),
interfaceType.getMethod("getObject", String.class, String.class, GetOptions[].class));
this.deleteMethod = TypeToken.of(interfaceType).method(
this.deleteMethod = Invokable.from(TypeToken.of(interfaceType),
interfaceType.getMethod("removeObject", String.class, String.class));
this.createMethod = TypeToken.of(interfaceType).method(
this.createMethod = Invokable.from(TypeToken.of(interfaceType),
interfaceType.getMethod("putObject", String.class, SwiftObject.class));
}
@ -110,7 +109,7 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
public HttpRequest signGetBlob(String container, String name) {
checkNotNull(container, "container");
checkNotNull(name, "name");
return cleanRequest(processor.apply(Invocation.create(interfaceType, getMethod,
return cleanRequest(processor.apply(Invocation.create(getMethod,
ImmutableList.<Object> of(container, name))));
}
@ -118,7 +117,7 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
public HttpRequest signGetBlob(String container, String name, long timeInSeconds) {
checkNotNull(container, "container");
checkNotNull(name, "name");
HttpRequest request = processor.apply(Invocation.create(interfaceType, getMethod,
GeneratedHttpRequest request = processor.apply(Invocation.create(getMethod,
ImmutableList.<Object> of(container, name)));
return cleanRequest(signForTemporaryAccess(request, timeInSeconds));
}
@ -127,7 +126,7 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
checkNotNull(container, "container");
checkNotNull(name, "name");
return cleanRequest(processor.apply(Invocation.create(interfaceType, getMethod,
return cleanRequest(processor.apply(Invocation.create(getMethod,
ImmutableList.of(container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options"))))));
}
@ -135,7 +134,7 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
public HttpRequest signPutBlob(String container, Blob blob) {
checkNotNull(container, "container");
checkNotNull(blob, "blob");
return cleanRequest(processor.apply(Invocation.create(interfaceType, createMethod,
return cleanRequest(processor.apply(Invocation.create(createMethod,
ImmutableList.<Object> of(container, blobToObject.apply(blob)))));
}
@ -143,7 +142,7 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
public HttpRequest signPutBlob(String container, Blob blob, long timeInSeconds) {
checkNotNull(container, "container");
checkNotNull(blob, "blob");
HttpRequest request = processor.apply(Invocation.create(interfaceType, createMethod,
GeneratedHttpRequest request = processor.apply(Invocation.create(createMethod,
ImmutableList.<Object> of(container, blobToObject.apply(blob))));
return cleanRequest(signForTemporaryAccess(request, timeInSeconds));
}
@ -152,7 +151,7 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
public HttpRequest signRemoveBlob(String container, String name) {
checkNotNull(container, "container");
checkNotNull(name, "name");
return cleanRequest(processor.apply(Invocation.create(interfaceType, deleteMethod,
return cleanRequest(processor.apply(Invocation.create(deleteMethod,
ImmutableList.<Object> of(container, name))));
}

View File

@ -31,7 +31,7 @@ import org.nnsoft.guice.rocoto.Rocoto;
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
import com.google.common.base.Throwables;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
import com.google.inject.Guice;
import com.google.inject.Injector;

View File

@ -26,12 +26,13 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -44,7 +45,7 @@ public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest<VCloudVer
public void testVersions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VCloudVersionsAsyncClient.class.getMethod("getSupportedVersions"));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");

View File

@ -22,8 +22,9 @@ import java.io.IOException;
import java.net.URI;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
import org.jclouds.vcloud.options.CatalogItemOptions;
import org.jclouds.vcloud.xml.CatalogHandler;
@ -31,7 +32,6 @@ 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}
@ -45,7 +45,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CatalogAsyncClient.class.getMethod("getCatalog", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -61,7 +61,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CatalogAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog"));
GeneratedHttpRequest 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");
@ -76,7 +76,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(CatalogAsyncClient.class.getMethod("getCatalogItem", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -93,7 +93,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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");
@ -110,7 +110,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsy
IOException {
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
GeneratedHttpRequest 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")));

View File

@ -22,14 +22,14 @@ import java.io.IOException;
import java.net.URI;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -43,7 +43,7 @@ public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest<NetworkAsy
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(NetworkAsyncClient.class.getMethod("getNetwork", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -60,7 +60,7 @@ public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest<NetworkAsy
public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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");

View File

@ -23,15 +23,15 @@ import java.net.URI;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
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}
@ -45,7 +45,7 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest<OrgAsyncClient
public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OrgAsyncClient.class.getMethod("listOrgs"));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");
@ -60,7 +60,7 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest<OrgAsyncClient
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OrgAsyncClient.class.getMethod("getOrg", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -76,7 +76,7 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest<OrgAsyncClient
public void testFindOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OrgAsyncClient.class.getMethod("findOrgNamed", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org"));
GeneratedHttpRequest 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");

View File

@ -22,16 +22,16 @@ import java.io.IOException;
import java.net.URI;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
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}
@ -45,7 +45,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClie
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TaskAsyncClient.class.getMethod("getTasksList", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -61,7 +61,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClie
public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TaskAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org"));
GeneratedHttpRequest 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");
@ -76,7 +76,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClie
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TaskAsyncClient.class.getMethod("getTask", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -92,7 +92,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClie
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TaskAsyncClient.class.getMethod("cancelTask", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");

View File

@ -23,9 +23,10 @@ import java.net.URI;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.util.Strings2;
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
import org.jclouds.vcloud.options.CloneVAppOptions;
@ -34,7 +35,6 @@ 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}
@ -49,7 +49,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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"));
@ -69,7 +69,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testCopyVAppToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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")));
@ -90,7 +90,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testMoveVAppToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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")));
@ -110,7 +110,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("deployVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -127,7 +127,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testDeployAndPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("deployAndPowerOnVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -144,7 +144,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("getVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -160,7 +160,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testRebootVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("rebootVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -177,7 +177,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("undeployVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -195,7 +195,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testUndeployAndSaveStateOfVAppSaveState() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("undeployAndSaveStateOfVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -214,7 +214,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("deleteVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -230,7 +230,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("powerOnVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -247,7 +247,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testPowerOffVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("powerOffVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -264,7 +264,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testResetVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("resetVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -281,7 +281,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testSuspendVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("suspendVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -298,7 +298,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClie
public void testShutdownVApp() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppAsyncClient.class.getMethod("shutdownVApp", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,

View File

@ -24,9 +24,10 @@ import java.io.IOException;
import java.net.URI;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.ovf.xml.EnvelopeHandler;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.util.Strings2;
import org.jclouds.vcloud.domain.network.FenceMode;
import org.jclouds.vcloud.domain.network.NetworkConfig;
@ -40,7 +41,6 @@ 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}
@ -56,7 +56,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
IOException {
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
GeneratedHttpRequest 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
@ -89,7 +89,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
public void testcopyVAppTemplateToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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"));
@ -109,7 +109,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
public void testcopyVAppTemplateToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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")));
@ -130,7 +130,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
public void testmoveVAppTemplateToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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")));
@ -151,7 +151,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
public void testcaptureVAppAsTemplateInVDC() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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")));
@ -172,7 +172,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
public void testcaptureVAppAsTemplateInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
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
GeneratedHttpRequest 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")));
@ -193,7 +193,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
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"));
GeneratedHttpRequest 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");
@ -208,7 +208,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("getVAppTemplate", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -224,7 +224,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppT
public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");

View File

@ -23,15 +23,15 @@ import java.net.URI;
import java.util.NoSuchElementException;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -57,7 +57,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient
public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "vdc"));
GeneratedHttpRequest 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");
@ -72,7 +72,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient
public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class));
HttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, null));
GeneratedHttpRequest 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");
@ -87,7 +87,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VDCAsyncClient.class.getMethod("getVDC", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");

View File

@ -22,10 +22,11 @@ import java.io.IOException;
import java.net.URI;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnInputStream;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.util.Strings2;
import org.jclouds.vcloud.domain.GuestCustomizationSection;
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
@ -36,7 +37,6 @@ 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}
@ -50,7 +50,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("getScreenThumbnailForVm", URI.class));
HttpRequest request = processor
GeneratedHttpRequest request = processor
.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");
@ -71,7 +71,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
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, ImmutableList.<Object> of(guest, URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(guest, URI
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
assertRequestLineEquals(request,
@ -89,7 +89,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testUpdateCPUCountOfVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("updateCPUCountOfVm", int.class, URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, URI
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
assertRequestLineEquals(request,
@ -107,7 +107,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testUpdateMemoryMBOfVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("updateMemoryMBOfVm", int.class, URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(512, URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(512, URI
.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
assertRequestLineEquals(request,
@ -125,7 +125,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testDeployVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("deployVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -142,7 +142,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testDeployAndPowerOnVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("deployAndPowerOnVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -159,7 +159,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testGetVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("getVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest 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");
@ -175,7 +175,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testRebootVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("rebootVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -192,7 +192,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testUndeployVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("undeployVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -210,7 +210,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testUndeployAndSaveStateOfVmSaveState() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("undeployAndSaveStateOfVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -229,7 +229,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testPowerOnVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("powerOnVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -246,7 +246,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testPowerOffVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("powerOffVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -263,7 +263,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testResetVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("resetVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -280,7 +280,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testSuspendVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("suspendVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,
@ -297,7 +297,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient>
public void testShutdownVm() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VmAsyncClient.class.getMethod("shutdownVm", URI.class));
HttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
assertRequestLineEquals(request,

View File

@ -28,7 +28,7 @@ import org.nnsoft.guice.rocoto.Rocoto;
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
import com.google.common.base.Throwables;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
import com.google.inject.Guice;
import com.google.inject.Injector;

View File

@ -30,14 +30,15 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.location.Provider;
import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.vcloud.endpoints.VCloudLogin;
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;
@ -53,7 +54,7 @@ public class VCloudLoginAsyncClientTest extends BaseAsyncClientTest<VCloudLoginA
public void testLogin() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(VCloudLoginAsyncClient.class.getMethod("login"));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");

View File

@ -40,7 +40,7 @@ import org.testng.annotations.Test;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
/**
* Tests behavior of {@code BlobStoreUtils}

View File

@ -26,12 +26,13 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.AnonymousRestApiMetadata;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code OpenStackAuthAsyncClient}
@ -44,7 +45,7 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest<OpenStackA
public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OpenStackAuthAsyncClient.class.getMethod("authenticate", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("foo", "bar"));
GeneratedHttpRequest 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");
@ -58,7 +59,7 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest<OpenStackA
public void testAuthenticateStorage() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(OpenStackAuthAsyncClient.class.getMethod("authenticateStorage", String.class, String.class));
HttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("foo", "bar"));
GeneratedHttpRequest 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");

View File

@ -25,7 +25,7 @@ import org.jclouds.reflect.Invocation;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import com.google.common.base.Throwables;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
public class BasePayloadTest {

View File

@ -30,14 +30,15 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.location.Provider;
import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.trmk.vcloud_0_8.endpoints.VCloudLogin;
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;
@ -54,7 +55,7 @@ public class TerremarkVCloudLoginAsyncClientTest extends BaseAsyncClientTest<Ter
public void testLogin() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TerremarkVCloudLoginAsyncClient.class.getMethod("login"));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest 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");

View File

@ -26,12 +26,13 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.GeneratedHttpRequest;
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}
@ -44,7 +45,7 @@ public class TerremarkVCloudVersionsAsyncClientTest extends BaseAsyncClientTest<
public void testVersions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = Invokable.from(TerremarkVCloudVersionsAsyncClient.class.getMethod("getSupportedVersions"));
HttpRequest request = processor.createRequest(method, ImmutableList.of());
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");

View File

@ -1,238 +0,0 @@
/**
* 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.concurrent.internal;
import static com.google.common.base.Optional.fromNullable;
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.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.internal.ForwardInvocationToInterface;
import org.jclouds.logging.Logger;
import org.jclouds.reflect.FunctionalReflection;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invocation.Result;
import org.jclouds.reflect.InvocationSuccess;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.internal.AsyncRestClientProxy;
import org.jclouds.util.Optionals2;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.Invokable;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.assistedinject.Assisted;
/**
* Generates RESTful clients from appropriately annotated interfaces.
*
* @author Adrian Cole
*/
public final class SyncProxy implements Function<Invocation, Result> {
public static interface Factory {
/**
* @param declaring
* type of the interface where all invokeds match those of {@code async} except the return values are
* dereferenced
* @param async
* object whose interface matched {@code declaring} except all invokeds return {@link ListenableFuture}
* @return blocking invocation handler
*/
SyncProxy create(Class<?> declaring, Object async);
}
/**
* CreateClientForCaller is parameterized, so clients it creates aren't singletons. For example,
* CreateClientForCaller satisfies a call like this:
* {@code context.getProviderSpecificContext().getApi().getOrgClientForName(name)}
*
* @author Adrian Cole
*/
public static class CreateClientForCaller implements Function<ForwardInvocationToInterface, Object> {
private final SyncProxy.Factory factory;
private final AsyncRestClientProxy.Caller.Factory asyncFactory;
@Inject
private CreateClientForCaller(SyncProxy.Factory factory, AsyncRestClientProxy.Caller.Factory asyncFactory) {
this.factory = factory;
this.asyncFactory = asyncFactory;
}
@Override
public Object apply(ForwardInvocationToInterface from) {
Object asyncClient = FunctionalReflection.newProxy(from.getInterfaceType(),
asyncFactory.caller(from.getInvocation(), from.getInterfaceType()));
checkState(asyncClient != null, "configuration error, sync client for " + from + " not found");
Class<?> type = Optionals2.unwrapIfOptional(from.getInvocation().getInvokable().getReturnType());
return FunctionalReflection.newProxy(type, factory.create(type, asyncClient));
}
}
@Resource
private Logger logger = Logger.NULL;
private final Function<InvocationSuccess, Optional<Object>> optionalConverter;
private final Object delegate;
private final Class<?> declaring;
private final Map<Invokable<?, ?>, Invokable<Object, ListenableFuture<?>>> invokedMap;
private final Map<Invokable<?, ?>, Invokable<Object, ?>> syncMethodMap;
private final Map<Invokable<?, ?>, Optional<Long>> timeoutMap;
private final Function<ForwardInvocationToInterface, Object> createClientForCaller;
private final Map<Class<?>, Class<?>> sync2Async;
private static final Set<Method> objectMethods = ImmutableSet.copyOf(Object.class.getMethods());
@SuppressWarnings("unchecked")
@Inject
@VisibleForTesting
SyncProxy(Function<InvocationSuccess, Optional<Object>> optionalConverter,
Function<ForwardInvocationToInterface, Object> createClientForCaller, Map<Class<?>, Class<?>> sync2Async,
@Named("TIMEOUTS") Map<String, Long> timeouts, @Assisted Class<?> declaring, @Assisted Object async)
throws SecurityException, NoSuchMethodException {
this.optionalConverter = optionalConverter;
this.createClientForCaller = createClientForCaller;
this.delegate = async;
this.declaring = declaring;
this.sync2Async = ImmutableMap.copyOf(sync2Async);
ImmutableMap.Builder<Invokable<?, ?>, Invokable<Object, ListenableFuture<?>>> invokedMapBuilder = ImmutableMap
.builder();
ImmutableMap.Builder<Invokable<?, ?>, Invokable<Object, ?>> syncMethodMapBuilder = ImmutableMap.builder();
for (Method invoked : declaring.getMethods()) {
if (!objectMethods.contains(invoked)) {
Method delegatedMethod = delegate.getClass().getMethod(invoked.getName(), invoked.getParameterTypes());
if (!Arrays.equals(delegatedMethod.getExceptionTypes(), invoked.getExceptionTypes()))
throw new IllegalArgumentException(String.format(
"invoked %s has different typed exceptions than delegated invoked %s", invoked, delegatedMethod));
if (delegatedMethod.getReturnType().isAssignableFrom(ListenableFuture.class)) {
invokedMapBuilder.put(Invokable.from(invoked), Invokable.class.cast(Invokable.from(delegatedMethod)));
} else {
syncMethodMapBuilder.put(Invokable.from(invoked), Invokable.class.cast(Invokable.from(delegatedMethod)));
}
}
}
invokedMap = invokedMapBuilder.build();
syncMethodMap = syncMethodMapBuilder.build();
ImmutableMap.Builder<Invokable<?, ?>, Optional<Long>> timeoutMapBuilder = ImmutableMap.builder();
for (Invokable<?, ?> invoked : invokedMap.keySet()) {
timeoutMapBuilder.put(invoked, timeoutInNanos(invoked, timeouts));
}
timeoutMap = timeoutMapBuilder.build();
}
@Override
public Result apply(Invocation invocation) {
if (invocation.getInvokable().isAnnotationPresent(Delegate.class))
return forwardToDelegate(invocation);
if (syncMethodMap.containsKey(invocation.getInvokable()))
return invokeOnDelegate(invocation);
return invokeFutureAndBlock(invocation);
}
private Result forwardToDelegate(Invocation invocation) {
Class<?> returnType = Optionals2.unwrapIfOptional(invocation.getInvokable().getReturnType());
// get the return type of the asynchronous class associated with this client
// ex. FloatingIPClient is associated with FloatingIPAsyncClient
Class<?> asyncClass = sync2Async.get(returnType);
checkState(asyncClass != null, "please configure corresponding async class for %s in your RestClientModule",
returnType);
// pass any parameters necessary to get a relevant instance of that async class
// ex. getClientForRegion("north") might return an instance whose endpoint is
// different that "south"
ForwardInvocationToInterface cma = ForwardInvocationToInterface.create(invocation, asyncClass);
Object result = createClientForCaller.apply(cma);
if (Optionals2.isReturnTypeOptional(invocation.getInvokable())) {
result = optionalConverter.apply(InvocationSuccess.create(invocation, result));
}
return Result.success(result);
}
private Result invokeFutureAndBlock(Invocation invocation) {
try {
Invokable<Object, ListenableFuture<?>> asyncMethod = invokedMap.get(invocation.getInvokable());
ListenableFuture<?> future = asyncMethod.invoke(delegate, invocation.getArgs().toArray());
Optional<Long> timeoutNanos = timeoutMap.get(invocation.getInvokable());
return block(future, timeoutNanos);
} catch (InvocationTargetException e) {
return Result.fail(e);
} catch (IllegalAccessException e) {
return Result.fail(e);
}
}
private Result block(ListenableFuture<?> future, Optional<Long> timeoutNanos) {
try {
if (timeoutNanos.isPresent()) {
logger.debug(">> blocking on %s for %s", future, timeoutNanos);
return Result.success(future.get(timeoutNanos.get(), TimeUnit.NANOSECONDS));
} else {
logger.debug(">> blocking on %s", future);
return Result.success(future.get());
}
} catch (ExecutionException e) {
return Result.fail(e.getCause());
} catch (InterruptedException e) {
return Result.fail(e); // TODO: should we kill the future?
} catch (TimeoutException e) {
return Result.fail(e);
}
}
private Result invokeOnDelegate(Invocation invocation) {
Invokable<Object, ?> toInvoke = syncMethodMap.get(invocation.getInvokable());
try {
return Result.success(toInvoke.invoke(delegate, invocation.getArgs().toArray()));
} catch (InvocationTargetException e) {
return Result.fail(e);
} catch (IllegalAccessException e) {
return Result.fail(e);
}
}
// override timeout by values configured in properties(in ms)
private Optional<Long> timeoutInNanos(Invokable<?, ?> invoked, Map<String, Long> timeouts) {
String className = declaring.getSimpleName();
Optional<Long> timeoutMillis = fromNullable(timeouts.get(className + "." + invoked.getName())).or(
fromNullable(timeouts.get(className))).or(fromNullable(timeouts.get("default")));
if (timeoutMillis.isPresent())
return Optional.of(TimeUnit.MILLISECONDS.toNanos(timeoutMillis.get()));
return Optional.absent();
}
@Override
public String toString() {
return String.format("%s->%s", declaring.getClass().getSimpleName(), delegate.getClass().getSimpleName());
}
}

View File

@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import com.google.common.base.Objects;
import com.google.common.reflect.Invokable;
/**
* Command whose endpoint is an http service.
@ -134,9 +133,7 @@ public class HttpCommand {
public String toString() {
if (request instanceof GeneratedHttpRequest) {
GeneratedHttpRequest gRequest = GeneratedHttpRequest.class.cast(request);
return String.format("[method=%s.%s, request=%s]",
gRequest.getInvocation().getInterfaceType().getSimpleName(), gRequest.getInvocation().getInvokable()
.getName(), gRequest.getRequestLine());
return String.format("[method=%s, request=%s]", gRequest.getInvocation(), gRequest.getRequestLine());
}
return "[request=" + request.getRequestLine() + "]";
}

View File

@ -66,7 +66,7 @@ import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
import com.google.inject.Inject;
/**

View File

@ -1,84 +0,0 @@
/**
* 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.internal;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.reflect.Invocation;
import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
* internal type to {@link SyncProxy} which is likely to be removed
*
* @author Adrian Cole
*/
@Beta
public final class ForwardInvocationToInterface {
/**
* @param interfaceType
* {@link #getInterfaceType()}
*/
public static ForwardInvocationToInterface create(Invocation invocation, Class<?> interfaceType) {
return new ForwardInvocationToInterface(invocation, interfaceType);
}
private final Invocation invocation;
private final Class<?> interfaceType;
private ForwardInvocationToInterface(Invocation invocation, Class<?> interfaceType) {
this.invocation = checkNotNull(invocation, "invocation");
this.interfaceType = checkNotNull(interfaceType, "interfaceType");
}
public Invocation getInvocation() {
return invocation;
}
public Class<?> getInterfaceType() {
return interfaceType;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ForwardInvocationToInterface that = ForwardInvocationToInterface.class.cast(o);
return equal(this.invocation, that.invocation) && equal(this.interfaceType, that.interfaceType);
}
@Override
public int hashCode() {
return Objects.hashCode(invocation, interfaceType);
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").omitNullValues().add("invocation", invocation).add("interfaceType", interfaceType);
}
}

View File

@ -0,0 +1,180 @@
/**
* 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 com.google.common.base.Preconditions.checkNotNull;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.reflect.Invokable;
/**
*
* based on the {@link com.google.reflect.AccessibleObject} copied in as {@link com.google.reflect.Invokable} is package
* private.
*
* @author Adrian Cole
* @since 1.6
*/
class Element extends AccessibleObject implements Member {
private final AccessibleObject accessibleObject;
protected final Member member;
<M extends AccessibleObject & Member> Element( M member) {
this.member = checkNotNull(member, "member");
this.accessibleObject = member;
}
@Override
public final boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
return accessibleObject.isAnnotationPresent(annotationClass);
}
@Override
public final <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
return accessibleObject.getAnnotation(annotationClass);
}
@Override
public final Annotation[] getAnnotations() {
return accessibleObject.getAnnotations();
}
@Override
public final Annotation[] getDeclaredAnnotations() {
return accessibleObject.getDeclaredAnnotations();
}
@Override
public final void setAccessible(boolean flag) throws SecurityException {
accessibleObject.setAccessible(flag);
}
@Override
public final boolean isAccessible() {
return accessibleObject.isAccessible();
}
@Override
public Class<?> getDeclaringClass() {
return member.getDeclaringClass();
}
@Override
public final String getName() {
return member.getName();
}
@Override
public final int getModifiers() {
return member.getModifiers();
}
@Override
public final boolean isSynthetic() {
return member.isSynthetic();
}
/** Returns true if the element is public. */
public final boolean isPublic() {
return Modifier.isPublic(getModifiers());
}
/** Returns true if the element is protected. */
public final boolean isProtected() {
return Modifier.isProtected(getModifiers());
}
/** Returns true if the element is package-private. */
public final boolean isPackagePrivate() {
return !isPrivate() && !isPublic() && !isProtected();
}
/** Returns true if the element is private. */
public final boolean isPrivate() {
return Modifier.isPrivate(getModifiers());
}
/** Returns true if the element is static. */
public final boolean isStatic() {
return Modifier.isStatic(getModifiers());
}
/**
* Returns {@code true} if this method is final, per {@code Modifier.isFinal(getModifiers())}.
*
* <p>
* Note that a method may still be effectively "final", or non-overridable when it has no {@code final} keyword. For
* example, it could be private, or it could be declared by a final class. To tell whether a method is overridable,
* use {@link Invokable#isOverridable}.
*/
public final boolean isFinal() {
return Modifier.isFinal(getModifiers());
}
/** Returns true if the method is abstract. */
public final boolean isAbstract() {
return Modifier.isAbstract(getModifiers());
}
/** Returns true if the element is native. */
public final boolean isNative() {
return Modifier.isNative(getModifiers());
}
/** Returns true if the method is synchronized. */
public final boolean isSynchronized() {
return Modifier.isSynchronized(getModifiers());
}
/** Returns true if the field is volatile. */
final boolean isVolatile() {
return Modifier.isVolatile(getModifiers());
}
/** Returns true if the field is transient. */
final boolean isTransient() {
return Modifier.isTransient(getModifiers());
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof Element) {
Element that = (Element) obj;
return member.equals(that.member);
}
return false;
}
@Override
public int hashCode() {
return member.hashCode();
}
@Override
public String toString() {
return member.toString();
}
}

View File

@ -38,7 +38,7 @@ import com.google.common.annotations.Beta;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.Invokable;
import com.google.common.reflect.TypeToken;
/**
* Static utilities relating to functional Java reflection.
@ -48,8 +48,8 @@ import com.google.common.reflect.Invokable;
@Beta
public final class FunctionalReflection {
/**
* Returns a proxy instance that implements {@code interfaceType} by dispatching method invocations to
* {@code invocationFunction}. The class loader of {@code interfaceType} will be used to define the proxy class.
* Returns a proxy instance that implements {@code enclosingType} by dispatching method invocations to
* {@code invocationFunction}. The class loader of {@code enclosingType} will be used to define the proxy class.
* <p>
* Usage example:
*
@ -72,26 +72,37 @@ public final class FunctionalReflection {
* @param invocationFunction
* returns a result or a top-level exception, or result
* @throws IllegalArgumentException
* if {@code interfaceType} does not specify the type of a Java interface
* if {@code enclosingType} does not specify the type of a Java interface
* @see com.google.common.reflect.AbstractInvocationHandler#invoke(Object, Method, Object[])
* @see com.google.common.reflect.Reflection#newProxy(Class, java.lang.reflect.InvocationHandler)
*/
public static <T> T newProxy(Class<T> interfaceType, Function<Invocation, Result> invocationFunction) {
checkNotNull(interfaceType, "interfaceType");
public static <T> T newProxy(TypeToken<T> enclosingType, Function<Invocation, Result> invocationFunction) {
checkNotNull(enclosingType, "enclosingType");
checkNotNull(invocationFunction, "invocationFunction");
checkArgument(interfaceType.isInterface(), "%s is not an interface", interfaceType);
Object object = Proxy.newProxyInstance(interfaceType.getClassLoader(), new Class<?>[] { interfaceType },
new FunctionalInvocationHandler<T>(interfaceType, invocationFunction));
return interfaceType.cast(object);
return newProxy(enclosingType.getRawType(), new FunctionalInvocationHandler<T>(enclosingType, invocationFunction));
}
public static <T> T newProxy(Class<T> enclosingType, Function<Invocation, Result> invocationFunction) {
checkNotNull(invocationFunction, "invocationFunction");
return newProxy(enclosingType,
new FunctionalInvocationHandler<T>(TypeToken.of(enclosingType), invocationFunction));
}
@SuppressWarnings("unchecked")
private static <T> T newProxy(Class<? super T> enclosingType, FunctionalInvocationHandler<T> invocationHandler) {
checkNotNull(enclosingType, "enclosingType");
checkArgument(enclosingType.isInterface(), "%s is not an interface", enclosingType);
return (T) Proxy.newProxyInstance(enclosingType.getClassLoader(), new Class<?>[] { enclosingType },
invocationHandler);
}
private static final class FunctionalInvocationHandler<T> extends
com.google.common.reflect.AbstractInvocationHandler {
private final Class<T> interfaceType;
private final TypeToken<T> enclosingType;
private final Function<Invocation, Result> invocationFunction;
private FunctionalInvocationHandler(Class<T> interfaceType, Function<Invocation, Result> invocationFunction) {
this.interfaceType = interfaceType;
private FunctionalInvocationHandler(TypeToken<T> enclosingType, Function<Invocation, Result> invocationFunction) {
this.enclosingType = enclosingType;
this.invocationFunction = invocationFunction;
}
@ -102,9 +113,9 @@ public final class FunctionalReflection {
args = ImmutableList.copyOf(args);
else
args = Collections.unmodifiableList(args);
Invokable<?, ?> invokable = Invokable.class.cast(Invokable.from(invoked));
Invokable<T, ?> invokable = Invokable.from(enclosingType, invoked);
// not yet support the proxy arg
Invocation invocation = Invocation.create(interfaceType, invokable, args);
Invocation invocation = Invocation.create(invokable, args);
Result result;
try {
result = invocationFunction.apply(invocation);
@ -125,13 +136,13 @@ public final class FunctionalReflection {
if (o == null || getClass() != o.getClass())
return false;
FunctionalInvocationHandler<?> that = FunctionalInvocationHandler.class.cast(o);
return equal(this.interfaceType, that.interfaceType)
return equal(this.enclosingType, that.enclosingType)
&& equal(this.invocationFunction, that.invocationFunction);
}
@Override
public int hashCode() {
return Objects.hashCode(interfaceType, invocationFunction);
return Objects.hashCode(enclosingType, invocationFunction);
}
@Override

View File

@ -19,7 +19,6 @@
package org.jclouds.reflect;
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 java.util.List;
@ -28,12 +27,10 @@ import org.jclouds.javax.annotation.Nullable;
import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.reflect.Invokable;
/**
* Context needed to call {@link com.google.common.reflect.Invokable#invoke(Object, Object...)}
* Context needed to call {@link org.jclouds.reflect.Invokable#invoke(Object, Object...)}
*
* @author Adrian Cole
*/
@ -41,48 +38,21 @@ import com.google.common.reflect.Invokable;
public final class Invocation {
/**
* Use this class when the invokable could be inherited. For example, a method is inherited when it cannot be
* retrieved by {@link Class#getDeclaredMethods()}, but it can be retrieved by {@link Class#getMethods()}.
*
* @param interfaceType
* type that either declared or inherited {@code invokable}, or was forwarded a call to it.
* @param args
* as these represent parameters, can contain nulls
*/
public static Invocation create(Class<?> interfaceType, Invokable<?, ?> invokable, List<Object> args) {
checkArgument(invokable.getDeclaringClass().isAssignableFrom(interfaceType), "%s isn't assignable from %s",
invokable.getDeclaringClass(), interfaceType);
return new Invocation(interfaceType, invokable, args);
}
/**
* Note: use {@link #create(Class, Invokable, List)} when the invokable was inherited.
*
* @param args
* as these represent parameters, can contain nulls
*/
public static Invocation create(Invokable<?, ?> invokable, List<Object> args) {
return new Invocation(invokable.getDeclaringClass(), invokable, args);
return new Invocation(invokable, args);
}
private final Class<?> interfaceType;
private final Invokable<?, ?> invokable;
private final List<Object> args;
private Invocation(Class<?> interfaceType, Invokable<?, ?> invokable, List<Object> args) {
this.interfaceType = checkNotNull(interfaceType, "interfaceType");
private Invocation(Invokable<?, ?> invokable, List<Object> args) {
this.invokable = checkNotNull(invokable, "invokable");
this.args = checkNotNull(args, "args");
}
/**
* different than {@link Invokable#getDeclaringClass()} when {@link #getInvokable()} is a member of a class it was
* not declared in.
*/
public Class<?> getInterfaceType() {
return interfaceType;
}
/**
* what we can invoke
*/
@ -107,19 +77,17 @@ public final class Invocation {
if (o == null || getClass() != o.getClass())
return false;
Invocation that = Invocation.class.cast(o);
return equal(this.interfaceType, that.interfaceType) && equal(this.invokable, that.invokable)
&& equal(this.args, that.args);
return equal(this.invokable, that.invokable) && equal(this.args, that.args);
}
@Override
public int hashCode() {
return Objects.hashCode(interfaceType, invokable, args);
return Objects.hashCode(invokable, args);
}
@Override
public String toString() {
return Objects.toStringHelper("").omitNullValues().add("interfaceType", interfaceType)
.add("invokable", invokable).add("args", args.size() != 0 ? args : null).toString();
return String.format("%s%s", invokable, args);
}
/**
@ -175,12 +143,8 @@ public final class Invocation {
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").omitNullValues().add("result", result.orNull())
.add("throwable", throwable.orNull());
.add("throwable", throwable.orNull()).toString();
}
}

View File

@ -29,7 +29,7 @@ import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional;
/**
* Holds the context of a successful call to {@link com.google.common.reflect.Invokable#invoke(Object, Object...)}
* Holds the context of a successful call to {@link org.jclouds.reflect.Invokable#invoke(Object, Object...)}
*
* @author Adrian Cole
*/

View File

@ -0,0 +1,347 @@
/**
* 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 com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.TypeToken;
/**
* based on the {@link com.google.reflect.AccessibleObject} copied in as {@link com.google.reflect.Invokable} is package
* private. This adds access to {#link {@link #getEnclosingType()} and folds in ability to lookup methods and
* constructors by name.
*
* @author Adrian Cole
* @since 1.6
*/
@Beta
public abstract class Invokable<T, R> extends Element implements GenericDeclaration {
protected final TypeToken<?> enclosingType;
<M extends AccessibleObject & Member> Invokable(TypeToken<?> enclosingType, M member) {
super(member);
this.enclosingType = checkNotNull(enclosingType, "enclosingType");
}
/** Returns {@link Invokable} of {@code method}. */
public static Invokable<?, Object> from(Method method) {
return from(TypeToken.of(method.getDeclaringClass()), method);
}
/** Returns {@link Invokable} of {@code constructor}. */
public static <T> Invokable<T, T> from(Constructor<T> constructor) {
return from(TypeToken.of(constructor.getDeclaringClass()), constructor);
}
/** Returns {@link Invokable} of {@code method}. */
public static <T> Invokable<T, Object> from(TypeToken<T> enclosingType, Method method) {
return new MethodInvokable<T>(enclosingType, method);
}
/** Returns {@link Invokable} of {@code constructor}. */
public static <T> Invokable<T, T> from(TypeToken<T> enclosingType, Constructor<T> constructor) {
return new ConstructorInvokable<T>(enclosingType, constructor);
}
/**
* different than {@link #getDeclaringClass()} when this is a member of a class it was not declared in.
*/
public TypeToken<?> getEnclosingType() {
return enclosingType;
}
/**
* Returns {@code true} if this is an overridable method. Constructors, private, static or final methods, or methods
* declared by final classes are not overridable.
*/
public abstract boolean isOverridable();
/** Returns {@code true} if this was declared to take a variable number of arguments. */
public abstract boolean isVarArgs();
/**
* Invokes with {@code receiver} as 'this' and {@code args} passed to the underlying method and returns the return
* value; or calls the underlying constructor with {@code args} and returns the constructed instance.
*
* @throws IllegalAccessException
* if this {@code Constructor} object enforces Java language access control and the underlying method or
* constructor is inaccessible.
* @throws IllegalArgumentException
* if the number of actual and formal parameters differ; if an unwrapping conversion for primitive
* arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the
* corresponding formal parameter type by a method invocation conversion.
* @throws InvocationTargetException
* if the underlying method or constructor throws an exception.
*/
// All subclasses are owned by us and we'll make sure to get the R type right.
@SuppressWarnings("unchecked")
public final R invoke(@Nullable T receiver, Object... args) throws InvocationTargetException, IllegalAccessException {
return (R) invokeInternal(receiver, checkNotNull(args, "args"));
}
/** Returns the return type of this {@code Invokable}. */
// All subclasses are owned by us and we'll make sure to get the R type right.
@SuppressWarnings("unchecked")
public final TypeToken<? extends R> getReturnType() {
return (TypeToken<? extends R>) TypeToken.of(getGenericReturnType());
}
/**
* Returns all declared parameters of this {@code Invokable}. Note that if this is a constructor of a non-static
* inner class, unlike {@link Constructor#getParameterTypes}, the hidden {@code this} parameter of the enclosing
* class is excluded from the returned parameters.
*/
public final ImmutableList<Parameter> getParameters() {
Type[] parameterTypes = getGenericParameterTypes();
Annotation[][] annotations = getParameterAnnotations();
ImmutableList.Builder<Parameter> builder = ImmutableList.builder();
for (int i = 0; i < parameterTypes.length; i++) {
builder.add(new Parameter(this, i, TypeToken.of(parameterTypes[i]), annotations[i]));
}
return builder.build();
}
/** Returns all declared exception types of this {@code Invokable}. */
public final ImmutableList<TypeToken<? extends Throwable>> getExceptionTypes() {
ImmutableList.Builder<TypeToken<? extends Throwable>> builder = ImmutableList.builder();
for (Type type : getGenericExceptionTypes()) {
// getGenericExceptionTypes() will never return a type that's not exception
@SuppressWarnings("unchecked")
TypeToken<? extends Throwable> exceptionType = (TypeToken<? extends Throwable>) TypeToken.of(type);
builder.add(exceptionType);
}
return builder.build();
}
/**
* Explicitly specifies the return type of this {@code Invokable}. For example:
*
* <pre>
* {
* &#064;code
* Method factoryMethod = Person.class.getMethod(&quot;create&quot;);
* Invokable&lt;?, Person&gt; factory = Invokable.of(getNameMethod).returning(Person.class);
* }
* </pre>
*/
public final <R1 extends R> Invokable<T, R1> returning(Class<R1> returnType) {
return returning(TypeToken.of(returnType));
}
/** Explicitly specifies the return type of this {@code Invokable}. */
public final <R1 extends R> Invokable<T, R1> returning(TypeToken<R1> returnType) {
if (!returnType.isAssignableFrom(getReturnType())) {
throw new IllegalArgumentException("Invokable is known to return " + getReturnType() + ", not " + returnType);
}
@SuppressWarnings("unchecked")
// guarded by previous check
Invokable<T, R1> specialized = (Invokable<T, R1>) this;
return specialized;
}
@SuppressWarnings("unchecked")
// The declaring class is T's raw class, or one of its supertypes.
@Override
public final Class<? super T> getDeclaringClass() {
return (Class<? super T>) super.getDeclaringClass();
}
abstract Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException,
IllegalAccessException;
abstract Type[] getGenericParameterTypes();
/** This should never return a type that's not a subtype of Throwable. */
abstract Type[] getGenericExceptionTypes();
abstract Annotation[][] getParameterAnnotations();
abstract Type getGenericReturnType();
static class MethodInvokable<T> extends Invokable<T, Object> {
private final Method method;
MethodInvokable(TypeToken<?> enclosingType, Method method) {
super(enclosingType, method);
this.method = method;
checkArgument(TypeToken.of(method.getDeclaringClass()).isAssignableFrom(enclosingType),
"%s not declared by %s", method, enclosingType);
}
@Override
final Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException,
IllegalAccessException {
return method.invoke(receiver, args);
}
@Override
Type getGenericReturnType() {
return resolveType(method.getGenericReturnType()).getType();
}
@Override
Type[] getGenericParameterTypes() {
return resolveInPlace(method.getGenericParameterTypes());
}
@Override
Type[] getGenericExceptionTypes() {
return resolveInPlace(method.getGenericExceptionTypes());
}
@Override
final Annotation[][] getParameterAnnotations() {
return method.getParameterAnnotations();
}
@Override
public final TypeVariable<?>[] getTypeParameters() {
return method.getTypeParameters();
}
@Override
public final boolean isOverridable() {
return !(isFinal() || isPrivate() || isStatic() || Modifier.isFinal(getDeclaringClass().getModifiers()));
}
@Override
public final boolean isVarArgs() {
return method.isVarArgs();
}
}
protected TypeToken<?> resolveType(Type type) {
return enclosingType.resolveType(type);
}
protected Type[] resolveInPlace(Type[] types) {
for (int i = 0; i < types.length; i++) {
types[i] = resolveType(types[i]).getType();
}
return types;
}
static class ConstructorInvokable<T> extends Invokable<T, T> {
private final Constructor<?> constructor;
ConstructorInvokable(TypeToken<?> enclosingType, Constructor<?> constructor) {
super(enclosingType, constructor);
this.constructor = constructor;
checkArgument(constructor.getDeclaringClass() == enclosingType.getRawType(), "%s not declared by %s",
constructor, enclosingType.getRawType());
}
@Override
final Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException,
IllegalAccessException {
try {
return constructor.newInstance(args);
} catch (InstantiationException e) {
throw new RuntimeException(constructor + " failed.", e);
}
}
@Override
Type getGenericReturnType() {
return resolveType(constructor.getDeclaringClass()).getType();
}
@Override
Type[] getGenericParameterTypes() {
Type[] types = constructor.getGenericParameterTypes();
Class<?> declaringClass = constructor.getDeclaringClass();
if (!Modifier.isStatic(declaringClass.getModifiers()) && declaringClass.getEnclosingClass() != null) {
if (types.length == constructor.getParameterTypes().length) {
// first parameter is the hidden 'this'
return Arrays.copyOfRange(types, 1, types.length);
}
}
return resolveInPlace(types);
}
@Override
Type[] getGenericExceptionTypes() {
return resolveInPlace(constructor.getGenericExceptionTypes());
}
@Override
final Annotation[][] getParameterAnnotations() {
return constructor.getParameterAnnotations();
}
@Override
public final TypeVariable<?>[] getTypeParameters() {
return constructor.getTypeParameters();
}
@Override
public final boolean isOverridable() {
return false;
}
@Override
public final boolean isVarArgs() {
return constructor.isVarArgs();
}
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Invokable<?, ?> that = Invokable.class.cast(o);
return equal(this.enclosingType, that.enclosingType) && super.equals(o);
}
@Override
public int hashCode() {
return Objects.hashCode(enclosingType, super.hashCode());
}
@Override
public String toString() {
int parametersTypeHashCode = 0;
for (Parameter param : getParameters())
parametersTypeHashCode += param.getType().hashCode();
return String.format("%s.%s[%s]", enclosingType.getRawType().getSimpleName(), getName(), parametersTypeHashCode);
}
}

View File

@ -0,0 +1,115 @@
/**
* 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 com.google.common.base.Preconditions.checkNotNull;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
import com.google.common.reflect.TypeToken;
/**
*
* based on the {@link com.google.reflect.AccessibleObject} copied in as {@link com.google.reflect.Parameter} is package
* private and decided not to add {@link #getPosition}
*
* @author Adrian Cole
* @since 1.6
*/
@Beta
public final class Parameter implements AnnotatedElement {
private final Invokable<?, ?> declaration;
private final int position;
private final TypeToken<?> type;
private final ImmutableList<Annotation> annotations;
Parameter(Invokable<?, ?> declaration, int position, TypeToken<?> type, Annotation[] annotations) {
this.declaration = declaration;
this.position = position;
this.type = type;
this.annotations = ImmutableList.copyOf(annotations);
}
/** Returns the position of the parameter. */
public int getPosition() {
return position;
}
/** Returns the type of the parameter. */
public TypeToken<?> getType() {
return type;
}
/** Returns the {@link Invokable} that declares this parameter. */
public Invokable<?, ?> getDeclaringInvokable() {
return declaration;
}
@Override
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
return getAnnotation(annotationType) != null;
}
@Override
@Nullable
public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
for (Annotation annotation : annotations) {
if (annotationType.isInstance(annotation)) {
return annotationType.cast(annotation);
}
}
return null;
}
@Override
public Annotation[] getAnnotations() {
return getDeclaredAnnotations();
}
@Override
public Annotation[] getDeclaredAnnotations() {
return annotations.toArray(new Annotation[annotations.size()]);
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof Parameter) {
Parameter that = (Parameter) obj;
return position == that.position && declaration.equals(that.declaration);
}
return false;
}
@Override
public int hashCode() {
return position;
}
@Override
public String toString() {
return type + " arg" + position;
}
}

View File

@ -27,12 +27,12 @@ import javax.inject.Inject;
import org.jclouds.predicates.Validator;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Parameter;
import org.jclouds.rest.annotations.ParamValidators;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.reflect.Parameter;
import com.google.inject.Injector;
/**

View File

@ -32,7 +32,7 @@ import org.jclouds.rest.MapBinder;
import org.jclouds.rest.annotations.Payload;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import com.google.common.reflect.Invokable;
import org.jclouds.reflect.Invokable;
/**
*

View File

@ -22,7 +22,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.reflect.FunctionalReflection;
import org.jclouds.rest.internal.AsyncRestClientProxy;
import org.jclouds.rest.internal.InvokeAsyncApi;
import com.google.inject.Provider;
import com.google.inject.TypeLiteral;
@ -34,10 +34,10 @@ import com.google.inject.TypeLiteral;
@Singleton
public class AsyncClientProvider<A> implements Provider<A> {
private final Class<? super A> asyncClientType;
private final AsyncRestClientProxy proxy;
private final InvokeAsyncApi proxy;
@Inject
private AsyncClientProvider(AsyncRestClientProxy proxy, TypeLiteral<A> asyncClientType) {
private AsyncClientProvider(InvokeAsyncApi proxy, TypeLiteral<A> asyncClientType) {
this.proxy = proxy;
this.asyncClientType = asyncClientType.getRawType();
}

View File

@ -46,8 +46,10 @@ public class BinderUtils {
* type type that returns {@link ListenableFuture}
*/
public static <S, A> void bindClientAndAsyncClient(Binder binder, Class<S> sync, Class<A> async) {
bindAsyncClient(binder, async);
bindClient(binder, sync, async);
bindClass(binder, sync);
bindClass(binder, async);
bindAsyncClientProvider(binder, async);
bindClientProvider(binder, sync, async);
}
/**
@ -64,9 +66,14 @@ public class BinderUtils {
* @param async
* type type that returns {@link ListenableFuture}
*/
@SuppressWarnings("unchecked")
public static <S, A> void bindClient(Binder binder, Class<S> sync, Class<A> async) {
bindClass(binder, sync);
bindClass(binder, async);
bindClientProvider(binder, sync, async);
}
@SuppressWarnings("unchecked")
private static <S, A> void bindClientProvider(Binder binder, Class<S> sync, Class<A> async) {
TypeToken<ClientProvider<S, A>> token = new TypeToken<ClientProvider<S, A>>() {
private static final long serialVersionUID = 1L;
}.where(new TypeParameter<S>() {
@ -83,9 +90,13 @@ public class BinderUtils {
}, sync).getType()))).toInstance(sync);
}
@SuppressWarnings("unchecked")
private static <T> void bindAsyncClient(Binder binder, Class<T> async) {
public static <T> void bindAsyncClient(Binder binder, Class<T> async) {
bindClass(binder, async);
bindAsyncClientProvider(binder, async);
}
@SuppressWarnings("unchecked")
private static <T> void bindAsyncClientProvider(Binder binder, Class<T> async) {
TypeToken<AsyncClientProvider<T>> token = new TypeToken<AsyncClientProvider<T>>() {
private static final long serialVersionUID = 1L;
}.where(new TypeParameter<T>() {

View File

@ -21,9 +21,12 @@ package org.jclouds.rest.config;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.concurrent.internal.SyncProxy;
import org.jclouds.reflect.FunctionalReflection;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.internal.InvokeSyncApi;
import com.google.common.cache.Cache;
import com.google.common.reflect.TypeToken;
import com.google.inject.Provider;
/**
@ -35,20 +38,22 @@ import com.google.inject.Provider;
@Singleton
public class ClientProvider<S, A> implements Provider<S> {
private final SyncProxy.Factory factory;
private final InvokeSyncApi.Factory factory;
private final Class<S> syncClientType;
private final A asyncClient;
@Inject
private ClientProvider(SyncProxy.Factory factory, Class<S> syncClientType, A asyncClient) {
private ClientProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables, InvokeSyncApi.Factory factory,
Class<S> syncClientType, Class<A> asyncClientType, A asyncClient) {
this.factory = factory;
this.asyncClient = asyncClient;
this.syncClientType = syncClientType;
RestModule.putInvokables(TypeToken.of(syncClientType), TypeToken.of(asyncClientType), invokables);
}
@Override
@Singleton
public S get() {
return FunctionalReflection.newProxy(syncClientType, factory.create(syncClientType, asyncClient));
return FunctionalReflection.newProxy(syncClientType, factory.create(asyncClient));
}
}

View File

@ -60,6 +60,7 @@ public class RestClientModule<S, A> extends RestModule {
"unbound type variable: %s, use ctor that explicitly assigns this", type);
return type;
}
/**
* @see #RestClientModule(Map)
*/
@ -91,8 +92,6 @@ public class RestClientModule<S, A> extends RestModule {
bindRetryHandlers();
}
/**
* overrides this to change the default retry handlers for the http engine
*

View File

@ -18,39 +18,60 @@
*/
package org.jclouds.rest.config;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.collect.Iterables.any;
import static com.google.common.collect.Maps.transformValues;
import static com.google.common.util.concurrent.Atomics.newReference;
import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX;
import static org.jclouds.http.HttpUtils.tryFindHttpMethod;
import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient;
import static org.jclouds.util.Maps2.transformKeys;
import static org.jclouds.util.Predicates2.startsWith;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Named;
import javax.inject.Singleton;
import javax.ws.rs.Path;
import org.jclouds.concurrent.internal.SyncProxy;
import org.jclouds.concurrent.internal.SyncProxy.CreateClientForCaller;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.internal.FilterStringsBoundToInjectorByName;
import org.jclouds.internal.ForwardInvocationToInterface;
import org.jclouds.json.config.GsonModule;
import org.jclouds.location.config.LocationModule;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invokable;
import org.jclouds.reflect.Parameter;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.HttpAsyncClient;
import org.jclouds.rest.HttpClient;
import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith;
import org.jclouds.rest.internal.AsyncRestClientProxy;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.util.Maps2;
import org.jclouds.util.Predicates2;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.rest.internal.InvokeAsyncApi;
import org.jclouds.rest.internal.InvokeFutureAndBlock;
import org.jclouds.rest.internal.InvokeListenableFutureViaHttp;
import org.jclouds.rest.internal.InvokeSyncApi;
import org.jclouds.rest.internal.TransformerForRequest;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.Atomics;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
@ -60,31 +81,105 @@ public class RestModule extends AbstractModule {
public static final TypeLiteral<Supplier<URI>> URI_SUPPLIER_TYPE = new TypeLiteral<Supplier<URI>>() {
};
private final Map<Class<?>, Class<?>> sync2Async;
protected final AtomicReference<AuthorizationException> authException = Atomics.newReference();
protected final Map<Class<?>, Class<?>> sync2Async;
protected final AtomicReference<AuthorizationException> authException = newReference();
public RestModule() {
this(ImmutableMap.<Class<?>, Class<?>> of());
}
private static final Set<Method> objectMethods = ImmutableSet.copyOf(Object.class.getMethods());
public RestModule(Map<Class<?>, Class<?>> sync2Async) {
this.sync2Async = sync2Async;
}
@Provides
@Singleton
protected Predicate<Invokable<?, ?>> mapsToAsyncHttpRequest(final Cache<Invokable<?, ?>, Invokable<?, ?>> backing) {
return new Predicate<Invokable<?, ?>>() {
public boolean apply(Invokable<?, ?> in) { // TODO: this is dynamic, but perhaps needs to be cached
return FluentIterable.from(backing.asMap().values()).anyMatch(mapsToAsyncHttpRequest(in));
}
};
}
private static Predicate<Invokable<?, ?>> mapsToAsyncHttpRequest(Invokable<?, ?> toTest) {
final int soughtHash = hashEnclosingTypeNameAndParameters(toTest);
return 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);
}
}) && in.getReturnType().getRawType().isAssignableFrom(ListenableFuture.class)
&& soughtHash == hashEnclosingTypeNameAndParameters(in);
}
};
}
/**
* when looking for a match, we ignore the return type
*/
public static int hashEnclosingTypeNameAndParameters(Invokable<?, ?> in) {
int parametersTypeHashCode = 0;
for (Parameter param : in.getParameters())
parametersTypeHashCode += param.getType().hashCode();
return Objects.hashCode(in.getEnclosingType(), in.getName(), parametersTypeHashCode);
}
/**
* seeds well-known invokables.
*/
@Provides
@Singleton
protected Cache<Invokable<?, ?>, Invokable<?, ?>> seedKnownSync2AsyncInvokables() {
Cache<Invokable<?, ?>, Invokable<?, ?>> sync2AsyncBuilder = CacheBuilder.newBuilder().build();
putInvokables(TypeToken.of(HttpClient.class), TypeToken.of(HttpAsyncClient.class), sync2AsyncBuilder);
for (Class<?> s : sync2Async.keySet()) {
putInvokables(TypeToken.of(s), TypeToken.of(sync2Async.get(s)), sync2AsyncBuilder);
}
return sync2AsyncBuilder;
}
// accessible for ClientProvider
public static void putInvokables(TypeToken<?> sync, TypeToken<?> async, Cache<Invokable<?, ?>, Invokable<?, ?>> cache) {
for (Method invoked : sync.getRawType().getMethods()) {
if (!objectMethods.contains(invoked)) {
try {
Method delegatedMethod = async.getRawType().getMethod(invoked.getName(), invoked.getParameterTypes());
checkArgument(Arrays.equals(delegatedMethod.getExceptionTypes(), invoked.getExceptionTypes()), "invoked %s has different typed exceptions than delegated invoked %s", invoked,
delegatedMethod);
invoked.setAccessible(true);
delegatedMethod.setAccessible(true);
cache.put(Invokable.from(sync, invoked), Invokable.from(async, delegatedMethod));
} catch (SecurityException e) {
throw propagate(e);
} catch (NoSuchMethodException e) {
throw propagate(e);
}
}
}
}
protected void installLocations() {
install(new LocationModule());
}
@Override
protected void configure() {
bind(new TypeLiteral<Map<Class<?>, Class<?>>>(){}).toInstance(sync2Async);
bind(new TypeLiteral<Map<Class<?>, Class<?>>>() {
}).toInstance(sync2Async);
install(new SaxParserModule());
install(new GsonModule());
install(new FactoryModuleBuilder().build(BindToJsonPayloadWrappedWith.Factory.class));
install(new FactoryModuleBuilder().build(RestAnnotationProcessor.Caller.Factory.class));
install(new FactoryModuleBuilder().build(AsyncRestClientProxy.Caller.Factory.class));
install(new FactoryModuleBuilder().build(InvokeAsyncApi.Delegate.Factory.class));
install(new FactoryModuleBuilder().build(InvokeFutureAndBlock.Factory.class));
install(new FactoryModuleBuilder().build(InvokeListenableFutureViaHttp.Caller.Factory.class));
bind(IdentityFunction.class).toInstance(IdentityFunction.INSTANCE);
install(new FactoryModuleBuilder().build(SyncProxy.Factory.class));
install(new FactoryModuleBuilder().build(InvokeSyncApi.Factory.class));
bindClientAndAsyncClient(binder(), HttpClient.class, HttpAsyncClient.class);
// this will help short circuit scenarios that can otherwise lock out users
bind(new TypeLiteral<AtomicReference<AuthorizationException>>() {
@ -93,8 +188,10 @@ public class RestModule extends AbstractModule {
}).to(FilterStringsBoundToInjectorByName.class);
bind(new TypeLiteral<Function<Predicate<String>, Map<String, String>>>() {
}).to(FilterStringsBoundToInjectorByName.class);
bind(new TypeLiteral<Function<ForwardInvocationToInterface, Object>>() {
}).to(CreateClientForCaller.class);
bind(new TypeLiteral<Function<Invocation, ListenableFuture<?>>>() {
}).to(InvokeListenableFutureViaHttp.class);
bind(new TypeLiteral<Function<GeneratedHttpRequest, Function<HttpResponse, ?>>>() {
}).to(TransformerForRequest.class);
installLocations();
}
@ -102,22 +199,16 @@ public class RestModule extends AbstractModule {
@Singleton
@Named("TIMEOUTS")
protected Map<String, Long> timeouts(Function<Predicate<String>, Map<String, String>> filterStringsBoundByName) {
Map<String, String> stringBoundWithTimeoutPrefix = filterStringsBoundByName.apply(Predicates2.startsWith(PROPERTY_TIMEOUTS_PREFIX));
Map<String, Long> longsByName = Maps.transformValues(stringBoundWithTimeoutPrefix, new Function<String, Long>() {
@Override
Map<String, String> stringBoundWithTimeoutPrefix = filterStringsBoundByName.apply(startsWith(PROPERTY_TIMEOUTS_PREFIX));
Map<String, Long> longsByName = transformValues(stringBoundWithTimeoutPrefix, new Function<String, Long>() {
public Long apply(String input) {
return Long.valueOf(String.valueOf(input));
}
});
return Maps2.transformKeys(longsByName, new Function<String, String>() {
@Override
return transformKeys(longsByName, new Function<String, String>() {
public String apply(String input) {
return input.replaceFirst(PROPERTY_TIMEOUTS_PREFIX, "");
}
});
}

View File

@ -1,529 +0,0 @@
/**
* 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.rest.internal;
import static com.google.common.base.Functions.compose;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Predicates.in;
import static com.google.common.base.Predicates.not;
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.util.concurrent.Futures.immediateFailedFuture;
import static com.google.common.util.concurrent.Futures.transform;
import static com.google.common.util.concurrent.Futures.withFallback;
import static com.google.inject.util.Types.newParameterizedType;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static org.jclouds.concurrent.Futures.makeListenable;
import static org.jclouds.http.HttpUtils.tryFindHttpMethod;
import static org.jclouds.util.Optionals2.isReturnTypeOptional;
import static org.jclouds.util.Optionals2.unwrapIfOptional;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
import java.net.URI;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Qualifier;
import javax.inject.Singleton;
import javax.lang.model.type.NullType;
import javax.ws.rs.Path;
import org.jclouds.Constants;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.functions.IdentityFunction;
import org.jclouds.functions.OnlyElementOrNull;
import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpCommandExecutorService;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.http.functions.ParseJson;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
import org.jclouds.http.functions.ParseXMLWithJAXB;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnInputStream;
import org.jclouds.http.functions.ReturnStringIf2xx;
import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.json.internal.GsonWrapper;
import org.jclouds.logging.Logger;
import org.jclouds.reflect.FunctionalReflection;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invocation.Result;
import org.jclouds.reflect.InvocationSuccess;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.InvocationContext;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.ResponseParser;
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 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;
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.Invokable;
import com.google.common.reflect.Parameter;
import com.google.common.reflect.TypeToken;
import com.google.common.util.concurrent.FutureFallback;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Binding;
import com.google.inject.ConfigurationException;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Provides;
import com.google.inject.ProvisionException;
import com.google.inject.TypeLiteral;
import com.google.inject.assistedinject.Assisted;
/**
* Generates RESTful clients from appropriately annotated interfaces.
* <p/>
* Particularly, this code delegates calls to other things.
* <ol>
* <li>if the invoked has a {@link Provides} annotation, it responds via a {@link Injector} lookup</li>
* <li>if the invoked has a {@link Delegate} annotation, it responds with an instance of interface set in returnVal,
* adding the current JAXrs annotations to whatever are on that class.</li>
* <ul>
* <li>ex. if the invoked with {@link Delegate} has a {@code Path} annotation, and the returnval interface also has
* {@code Path}, these values are combined.</li>
* </ul>
* <li>if {@link RestAnnotationProcessor#delegationMap} contains a mapping for this, and the returnVal is properly
* assigned as a {@link ListenableFuture}, it responds with an http implementation.</li>
* <li>otherwise a RuntimeException is thrown with a message including:
* {@code invoked is intended solely to set constants}</li>
* </ol>
*
* @author Adrian Cole
*/
@Singleton
public class AsyncRestClientProxy implements Function<Invocation, Result> {
public final static class Caller extends AsyncRestClientProxy {
public static interface Factory {
Caller caller(Invocation caller, Class<?> interfaceType);
}
@Inject
private Caller(Injector injector, Function<InvocationSuccess, Optional<Object>> optionalConverter,
HttpCommandExecutorService http, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads,
Caller.Factory factory, RestAnnotationProcessor.Caller.Factory rap, ParseSax.Factory parserFactory,
@Assisted Invocation caller) {
super(injector, optionalConverter, http, userThreads, factory, rap.caller(caller), parserFactory);
}
}
@Resource
private Logger logger = Logger.NULL;
private final Injector injector;
private final HttpCommandExecutorService http;
private final ExecutorService userThreads;
private final Function<InvocationSuccess, Optional<Object>> optionalConverter;
private final Caller.Factory factory;
private final RestAnnotationProcessor annotationProcessor;
private final ParseSax.Factory parserFactory;
private static final LoadingCache<Class<?>, Set<InterfaceNameAndParameters>> delegationMapCache = CacheBuilder
.newBuilder().build(new CacheLoader<Class<?>, Set<InterfaceNameAndParameters>>() {
public Set<InterfaceNameAndParameters> load(final Class<?> interfaceType) throws ExecutionException {
return FluentIterable.from(ImmutableSet.copyOf(interfaceType.getMethods()))
.filter(not(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);
}
}).transform(new Function<Invokable<?, ?>, InterfaceNameAndParameters>() {
public InterfaceNameAndParameters apply(Invokable<?, ?> in) {
return new InterfaceNameAndParameters(interfaceType, in.getName(), in.getParameters());
}
}).toSet();
}
});
private static final class InterfaceNameAndParameters {
private final Class<?> interfaceType;
private final String name;
private final int parametersTypeHashCode;
private InterfaceNameAndParameters(Class<?> interfaceType, String name, ImmutableList<Parameter> parameters) {
this.interfaceType = interfaceType;
this.name = name;
int parametersTypeHashCode = 0;
for (Parameter param : parameters)
parametersTypeHashCode += param.getType().hashCode();
this.parametersTypeHashCode = parametersTypeHashCode;
}
public int hashCode() {
return Objects.hashCode(interfaceType, name, parametersTypeHashCode);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
InterfaceNameAndParameters that = InterfaceNameAndParameters.class.cast(o);
return equal(this.interfaceType, that.interfaceType) && equal(this.name, that.name)
&& equal(this.parametersTypeHashCode, that.parametersTypeHashCode);
}
}
@Inject
private AsyncRestClientProxy(Injector injector, Function<InvocationSuccess, Optional<Object>> optionalConverter,
HttpCommandExecutorService http, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads,
Caller.Factory factory, RestAnnotationProcessor annotationProcessor, ParseSax.Factory parserFactory) {
this.injector = injector;
this.optionalConverter = optionalConverter;
this.http = http;
this.userThreads = userThreads;
this.factory = factory;
this.annotationProcessor = annotationProcessor;
this.parserFactory = parserFactory;
}
private static final Predicate<Annotation> isQualifierPresent = new Predicate<Annotation>() {
public boolean apply(Annotation input) {
return input.annotationType().isAnnotationPresent(Qualifier.class);
}
};
@Override
public Result apply(Invocation invocation) {
if (invocation.getInvokable().isAnnotationPresent(Provides.class)) {
return Result.success(lookupValueFromGuice(invocation.getInvokable()));
} else if (invocation.getInvokable().isAnnotationPresent(Delegate.class)) {
return Result.success(propagateContextToDelegate(invocation));
} else if (isAsyncOrDelegate(invocation)) {
return Result.success(createListenableFutureForHttpRequestMappedToMethodAndArgs(invocation));
} else {
return Result.fail(new IllegalStateException(String.format(
"Method is not annotated as either http or provider invoked: %s", invocation.getInvokable())));
}
}
private boolean isAsyncOrDelegate(Invocation invocation) {
return delegationMapCache.getUnchecked(invocation.getInterfaceType()).contains(
new InterfaceNameAndParameters(invocation.getInterfaceType(), invocation.getInvokable().getName(),
invocation.getInvokable().getParameters()));
}
private Object propagateContextToDelegate(Invocation invocation) {
Class<?> returnType = unwrapIfOptional(invocation.getInvokable().getReturnType());
Object result = FunctionalReflection.newProxy(returnType, factory.caller(invocation, returnType));
if (isReturnTypeOptional(invocation.getInvokable())) {
return optionalConverter.apply(InvocationSuccess.create(invocation, result));
}
return result;
}
private Object lookupValueFromGuice(Invokable<?, ?> invoked) {
try {
Type genericReturnType = invoked.getReturnType().getType();
try {
Annotation qualifier = find(ImmutableList.copyOf(invoked.getAnnotations()), isQualifierPresent);
return getInstanceOfTypeWithQualifier(genericReturnType, qualifier);
} catch (ProvisionException e) {
throw propagate(e.getCause());
} catch (RuntimeException e) {
return instanceOfTypeOrPropagate(genericReturnType, e);
}
} catch (ProvisionException e) {
AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class);
if (aex != null)
throw aex;
throw e;
}
}
private Object instanceOfTypeOrPropagate(Type genericReturnType, RuntimeException e) {
try {
// look for an existing binding
Binding<?> binding = injector.getExistingBinding(Key.get(genericReturnType));
if (binding != null)
return binding.getProvider().get();
// then, try looking via supplier
binding = injector.getExistingBinding(Key.get(newParameterizedType(Supplier.class, genericReturnType)));
if (binding != null)
return Supplier.class.cast(binding.getProvider().get()).get();
// else try to create an instance
return injector.getInstance(Key.get(genericReturnType));
} catch (ConfigurationException ce) {
throw e;
}
}
private Object getInstanceOfTypeWithQualifier(Type genericReturnType, Annotation qualifier) {
// look for an existing binding
Binding<?> binding = injector.getExistingBinding(Key.get(genericReturnType, qualifier));
if (binding != null)
return binding.getProvider().get();
// then, try looking via supplier
binding = injector
.getExistingBinding(Key.get(newParameterizedType(Supplier.class, genericReturnType), qualifier));
if (binding != null)
return Supplier.class.cast(binding.getProvider().get()).get();
// else try to create an instance
return injector.getInstance(Key.get(genericReturnType, qualifier));
}
@SuppressWarnings("unchecked")
@VisibleForTesting
static Function<HttpResponse, ?> createResponseParser(ParseSax.Factory parserFactory, Injector injector,
Invocation invocation, HttpRequest request) {
Function<HttpResponse, ?> transformer;
Class<? extends HandlerWithResult<?>> handler = getSaxResponseParserClassOrNull(invocation.getInvokable());
if (handler != null) {
transformer = parserFactory.create(injector.getInstance(handler));
} else {
transformer = getTransformerForMethod(invocation, injector);
}
if (transformer instanceof InvocationContext<?>) {
((InvocationContext<?>) transformer).setContext(request);
}
if (invocation.getInvokable().isAnnotationPresent(Transform.class)) {
Function<?, ?> wrappingTransformer = injector.getInstance(invocation.getInvokable()
.getAnnotation(Transform.class).value());
if (wrappingTransformer instanceof InvocationContext<?>) {
((InvocationContext<?>) wrappingTransformer).setContext(request);
}
transformer = compose(Function.class.cast(wrappingTransformer), transformer);
}
return transformer;
}
private static Class<? extends HandlerWithResult<?>> getSaxResponseParserClassOrNull(Invokable<?, ?> invoked) {
XMLResponseParser annotation = invoked.getAnnotation(XMLResponseParser.class);
if (annotation != null) {
return annotation.value();
}
return null;
}
// TODO: refactor this out of here
@VisibleForTesting
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Function<HttpResponse, ?> getTransformerForMethod(Invocation invocation, Injector injector) {
Invokable<?, ?> invoked = invocation.getInvokable();
Function<HttpResponse, ?> transformer;
if (invoked.isAnnotationPresent(SelectJson.class)) {
Type returnVal = getReturnTypeFor(invoked.getReturnType());
if (invoked.isAnnotationPresent(OnlyElement.class))
returnVal = newParameterizedType(Set.class, returnVal);
transformer = new ParseFirstJsonValueNamed(injector.getInstance(GsonWrapper.class),
TypeLiteral.get(returnVal), invoked.getAnnotation(SelectJson.class).value());
if (invoked.isAnnotationPresent(OnlyElement.class))
transformer = compose(new OnlyElementOrNull(), transformer);
} else {
transformer = injector.getInstance(getParserOrThrowException(invocation));
}
return transformer;
}
private ListenableFuture<?> createListenableFutureForHttpRequestMappedToMethodAndArgs(Invocation invocation) {
String name = invocation.getInterfaceType().getSimpleName() + "." + invocation.getInvokable().getName();
logger.trace(">> converting %s", name);
FutureFallback<?> fallback = fallbacks.getUnchecked(invocation.getInvokable());
// in case there is an exception creating the request, we should at least pass in args
if (fallback instanceof InvocationContext) {
InvocationContext.class.cast(fallback).setContext((HttpRequest) null);
}
ListenableFuture<?> result;
try {
GeneratedHttpRequest request = annotationProcessor.apply(invocation);
if (fallback instanceof InvocationContext) {
InvocationContext.class.cast(fallback).setContext(request);
}
logger.trace("<< converted %s to %s", name, request.getRequestLine());
Function<HttpResponse, ?> transformer = createResponseParser(parserFactory, injector, invocation, request);
logger.trace("<< response from %s is parsed by %s", name, transformer.getClass().getSimpleName());
logger.debug(">> invoking %s", name);
result = transform(makeListenable(http.submit(new HttpCommand(request)), userThreads), transformer);
} catch (RuntimeException e) {
AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class);
if (aex != null)
e = aex;
try {
return fallback.create(e);
} catch (Exception ex) {
return immediateFailedFuture(ex);
}
}
logger.trace("<< exceptions from %s are parsed by %s", name, fallback.getClass().getSimpleName());
return withFallback(result, fallback);
}
@Override
public String toString() {
return String.format("async->http");
}
private final LoadingCache<Invokable<?, ?>, FutureFallback<?>> fallbacks = CacheBuilder.newBuilder().build(
new CacheLoader<Invokable<?, ?>, FutureFallback<?>>() {
@Override
public FutureFallback<?> load(Invokable<?, ?> key) throws Exception {
Fallback annotation = key.getAnnotation(Fallback.class);
if (annotation != null) {
return injector.getInstance(annotation.value());
}
return injector.getInstance(MapHttp4xxCodesToExceptions.class);
}
});
private static final TypeToken<ListenableFuture<Boolean>> futureBooleanLiteral = new TypeToken<ListenableFuture<Boolean>>() {
private static final long serialVersionUID = 1L;
};
private static final TypeToken<ListenableFuture<String>> futureStringLiteral = new TypeToken<ListenableFuture<String>>() {
private static final long serialVersionUID = 1L;
};
private static final TypeToken<ListenableFuture<Void>> futureVoidLiteral = new TypeToken<ListenableFuture<Void>>() {
private static final long serialVersionUID = 1L;
};
private static final TypeToken<ListenableFuture<URI>> futureURILiteral = new TypeToken<ListenableFuture<URI>>() {
private static final long serialVersionUID = 1L;
};
private static final TypeToken<ListenableFuture<InputStream>> futureInputStreamLiteral = new TypeToken<ListenableFuture<InputStream>>() {
private static final long serialVersionUID = 1L;
};
private static final TypeToken<ListenableFuture<HttpResponse>> futureHttpResponseLiteral = new TypeToken<ListenableFuture<HttpResponse>>() {
private static final long serialVersionUID = 1L;
};
@SuppressWarnings("unchecked")
@VisibleForTesting
static Key<? extends Function<HttpResponse, ?>> getParserOrThrowException(Invocation invocation) {
Invokable<?, ?> invoked = invocation.getInvokable();
ResponseParser annotation = invoked.getAnnotation(ResponseParser.class);
if (annotation == null) {
if (invoked.getReturnType().equals(void.class) || invoked.getReturnType().equals(futureVoidLiteral)) {
return Key.get(ReleasePayloadAndReturn.class);
} else if (invoked.getReturnType().equals(boolean.class) || invoked.getReturnType().equals(Boolean.class)
|| invoked.getReturnType().equals(futureBooleanLiteral)) {
return Key.get(ReturnTrueIf2xx.class);
} else if (invoked.getReturnType().equals(InputStream.class)
|| invoked.getReturnType().equals(futureInputStreamLiteral)) {
return Key.get(ReturnInputStream.class);
} else if (invoked.getReturnType().equals(HttpResponse.class)
|| invoked.getReturnType().equals(futureHttpResponseLiteral)) {
return Key.get(Class.class.cast(IdentityFunction.class));
} else if (RestAnnotationProcessor.getAcceptHeaders(invocation).contains(APPLICATION_JSON)) {
return getJsonParserKeyForMethod(invoked);
} else if (RestAnnotationProcessor.getAcceptHeaders(invocation).contains(APPLICATION_XML)
|| invoked.isAnnotationPresent(JAXBResponseParser.class)) {
return getJAXBParserKeyForMethod(invoked);
} else if (invoked.getReturnType().equals(String.class) || invoked.getReturnType().equals(futureStringLiteral)) {
return Key.get(ReturnStringIf2xx.class);
} else if (invoked.getReturnType().equals(URI.class) || invoked.getReturnType().equals(futureURILiteral)) {
return Key.get(ParseURIFromListOrLocationHeaderIf20x.class);
} else {
throw new IllegalStateException("You must specify a ResponseParser annotation on: " + invoked.toString());
}
}
return Key.get(annotation.value());
}
@SuppressWarnings("unchecked")
private static Key<? extends Function<HttpResponse, ?>> getJAXBParserKeyForMethod(Invokable<?, ?> invoked) {
Optional<Type> configuredReturnVal = Optional.absent();
if (invoked.isAnnotationPresent(JAXBResponseParser.class)) {
Type configuredClass = invoked.getAnnotation(JAXBResponseParser.class).value();
configuredReturnVal = configuredClass.equals(NullType.class) ? Optional.<Type> absent() : Optional
.<Type> of(configuredClass);
}
Type returnVal = configuredReturnVal.or(getReturnTypeFor(invoked.getReturnType()));
Type parserType = newParameterizedType(ParseXMLWithJAXB.class, returnVal);
return (Key<? extends Function<HttpResponse, ?>>) Key.get(parserType);
}
@SuppressWarnings({ "unchecked" })
private static Key<? extends Function<HttpResponse, ?>> getJsonParserKeyForMethod(Invokable<?, ?> invoked) {
ParameterizedType parserType;
if (invoked.isAnnotationPresent(Unwrap.class)) {
parserType = newParameterizedType(UnwrapOnlyJsonValue.class, getReturnTypeFor(invoked.getReturnType()));
} else {
parserType = newParameterizedType(ParseJson.class, getReturnTypeFor(invoked.getReturnType()));
}
return (Key<? extends Function<HttpResponse, ?>>) Key.get(parserType);
}
private static Type getReturnTypeFor(TypeToken<?> typeToken) {
Type returnVal = typeToken.getType();
if (typeToken.getRawType().getTypeParameters().length == 0) {
returnVal = typeToken.getRawType();
} else if (typeToken.getRawType().equals(ListenableFuture.class)) {
ParameterizedType futureType = (ParameterizedType) typeToken.getType();
returnVal = futureType.getActualTypeArguments()[0];
if (returnVal instanceof WildcardType)
returnVal = WildcardType.class.cast(returnVal).getUpperBounds()[0];
}
return returnVal;
}
}

View File

@ -0,0 +1,127 @@
package org.jclouds.rest.internal;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.collect.Iterables.find;
import static com.google.inject.util.Types.newParameterizedType;
import static org.jclouds.util.Optionals2.isReturnTypeOptional;
import static org.jclouds.util.Optionals2.unwrapIfOptional;
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.inject.Qualifier;
import org.jclouds.reflect.FunctionalReflection;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invocation.Result;
import org.jclouds.reflect.InvocationSuccess;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.annotations.Delegate;
import com.google.common.annotations.Beta;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.inject.Binding;
import com.google.inject.ConfigurationException;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Provides;
import com.google.inject.ProvisionException;
@Beta
abstract class BaseInvocationFunction implements Function<Invocation, Result> {
protected final Injector injector;
protected final Function<InvocationSuccess, Optional<Object>> optionalConverter;
protected BaseInvocationFunction(Injector injector, Function<InvocationSuccess, Optional<Object>> optionalConverter) {
this.injector = injector;
this.optionalConverter = optionalConverter;
}
protected abstract Result invoke(Invocation in);
protected abstract Function<Invocation, Result> forwardInvocations(Invocation invocation, Class<?> returnType);
@Override
public Result apply(Invocation invocation) {
if (invocation.getInvokable().isAnnotationPresent(Provides.class))
return Result.success(lookupValueFromGuice(invocation.getInvokable()));
else if (invocation.getInvokable().isAnnotationPresent(Delegate.class))
return Result.success(propagateContextToDelegate(invocation));
return invoke(invocation);
}
private Object propagateContextToDelegate(Invocation invocation) {
Class<?> returnType = unwrapIfOptional(invocation.getInvokable().getReturnType());
Object result = FunctionalReflection.newProxy(returnType, forwardInvocations(invocation, returnType));
if (isReturnTypeOptional(invocation.getInvokable())) {
result = optionalConverter.apply(InvocationSuccess.create(invocation, result));
}
return result;
}
static final Predicate<Annotation> isQualifierPresent = new Predicate<Annotation>() {
public boolean apply(Annotation input) {
return input.annotationType().isAnnotationPresent(Qualifier.class);
}
};
private Object lookupValueFromGuice(Invokable<?, ?> invoked) {
try {
Type genericReturnType = invoked.getReturnType().getType();
try {
Annotation qualifier = find(ImmutableList.copyOf(invoked.getAnnotations()), isQualifierPresent);
return getInstanceOfTypeWithQualifier(genericReturnType, qualifier);
} catch (ProvisionException e) {
throw propagate(e.getCause());
} catch (RuntimeException e) {
return instanceOfTypeOrPropagate(genericReturnType, e);
}
} catch (ProvisionException e) {
AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class);
if (aex != null)
throw aex;
throw e;
}
}
Object instanceOfTypeOrPropagate(Type genericReturnType, RuntimeException e) {
try {
// look for an existing binding
Binding<?> binding = injector.getExistingBinding(Key.get(genericReturnType));
if (binding != null)
return binding.getProvider().get();
// then, try looking via supplier
binding = injector.getExistingBinding(Key.get(newParameterizedType(Supplier.class, genericReturnType)));
if (binding != null)
return Supplier.class.cast(binding.getProvider().get()).get();
// else try to create an instance
return injector.getInstance(Key.get(genericReturnType));
} catch (ConfigurationException ce) {
throw e;
}
}
Object getInstanceOfTypeWithQualifier(Type genericReturnType, Annotation qualifier) {
// look for an existing binding
Binding<?> binding = injector.getExistingBinding(Key.get(genericReturnType, qualifier));
if (binding != null)
return binding.getProvider().get();
// then, try looking via supplier
binding = injector
.getExistingBinding(Key.get(newParameterizedType(Supplier.class, genericReturnType), qualifier));
if (binding != null)
return Supplier.class.cast(binding.getProvider().get()).get();
// else try to create an instance
return injector.getInstance(Key.get(genericReturnType, qualifier));
}
}

View File

@ -37,15 +37,15 @@ import com.google.common.collect.Multimap;
* @author Adrian Cole
*/
public final class GeneratedHttpRequest extends HttpRequest {
public static Builder builder() {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
public Builder toBuilder() {
return new Builder().fromGeneratedHttpRequest(this);
}
public final static class Builder extends HttpRequest.Builder<Builder> {
public final static class Builder extends HttpRequest.Builder<Builder> {
protected Invocation invocation;
protected Optional<Invocation> caller = Optional.absent();
@ -57,7 +57,7 @@ public final class GeneratedHttpRequest extends HttpRequest {
return this;
}
/**
/**
* @see GeneratedHttpRequest#getCaller()
*/
public Builder caller(@Nullable Invocation caller) {
@ -71,9 +71,15 @@ public final class GeneratedHttpRequest extends HttpRequest {
}
public Builder fromGeneratedHttpRequest(GeneratedHttpRequest in) {
return super.fromHttpRequest(in)
.invocation(in.invocation)
.caller(in.getCaller().orNull());
return super.fromHttpRequest(in).invocation(in.invocation).caller(in.getCaller().orNull());
}
Invocation getInvocation() {
return invocation;
}
Optional<Invocation> getCaller() {
return caller;
}
@Override
@ -81,7 +87,7 @@ public final class GeneratedHttpRequest extends HttpRequest {
return this;
}
}
private final Invocation invocation;
private final Optional<Invocation> caller;

View File

@ -0,0 +1,122 @@
/**
* 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.rest.internal;
import static com.google.common.base.Preconditions.checkState;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.logging.Logger;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invocation.Result;
import org.jclouds.reflect.InvocationSuccess;
import org.jclouds.reflect.Invokable;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.assistedinject.Assisted;
/**
* Generates RESTful clients from appropriately annotated interfaces.
* <p/>
* Particularly, this code delegates calls to other things.
* <ol>
* <li>if the invoked has a {@link Provides} annotation, it responds via a {@link Injector} lookup</li>
* <li>if the invoked has a {@link Delegate} annotation, it responds with an instance of interface set in returnVal,
* adding the current JAXrs annotations to whatever are on that class.</li>
* <ul>
* <li>ex. if the invoked with {@link Delegate} has a {@code Path} annotation, and the returnval interface also has
* {@code Path}, these values are combined.</li>
* </ul>
* <li>if {@link RestAnnotationProcessor#delegationMap} contains a mapping for this, and the returnVal is properly
* assigned as a {@link ListenableFuture}, it responds with an http implementation.</li>
* <li>otherwise a RuntimeException is thrown with a message including:
* {@code invoked is intended solely to set constants}</li>
* </ol>
*
* @author Adrian Cole
*/
@Singleton
public class InvokeAsyncApi extends BaseInvocationFunction {
public final static class Delegate extends InvokeAsyncApi {
public static interface Factory {
Delegate caller(Invocation caller);
}
private final String string;
@Inject
private Delegate(Injector injector, Function<InvocationSuccess, Optional<Object>> optionalConverter,
Predicate<Invokable<?, ?>> mapsToAsyncHttpRequest,
InvokeListenableFutureViaHttp.Caller.Factory httpCallerFactory, Delegate.Factory factory,
@Assisted Invocation caller) {
super(injector, optionalConverter, mapsToAsyncHttpRequest, httpCallerFactory.caller(caller), factory);
this.string = String.format("%s->%s", caller, caller.getInvokable().getReturnType().getRawType()
.getSimpleName());
}
@Override
public String toString() {
return string;
}
}
@Resource
private Logger logger = Logger.NULL;
private final Predicate<Invokable<?, ?>> mapsToAsyncHttpRequest;
private final Function<Invocation, ListenableFuture<?>> invokeMethod;
private final Delegate.Factory factory;
@Inject
private InvokeAsyncApi(Injector injector, Function<InvocationSuccess, Optional<Object>> optionalConverter,
Predicate<Invokable<?, ?>> mapsToAsyncHttpRequest, Function<Invocation, ListenableFuture<?>> invokeMethod,
Delegate.Factory factory) {
super(injector, optionalConverter);
this.mapsToAsyncHttpRequest = mapsToAsyncHttpRequest;
this.invokeMethod = invokeMethod;
this.factory = factory;
}
@Override
protected Result invoke(Invocation invocation) {
checkState(mapsToAsyncHttpRequest.apply(invocation.getInvokable()),
"please configure corresponding async class for %s in your RestClientModule", invocation.getInvokable());
return Result.success(invokeMethod.apply(invocation));
}
@Override
protected Function<Invocation, Result> forwardInvocations(Invocation invocation, Class<?> returnType) {
return factory.caller(invocation);
}
@Override
public String toString() {
return String.format("async->http");
}
}

View File

@ -0,0 +1,116 @@
/**
* 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.rest.internal;
import static com.google.common.base.Optional.fromNullable;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.logging.Logger;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invocation.Result;
import org.jclouds.reflect.Invokable;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.cache.Cache;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.assistedinject.Assisted;
public class InvokeFutureAndBlock implements Function<Invocation, Result> {
public static interface Factory {
/**
* @param receiver
* object whose interface matched {@code declaring} except all invokeds return {@link ListenableFuture}
* @return blocking invocation handler
*/
InvokeFutureAndBlock create(Object async);
}
@Resource
private Logger logger = Logger.NULL;
private final Cache<Invokable<?, ?>, Invokable<?, ?>> sync2AsyncInvokables;
private final Map<String, Long> timeouts;
private final Object receiver;
@Inject
@VisibleForTesting
InvokeFutureAndBlock(Cache<Invokable<?, ?>, Invokable<?, ?>> sync2AsyncInvokables,
@Named("TIMEOUTS") Map<String, Long> timeouts, @Assisted Object receiver) {
this.receiver = receiver;
this.sync2AsyncInvokables = sync2AsyncInvokables;
this.timeouts = timeouts;
}
@Override
public Result apply(Invocation invocation) {
@SuppressWarnings("unchecked")
Invokable<? super Object, ListenableFuture<?>> asyncMethod = Invokable.class.cast(sync2AsyncInvokables
.getIfPresent(invocation.getInvokable()));
try {
ListenableFuture<?> future = asyncMethod.invoke(receiver, invocation.getArgs().toArray());
Optional<Long> timeoutNanos = timeoutInNanos(invocation.getInvokable(), timeouts);
return block(future, timeoutNanos);
} catch (InvocationTargetException e) {
return Result.fail(e);
} catch (IllegalAccessException e) {
return Result.fail(e);
}
}
private Result block(ListenableFuture<?> future, Optional<Long> timeoutNanos) {
try {
if (timeoutNanos.isPresent()) {
logger.debug(">> blocking on %s for %s", future, timeoutNanos);
return Result.success(future.get(timeoutNanos.get(), TimeUnit.NANOSECONDS));
} else {
logger.debug(">> blocking on %s", future);
return Result.success(future.get());
}
} catch (ExecutionException e) {
return Result.fail(e.getCause());
} catch (InterruptedException e) {
return Result.fail(e); // TODO: should we kill the future?
} catch (TimeoutException e) {
return Result.fail(e);
}
}
// override timeout by values configured in properties(in ms)
private Optional<Long> timeoutInNanos(Invokable<?, ?> invoked, Map<String, Long> timeouts) {
String className = invoked.getEnclosingType().getRawType().getSimpleName();
Optional<Long> timeoutMillis = fromNullable(timeouts.get(className + "." + invoked.getName())).or(
fromNullable(timeouts.get(className))).or(fromNullable(timeouts.get("default")));
if (timeoutMillis.isPresent())
return Optional.of(TimeUnit.MILLISECONDS.toNanos(timeoutMillis.get()));
return Optional.absent();
}
}

View File

@ -0,0 +1,146 @@
/**
* 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.rest.internal;
import static com.google.common.base.Objects.equal;
import static com.google.common.util.concurrent.Futures.transform;
import static com.google.common.util.concurrent.Futures.withFallback;
import static org.jclouds.concurrent.Futures.makeListenable;
import java.util.concurrent.ExecutorService;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpCommandExecutorService;
import org.jclouds.http.HttpResponse;
import org.jclouds.logging.Logger;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invokable;
import org.jclouds.rest.InvocationContext;
import org.jclouds.rest.annotations.Fallback;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.FutureFallback;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Injector;
import com.google.inject.assistedinject.Assisted;
@Singleton
public class InvokeListenableFutureViaHttp implements Function<Invocation, ListenableFuture<?>> {
public final static class Caller extends InvokeListenableFutureViaHttp {
public static interface Factory {
Caller caller(Invocation caller);
}
@Inject
private Caller(Injector injector, RestAnnotationProcessor annotationProcessor, HttpCommandExecutorService http,
Function<GeneratedHttpRequest, Function<HttpResponse, ?>> transformerForRequest,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, @Assisted Invocation caller) {
super(injector, annotationProcessor.caller(caller), http, transformerForRequest, userThreads);
}
}
@Resource
private Logger logger = Logger.NULL;
private final Injector injector;
private final RestAnnotationProcessor annotationProcessor;
private final HttpCommandExecutorService http;
private final Function<GeneratedHttpRequest, Function<HttpResponse, ?>> transformerForRequest;
private final ExecutorService userThreads;
@Inject
private InvokeListenableFutureViaHttp(Injector injector, RestAnnotationProcessor annotationProcessor,
HttpCommandExecutorService http,
Function<GeneratedHttpRequest, Function<HttpResponse, ?>> transformerForRequest,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads) {
this.injector = injector;
this.annotationProcessor = annotationProcessor;
this.http = http;
this.userThreads = userThreads;
this.transformerForRequest = transformerForRequest;
}
private final LoadingCache<Invokable<?, ?>, FutureFallback<?>> fallbacks = CacheBuilder.newBuilder().build(
new CacheLoader<Invokable<?, ?>, FutureFallback<?>>() {
@Override
public FutureFallback<?> load(Invokable<?, ?> key) throws Exception {
Fallback annotation = key.getAnnotation(Fallback.class);
if (annotation != null) {
return injector.getInstance(annotation.value());
}
return injector.getInstance(MapHttp4xxCodesToExceptions.class);
}
});
@Override
public ListenableFuture<?> apply(Invocation invocation) {
String name = invocation.getInvokable().toString();
logger.trace(">> converting %s", name);
GeneratedHttpRequest request = annotationProcessor.apply(invocation);
logger.trace("<< converted %s to %s", name, request.getRequestLine());
Function<HttpResponse, ?> transformer = transformerForRequest.apply(request);
logger.trace("<< response from %s is parsed by %s", name, transformer.getClass().getSimpleName());
logger.debug(">> invoking %s", name);
ListenableFuture<?> result = transform(makeListenable(http.submit(new HttpCommand(request)), userThreads), transformer);
FutureFallback<?> fallback = fallbacks.getUnchecked(invocation.getInvokable());
if (fallback instanceof InvocationContext) {
InvocationContext.class.cast(fallback).setContext(request);
}
logger.trace("<< exceptions from %s are parsed by %s", name, fallback.getClass().getSimpleName());
return withFallback(result, fallback);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
InvokeListenableFutureViaHttp that = InvokeListenableFutureViaHttp.class.cast(o);
return equal(this.annotationProcessor, that.annotationProcessor);
}
@Override
public int hashCode() {
return Objects.hashCode(annotationProcessor);
}
@Override
public String toString() {
return Objects.toStringHelper("").omitNullValues().add("annotationParser", annotationProcessor).toString();
}
}

View File

@ -0,0 +1,123 @@
/**
* 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.rest.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import javax.annotation.Resource;
import javax.inject.Inject;
import org.jclouds.logging.Logger;
import org.jclouds.reflect.FunctionalReflection;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invocation.Result;
import org.jclouds.reflect.InvocationSuccess;
import org.jclouds.reflect.Invokable;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.cache.Cache;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Injector;
import com.google.inject.assistedinject.Assisted;
/**
*
* @author Adrian Cole
*/
public final class InvokeSyncApi extends BaseInvocationFunction {
public static interface Factory {
/**
* @param receiver
* object whose interface matched {@code declaring} except all invokeds return {@link ListenableFuture}
* @return blocking invocation handler
*/
InvokeSyncApi create(Object receiver);
}
@Resource
private Logger logger = Logger.NULL;
private final InvokeSyncApi.Factory factory;
private final InvokeAsyncApi.Delegate.Factory asyncFactory;
private final Map<Class<?>, Class<?>> sync2Async;
private final Cache<Invokable<?, ?>, Invokable<?, ?>> sync2AsyncInvokables;
private final InvokeFutureAndBlock.Factory blocker;
private final Object receiver;
@Inject
@VisibleForTesting
InvokeSyncApi(Injector injector, Function<InvocationSuccess, Optional<Object>> optionalConverter,
InvokeSyncApi.Factory factory, InvokeAsyncApi.Delegate.Factory asyncFactory,
Map<Class<?>, Class<?>> sync2Async, Cache<Invokable<?, ?>, Invokable<?, ?>> sync2AsyncInvokables,
InvokeFutureAndBlock.Factory blocker, @Assisted Object receiver) {
super(injector, optionalConverter);
this.factory = factory;
this.asyncFactory = asyncFactory;
this.sync2Async = sync2Async;
this.sync2AsyncInvokables = sync2AsyncInvokables;
this.blocker = blocker;
this.receiver = receiver;
}
@SuppressWarnings("unchecked")
@Override
protected Result invoke(Invocation in) {
@SuppressWarnings("rawtypes")
Invokable async = checkNotNull(sync2AsyncInvokables.getIfPresent(in.getInvokable()), "invokable %s not in %s",
in.getInvokable(), sync2AsyncInvokables);
if (async.getReturnType().getRawType().isAssignableFrom(ListenableFuture.class)) {
return blocker.create(receiver).apply(in);
}
try { // try any method
return Result.success(async.invoke(receiver, in.getArgs().toArray()));
} catch (InvocationTargetException e) {
return Result.fail(e);
} catch (IllegalAccessException e) {
return Result.fail(e);
}
}
@Override
protected Function<Invocation, Result> forwardInvocations(Invocation invocation, Class<?> returnType) {
// get the return type of the asynchronous class associated with this client
// ex. FloatingIPClient is associated with FloatingIPAsyncClient
Class<?> asyncClass = sync2Async.get(returnType);
checkState(asyncClass != null, "please configure corresponding async class for %s in your RestClientModule",
returnType);
// pass any parameters necessary to get a relevant instance of that async class
// ex. getClientForRegion("north") might return an instance whose endpoint is
// different that "south"
Object asyncProxy = FunctionalReflection.newProxy(asyncClass, asyncFactory.caller(invocation));
checkState(asyncProxy != null, "configuration error, sync client for " + invocation + " not found");
return factory.create(asyncProxy);
}
@Override
public String toString() {
return String.format("syncProxy(%s)", receiver);
}
}

View File

@ -78,6 +78,8 @@ import org.jclouds.io.payloads.Part.PartOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.logging.Logger;
import org.jclouds.reflect.Invocation;
import org.jclouds.reflect.Invokable;
import org.jclouds.reflect.Parameter;
import org.jclouds.rest.Binder;
import org.jclouds.rest.InputParamValidator;
import org.jclouds.rest.annotations.ApiVersion;
@ -119,13 +121,10 @@ import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.primitives.Chars;
import com.google.common.reflect.Invokable;
import com.google.common.reflect.Parameter;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import com.google.inject.assistedinject.Assisted;
/**
* Creates http invocation.getInvoked()s based on annotations on a class or interface.
@ -134,44 +133,6 @@ import com.google.inject.assistedinject.Assisted;
*/
public class RestAnnotationProcessor implements Function<Invocation, GeneratedHttpRequest> {
public static final class Caller extends RestAnnotationProcessor {
public static interface Factory {
Caller caller(Invocation caller);
}
private final Invocation caller;
@Inject
private Caller(Injector injector, @ApiVersion String apiVersion, @BuildVersion String buildVersion,
HttpUtils utils, ContentMetadataCodec contentMetadataCodec, InputParamValidator inputParamValidator,
@Assisted Invocation caller) {
super(injector, apiVersion, buildVersion, utils, contentMetadataCodec, inputParamValidator);
this.caller = caller;
}
@Override
protected GeneratedHttpRequest.Builder requestBuilder() {
return super.requestBuilder().caller(caller);
}
@Override
protected Optional<URI> findEndpoint(Invocation invocation) {
Optional<URI> endpoint = getEndpointFor(caller);
if (endpoint.isPresent())
logger.trace("using endpoint %s from caller %s for %s", endpoint, caller, invocation);
else
endpoint = super.findEndpoint(invocation);
return endpoint;
}
@Override
protected Multimap<String, Object> addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) {
return ImmutableMultimap.<String, Object> builder().putAll(super.addPathAndGetTokens(caller, uriBuilder))
.putAll(super.addPathAndGetTokens(invocation, uriBuilder)).build();
}
}
@Resource
protected Logger logger = Logger.NULL;
@ -208,6 +169,13 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
public GeneratedHttpRequest createRequest(Invokable<?, ?> invokable, List<Object> args) {
return apply(Invocation.create(invokable, args));
}
private Invocation caller;
RestAnnotationProcessor caller(Invocation caller) {
this.caller = caller;
return this;
}
@Override
public GeneratedHttpRequest apply(Invocation invocation) {
@ -220,14 +188,20 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
endpoint = Optional.fromNullable(r.getEndpoint());
if (endpoint.isPresent())
logger.trace("using endpoint %s from invocation.getArgs() for %s", endpoint, invocation);
} else {
} else if (caller != null){
endpoint = getEndpointFor(caller);
if (endpoint.isPresent())
logger.trace("using endpoint %s from caller %s for %s", endpoint, caller, invocation);
else
endpoint = findEndpoint(invocation);
}else {
endpoint = findEndpoint(invocation);
}
if (!endpoint.isPresent())
throw new NoSuchElementException(format("no endpoint found for %s", invocation));
GeneratedHttpRequest.Builder requestBuilder = requestBuilder();
GeneratedHttpRequest.Builder requestBuilder = GeneratedHttpRequest.builder().caller(caller);
if (r != null) {
requestBuilder.fromHttpRequest(r);
} else {
@ -245,6 +219,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
overridePathEncoding(uriBuilder, invocation);
if (caller != null)
tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
Multimap<String, Object> formParams = addFormParams(tokenValues, invocation);
@ -353,9 +329,9 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
}
private void overridePathEncoding(UriBuilder uriBuilder, Invocation invocation) {
if (invocation.getInterfaceType().isAnnotationPresent(SkipEncoding.class)) {
uriBuilder.skipPathEncoding(Chars.asList(invocation.getInterfaceType().getAnnotation(SkipEncoding.class)
.value()));
if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(SkipEncoding.class)) {
uriBuilder.skipPathEncoding(Chars.asList(invocation.getInvokable().getEnclosingType().getRawType()
.getAnnotation(SkipEncoding.class).value()));
}
if (invocation.getInvokable().isAnnotationPresent(SkipEncoding.class)) {
uriBuilder.skipPathEncoding(Chars.asList(invocation.getInvokable().getAnnotation(SkipEncoding.class).value()));
@ -387,9 +363,10 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
return endpoint;
}
protected Multimap<String, Object> addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) {
if (invocation.getInterfaceType().isAnnotationPresent(Path.class))
uriBuilder.appendPath(invocation.getInterfaceType().getAnnotation(Path.class).value());
private Multimap<String, Object> addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) {
if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(Path.class))
uriBuilder.appendPath(invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(Path.class)
.value());
if (invocation.getInvokable().isAnnotationPresent(Path.class))
uriBuilder.appendPath(invocation.getInvokable().getAnnotation(Path.class).value());
return getPathParamKeyValues(invocation);
@ -397,8 +374,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
private Multimap<String, Object> addFormParams(Multimap<String, ?> tokenValues, Invocation invocation) {
Multimap<String, Object> formMap = LinkedListMultimap.create();
if (invocation.getInterfaceType().isAnnotationPresent(FormParams.class)) {
FormParams form = invocation.getInterfaceType().getAnnotation(FormParams.class);
if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(FormParams.class)) {
FormParams form = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(FormParams.class);
addForm(formMap, form, tokenValues);
}
@ -415,8 +392,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
private Multimap<String, Object> addQueryParams(Multimap<String, ?> tokenValues, Invocation invocation) {
Multimap<String, Object> queryMap = LinkedListMultimap.create();
if (invocation.getInterfaceType().isAnnotationPresent(QueryParams.class)) {
QueryParams query = invocation.getInterfaceType().getAnnotation(QueryParams.class);
if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(QueryParams.class)) {
QueryParams query = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(QueryParams.class);
addQuery(queryMap, query, tokenValues);
}
@ -466,12 +443,13 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
private List<HttpRequestFilter> getFiltersIfAnnotated(Invocation invocation) {
List<HttpRequestFilter> filters = newArrayList();
if (invocation.getInterfaceType().isAnnotationPresent(RequestFilters.class)) {
for (Class<? extends HttpRequestFilter> clazz : invocation.getInterfaceType()
if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(RequestFilters.class)) {
for (Class<? extends HttpRequestFilter> clazz : invocation.getInvokable().getEnclosingType().getRawType()
.getAnnotation(RequestFilters.class).value()) {
HttpRequestFilter instance = injector.getInstance(clazz);
filters.add(instance);
logger.trace("adding filter %s from annotation on %s", instance, invocation.getInterfaceType().getName());
logger.trace("adding filter %s from annotation on %s", instance, invocation.getInvokable()
.getEnclosingType().getRawType().getName());
}
}
if (invocation.getInvokable().isAnnotationPresent(RequestFilters.class)) {
@ -526,8 +504,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
Endpoint annotation;
if (invocation.getInvokable().isAnnotationPresent(Endpoint.class)) {
annotation = invocation.getInvokable().getAnnotation(Endpoint.class);
} else if (invocation.getInterfaceType().isAnnotationPresent(Endpoint.class)) {
annotation = invocation.getInterfaceType().getAnnotation(Endpoint.class);
} else if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(Endpoint.class)) {
annotation = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(Endpoint.class);
} else {
logger.trace("no annotations on class or invocation.getInvoked(): %s", invocation.getInvokable());
return Optional.absent();
@ -587,8 +565,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
}
private boolean shouldAddHostHeader(Invocation invocation) {
return (invocation.getInterfaceType().isAnnotationPresent(VirtualHost.class) || invocation.getInvokable()
.isAnnotationPresent(VirtualHost.class));
return (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(VirtualHost.class) || invocation
.getInvokable().isAnnotationPresent(VirtualHost.class));
}
private GeneratedHttpRequest decorateRequest(GeneratedHttpRequest request) throws NegativeArraySizeException {
@ -610,15 +588,14 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
if (args.size() >= position + 1 && arg != null) {
Class<?> parameterType = entry.getType().getRawType();
Class<? extends Object> argType = arg.getClass();
if (!argType.isArray() && parameterType.isArray()) { // TODO && varinvocation.getArgs() guava issue 1244
if (!argType.isArray() && parameterType.isArray() && invocation.getInvokable().isVarArgs()) {
int arrayLength = args.size() - invocation.getInvokable().getParameters().size() + 1;
if (arrayLength == 0)
break OUTER;
arg = (Object[]) Array.newInstance(arg.getClass(), arrayLength);
System.arraycopy(args.toArray(), position, arg, 0, arrayLength);
shouldBreak = true;
} else if (argType.isArray() && parameterType.isArray()) { // TODO && varinvocation.getArgs() guava issue
// 1244
} else if (argType.isArray() && parameterType.isArray() && invocation.getInvokable().isVarArgs()) {
} else {
if (arg.getClass().isArray()) {
Object[] payloadArray = (Object[]) arg;
@ -631,8 +608,9 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
if (shouldBreak)
break OUTER;
} else {
if (position + 1 == invocation.getInvokable().getParameters().size() && entry.getType().isArray())
continue OUTER; // TODO should only skip on null when varinvocation.getArgs(): guava issue 1244
if (position + 1 == invocation.getInvokable().getParameters().size() && entry.getType().isArray()
&& invocation.getInvokable().isVarArgs())
continue OUTER;
if (entry.isAnnotationPresent(Nullable.class)) {
continue OUTER;
@ -652,7 +630,7 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
Class<?> type = param.getType().getRawType();
if (HttpRequestOptions.class.isAssignableFrom(type)
|| HttpRequestOptions[].class.isAssignableFrom(type))
toReturn.add(param.hashCode()); // TODO position guava issue 1243
toReturn.add(param.getPosition());
}
return toReturn.build();
}
@ -685,7 +663,7 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
addHeaderIfAnnotationPresentOnMethod(headers, invocation, tokenValues);
for (Parameter headerParam : parametersWithAnnotation(invocation.getInvokable(), HeaderParam.class)) {
Annotation key = headerParam.getAnnotation(HeaderParam.class);
String value = invocation.getArgs().get(headerParam.hashCode()).toString(); // TODO position guava issue 1243
String value = invocation.getArgs().get(headerParam.getPosition()).toString();
value = replaceTokens(value, tokenValues);
headers.put(((HeaderParam) key).value(), value);
}
@ -703,13 +681,14 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
// TODO: refactor this out
static Set<String> getAcceptHeaders(Invocation invocation) {
Optional<Consumes> accept = Optional.fromNullable(invocation.getInvokable().getAnnotation(Consumes.class)).or(
Optional.fromNullable(invocation.getInterfaceType().getAnnotation(Consumes.class)));
Optional.fromNullable(invocation.getInvokable().getEnclosingType().getRawType()
.getAnnotation(Consumes.class)));
return (accept.isPresent()) ? ImmutableSet.copyOf(accept.get().value()) : ImmutableSet.<String> of();
}
private static void addProducesIfPresentOnTypeOrMethod(Multimap<String, String> headers, Invocation invocation) {
if (invocation.getInterfaceType().isAnnotationPresent(Produces.class)) {
Produces header = invocation.getInterfaceType().getAnnotation(Produces.class);
if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(Produces.class)) {
Produces header = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(Produces.class);
headers.replaceValues(CONTENT_TYPE, asList(header.value()));
}
if (invocation.getInvokable().isAnnotationPresent(Produces.class)) {
@ -720,8 +699,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
private static void addHeaderIfAnnotationPresentOnMethod(Multimap<String, String> headers, Invocation invocation,
Multimap<String, ?> tokenValues) {
if (invocation.getInterfaceType().isAnnotationPresent(Headers.class)) {
Headers header = invocation.getInterfaceType().getAnnotation(Headers.class);
if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(Headers.class)) {
Headers header = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(Headers.class);
addHeader(headers, header, tokenValues);
}
if (invocation.getInvokable().isAnnotationPresent(Headers.class)) {
@ -747,7 +726,7 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
options.contentType(partParam.contentType());
if (!PartParam.NO_FILENAME.equals(partParam.filename()))
options.filename(replaceTokens(partParam.filename(), tokenValues));
Object arg = invocation.getArgs().get(param.hashCode()); // TODO position guava issue 1243
Object arg = invocation.getArgs().get(param.getPosition());
checkNotNull(arg, partParam.name());
Part part = Part.create(partParam.name(), newPayload(arg), options);
parts.add(part);
@ -760,8 +739,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
for (Parameter param : parametersWithAnnotation(invocation.getInvokable(), PathParam.class)) {
PathParam pathParam = param.getAnnotation(PathParam.class);
String paramKey = pathParam.value();
Optional<?> paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), param.hashCode(),
paramKey); // TODO position guava issue 1243
Optional<?> paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class),
param.getPosition(), paramKey);
if (paramValue.isPresent())
pathParamValues.put(paramKey, paramValue.get().toString());
}
@ -780,8 +759,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
private static boolean checkPresentOrNullable(Invocation invocation, String paramKey, int argIndex, Object arg) {
if (arg == null && !invocation.getInvokable().getParameters().get(argIndex).isAnnotationPresent(Nullable.class))
throw new NullPointerException(format("param{%s} for invocation %s.%s", paramKey, invocation
.getInterfaceType().getSimpleName(), invocation.getInvokable().getName()));
throw new NullPointerException(format("param{%s} for invocation %s.%s", paramKey, invocation.getInvokable()
.getEnclosingType().getRawType().getSimpleName(), invocation.getInvokable().getName()));
return true;
}
@ -790,8 +769,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
for (Parameter param : parametersWithAnnotation(invocation.getInvokable(), FormParam.class)) {
FormParam formParam = param.getAnnotation(FormParam.class);
String paramKey = formParam.value();
Optional<?> paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), param.hashCode(),
paramKey); // TODO position guava issue 1243
Optional<?> paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class),
param.getPosition(), paramKey);
if (paramValue.isPresent())
formParamValues.put(paramKey, paramValue.get().toString());
}
@ -803,8 +782,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
for (Parameter param : parametersWithAnnotation(invocation.getInvokable(), QueryParam.class)) {
QueryParam queryParam = param.getAnnotation(QueryParam.class);
String paramKey = queryParam.value();
Optional<?> paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), param.hashCode(),
paramKey); // TODO position guava issue 1243
Optional<?> paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class),
param.getPosition(), paramKey);
if (paramValue.isPresent())
if (paramValue.get() instanceof Iterable) {
@SuppressWarnings("unchecked")
@ -822,8 +801,8 @@ public class RestAnnotationProcessor implements Function<Invocation, GeneratedHt
for (Parameter param : parametersWithAnnotation(invocation.getInvokable(), PayloadParam.class)) {
PayloadParam payloadParam = param.getAnnotation(PayloadParam.class);
String paramKey = payloadParam.value();
Optional<?> paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), param.hashCode(),
paramKey); // TODO position guava issue 1243
Optional<?> paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class),
param.getPosition(), paramKey);
if (paramValue.isPresent())
payloadParamValues.put(paramKey, paramValue.get());
}

Some files were not shown because too many files have changed in this diff Show More