mirror of https://github.com/apache/jclouds.git
cleaned up http builders and expect tests
This commit is contained in:
parent
c8c2d5f175
commit
05fd64af44
|
@ -27,27 +27,27 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.atmos.domain.UserMetadata;
|
import org.jclouds.atmos.domain.UserMetadata;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Multimaps;
|
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
import com.google.common.collect.Multimaps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindUserMetadataToHeaders implements Binder, Function<UserMetadata, Map<String, String>> {
|
public class BindUserMetadataToHeaders implements Binder, Function<UserMetadata, Map<String, String>> {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
checkArgument(checkNotNull(input, "input") instanceof UserMetadata,
|
checkArgument(checkNotNull(input, "input") instanceof UserMetadata,
|
||||||
"this binder is only valid for UserMetadatas!");
|
"this binder is only valid for UserMetadatas!");
|
||||||
checkNotNull(request, "request");
|
checkNotNull(request, "request");
|
||||||
|
return (R) request.toBuilder().replaceHeaders(Multimaps.forMap(apply(UserMetadata.class.cast(input)))).build();
|
||||||
return ModifyRequest.putHeaders(request, Multimaps.forMap(apply(UserMetadata.class.cast(input))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,8 +25,6 @@ import org.jclouds.atmos.domain.MutableContentMetadata;
|
||||||
import org.jclouds.io.ContentMetadataBuilder;
|
import org.jclouds.io.ContentMetadataBuilder;
|
||||||
import org.jclouds.io.payloads.BaseMutableContentMetadata;
|
import org.jclouds.io.payloads.BaseMutableContentMetadata;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpRequestFilter;
|
import org.jclouds.http.HttpRequestFilter;
|
||||||
import org.jclouds.http.HttpUtils;
|
import org.jclouds.http.HttpUtils;
|
||||||
import org.jclouds.http.internal.SignatureWire;
|
import org.jclouds.http.internal.SignatureWire;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.io.InputSuppliers;
|
import org.jclouds.io.InputSuppliers;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.annotations.Credential;
|
import org.jclouds.rest.annotations.Credential;
|
||||||
|
@ -51,8 +50,8 @@ import org.jclouds.util.Strings2;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Multimaps;
|
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
import com.google.common.collect.Multimaps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signs the EMC Atmos Online Storage request.
|
* Signs the EMC Atmos Online Storage request.
|
||||||
|
@ -98,9 +97,9 @@ public class SignRequest implements HttpRequestFilter {
|
||||||
builder.put(HttpHeaders.DATE, date);
|
builder.put(HttpHeaders.DATE, date);
|
||||||
if (request.getHeaders().containsKey(AtmosHeaders.DATE))
|
if (request.getHeaders().containsKey(AtmosHeaders.DATE))
|
||||||
builder.put(AtmosHeaders.DATE, date);
|
builder.put(AtmosHeaders.DATE, date);
|
||||||
request = ModifyRequest.replaceHeaders(request, Multimaps.forMap(builder.build()));
|
request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build();
|
||||||
String signature = calculateSignature(createStringToSign(request));
|
String signature = calculateSignature(createStringToSign(request));
|
||||||
request = ModifyRequest.replaceHeader(request, AtmosHeaders.SIGNATURE, signature);
|
request = request.toBuilder().replaceHeader(AtmosHeaders.SIGNATURE, signature).build();
|
||||||
utils.logRequest(signatureLog, request, "<<");
|
utils.logRequest(signatureLog, request, "<<");
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ package org.jclouds.atmos.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.atmos.domain.AtmosObject;
|
import org.jclouds.atmos.domain.AtmosObject;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -50,27 +47,27 @@ public class BindMetadataToHeadersTest {
|
||||||
object.setPayload(payload);
|
object.setPayload(payload);
|
||||||
object.getUserMetadata().getListableMetadata().put("apple", "bear");
|
object.getUserMetadata().getListableMetadata().put("apple", "bear");
|
||||||
object.getUserMetadata().getListableMetadata().put("sushi", "king");
|
object.getUserMetadata().getListableMetadata().put("sushi", "king");
|
||||||
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, object);
|
request = binder.bindToRequest(request, object);
|
||||||
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
|
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustBeAtmosObject() {
|
public void testMustBeAtmosObject() {
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
binder.bindToRequest(request, new File("foo"));
|
binder.bindToRequest(request, new File("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNullIsBad() {
|
public void testNullIsBad() {
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNullPayloadIsBad() {
|
public void testNullPayloadIsBad() {
|
||||||
AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null);
|
AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null);
|
||||||
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
|
||||||
binder.bindToRequest(request, object);
|
binder.bindToRequest(request, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +77,7 @@ public class BindMetadataToHeadersTest {
|
||||||
Payload payload = Payloads.newStringPayload("");
|
Payload payload = Payloads.newStringPayload("");
|
||||||
payload.getContentMetadata().setContentLength(null);
|
payload.getContentMetadata().setContentLength(null);
|
||||||
object.setPayload(payload);
|
object.setPayload(payload);
|
||||||
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
|
||||||
binder.bindToRequest(request, object);
|
binder.bindToRequest(request, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,6 @@ package org.jclouds.atmos.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.atmos.domain.UserMetadata;
|
import org.jclouds.atmos.domain.UserMetadata;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -46,7 +43,7 @@ public class BindUserMetadataToHeadersTest {
|
||||||
UserMetadata metadata = new UserMetadata();
|
UserMetadata metadata = new UserMetadata();
|
||||||
metadata.getMetadata().put("apple", "bear");
|
metadata.getMetadata().put("apple", "bear");
|
||||||
metadata.getMetadata().put("sushi", "king");
|
metadata.getMetadata().put("sushi", "king");
|
||||||
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, metadata);
|
request = binder.bindToRequest(request, metadata);
|
||||||
assertEquals(request.getFirstHeaderOrNull("x-emc-meta"), "apple=bear,sushi=king");
|
assertEquals(request.getFirstHeaderOrNull("x-emc-meta"), "apple=bear,sushi=king");
|
||||||
}
|
}
|
||||||
|
@ -55,7 +52,7 @@ public class BindUserMetadataToHeadersTest {
|
||||||
UserMetadata metadata = new UserMetadata();
|
UserMetadata metadata = new UserMetadata();
|
||||||
metadata.getListableMetadata().put("apple", "bear");
|
metadata.getListableMetadata().put("apple", "bear");
|
||||||
metadata.getListableMetadata().put("sushi", "king");
|
metadata.getListableMetadata().put("sushi", "king");
|
||||||
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, metadata);
|
request = binder.bindToRequest(request, metadata);
|
||||||
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
|
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
|
||||||
}
|
}
|
||||||
|
@ -64,7 +61,7 @@ public class BindUserMetadataToHeadersTest {
|
||||||
UserMetadata tagsdata = new UserMetadata();
|
UserMetadata tagsdata = new UserMetadata();
|
||||||
tagsdata.getTags().add("apple");
|
tagsdata.getTags().add("apple");
|
||||||
tagsdata.getTags().add("sushi");
|
tagsdata.getTags().add("sushi");
|
||||||
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, tagsdata);
|
request = binder.bindToRequest(request, tagsdata);
|
||||||
assertEquals(request.getFirstHeaderOrNull("x-emc-tags"), "apple,sushi");
|
assertEquals(request.getFirstHeaderOrNull("x-emc-tags"), "apple,sushi");
|
||||||
}
|
}
|
||||||
|
@ -73,20 +70,20 @@ public class BindUserMetadataToHeadersTest {
|
||||||
UserMetadata tagsdata = new UserMetadata();
|
UserMetadata tagsdata = new UserMetadata();
|
||||||
tagsdata.getListableTags().add("apple");
|
tagsdata.getListableTags().add("apple");
|
||||||
tagsdata.getListableTags().add("sushi");
|
tagsdata.getListableTags().add("sushi");
|
||||||
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, tagsdata);
|
request = binder.bindToRequest(request, tagsdata);
|
||||||
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-tags"), "apple,sushi");
|
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-tags"), "apple,sushi");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustBeUserMetadata() {
|
public void testMustBeUserMetadata() {
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
binder.bindToRequest(request, new File("foo"));
|
binder.bindToRequest(request, new File("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
|
@Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
|
||||||
public void testNullIsBad() {
|
public void testNullIsBad() {
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@ package org.jclouds.atmos.blobstore;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
|
@ -35,7 +33,6 @@ import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.Blob.Factory;
|
import org.jclouds.blobstore.domain.Blob.Factory;
|
||||||
import org.jclouds.date.TimeStamp;
|
import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.io.ContentMetadata;
|
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.atmos.filters;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
@ -42,9 +41,9 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -122,7 +121,10 @@ public class SignRequestTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpRequest newRequest(Multimap<String, String> headers) {
|
public HttpRequest newRequest(Multimap<String, String> headers) {
|
||||||
HttpRequest request = new HttpRequest("POST", URI.create("http://localhost/rest/objects"), headers);
|
HttpRequest request = HttpRequest.builder()
|
||||||
|
.method("POST")
|
||||||
|
.endpoint("http://localhost/rest/objects")
|
||||||
|
.headers(headers).build();
|
||||||
request.setPayload("");
|
request.setPayload("");
|
||||||
request.getPayload().getContentMetadata().setContentLength(4286l);
|
request.getPayload().getContentMetadata().setContentLength(4286l);
|
||||||
request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.jclouds.io.Payloads;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
|
||||||
|
@ -51,8 +50,11 @@ public class ParseDirectoryListFromContentAndHeadersTest extends BaseHandlerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithToken() {
|
public void testWithToken() {
|
||||||
HttpResponse response = new HttpResponse(200, "ok", Payloads.newPayload(getClass().getResourceAsStream(
|
HttpResponse response = HttpResponse.builder()
|
||||||
"/list_basic.xml")), ImmutableMultimap.of(AtmosHeaders.TOKEN, "token"));
|
.statusCode(200)
|
||||||
|
.message("ok")
|
||||||
|
.payload(Payloads.newPayload(getClass().getResourceAsStream("/list_basic.xml")))
|
||||||
|
.addHeader(AtmosHeaders.TOKEN, "token").build();
|
||||||
|
|
||||||
BoundedSet<DirectoryEntry> result = createFn().apply(response);
|
BoundedSet<DirectoryEntry> result = createFn().apply(response);
|
||||||
assertEquals(result, new BoundedLinkedHashSet<DirectoryEntry>(values(), "token"));
|
assertEquals(result, new BoundedLinkedHashSet<DirectoryEntry>(values(), "token"));
|
||||||
|
@ -60,8 +62,11 @@ public class ParseDirectoryListFromContentAndHeadersTest extends BaseHandlerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithoutToken() {
|
public void testWithoutToken() {
|
||||||
HttpResponse response = new HttpResponse(200, "ok", Payloads.newPayload(getClass().getResourceAsStream(
|
HttpResponse response = HttpResponse.builder()
|
||||||
"/list_basic.xml")));
|
.statusCode(200)
|
||||||
|
.message("ok")
|
||||||
|
.payload(Payloads.newPayload(getClass().getResourceAsStream("/list_basic.xml"))).build();
|
||||||
|
|
||||||
BoundedSet<DirectoryEntry> result = createFn().apply(response);
|
BoundedSet<DirectoryEntry> result = createFn().apply(response);
|
||||||
|
|
||||||
assertEquals(ImmutableSet.copyOf(result), values());
|
assertEquals(ImmutableSet.copyOf(result), values());
|
||||||
|
|
|
@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
import org.jclouds.atmos.domain.AtmosObject;
|
import org.jclouds.atmos.domain.AtmosObject;
|
||||||
import org.jclouds.atmos.reference.AtmosHeaders;
|
import org.jclouds.atmos.reference.AtmosHeaders;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
@ -34,17 +33,21 @@ import com.google.inject.Guice;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit", testName = "ParseObjectFromHeadersAndHttpContentTest")
|
||||||
public class ParseObjectFromHeadersAndHttpContentTest {
|
public class ParseObjectFromHeadersAndHttpContentTest {
|
||||||
|
|
||||||
static final HttpResponse RESPONSE = new HttpResponse(200, "ok", Payloads.newStringPayload(""),
|
static final HttpResponse RESPONSE = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.message("ok")
|
||||||
|
.payload("")
|
||||||
|
.headers(
|
||||||
ImmutableMultimap.of(AtmosHeaders.TAGS, "tag1, tag2", AtmosHeaders.LISTABLE_TAGS,
|
ImmutableMultimap.of(AtmosHeaders.TAGS, "tag1, tag2", AtmosHeaders.LISTABLE_TAGS,
|
||||||
"listabletag1, listabletag2", AtmosHeaders.META,
|
"listabletag1, listabletag2", AtmosHeaders.META,
|
||||||
"meta1=foo1, content-md5=1f3870be274f6c49b3e31a0c6728957f, atime=2009-10-12T16:09:42Z, mtime=2009-10-19T04:37:00Z,"
|
"meta1=foo1, content-md5=1f3870be274f6c49b3e31a0c6728957f, atime=2009-10-12T16:09:42Z, mtime=2009-10-19T04:37:00Z,"
|
||||||
+ " ctime=2009-10-19T04:37:00Z, itime=2009-10-12T16:09:42Z, type=directory, uid=root, "
|
+ " ctime=2009-10-19T04:37:00Z, itime=2009-10-12T16:09:42Z, type=directory, uid=root, "
|
||||||
+ "gid=rootr, objectid=4980cdb2b010109b04a44f7bb83f5f04ad354c638ae5, "
|
+ "gid=rootr, objectid=4980cdb2b010109b04a44f7bb83f5f04ad354c638ae5, "
|
||||||
+ "objname=e913e09366364e9ba384b8fead643d43, size=4096, nlink=1, policyname=default",
|
+ "objname=e913e09366364e9ba384b8fead643d43, size=4096, nlink=1, policyname=default",
|
||||||
AtmosHeaders.LISTABLE_META, "listablemeta1=listablefoo1, listablemeta2=listablefoo2"));
|
AtmosHeaders.LISTABLE_META, "listablemeta1=listablefoo1, listablemeta2=listablefoo2")).build();
|
||||||
|
|
||||||
public static final AtmosObject EXPECTED;
|
public static final AtmosObject EXPECTED;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.util.SortedSet;
|
||||||
import org.jclouds.cloudfiles.domain.ContainerCDNMetadata;
|
import org.jclouds.cloudfiles.domain.ContainerCDNMetadata;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.ParseJson;
|
import org.jclouds.http.functions.ParseJson;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -61,6 +60,6 @@ public class ParseContainerCDNMetadataListFromJsonResponseTest {
|
||||||
ParseJson<SortedSet<ContainerCDNMetadata>> parser = i.getInstance(Key
|
ParseJson<SortedSet<ContainerCDNMetadata>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<ParseJson<SortedSet<ContainerCDNMetadata>>>() {
|
.get(new TypeLiteral<ParseJson<SortedSet<ContainerCDNMetadata>>>() {
|
||||||
}));
|
}));
|
||||||
assertEquals(parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))), expects);
|
assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build()), expects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,6 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends BaseAsync
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
GetAuth provideGetAuth() {
|
GetAuth provideGetAuth() {
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class CloudServersComputeServiceContextModule extends
|
||||||
|
|
||||||
// we aren't converting location from a provider-specific type
|
// we aren't converting location from a provider-specific type
|
||||||
bind(new TypeLiteral<Function<Location, Location>>() {
|
bind(new TypeLiteral<Function<Location, Location>>() {
|
||||||
}).to((Class) IdentityFunction.class);
|
}).to(Class.class.cast(IdentityFunction.class));
|
||||||
|
|
||||||
bind(new TypeLiteral<ImageExtension>() {
|
bind(new TypeLiteral<ImageExtension>() {
|
||||||
}).to(CloudServersImageExtension.class);
|
}).to(CloudServersImageExtension.class);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.List;
|
||||||
import org.jclouds.cloudservers.domain.Addresses;
|
import org.jclouds.cloudservers.domain.Addresses;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ public class ParseAddressesFromJsonResponseTest {
|
||||||
|
|
||||||
UnwrapOnlyJsonValue<Addresses> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Addresses>>() {
|
UnwrapOnlyJsonValue<Addresses> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Addresses>>() {
|
||||||
}));
|
}));
|
||||||
Addresses response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
Addresses response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
List<String> publicAddresses = ImmutableList.of("67.23.10.132", "67.23.10.131");
|
List<String> publicAddresses = ImmutableList.of("67.23.10.132", "67.23.10.131");
|
||||||
|
|
||||||
List<String> privateAddresses = ImmutableList.of("10.176.42.16");
|
List<String> privateAddresses = ImmutableList.of("10.176.42.16");
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.jclouds.cloudservers.domain.DailyBackup;
|
||||||
import org.jclouds.cloudservers.domain.WeeklyBackup;
|
import org.jclouds.cloudservers.domain.WeeklyBackup;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ public class ParseBackupScheduleFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
|
||||||
}));
|
}));
|
||||||
BackupSchedule response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
BackupSchedule response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
assertEquals(new BackupSchedule(WeeklyBackup.THURSDAY, DailyBackup.H_0400_0600, true), response);
|
assertEquals(new BackupSchedule(WeeklyBackup.THURSDAY, DailyBackup.H_0400_0600, true), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +60,9 @@ public class ParseBackupScheduleFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
|
||||||
}));
|
}));
|
||||||
BackupSchedule response = parser.apply(new HttpResponse(200, "ok", Payloads
|
BackupSchedule response = parser.apply(HttpResponse.builder()
|
||||||
.newStringPayload("{\"backupSchedule\":{\"enabled\" : false}}")));
|
.statusCode(200).message("ok")
|
||||||
|
.payload("{\"backupSchedule\":{\"enabled\" : false}}").build());
|
||||||
assertEquals(new BackupSchedule(), response);
|
assertEquals(new BackupSchedule(), response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.io.InputStream;
|
||||||
import org.jclouds.cloudservers.domain.Flavor;
|
import org.jclouds.cloudservers.domain.Flavor;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -57,7 +56,7 @@ public class ParseFlavorFromJsonResponseTest {
|
||||||
|
|
||||||
UnwrapOnlyJsonValue<Flavor> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Flavor>>() {
|
UnwrapOnlyJsonValue<Flavor> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Flavor>>() {
|
||||||
}));
|
}));
|
||||||
Flavor response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
Flavor response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.List;
|
||||||
import org.jclouds.cloudservers.domain.Flavor;
|
import org.jclouds.cloudservers.domain.Flavor;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ public class ParseFlavorListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
|
||||||
}));
|
}));
|
||||||
List<Flavor> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<Flavor> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +64,7 @@ public class ParseFlavorListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
|
||||||
}));
|
}));
|
||||||
List<Flavor> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<Flavor> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
assertEquals(response.get(0).getId(), 1);
|
assertEquals(response.get(0).getId(), 1);
|
||||||
assertEquals(response.get(0).getName(), "256 MB Server");
|
assertEquals(response.get(0).getName(), "256 MB Server");
|
||||||
assertEquals(response.get(0).getDisk(), new Integer(10));
|
assertEquals(response.get(0).getDisk(), new Integer(10));
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.jclouds.cloudservers.domain.ImageStatus;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
||||||
|
@ -85,7 +84,7 @@ public class ParseImageFromJsonResponseTest {
|
||||||
|
|
||||||
UnwrapOnlyJsonValue<Image> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Image>>() {
|
UnwrapOnlyJsonValue<Image> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Image>>() {
|
||||||
}));
|
}));
|
||||||
Image response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
Image response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.jclouds.cloudservers.domain.ImageStatus;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
||||||
|
@ -67,7 +66,7 @@ public class ParseImageListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<Image>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<Image>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Image>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Image>>>() {
|
||||||
}));
|
}));
|
||||||
List<Image> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<Image> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +77,7 @@ public class ParseImageListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<Image>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<Image>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Image>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Image>>>() {
|
||||||
}));
|
}));
|
||||||
List<Image> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<Image> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response.get(0).getId(), 2);
|
assertEquals(response.get(0).getId(), 2);
|
||||||
assertEquals(response.get(0).getName(), "CentOS 5.2");
|
assertEquals(response.get(0).getName(), "CentOS 5.2");
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ public class ParseInetAddressListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<String>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<String>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<String>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<String>>>() {
|
||||||
}));
|
}));
|
||||||
List<String> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<String> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response, ImmutableList.of("67.23.10.132", "67.23.10.131"));
|
assertEquals(response, ImmutableList.of("67.23.10.132", "67.23.10.131"));
|
||||||
}
|
}
|
||||||
|
@ -63,7 +62,7 @@ public class ParseInetAddressListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<String>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<String>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<String>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<String>>>() {
|
||||||
}));
|
}));
|
||||||
List<String> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<String> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response, ImmutableList.of("10.176.42.16"));
|
assertEquals(response, ImmutableList.of("10.176.42.16"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.jclouds.cloudservers.domain.Server;
|
||||||
import org.jclouds.cloudservers.domain.ServerStatus;
|
import org.jclouds.cloudservers.domain.ServerStatus;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -75,7 +74,7 @@ public class ParseServerFromJsonResponseTest {
|
||||||
|
|
||||||
UnwrapOnlyJsonValue<Server> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Server>>() {
|
UnwrapOnlyJsonValue<Server> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Server>>() {
|
||||||
}));
|
}));
|
||||||
Server response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
Server response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.jclouds.cloudservers.domain.Server;
|
||||||
import org.jclouds.cloudservers.domain.ServerStatus;
|
import org.jclouds.cloudservers.domain.ServerStatus;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ public class ParseServerListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<Server>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<Server>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Server>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Server>>>() {
|
||||||
}));
|
}));
|
||||||
List<Server> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<Server> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +69,7 @@ public class ParseServerListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<Server>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<Server>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Server>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Server>>>() {
|
||||||
}));
|
}));
|
||||||
List<Server> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<Server> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response.get(0).getId(), 1234);
|
assertEquals(response.get(0).getId(), 1234);
|
||||||
assertEquals(response.get(0).getName(), "sample-server");
|
assertEquals(response.get(0).getName(), "sample-server");
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.net.UnknownHostException;
|
||||||
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ public class ParseSharedIpGroupFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<SharedIpGroup> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<SharedIpGroup> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<SharedIpGroup>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<SharedIpGroup>>() {
|
||||||
}));
|
}));
|
||||||
SharedIpGroup response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
SharedIpGroup response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response.getId(), 1234);
|
assertEquals(response.getId(), 1234);
|
||||||
assertEquals(response.getName(), "Shared IP Group 1");
|
assertEquals(response.getName(), "Shared IP Group 1");
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.List;
|
||||||
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
import org.jclouds.cloudservers.domain.SharedIpGroup;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ public class ParseSharedIpGroupListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<SharedIpGroup>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<SharedIpGroup>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<SharedIpGroup>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<SharedIpGroup>>>() {
|
||||||
}));
|
}));
|
||||||
List<SharedIpGroup> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<SharedIpGroup> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
|
|
||||||
|
@ -68,7 +67,7 @@ public class ParseSharedIpGroupListFromJsonResponseTest {
|
||||||
UnwrapOnlyJsonValue<List<SharedIpGroup>> parser = i.getInstance(Key
|
UnwrapOnlyJsonValue<List<SharedIpGroup>> parser = i.getInstance(Key
|
||||||
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<SharedIpGroup>>>() {
|
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<SharedIpGroup>>>() {
|
||||||
}));
|
}));
|
||||||
List<SharedIpGroup> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
List<SharedIpGroup> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response.get(0).getId(), 1234);
|
assertEquals(response.get(0).getId(), 1234);
|
||||||
assertEquals(response.get(0).getName(), "Shared IP Group 1");
|
assertEquals(response.get(0).getName(), "Shared IP Group 1");
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudservers.handlers;
|
package org.jclouds.cloudservers.handlers;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.jclouds.cloudservers.CloudServersClient;
|
import org.jclouds.cloudservers.CloudServersClient;
|
||||||
import org.jclouds.cloudservers.internal.BaseCloudServersRestClientExpectTest;
|
import org.jclouds.cloudservers.internal.BaseCloudServersRestClientExpectTest;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -28,8 +26,6 @@ import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code RetryOnRenew} handler
|
* Tests behavior of {@code RetryOnRenew} handler
|
||||||
*
|
*
|
||||||
|
@ -42,16 +38,14 @@ public class RetryOnRenewExpectTest extends BaseCloudServersRestClientExpectTest
|
||||||
public void testShouldReauthenticateOn401() {
|
public void testShouldReauthenticateOn401() {
|
||||||
|
|
||||||
HttpRequest deleteImage = HttpRequest.builder().method("DELETE")
|
HttpRequest deleteImage = HttpRequest.builder().method("DELETE")
|
||||||
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
|
.endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")
|
||||||
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken).build()).build();
|
.addHeader("X-Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse pleaseRenew = HttpResponse
|
HttpResponse pleaseRenew = HttpResponse
|
||||||
.builder()
|
.builder()
|
||||||
.statusCode(401)
|
.statusCode(401)
|
||||||
.message("HTTP/1.1 401 Unauthorized")
|
.message("HTTP/1.1 401 Unauthorized")
|
||||||
.payload(
|
.payload("[{\"unauthorized\":{\"message\":\"Invalid authentication token. Please renew.\",\"code\":401}}]")
|
||||||
Payloads
|
|
||||||
.newStringPayload("[{\"unauthorized\":{\"message\":\"Invalid authentication token. Please renew.\",\"code\":401}}]"))
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// second auth uses same creds as initial one
|
// second auth uses same creds as initial one
|
||||||
|
@ -59,15 +53,13 @@ public class RetryOnRenewExpectTest extends BaseCloudServersRestClientExpectTest
|
||||||
|
|
||||||
String authToken2 = "12345678-9012-47c0-9770-2c5097da25fc";
|
String authToken2 = "12345678-9012-47c0-9770-2c5097da25fc";
|
||||||
|
|
||||||
HttpResponse responseWithUrls2 = HttpResponse
|
HttpResponse responseWithUrls2 = responseWithAuth.toBuilder()
|
||||||
.Builder.from(responseWithAuth)
|
.payload(responseWithAuth.getPayload().getRawContent().toString().replace(authToken, authToken2))
|
||||||
.payload(
|
.build();
|
||||||
Payloads.newPayload(responseWithAuth.getPayload().getRawContent().toString()
|
|
||||||
.replace(authToken, authToken2))).build();
|
|
||||||
|
|
||||||
HttpRequest deleteImage2 = HttpRequest.builder().method("DELETE")
|
HttpRequest deleteImage2 = HttpRequest.builder().method("DELETE")
|
||||||
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
|
.endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")
|
||||||
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken2).build()).build();
|
.addHeader("X-Auth-Token", authToken2).build();
|
||||||
|
|
||||||
HttpResponse imageDeleted = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content").build();
|
HttpResponse imageDeleted = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content").build();
|
||||||
|
|
||||||
|
@ -80,15 +72,14 @@ public class RetryOnRenewExpectTest extends BaseCloudServersRestClientExpectTest
|
||||||
@Test(expectedExceptions = AuthorizationException.class)
|
@Test(expectedExceptions = AuthorizationException.class)
|
||||||
public void testDoesNotReauthenticateOnFatal401() {
|
public void testDoesNotReauthenticateOnFatal401() {
|
||||||
HttpRequest deleteImage = HttpRequest.builder().method("DELETE")
|
HttpRequest deleteImage = HttpRequest.builder().method("DELETE")
|
||||||
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
|
.endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")
|
||||||
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken).build()).build();
|
.addHeader("X-Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse unauthResponse = HttpResponse
|
HttpResponse unauthResponse = HttpResponse
|
||||||
.builder()
|
.builder()
|
||||||
.statusCode(401)
|
.statusCode(401)
|
||||||
.message("HTTP/1.1 401 Unauthorized")
|
.message("HTTP/1.1 401 Unauthorized")
|
||||||
.payload(
|
.payload("[{\"unauthorized\":{\"message\":\"Fatal unauthorized.\",\"code\":401}}]")
|
||||||
Payloads.newStringPayload("[{\"unauthorized\":{\"message\":\"Fatal unauthorized.\",\"code\":401}}]"))
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
CloudServersClient client = orderedRequestsSendResponses(initialAuth, responseWithAuth, deleteImage,
|
CloudServersClient client = orderedRequestsSendResponses(initialAuth, responseWithAuth, deleteImage,
|
||||||
|
|
|
@ -23,10 +23,6 @@ import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withS
|
||||||
import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup;
|
import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -54,7 +50,7 @@ public class CreateServerOptionsTest {
|
||||||
|
|
||||||
private HttpRequest buildRequest(CreateServerOptions options) {
|
private HttpRequest buildRequest(CreateServerOptions options) {
|
||||||
injector.injectMembers(options);
|
injector.injectMembers(options);
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
options.bindToRequest(request, ImmutableMap.<String, Object>of("name", "foo", "imageId", "1", "flavorId", "2"));
|
options.bindToRequest(request, ImmutableMap.<String, Object>of("name", "foo", "imageId", "1", "flavorId", "2"));
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,6 @@ package org.jclouds.cloudservers.options;
|
||||||
import static org.jclouds.cloudservers.options.CreateSharedIpGroupOptions.Builder.withServer;
|
import static org.jclouds.cloudservers.options.CreateSharedIpGroupOptions.Builder.withServer;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -52,7 +48,7 @@ public class CreateSharedIpGroupOptionsTest {
|
||||||
|
|
||||||
private HttpRequest buildRequest(CreateSharedIpGroupOptions options) {
|
private HttpRequest buildRequest(CreateSharedIpGroupOptions options) {
|
||||||
injector.injectMembers(options);
|
injector.injectMembers(options);
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
options.bindToRequest(request, ImmutableMap.<String,Object>of("name", "foo"));
|
options.bindToRequest(request, ImmutableMap.<String,Object>of("name", "foo"));
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,8 @@ package org.jclouds.cloudservers.options;
|
||||||
import static org.jclouds.cloudservers.options.RebuildServerOptions.Builder.withImage;
|
import static org.jclouds.cloudservers.options.RebuildServerOptions.Builder.withImage;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -52,7 +49,7 @@ public class RebuildServerOptionsTest {
|
||||||
|
|
||||||
private HttpRequest buildRequest(RebuildServerOptions options) {
|
private HttpRequest buildRequest(RebuildServerOptions options) {
|
||||||
injector.injectMembers(options);
|
injector.injectMembers(options);
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
options.bindToRequest(request, new HashMap<String, Object>());
|
options.bindToRequest(request, new HashMap<String, Object>());
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
|
|
||||||
import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
|
import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
|
||||||
import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -59,8 +58,7 @@ public class BindCloneDriveOptionsToPlainTextString implements MapBinder {
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
|
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
|
||||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||||
"this binder is only valid for GeneratedHttpRequests!");
|
"this binder is only valid for GeneratedHttpRequests!");
|
||||||
@SuppressWarnings("unchecked")
|
GeneratedHttpRequest gRequest = GeneratedHttpRequest.class.cast(request);
|
||||||
GeneratedHttpRequest<CloudSigmaAsyncClient> gRequest = (GeneratedHttpRequest<CloudSigmaAsyncClient>) request;
|
|
||||||
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
||||||
|
|
||||||
CloneDriveOptions options = findOptionsInArgsOrNull(gRequest);
|
CloneDriveOptions options = findOptionsInArgsOrNull(gRequest);
|
||||||
|
@ -78,7 +76,7 @@ public class BindCloneDriveOptionsToPlainTextString implements MapBinder {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CloneDriveOptions findOptionsInArgsOrNull(GeneratedHttpRequest<?> gRequest) {
|
static CloneDriveOptions findOptionsInArgsOrNull(GeneratedHttpRequest gRequest) {
|
||||||
for (Object arg : gRequest.getArgs()) {
|
for (Object arg : gRequest.getArgs()) {
|
||||||
if (arg instanceof CloneDriveOptions) {
|
if (arg instanceof CloneDriveOptions) {
|
||||||
return (CloneDriveOptions) arg;
|
return (CloneDriveOptions) arg;
|
||||||
|
|
|
@ -77,11 +77,11 @@ public class CloudSigmaComputeServiceContextModule extends
|
||||||
bind(new TypeLiteral<Function<ServerInfo, NodeMetadata>>() {
|
bind(new TypeLiteral<Function<ServerInfo, NodeMetadata>>() {
|
||||||
}).to(ServerInfoToNodeMetadata.class);
|
}).to(ServerInfoToNodeMetadata.class);
|
||||||
bind(new TypeLiteral<Function<Hardware, Hardware>>() {
|
bind(new TypeLiteral<Function<Hardware, Hardware>>() {
|
||||||
}).to((Class) IdentityFunction.class);
|
}).to(Class.class.cast(IdentityFunction.class));
|
||||||
bind(new TypeLiteral<Function<DriveInfo, Image>>() {
|
bind(new TypeLiteral<Function<DriveInfo, Image>>() {
|
||||||
}).to(PreinstalledDiskToImage.class);
|
}).to(PreinstalledDiskToImage.class);
|
||||||
bind(new TypeLiteral<Function<Location, Location>>() {
|
bind(new TypeLiteral<Function<Location, Location>>() {
|
||||||
}).to((Class) IdentityFunction.class);
|
}).to(Class.class.cast(IdentityFunction.class));
|
||||||
bind(new TypeLiteral<Function<Device, Volume>>() {
|
bind(new TypeLiteral<Function<Device, Volume>>() {
|
||||||
}).to(DeviceToVolume.class);
|
}).to(DeviceToVolume.class);
|
||||||
bind(new TypeLiteral<Function<Server, String>>() {
|
bind(new TypeLiteral<Function<Server, String>>() {
|
||||||
|
|
|
@ -23,11 +23,11 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.cloudsigma.domain.DriveInfo;
|
import org.jclouds.cloudsigma.domain.DriveInfo;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.Image.Status;
|
||||||
import org.jclouds.compute.domain.ImageBuilder;
|
import org.jclouds.compute.domain.ImageBuilder;
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
|
|
||||||
import org.jclouds.compute.domain.Image.Status;
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem.Builder;
|
import org.jclouds.compute.domain.OperatingSystem.Builder;
|
||||||
|
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
|
@ -37,11 +37,11 @@ import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.HardwareBuilder;
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata.Status;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.Processor;
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
import org.jclouds.compute.domain.VolumeBuilder;
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
import org.jclouds.compute.domain.NodeMetadata.Status;
|
|
||||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class BindCloneDriveOptionsToPlainTextStringTest {
|
||||||
|
|
||||||
protected void assertInputAndArgsCreatesPayload(ImmutableMap<String, Object> inputMap, List<Object> args,
|
protected void assertInputAndArgsCreatesPayload(ImmutableMap<String, Object> inputMap, List<Object> args,
|
||||||
String expected) {
|
String expected) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(args).atLeastOnce();
|
expect(request.getArgs()).andReturn(args).atLeastOnce();
|
||||||
request.setPayload(expected);
|
request.setPayload(expected);
|
||||||
Payload payload = createMock(Payload.class);
|
Payload payload = createMock(Payload.class);
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
@ -61,7 +60,7 @@ public class BindDriveDataToPlainTextStringTest {
|
||||||
}).getInstance(BindDriveDataToPlainTextString.class);
|
}).getInstance(BindDriveDataToPlainTextString.class);
|
||||||
|
|
||||||
public void testSimple() {
|
public void testSimple() {
|
||||||
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
|
||||||
FN.bindToRequest(request, new DriveData.Builder().name("foo").size(100l).build());
|
FN.bindToRequest(request, new DriveData.Builder().name("foo").size(100l).build());
|
||||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
||||||
assertEquals(request.getPayload().getRawContent(), "name foo\nsize 100");
|
assertEquals(request.getPayload().getRawContent(), "name foo\nsize 100");
|
||||||
|
@ -77,7 +76,7 @@ public class BindDriveDataToPlainTextStringTest {
|
||||||
.use(ImmutableSet.of("tag1", "tag2"))//
|
.use(ImmutableSet.of("tag1", "tag2"))//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
|
||||||
FN.bindToRequest(request, input);
|
FN.bindToRequest(request, input);
|
||||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
||||||
assertEquals(request.getPayload().getRawContent(),
|
assertEquals(request.getPayload().getRawContent(),
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
@ -62,7 +61,7 @@ public class BindDriveToPlainTextStringTest {
|
||||||
}).getInstance(BindDriveToPlainTextString.class);
|
}).getInstance(BindDriveToPlainTextString.class);
|
||||||
|
|
||||||
public void testSimple() {
|
public void testSimple() {
|
||||||
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
|
||||||
FN.bindToRequest(request, new CreateDriveRequest.Builder().name("foo").size(100l).build());
|
FN.bindToRequest(request, new CreateDriveRequest.Builder().name("foo").size(100l).build());
|
||||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
||||||
assertEquals(request.getPayload().getRawContent(), "name foo\nsize 100");
|
assertEquals(request.getPayload().getRawContent(), "name foo\nsize 100");
|
||||||
|
@ -78,7 +77,7 @@ public class BindDriveToPlainTextStringTest {
|
||||||
.use(ImmutableSet.of("tag1", "tag2"))//
|
.use(ImmutableSet.of("tag1", "tag2"))//
|
||||||
.encryptionCipher("aes-xts-plain").avoid(ImmutableSet.of("avoid1")).build();
|
.encryptionCipher("aes-xts-plain").avoid(ImmutableSet.of("avoid1")).build();
|
||||||
|
|
||||||
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
|
||||||
FN.bindToRequest(request, input);
|
FN.bindToRequest(request, input);
|
||||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
||||||
assertEquals(request.getPayload().getRawContent(),
|
assertEquals(request.getPayload().getRawContent(),
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
@ -37,9 +36,9 @@ import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.base.Throwables;
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
@ -83,7 +82,7 @@ public class BindServerToPlainTextStringTest {
|
||||||
}).getInstance(BindServerToPlainTextString.class);
|
}).getInstance(BindServerToPlainTextString.class);
|
||||||
|
|
||||||
public void testSimple() throws IOException {
|
public void testSimple() throws IOException {
|
||||||
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
|
||||||
FN.bindToRequest(request, SERVER);
|
FN.bindToRequest(request, SERVER);
|
||||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
|
||||||
assertEquals(request.getPayload().getRawContent(), CREATED_SERVER);
|
assertEquals(request.getPayload().getRawContent(), CREATED_SERVER);
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.functions;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -37,13 +36,13 @@ public class KeyValuesDelimitedByBlankLinesToDriveInfoTest {
|
||||||
KeyValuesDelimitedByBlankLinesToDriveInfo.class);
|
KeyValuesDelimitedByBlankLinesToDriveInfo.class);
|
||||||
|
|
||||||
public void testNone() {
|
public void testNone() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null);
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null);
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", null)), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOne() {
|
public void testOne() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToDriveInfoTest.class
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToDriveInfoTest.class
|
||||||
.getResourceAsStream("/drive.txt")))), MapToDriveInfoTest.ONE);
|
.getResourceAsStream("/drive.txt")).build()), MapToDriveInfoTest.ONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.functions;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -37,13 +36,13 @@ public class KeyValuesDelimitedByBlankLinesToProfileInfoTest {
|
||||||
KeyValuesDelimitedByBlankLinesToProfileInfo.class);
|
KeyValuesDelimitedByBlankLinesToProfileInfo.class);
|
||||||
|
|
||||||
public void testNone() {
|
public void testNone() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null);
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null);
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", null)), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOne() {
|
public void testOne() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToProfileInfoTest.class
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToProfileInfoTest.class
|
||||||
.getResourceAsStream("/profile.txt")))), MapToProfileInfoTest.ONE);
|
.getResourceAsStream("/profile.txt")).build()), MapToProfileInfoTest.ONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.jclouds.cloudsigma.domain.NIC;
|
||||||
import org.jclouds.cloudsigma.domain.ServerMetrics;
|
import org.jclouds.cloudsigma.domain.ServerMetrics;
|
||||||
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
|
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -63,18 +62,18 @@ public class KeyValuesDelimitedByBlankLinesToServerInfoTest {
|
||||||
}).getInstance(KeyValuesDelimitedByBlankLinesToServerInfo.class);
|
}).getInstance(KeyValuesDelimitedByBlankLinesToServerInfo.class);
|
||||||
|
|
||||||
public void testNone() {
|
public void testNone() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null);
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null);
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", null)), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOne() {
|
public void testOne() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToServerInfoTest.class
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class
|
||||||
.getResourceAsStream("/servers.txt")))), MapToServerInfoTest.ONE);
|
.getResourceAsStream("/servers.txt")).build()), MapToServerInfoTest.ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNew() {
|
public void testNew() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToServerInfoTest.class
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class
|
||||||
.getResourceAsStream("/new_server.txt")))), MapToServerInfoTest.NEW);
|
.getResourceAsStream("/new_server.txt")).build()), MapToServerInfoTest.NEW);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.functions;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -37,13 +36,13 @@ public class KeyValuesDelimitedByBlankLinesToVLANInfoTest {
|
||||||
KeyValuesDelimitedByBlankLinesToVLANInfo.class);
|
KeyValuesDelimitedByBlankLinesToVLANInfo.class);
|
||||||
|
|
||||||
public void testNone() {
|
public void testNone() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null);
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null);
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", null)), null);
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOne() {
|
public void testOne() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToVLANInfoTest.class
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToVLANInfoTest.class
|
||||||
.getResourceAsStream("/vlan.txt")))), MapToVLANInfoTest.ONE);
|
.getResourceAsStream("/vlan.txt")).build()), MapToVLANInfoTest.ONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.cloudsigma.domain.DriveInfo;
|
import org.jclouds.cloudsigma.domain.DriveInfo;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -39,13 +38,13 @@ public class ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSetTest {
|
||||||
ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class);
|
ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class);
|
||||||
|
|
||||||
public void testNone() {
|
public void testNone() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), ImmutableSet.<DriveInfo> of());
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet.<DriveInfo> of());
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), ImmutableSet.<DriveInfo> of());
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), ImmutableSet.<DriveInfo> of());
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", null)), ImmutableSet.<DriveInfo> of());
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet.<DriveInfo> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOne() {
|
public void testOne() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToDriveInfoTest.class
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToDriveInfoTest.class
|
||||||
.getResourceAsStream("/drive.txt")))), ImmutableSet.<DriveInfo> of(MapToDriveInfoTest.ONE));
|
.getResourceAsStream("/drive.txt")).build()), ImmutableSet.<DriveInfo> of(MapToDriveInfoTest.ONE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.jclouds.cloudsigma.domain.ServerInfo;
|
||||||
import org.jclouds.cloudsigma.domain.ServerMetrics;
|
import org.jclouds.cloudsigma.domain.ServerMetrics;
|
||||||
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
|
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -66,15 +65,15 @@ public class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest {
|
||||||
}).getInstance(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class);
|
}).getInstance(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class);
|
||||||
|
|
||||||
public void testNone() {
|
public void testNone() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), ImmutableSet.<ServerInfo> of());
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet.<ServerInfo> of());
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))),
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()),
|
||||||
ImmutableSet.<ServerInfo> of());
|
ImmutableSet.<ServerInfo> of());
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", null)), ImmutableSet.<ServerInfo> of());
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet.<ServerInfo> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOne() {
|
public void testOne() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToServerInfoTest.class
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class
|
||||||
.getResourceAsStream("/servers.txt")))), ImmutableSet.<ServerInfo> of(MapToServerInfoTest.ONE,
|
.getResourceAsStream("/servers.txt")).build()), ImmutableSet.<ServerInfo> of(MapToServerInfoTest.ONE,
|
||||||
MapToServerInfoTest.TWO));
|
MapToServerInfoTest.TWO));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.cloudsigma.domain.VLANInfo;
|
import org.jclouds.cloudsigma.domain.VLANInfo;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -39,13 +38,13 @@ public class ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest {
|
||||||
ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class);
|
ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class);
|
||||||
|
|
||||||
public void testNone() {
|
public void testNone() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), ImmutableSet.<VLANInfo> of());
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet.<VLANInfo> of());
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), ImmutableSet.<VLANInfo> of());
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), ImmutableSet.<VLANInfo> of());
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", null)), ImmutableSet.<VLANInfo> of());
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet.<VLANInfo> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOne() {
|
public void testOne() {
|
||||||
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToVLANInfoTest.class
|
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToVLANInfoTest.class
|
||||||
.getResourceAsStream("/vlan.txt")))), ImmutableSet.<VLANInfo> of(MapToVLANInfoTest.ONE));
|
.getResourceAsStream("/vlan.txt")).build()), ImmutableSet.<VLANInfo> of(MapToVLANInfoTest.ONE));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,7 +24,6 @@ import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -45,7 +44,7 @@ public class SplitNewlinesTest {
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
InputStream is = SplitNewlinesTest.class.getResourceAsStream("/uuids.txt");
|
InputStream is = SplitNewlinesTest.class.getResourceAsStream("/uuids.txt");
|
||||||
Set<String> list = createParser().apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
Set<String> list = createParser().apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
assertEquals(list, ImmutableSortedSet.of("7e8ab721-81c9-4cb9-a651-4cafbfe1501c",
|
assertEquals(list, ImmutableSortedSet.of("7e8ab721-81c9-4cb9-a651-4cafbfe1501c",
|
||||||
"ea6a8fdb-dab3-4d06-86c2-41a5835e6ed9", "74744450-d338-4087-b3b8-59b505110a57"));
|
"ea6a8fdb-dab3-4d06-86c2-41a5835e6ed9", "74744450-d338-4087-b3b8-59b505110a57"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,8 @@ import org.easymock.IArgumentMatcher;
|
||||||
import org.jclouds.http.HttpCommand;
|
import org.jclouds.http.HttpCommand;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
import org.jclouds.util.Strings2;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -103,9 +101,8 @@ public class CloudSigmaErrorHandlerTest {
|
||||||
CloudSigmaErrorHandler function = Guice.createInjector().getInstance(CloudSigmaErrorHandler.class);
|
CloudSigmaErrorHandler function = Guice.createInjector().getInstance(CloudSigmaErrorHandler.class);
|
||||||
|
|
||||||
HttpCommand command = createMock(HttpCommand.class);
|
HttpCommand command = createMock(HttpCommand.class);
|
||||||
HttpRequest request = new HttpRequest(method, uri);
|
HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
|
||||||
HttpResponse response = new HttpResponse(statusCode, message, Payloads.newInputStreamPayload(Strings2
|
HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
|
||||||
.toInputStream(content)));
|
|
||||||
response.getPayload().getContentMetadata().setContentType(contentType);
|
response.getPayload().getContentMetadata().setContentType(contentType);
|
||||||
|
|
||||||
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
||||||
|
|
|
@ -29,7 +29,7 @@ import javax.inject.Singleton;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
import org.jclouds.http.utils.Queries;
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
@ -58,12 +58,12 @@ public class BindAccountSecurityGroupPairsToIndexedQueryParams implements Binder
|
||||||
UriBuilder builder = uriBuilderProvider.get();
|
UriBuilder builder = uriBuilderProvider.get();
|
||||||
builder.uri(request.getEndpoint());
|
builder.uri(request.getEndpoint());
|
||||||
Builder<String, String> map = ImmutableMultimap.<String, String> builder().putAll(
|
Builder<String, String> map = ImmutableMultimap.<String, String> builder().putAll(
|
||||||
ModifyRequest.parseQueryToMap(request.getEndpoint().getQuery()));
|
Queries.parseQueryToMap(request.getEndpoint().getQuery()));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Entry<String, String> entry : pairs.entries())
|
for (Entry<String, String> entry : pairs.entries())
|
||||||
map.put(String.format("usersecuritygrouplist[%d].account", i), entry.getKey()).put(
|
map.put(String.format("usersecuritygrouplist[%d].account", i), entry.getKey()).put(
|
||||||
String.format("usersecuritygrouplist[%d].group", i++), entry.getValue());
|
String.format("usersecuritygrouplist[%d].group", i++), entry.getValue());
|
||||||
builder.replaceQuery(ModifyRequest.makeQueryLine(map.build(), null));
|
builder.replaceQuery(Queries.makeQueryLine(map.build(), null));
|
||||||
return (R) request.toBuilder().endpoint(builder.build()).build();
|
return (R) request.toBuilder().endpoint(builder.build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,9 @@ package org.jclouds.cloudstack.binders;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
@ -39,12 +35,6 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindCIDRsToCommaDelimitedQueryParam implements Binder {
|
public class BindCIDRsToCommaDelimitedQueryParam implements Binder {
|
||||||
private final Provider<UriBuilder> uriBuilderProvider;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public BindCIDRsToCommaDelimitedQueryParam(Provider<UriBuilder> uriBuilderProvider) {
|
|
||||||
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,6 +42,6 @@ public class BindCIDRsToCommaDelimitedQueryParam implements Binder {
|
||||||
checkArgument(input instanceof Iterable<?>, "this binder is only valid for Iterables!");
|
checkArgument(input instanceof Iterable<?>, "this binder is only valid for Iterables!");
|
||||||
Iterable<String> cidrs = (Iterable<String>) checkNotNull(input, "cidr list");
|
Iterable<String> cidrs = (Iterable<String>) checkNotNull(input, "cidr list");
|
||||||
checkArgument(Iterables.size(cidrs) > 0, "you must specify at least one cidr range");
|
checkArgument(Iterables.size(cidrs) > 0, "you must specify at least one cidr range");
|
||||||
return ModifyRequest.addQueryParam(request, "cidrlist", Joiner.on(',').join(cidrs), uriBuilderProvider.get());
|
return (R) request.toBuilder().replaceQueryParam("cidrlist", Joiner.on(',').join(cidrs)).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,9 @@ package org.jclouds.cloudstack.binders;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
@ -38,12 +34,6 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindIdListToCommaDelimitedQueryParam implements Binder {
|
public class BindIdListToCommaDelimitedQueryParam implements Binder {
|
||||||
private final Provider<UriBuilder> uriBuilderProvider;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public BindIdListToCommaDelimitedQueryParam(Provider<UriBuilder> uriBuilderProvider) {
|
|
||||||
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,6 +41,6 @@ public class BindIdListToCommaDelimitedQueryParam implements Binder {
|
||||||
checkArgument(input instanceof Iterable<?>, "this binder is only valid for Iterables!");
|
checkArgument(input instanceof Iterable<?>, "this binder is only valid for Iterables!");
|
||||||
Iterable<Long> numbers = (Iterable<Long>) checkNotNull(input, "list of Longs");
|
Iterable<Long> numbers = (Iterable<Long>) checkNotNull(input, "list of Longs");
|
||||||
checkArgument(Iterables.size(numbers) > 0, "you must specify at least one element");
|
checkArgument(Iterables.size(numbers) > 0, "you must specify at least one element");
|
||||||
return ModifyRequest.addQueryParam(request, "ids", Joiner.on(',').join(numbers), uriBuilderProvider.get());
|
return (R) request.toBuilder().replaceQueryParam("ids", Joiner.on(',').join(numbers)).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,37 +19,31 @@
|
||||||
package org.jclouds.cloudstack.binders;
|
package org.jclouds.cloudstack.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.SnapshotPolicySchedule;
|
import org.jclouds.cloudstack.domain.SnapshotPolicySchedule;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindSnapshotPolicyScheduleToQueryParam implements Binder {
|
public class BindSnapshotPolicyScheduleToQueryParam implements Binder {
|
||||||
private final Provider<UriBuilder> uriBuilderProvider;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public BindSnapshotPolicyScheduleToQueryParam(Provider<UriBuilder> uriBuilderProvider) {
|
|
||||||
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
checkArgument(input instanceof SnapshotPolicySchedule, "this binder is only valid for SnapshotPolicySchedule");
|
checkArgument(input instanceof SnapshotPolicySchedule, "this binder is only valid for SnapshotPolicySchedule");
|
||||||
SnapshotPolicySchedule schedule = SnapshotPolicySchedule.class.cast(input);
|
SnapshotPolicySchedule schedule = SnapshotPolicySchedule.class.cast(input);
|
||||||
R modifiedResult = ModifyRequest.addQueryParam(request, "intervaltype", schedule.getInterval(), uriBuilderProvider.get());
|
Builder<String, String> builder = ImmutableMultimap.<String, String> builder();
|
||||||
modifiedResult = ModifyRequest.addQueryParam(modifiedResult, "schedule", schedule.getTime(), uriBuilderProvider.get());
|
builder.put("intervaltype", schedule.getInterval().toString());
|
||||||
return modifiedResult;
|
builder.put("schedule", schedule.getTime().toString());
|
||||||
|
return (R) request.toBuilder().replaceQueryParams(builder.build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,47 +19,40 @@
|
||||||
package org.jclouds.cloudstack.binders;
|
package org.jclouds.cloudstack.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.ws.rs.core.UriBuilder;
|
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.TemplateMetadata;
|
import org.jclouds.cloudstack.domain.TemplateMetadata;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Richard Downer
|
* @author Richard Downer
|
||||||
*/
|
*/
|
||||||
public class BindTemplateMetadataToQueryParams implements Binder {
|
public class BindTemplateMetadataToQueryParams implements Binder {
|
||||||
private final Provider<UriBuilder> uriBuilderProvider;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public BindTemplateMetadataToQueryParams(Provider<UriBuilder> uriBuilderProvider) {
|
|
||||||
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
checkArgument(input instanceof TemplateMetadata, "this binder is only valid for TemplateMetadata");
|
checkArgument(input instanceof TemplateMetadata, "this binder is only valid for TemplateMetadata");
|
||||||
TemplateMetadata metadata = (TemplateMetadata) input;
|
TemplateMetadata metadata = (TemplateMetadata) input;
|
||||||
request = ModifyRequest.addQueryParam(request, "name", metadata.getName(), uriBuilderProvider.get());
|
Builder<String, String> builder = ImmutableMultimap.<String, String>builder();
|
||||||
request = ModifyRequest.addQueryParam(request, "ostypeid", metadata.getOsTypeId(), uriBuilderProvider.get());
|
builder.put("name", metadata.getName());
|
||||||
request = ModifyRequest.addQueryParam(request, "displaytext", metadata.getDisplayText(), uriBuilderProvider.get());
|
builder.put("ostypeid", metadata.getOsTypeId());
|
||||||
|
builder.put("displaytext", metadata.getDisplayText());
|
||||||
if (metadata.getSnapshotId() != null) {
|
if (metadata.getSnapshotId() != null) {
|
||||||
request = ModifyRequest.addQueryParam(request, "snapshotid", metadata.getSnapshotId(), uriBuilderProvider.get());
|
builder.put("snapshotid", metadata.getSnapshotId());
|
||||||
}
|
}
|
||||||
if (metadata.getVolumeId() != null) {
|
if (metadata.getVolumeId() != null) {
|
||||||
request = ModifyRequest.addQueryParam(request, "volumeid", metadata.getVolumeId(), uriBuilderProvider.get());
|
builder.put("volumeid", metadata.getVolumeId());
|
||||||
}
|
}
|
||||||
if (metadata.getVirtualMachineId() != null) {
|
if (metadata.getVirtualMachineId() != null) {
|
||||||
request = ModifyRequest.addQueryParam(request, "virtualmachineid", metadata.getVirtualMachineId(), uriBuilderProvider.get());
|
builder.put("virtualmachineid", metadata.getVirtualMachineId());
|
||||||
}
|
}
|
||||||
if (metadata.isPasswordEnabled() != null) {
|
if (metadata.isPasswordEnabled() != null) {
|
||||||
request = ModifyRequest.addQueryParam(request, "passwordenabled", metadata.isPasswordEnabled(), uriBuilderProvider.get());
|
builder.put("passwordenabled", metadata.isPasswordEnabled().toString());
|
||||||
}
|
}
|
||||||
return request;
|
return (R) request.toBuilder().replaceQueryParams(builder.build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,14 @@
|
||||||
package org.jclouds.cloudstack.binders;
|
package org.jclouds.cloudstack.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.ws.rs.core.UriBuilder;
|
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.ResourceLimit;
|
import org.jclouds.cloudstack.domain.ResourceLimit;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*
|
*
|
||||||
|
@ -38,22 +35,17 @@ import org.jclouds.rest.Binder;
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
public class ResourceLimitToQueryParams implements Binder {
|
public class ResourceLimitToQueryParams implements Binder {
|
||||||
private final Provider<UriBuilder> uriBuilderProvider;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public ResourceLimitToQueryParams(Provider<UriBuilder> uriBuilderProvider) {
|
|
||||||
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
checkArgument(input instanceof ResourceLimit, "this binder is only valid for ResourceLimit");
|
checkArgument(input instanceof ResourceLimit, "this binder is only valid for ResourceLimit");
|
||||||
ResourceLimit limit = (ResourceLimit) input;
|
ResourceLimit limit = (ResourceLimit) input;
|
||||||
request = ModifyRequest.addQueryParam(request, "resourcetype", limit.getResourceType().getCode(),
|
Builder<String, String> builder = ImmutableMultimap.<String, String> builder();
|
||||||
uriBuilderProvider.get());
|
builder.put("resourcetype", limit.getResourceType().getCode() + "");
|
||||||
request = ModifyRequest.addQueryParam(request, "account", limit.getAccount(), uriBuilderProvider.get());
|
builder.put("account", limit.getAccount());
|
||||||
request = ModifyRequest.addQueryParam(request, "domainid", limit.getDomainId(), uriBuilderProvider.get());
|
builder.put("domainid", limit.getDomainId());
|
||||||
request = ModifyRequest.addQueryParam(request, "max", limit.getMax(), uriBuilderProvider.get());
|
builder.put("max", limit.getMax() + "");
|
||||||
return request;
|
return (R) request.toBuilder().replaceQueryParams(builder.build()).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,10 @@ package org.jclouds.cloudstack.compute.strategy;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Predicates.and;
|
import static com.google.common.base.Predicates.and;
|
||||||
import static com.google.common.base.Predicates.not;
|
|
||||||
import static com.google.common.collect.Iterables.filter;
|
import static com.google.common.collect.Iterables.filter;
|
||||||
import static org.jclouds.cloudstack.predicates.NetworkPredicates.defaultNetworkInZone;
|
import static org.jclouds.cloudstack.predicates.NetworkPredicates.defaultNetworkInZone;
|
||||||
import static org.jclouds.cloudstack.predicates.NetworkPredicates.supportsStaticNAT;
|
|
||||||
import static org.jclouds.cloudstack.predicates.NetworkPredicates.isIsolatedNetwork;
|
import static org.jclouds.cloudstack.predicates.NetworkPredicates.isIsolatedNetwork;
|
||||||
|
import static org.jclouds.cloudstack.predicates.NetworkPredicates.supportsStaticNAT;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
package org.jclouds.cloudstack.filters;
|
package org.jclouds.cloudstack.filters;
|
||||||
|
|
||||||
import static org.jclouds.http.utils.ModifyRequest.addQueryParam;
|
|
||||||
import static org.jclouds.http.utils.ModifyRequest.replaceHeader;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.LoginResponse;
|
import org.jclouds.cloudstack.domain.LoginResponse;
|
||||||
import org.jclouds.http.HttpException;
|
import org.jclouds.http.HttpException;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpRequest.Builder;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.net.HttpHeaders;
|
import com.google.common.net.HttpHeaders;
|
||||||
|
@ -25,22 +21,19 @@ import com.google.common.net.HttpHeaders;
|
||||||
public class AddSessionKeyAndJSessionIdToRequest implements AuthenticationFilter {
|
public class AddSessionKeyAndJSessionIdToRequest implements AuthenticationFilter {
|
||||||
|
|
||||||
private final Supplier<LoginResponse> loginResponseSupplier;
|
private final Supplier<LoginResponse> loginResponseSupplier;
|
||||||
private final Provider<UriBuilder> uriBuilderProvider;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AddSessionKeyAndJSessionIdToRequest(Supplier<LoginResponse> loginResponseSupplier,
|
public AddSessionKeyAndJSessionIdToRequest(Supplier<LoginResponse> loginResponseSupplier) {
|
||||||
Provider<UriBuilder> uriBuilderProvider) {
|
|
||||||
this.loginResponseSupplier = loginResponseSupplier;
|
this.loginResponseSupplier = loginResponseSupplier;
|
||||||
this.uriBuilderProvider = uriBuilderProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpRequest filter(HttpRequest request) throws HttpException {
|
public HttpRequest filter(HttpRequest request) throws HttpException {
|
||||||
LoginResponse loginResponse = loginResponseSupplier.get();
|
LoginResponse loginResponse = loginResponseSupplier.get();
|
||||||
|
Builder<?> builder = request.toBuilder();
|
||||||
request = replaceHeader(request, HttpHeaders.COOKIE, "JSESSIONID=" + loginResponse.getJSessionId());
|
builder.replaceHeader(HttpHeaders.COOKIE, "JSESSIONID=" + loginResponse.getJSessionId());
|
||||||
request = addQueryParam(request, "sessionkey", loginResponse.getSessionKey(), uriBuilderProvider.get());
|
builder.replaceQueryParam("sessionkey", loginResponse.getSessionKey());
|
||||||
return request;
|
return builder.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.jclouds.http.HttpException;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpUtils;
|
import org.jclouds.http.HttpUtils;
|
||||||
import org.jclouds.http.internal.SignatureWire;
|
import org.jclouds.http.internal.SignatureWire;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
import org.jclouds.http.utils.Queries;
|
||||||
import org.jclouds.io.InputSuppliers;
|
import org.jclouds.io.InputSuppliers;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.RequestSigner;
|
import org.jclouds.rest.RequestSigner;
|
||||||
|
@ -85,7 +85,7 @@ public class QuerySigner implements AuthenticationFilter, RequestSigner {
|
||||||
|
|
||||||
public HttpRequest filter(HttpRequest request) throws HttpException {
|
public HttpRequest filter(HttpRequest request) throws HttpException {
|
||||||
checkNotNull(request, "request must be present");
|
checkNotNull(request, "request must be present");
|
||||||
Multimap<String, String> decodedParams = ModifyRequest.parseQueryToMap(request.getEndpoint().getRawQuery());
|
Multimap<String, String> decodedParams = Queries.parseQueryToMap(request.getEndpoint().getRawQuery());
|
||||||
addSigningParams(decodedParams);
|
addSigningParams(decodedParams);
|
||||||
String stringToSign = createStringToSign(request, decodedParams);
|
String stringToSign = createStringToSign(request, decodedParams);
|
||||||
String signature = sign(stringToSign);
|
String signature = sign(stringToSign);
|
||||||
|
@ -94,7 +94,7 @@ public class QuerySigner implements AuthenticationFilter, RequestSigner {
|
||||||
.toBuilder()
|
.toBuilder()
|
||||||
.endpoint(
|
.endpoint(
|
||||||
builder.get().uri(request.getEndpoint())
|
builder.get().uri(request.getEndpoint())
|
||||||
.replaceQuery(ModifyRequest.makeQueryLine(decodedParams, null)).build()).build();
|
.replaceQuery(Queries.makeQueryLine(decodedParams, null)).build()).build();
|
||||||
utils.logRequest(signatureLog, request, "<<");
|
utils.logRequest(signatureLog, request, "<<");
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public class QuerySigner implements AuthenticationFilter, RequestSigner {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createStringToSign(HttpRequest input) {
|
public String createStringToSign(HttpRequest input) {
|
||||||
Multimap<String, String> decodedParams = ModifyRequest.parseQueryToMap(input.getEndpoint().getQuery());
|
Multimap<String, String> decodedParams = Queries.parseQueryToMap(input.getEndpoint().getQuery());
|
||||||
addSigningParams(decodedParams);
|
addSigningParams(decodedParams);
|
||||||
return createStringToSign(input, decodedParams);
|
return createStringToSign(input, decodedParams);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import javax.ws.rs.core.UriBuilder;
|
||||||
import org.jclouds.http.HttpException;
|
import org.jclouds.http.HttpException;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpRequestFilter;
|
import org.jclouds.http.HttpRequestFilter;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
import org.jclouds.http.utils.Queries;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
@ -48,7 +48,7 @@ public class ReEncodeQueryWithDefaultURLEncoder implements HttpRequestFilter {
|
||||||
public HttpRequest filter(HttpRequest request) throws HttpException {
|
public HttpRequest filter(HttpRequest request) throws HttpException {
|
||||||
UriBuilder builder = builders.get();
|
UriBuilder builder = builders.get();
|
||||||
builder.uri(request.getEndpoint());
|
builder.uri(request.getEndpoint());
|
||||||
Multimap<String, String> map = ModifyRequest.parseQueryToMap(request.getEndpoint().getRawQuery());
|
Multimap<String, String> map = Queries.parseQueryToMap(request.getEndpoint().getRawQuery());
|
||||||
builder.replaceQuery("");
|
builder.replaceQuery("");
|
||||||
for (String key : map.keySet())
|
for (String key : map.keySet())
|
||||||
builder.queryParam(key, getOnlyElement(map.get(key)));
|
builder.queryParam(key, getOnlyElement(map.get(key)));
|
||||||
|
|
|
@ -126,7 +126,6 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
|
||||||
install(new FactoryModuleBuilder().build(StaticNATVirtualMachineInNetwork.Factory.class));
|
install(new FactoryModuleBuilder().build(StaticNATVirtualMachineInNetwork.Factory.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected Predicate<String> jobComplete(JobComplete jobComplete) {
|
protected Predicate<String> jobComplete(JobComplete jobComplete) {
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
package org.jclouds.cloudstack.domain;
|
package org.jclouds.cloudstack.domain;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
import static org.testng.Assert.fail;
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.CloudStackContext;
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
|
@ -32,7 +31,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,12 +47,8 @@ public class AccountClientExpectTest extends BaseCloudStackRestClientExpectTest<
|
||||||
AccountClient client = requestSendsResponse(
|
AccountClient client = requestSendsResponse(
|
||||||
HttpRequest.builder()
|
HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(
|
.endpoint("http://localhost:8080/client/api?response=json&command=listAccounts&listAll=true&apiKey=identity&signature=yMZYMZxzFlaUsbfxtuppMwNhpXI%3D")
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=listAccounts&listAll=true&apiKey=identity&signature=yMZYMZxzFlaUsbfxtuppMwNhpXI%3D"))
|
.addHeader("Accept", "application/json")
|
||||||
.headers(
|
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,10 +48,7 @@ public class DomainDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listDomains&listAll=true&apiKey=identity&signature=sVFaGTu0DNSTVtWy3wtRt7KTx0w%3D"))
|
"command=listDomains&listAll=true&apiKey=identity&signature=sVFaGTu0DNSTVtWy3wtRt7KTx0w%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -74,10 +70,7 @@ public class DomainDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listDomains&listAll=true&apiKey=identity&signature=sVFaGTu0DNSTVtWy3wtRt7KTx0w%3D"))
|
"command=listDomains&listAll=true&apiKey=identity&signature=sVFaGTu0DNSTVtWy3wtRt7KTx0w%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -93,10 +86,7 @@ public class DomainDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listDomains&listAll=true&id=1&apiKey=identity&signature=M16YxHWKST%2FcIRUHvWhfWovJugU%3D"))
|
"command=listDomains&listAll=true&id=1&apiKey=identity&signature=M16YxHWKST%2FcIRUHvWhfWovJugU%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -114,10 +104,7 @@ public class DomainDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listDomains&listAll=true&id=1&apiKey=identity&signature=M16YxHWKST%2FcIRUHvWhfWovJugU%3D"))
|
"command=listDomains&listAll=true&id=1&apiKey=identity&signature=M16YxHWKST%2FcIRUHvWhfWovJugU%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -133,10 +120,7 @@ public class DomainDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listDomainChildren&listAll=true&id=1&isrecursive=true&apiKey=identity&signature=Jn6kFkloRvfaaivlJiHd0F5J3Jk%3D"))
|
"command=listDomainChildren&listAll=true&id=1&isrecursive=true&apiKey=identity&signature=Jn6kFkloRvfaaivlJiHd0F5J3Jk%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -160,10 +144,7 @@ public class DomainDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listDomainChildren&listAll=true&id=1&isrecursive=true&apiKey=identity&" +
|
"command=listDomainChildren&listAll=true&id=1&isrecursive=true&apiKey=identity&" +
|
||||||
"signature=Jn6kFkloRvfaaivlJiHd0F5J3Jk%3D"))
|
"signature=Jn6kFkloRvfaaivlJiHd0F5J3Jk%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
|
|
@ -18,25 +18,24 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.features;
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import static com.google.common.collect.Iterables.find;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import static com.google.common.collect.Sets.newHashSet;
|
import static com.google.common.collect.Sets.newHashSet;
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
import static org.jclouds.cloudstack.options.ListDomainChildrenOptions.Builder.parentDomainId;
|
import static org.jclouds.cloudstack.options.ListDomainChildrenOptions.Builder.parentDomainId;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.Domain;
|
import org.jclouds.cloudstack.domain.Domain;
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code DomainDomainClient}
|
* Tests behavior of {@code DomainDomainClient}
|
||||||
*
|
*
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,10 +50,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
|
||||||
"apiKey=identity&signature=9%2BtdTXe2uYLzAexPNgrMy5Tq8hE%3D"))
|
"apiKey=identity&signature=9%2BtdTXe2uYLzAexPNgrMy5Tq8hE%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -83,10 +79,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
|
||||||
"apiKey=identity&signature=9%2BtdTXe2uYLzAexPNgrMy5Tq8hE%3D"))
|
"apiKey=identity&signature=9%2BtdTXe2uYLzAexPNgrMy5Tq8hE%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -102,10 +95,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
|
||||||
"id=2017&apiKey=identity&signature=6coh9Qdwla94TN1Dl008WlhzZUY%3D"))
|
"id=2017&apiKey=identity&signature=6coh9Qdwla94TN1Dl008WlhzZUY%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -126,10 +116,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
|
||||||
"id=4&apiKey=identity&signature=rYd8gr7ptdSZlIehBEMQEKsm07Q%3D"))
|
"id=4&apiKey=identity&signature=rYd8gr7ptdSZlIehBEMQEKsm07Q%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -145,10 +132,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=createFirewallRule&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=createFirewallRule&" +
|
||||||
"ipaddressid=2&protocol=TCP&apiKey=identity&signature=d0MZ%2FyhQPAaV%2BYQmfZsQtQL2C28%3D"))
|
"ipaddressid=2&protocol=TCP&apiKey=identity&signature=d0MZ%2FyhQPAaV%2BYQmfZsQtQL2C28%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -183,10 +167,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listPortForwardingRules&listAll=true&apiKey=identity&signature=8SXGJZWdcJfVz4V90Pyod12x9dM%3D"))
|
"command=listPortForwardingRules&listAll=true&apiKey=identity&signature=8SXGJZWdcJfVz4V90Pyod12x9dM%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -213,10 +194,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listPortForwardingRules&listAll=true&apiKey=identity&signature=8SXGJZWdcJfVz4V90Pyod12x9dM%3D"))
|
"command=listPortForwardingRules&listAll=true&apiKey=identity&signature=8SXGJZWdcJfVz4V90Pyod12x9dM%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -232,10 +210,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listPortForwardingRules&listAll=true&id=15&apiKey=identity&signature=JL63p6cJzbb9vaffeV4u60IGlWE%3D"))
|
"command=listPortForwardingRules&listAll=true&id=15&apiKey=identity&signature=JL63p6cJzbb9vaffeV4u60IGlWE%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -257,10 +232,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listPortForwardingRules&listAll=true&id=4&apiKey=identity&signature=4blbBVn2%2BZfF8HwoglbmtYoDAjs%3D"))
|
"command=listPortForwardingRules&listAll=true&id=4&apiKey=identity&signature=4blbBVn2%2BZfF8HwoglbmtYoDAjs%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -277,10 +249,7 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=createPortForwardingRule&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=createPortForwardingRule&" +
|
||||||
"ipaddressid=2&publicport=22&protocol=tcp&virtualmachineid=1234&privateport=22&" +
|
"ipaddressid=2&publicport=22&protocol=tcp&virtualmachineid=1234&privateport=22&" +
|
||||||
"apiKey=identity&signature=84dtGzQp0G6k3z3Gkc3F%2FHBNS2Y%3D"))
|
"apiKey=identity&signature=84dtGzQp0G6k3z3Gkc3F%2FHBNS2Y%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,10 +48,7 @@ public class GlobalConfigurationClientExpectTest extends BaseCloudStackRestClien
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listConfigurations&listAll=true&apiKey=identity&signature=%2BJ9mTuw%2BZXaumzMAJAXgZQaO2cc%3D"))
|
"command=listConfigurations&listAll=true&apiKey=identity&signature=%2BJ9mTuw%2BZXaumzMAJAXgZQaO2cc%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -76,10 +72,7 @@ public class GlobalConfigurationClientExpectTest extends BaseCloudStackRestClien
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listConfigurations&listAll=true&apiKey=identity&signature=%2BJ9mTuw%2BZXaumzMAJAXgZQaO2cc%3D"))
|
"command=listConfigurations&listAll=true&apiKey=identity&signature=%2BJ9mTuw%2BZXaumzMAJAXgZQaO2cc%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -97,10 +90,7 @@ public class GlobalConfigurationClientExpectTest extends BaseCloudStackRestClien
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=updateConfiguration&name=expunge.delay&value=11&" +
|
"command=updateConfiguration&name=expunge.delay&value=11&" +
|
||||||
"apiKey=identity&signature=I2yG35EhfgIXYObeLfU3cvf%2BPeE%3D"))
|
"apiKey=identity&signature=I2yG35EhfgIXYObeLfU3cvf%2BPeE%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -123,10 +113,7 @@ public class GlobalConfigurationClientExpectTest extends BaseCloudStackRestClien
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=updateConfiguration&name=expunge.delay&value=11&" +
|
"command=updateConfiguration&name=expunge.delay&value=11&" +
|
||||||
"apiKey=identity&signature=I2yG35EhfgIXYObeLfU3cvf%2BPeE%3D"))
|
"apiKey=identity&signature=I2yG35EhfgIXYObeLfU3cvf%2BPeE%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
|
|
@ -31,8 +31,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the CloudStack GlobalDomainClient
|
* Test the CloudStack GlobalDomainClient
|
||||||
*
|
*
|
||||||
|
@ -48,10 +46,7 @@ public class GlobalDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=createDomain&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=createDomain&" +
|
||||||
"name=test&apiKey=identity&signature=6cxzEo7h63G0hgTTMLm4lGsSDK8%3D"))
|
"name=test&apiKey=identity&signature=6cxzEo7h63G0hgTTMLm4lGsSDK8%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -70,10 +65,7 @@ public class GlobalDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=createDomain&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=createDomain&" +
|
||||||
"name=test&apiKey=identity&signature=6cxzEo7h63G0hgTTMLm4lGsSDK8%3D"))
|
"name=test&apiKey=identity&signature=6cxzEo7h63G0hgTTMLm4lGsSDK8%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -89,10 +81,7 @@ public class GlobalDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=updateDomain&id=10&name=test-2&apiKey=identity&signature=5t1eUf2Eyf%2FaB6qt%2BqIj%2BmcwFIo%3D"))
|
"command=updateDomain&id=10&name=test-2&apiKey=identity&signature=5t1eUf2Eyf%2FaB6qt%2BqIj%2BmcwFIo%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -111,10 +100,7 @@ public class GlobalDomainClientExpectTest extends BaseCloudStackRestClientExpect
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=updateDomain&id=10&name=test-2&apiKey=identity&signature=5t1eUf2Eyf%2FaB6qt%2BqIj%2BmcwFIo%3D"))
|
"command=updateDomain&id=10&name=test-2&apiKey=identity&signature=5t1eUf2Eyf%2FaB6qt%2BqIj%2BmcwFIo%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -42,7 +41,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,9 +55,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testListHostsWhenResponseIs2xx() {
|
public void testListHostsWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=listHosts&listAll=true&apiKey=identity&signature=NnYyyEy30G3V2dcIt7w4WZ68AU8%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=listHosts&listAll=true&apiKey=identity&signature=NnYyyEy30G3V2dcIt7w4WZ68AU8%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/listhostsresponse.json"))
|
.payload(payloadFromResource("/listhostsresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -92,9 +89,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testListHostsEmptyOn404() {
|
public void testListHostsEmptyOn404() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=listHosts&listAll=true&apiKey=identity&signature=NnYyyEy30G3V2dcIt7w4WZ68AU8%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=listHosts&listAll=true&apiKey=identity&signature=NnYyyEy30G3V2dcIt7w4WZ68AU8%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder().statusCode(404).build();
|
HttpResponse response = HttpResponse.builder().statusCode(404).build();
|
||||||
GlobalHostClient client = requestSendsResponse(request, response);
|
GlobalHostClient client = requestSendsResponse(request, response);
|
||||||
|
|
||||||
|
@ -105,9 +101,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testAddHostWhenResponseIs2xx() {
|
public void testAddHostWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=addHost&zoneid=1&hypervisor=XenServer&url=http%3A%2F%2Fexample.com&username=fred&password=sekrit&hosttags=&allocationstate=Enabled&clusterid=1&clustername=Xen%20Clust%201&podid=1&apiKey=identity&signature=ExGaljKKQIlVbWk5hd0BnnjmBzs%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=addHost&zoneid=1&hypervisor=XenServer&url=http%3A%2F%2Fexample.com&username=fred&password=sekrit&hosttags=&allocationstate=Enabled&clusterid=1&clustername=Xen%20Clust%201&podid=1&apiKey=identity&signature=ExGaljKKQIlVbWk5hd0BnnjmBzs%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/addhostresponse.json"))
|
.payload(payloadFromResource("/addhostresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -126,9 +121,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testUpdateHostWhenResponseIs2xx() {
|
public void testUpdateHostWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=updateHost&id=1&allocationstate=Enabled&hosttags=&oscategoryid=5&apiKey=identity&signature=qTxNq9yQG8S108giqS%2FROFzgev8%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=updateHost&id=1&allocationstate=Enabled&hosttags=&oscategoryid=5&apiKey=identity&signature=qTxNq9yQG8S108giqS%2FROFzgev8%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/updatehostresponse.json"))
|
.payload(payloadFromResource("/updatehostresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -146,9 +140,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testUpdateHostPasswordWhenResponseIs2xx() {
|
public void testUpdateHostPasswordWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=updateHostPassword&hostid=1&password=sekrit&username=fred&apiKey=identity&signature=g9nMKDWoiU72y0HhaRFekZCgfJc%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=updateHostPassword&hostid=1&password=sekrit&username=fred&apiKey=identity&signature=g9nMKDWoiU72y0HhaRFekZCgfJc%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
|
||||||
|
@ -159,8 +152,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testDeleteHostWhenResponseIs2xx() {
|
public void testDeleteHostWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=deleteHost&id=1&forced=true&forcedestroylocalstorage=true&apiKey=identity&signature=ZdvO1BWBkdPiDAjsVlKtqDe6N7k%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=deleteHost&id=1&forced=true&forcedestroylocalstorage=true&apiKey=identity&signature=ZdvO1BWBkdPiDAjsVlKtqDe6N7k%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json")
|
||||||
.build();
|
.build();
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -172,9 +165,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testPrepareHostForMaintenanceWhenResponseIs2xx() {
|
public void testPrepareHostForMaintenanceWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=prepareHostForMaintenance&id=1&apiKey=identity&signature=9tDwdox%2FxAKmZr9kVrR6Ttnxf3U%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=prepareHostForMaintenance&id=1&apiKey=identity&signature=9tDwdox%2FxAKmZr9kVrR6Ttnxf3U%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/preparehostformaintenanceresponse.json"))
|
.payload(payloadFromResource("/preparehostformaintenanceresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -187,9 +179,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testCancelHostMaintenanceWhenResponseIs2xx() {
|
public void testCancelHostMaintenanceWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=cancelHostMaintenance&id=1&apiKey=identity&signature=9RduzuBoyRZKNTzAoVqUo9gRTfk%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=cancelHostMaintenance&id=1&apiKey=identity&signature=9RduzuBoyRZKNTzAoVqUo9gRTfk%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/cancelhostmaintenanceresponse.json"))
|
.payload(payloadFromResource("/cancelhostmaintenanceresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -202,9 +193,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testReconnectHostWhenResponseIs2xx() {
|
public void testReconnectHostWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=reconnectHost&id=1&apiKey=identity&signature=wJEF02vwdyOnJOTa%2BWMMK906aRU%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=reconnectHost&id=1&apiKey=identity&signature=wJEF02vwdyOnJOTa%2BWMMK906aRU%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/reconnecthostresponse.json"))
|
.payload(payloadFromResource("/reconnecthostresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -217,9 +207,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testAddSecondaryStorageWhenResponseIs2xx() {
|
public void testAddSecondaryStorageWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=addSecondaryStorage&url=nfs%3A%2F%2F10.26.26.165%2Fmnt%2Fnfs%2Fcs_sec&zoneid=1&apiKey=identity&signature=MccRKx1yPP43ImiO70WlhVDlAIA%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=addSecondaryStorage&url=nfs%3A%2F%2F10.26.26.165%2Fmnt%2Fnfs%2Fcs_sec&zoneid=1&apiKey=identity&signature=MccRKx1yPP43ImiO70WlhVDlAIA%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/addsecondarystorageresponse.json"))
|
.payload(payloadFromResource("/addsecondarystorageresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -238,9 +227,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testListClustersWhenResponseIs2xx() {
|
public void testListClustersWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=listClusters&listAll=true&apiKey=identity&signature=lbimqg0OKIq8sgQBpNmi4oQNFog%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=listClusters&listAll=true&apiKey=identity&signature=lbimqg0OKIq8sgQBpNmi4oQNFog%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/listclustersresponse.json"))
|
.payload(payloadFromResource("/listclustersresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -258,9 +246,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testListClustersEmptyOn404() {
|
public void testListClustersEmptyOn404() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=listClusters&listAll=true&apiKey=identity&signature=lbimqg0OKIq8sgQBpNmi4oQNFog%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=listClusters&listAll=true&apiKey=identity&signature=lbimqg0OKIq8sgQBpNmi4oQNFog%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder().statusCode(404).build();
|
HttpResponse response = HttpResponse.builder().statusCode(404).build();
|
||||||
GlobalHostClient client = requestSendsResponse(request, response);
|
GlobalHostClient client = requestSendsResponse(request, response);
|
||||||
|
|
||||||
|
@ -271,9 +258,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testAddClusterWhenResponseIs2xx() {
|
public void testAddClusterWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=addCluster&zoneid=1&clustertype=CloudManaged&clustername=Xen%20Clust%201&hypervisor=XenServer&allocationstate=Enabled&podid=1&url=http%3A%2F%2Fexample.com%2Fcluster&username=fred&password=sekrit&apiKey=identity&signature=2uIQ5qF0bVycXK111wxvogWp1Yw%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=addCluster&zoneid=1&clustertype=CloudManaged&clustername=Xen%20Clust%201&hypervisor=XenServer&allocationstate=Enabled&podid=1&url=http%3A%2F%2Fexample.com%2Fcluster&username=fred&password=sekrit&apiKey=identity&signature=2uIQ5qF0bVycXK111wxvogWp1Yw%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/addclusterresponse.json"))
|
.payload(payloadFromResource("/addclusterresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -289,9 +275,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testUpdateClusterWhenResponseIs2xx() {
|
public void testUpdateClusterWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=updateCluster&id=1&allocationstate=Enabled&clustername=Xen%20Clust%201&clustertype=CloudManaged&hypervisor=XenServer&managedstate=Managed&apiKey=identity&signature=%2FwbuYKwInciSXWkUf05lEfJZShQ%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=updateCluster&id=1&allocationstate=Enabled&clustername=Xen%20Clust%201&clustertype=CloudManaged&hypervisor=XenServer&managedstate=Managed&apiKey=identity&signature=%2FwbuYKwInciSXWkUf05lEfJZShQ%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.payload(payloadFromResource("/updateclusterresponse.json"))
|
.payload(payloadFromResource("/updateclusterresponse.json"))
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
@ -307,9 +292,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testUpdateClusterPasswordWhenResponseIs2xx() {
|
public void testUpdateClusterPasswordWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=updateHostPassword&clusterid=1&password=sekrit&username=fred&apiKey=identity&signature=xwc83%2BoYK0cuAiFQAlg%2F7%2F1IVHE%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=updateHostPassword&clusterid=1&password=sekrit&username=fred&apiKey=identity&signature=xwc83%2BoYK0cuAiFQAlg%2F7%2F1IVHE%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
|
||||||
|
@ -320,9 +304,8 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
public void testDeleteClusterWhenResponseIs2xx() {
|
public void testDeleteClusterWhenResponseIs2xx() {
|
||||||
HttpRequest request = HttpRequest.builder()
|
HttpRequest request = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?response=json&command=deleteCluster&id=1&apiKey=identity&signature=CKH26MFgKGY7Sosd17LjBMNa3AI%3D"))
|
.endpoint("http://localhost:8080/client/api?response=json&command=deleteCluster&id=1&apiKey=identity&signature=CKH26MFgKGY7Sosd17LjBMNa3AI%3D")
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put("Accept", "application/json").build())
|
.addHeader("Accept", "application/json").build();
|
||||||
.build();
|
|
||||||
HttpResponse response = HttpResponse.builder()
|
HttpResponse response = HttpResponse.builder()
|
||||||
.statusCode(200).build();
|
.statusCode(200).build();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,10 +47,7 @@ public class GlobalVlanClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listVlanIpRanges&listAll=true&apiKey=identity&signature=xPwCeAcMp9kDGbD5oPgztLtSdnU%3D"))
|
"command=listVlanIpRanges&listAll=true&apiKey=identity&signature=xPwCeAcMp9kDGbD5oPgztLtSdnU%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -100,10 +96,7 @@ public class GlobalVlanClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listVlanIpRanges&listAll=true&apiKey=identity&signature=xPwCeAcMp9kDGbD5oPgztLtSdnU%3D"))
|
"command=listVlanIpRanges&listAll=true&apiKey=identity&signature=xPwCeAcMp9kDGbD5oPgztLtSdnU%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
@ -119,10 +112,7 @@ public class GlobalVlanClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=createVlanIpRange&startip=10.22.22.51&endip=10.22.22.100&forvirtualnetwork=false&zoneid=2&vlan=untagged&account=system&domainid=1&podid=2&gateway=10.22.22.254&netmask=255.255.255.0&networkid=209&apiKey=identity&signature=XgDjPYAQNLMVCuSMGRA6QjV8mOY%3D"))
|
"command=createVlanIpRange&startip=10.22.22.51&endip=10.22.22.100&forvirtualnetwork=false&zoneid=2&vlan=untagged&account=system&domainid=1&podid=2&gateway=10.22.22.254&netmask=255.255.255.0&networkid=209&apiKey=identity&signature=XgDjPYAQNLMVCuSMGRA6QjV8mOY%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
@ -166,10 +156,7 @@ public class GlobalVlanClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=deleteVlanIpRange&id=1&apiKey=identity&signature=tTBbpdCndgHXdR397fbbJaN1RZU%3D"))
|
"command=deleteVlanIpRange&id=1&apiKey=identity&signature=tTBbpdCndgHXdR397fbbJaN1RZU%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
|
|
@ -120,10 +120,7 @@ public class GlobalZoneClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=deleteZone&id=6&apiKey=identity&signature=TfkzSIK8kzGJnIYo3DofECyuOII%3D"))
|
"command=deleteZone&id=6&apiKey=identity&signature=TfkzSIK8kzGJnIYo3DofECyuOII%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
|
|
@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.OSType;
|
import org.jclouds.cloudstack.domain.OSType;
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||||
|
|
|
@ -55,10 +55,7 @@ public class SSHKeyPairClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listSSHKeyPairs&listAll=true&apiKey=identity&signature=5d2J9u%2BdKpkQsadDbl9i9OcUSLQ%3D"))
|
"command=listSSHKeyPairs&listAll=true&apiKey=identity&signature=5d2J9u%2BdKpkQsadDbl9i9OcUSLQ%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(), response);
|
.build(), response);
|
||||||
|
|
||||||
assertEquals(client.listSSHKeyPairs(), ImmutableSet.of(
|
assertEquals(client.listSSHKeyPairs(), ImmutableSet.of(
|
||||||
|
@ -70,10 +67,7 @@ public class SSHKeyPairClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&" +
|
||||||
"name=jclouds-keypair&apiKey=identity&signature=hJIVCFOHhdOww3aq19tFHpeD2HI%3D"))
|
"name=jclouds-keypair&apiKey=identity&signature=hJIVCFOHhdOww3aq19tFHpeD2HI%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(), response);
|
.build(), response);
|
||||||
|
|
||||||
assertEquals(client.getSSHKeyPair("jclouds-keypair"),
|
assertEquals(client.getSSHKeyPair("jclouds-keypair"),
|
||||||
|
@ -89,10 +83,7 @@ public class SSHKeyPairClientExpectTest extends BaseCloudStackRestClientExpectTe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=createSSHKeyPair&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=createSSHKeyPair&" +
|
||||||
"name=jclouds-keypair&apiKey=identity&signature=8wk32PZF44jrBLH2HLel22%2BqMC4%3D"))
|
"name=jclouds-keypair&apiKey=identity&signature=8wk32PZF44jrBLH2HLel22%2BqMC4%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAuthorizeIngressICMPToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
|
public void testAuthorizeIngressICMPToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToCIDRs", String.class, int.class,
|
Method method = SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToCIDRs", String.class , int.class,
|
||||||
int.class, Iterable.class, AccountInDomainOptions[].class);
|
int.class, Iterable.class, AccountInDomainOptions[].class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, 2, 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"));
|
HttpRequest httpRequest = processor.createRequest(method, 2, 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"));
|
||||||
|
|
||||||
|
|
|
@ -55,10 +55,7 @@ public class SessionClientExpectTest extends BaseCloudStackRestClientExpectTest<
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&command=login&" +
|
URI.create("http://localhost:8080/client/api?response=json&command=login&" +
|
||||||
"username=" + user + "&password=" + md5password + "&domain=" + URLEncoder.encode(domain)))
|
"username=" + user + "&password=" + md5password + "&domain=" + URLEncoder.encode(domain)))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String jSessionId = "90DD65D13AEAA590ECCA312D150B9F6D";
|
String jSessionId = "90DD65D13AEAA590ECCA312D150B9F6D";
|
||||||
|
|
|
@ -34,8 +34,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the CloudStack VirtualMachineClientClient
|
* Test the CloudStack VirtualMachineClientClient
|
||||||
*
|
*
|
||||||
|
@ -67,10 +65,7 @@ public class VirtualMachineClientExpectTest extends BaseCloudStackRestClientExpe
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=getVMPassword&id=1&apiKey=identity&signature=SVA2r1KRj4yG03rATMLPZWS%2BKnw%3D"))
|
"command=getVMPassword&id=1&apiKey=identity&signature=SVA2r1KRj4yG03rATMLPZWS%2BKnw%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,20 +43,19 @@ public class ZoneClientExpectTest extends BaseCloudStackRestClientExpectTest<Zon
|
||||||
|
|
||||||
public void testListZonesWhenResponseIs2xx() {
|
public void testListZonesWhenResponseIs2xx() {
|
||||||
ZoneClient client = requestSendsResponse(
|
ZoneClient client = requestSendsResponse(
|
||||||
HttpRequest.builder()
|
HttpRequest.builder().method("GET")
|
||||||
.method("GET")
|
.endpoint("http://localhost:8080/client/api")
|
||||||
.endpoint(
|
.addQueryParam("response", "json")
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
.addQueryParam("command", "listZones")
|
||||||
"command=listZones&listAll=true&apiKey=identity&signature=8iHCtck0qfxFTqJ8reyAObRf31I%3D"))
|
.addQueryParam("listAll", "true")
|
||||||
.headers(
|
.addQueryParam("apiKey", "identity")
|
||||||
ImmutableMultimap.<String, String>builder()
|
.addQueryParam("signature", "8iHCtck0qfxFTqJ8reyAObRf31I%3D")
|
||||||
.put("Accept", "application/json")
|
.addHeader("Accept", "application/json")
|
||||||
.build())
|
.build(),
|
||||||
.build(),
|
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.payload(payloadFromResource("/listzonesresponse.json"))
|
.payload(payloadFromResource("/listzonesresponse.json"))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
assertEquals(client.listZones(),
|
assertEquals(client.listZones(),
|
||||||
ImmutableSet.of(
|
ImmutableSet.of(
|
||||||
|
@ -80,10 +78,7 @@ public class ZoneClientExpectTest extends BaseCloudStackRestClientExpectTest<Zon
|
||||||
.endpoint(
|
.endpoint(
|
||||||
URI.create("http://localhost:8080/client/api?response=json&" +
|
URI.create("http://localhost:8080/client/api?response=json&" +
|
||||||
"command=listZones&listAll=true&apiKey=identity&signature=8iHCtck0qfxFTqJ8reyAObRf31I%3D"))
|
"command=listZones&listAll=true&apiKey=identity&signature=8iHCtck0qfxFTqJ8reyAObRf31I%3D"))
|
||||||
.headers(
|
.addHeader("Accept", "application/json")
|
||||||
ImmutableMultimap.<String, String>builder()
|
|
||||||
.put("Accept", "application/json")
|
|
||||||
.build())
|
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder()
|
HttpResponse.builder()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
|
|
|
@ -20,8 +20,6 @@ package org.jclouds.cloudstack.filters;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.jclouds.ContextBuilder;
|
import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.IntegrationTestAsyncClient;
|
import org.jclouds.http.IntegrationTestAsyncClient;
|
||||||
|
@ -59,7 +57,7 @@ public class QuerySignerTest {
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
filter.createStringToSign(HttpRequest.builder().method("GET")
|
filter.createStringToSign(HttpRequest.builder().method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build()),
|
.endpoint("http://localhost:8080/client/api?command=listZones").build()),
|
||||||
"apikey=apikey&command=listzones");
|
"apikey=apikey&command=listzones");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,18 +66,18 @@ public class QuerySignerTest {
|
||||||
QuerySigner filter = INJECTOR.getInstance(QuerySigner.class);
|
QuerySigner filter = INJECTOR.getInstance(QuerySigner.class);
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
filter.filter(
|
filter.filter(
|
||||||
HttpRequest.builder().method("GET")
|
HttpRequest.builder().method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build())
|
.endpoint("http://localhost:8080/client/api?command=listZones").build())
|
||||||
.getRequestLine(),
|
.getRequestLine(),
|
||||||
"GET http://localhost:8080/client/api?command=listZones&apiKey=apiKey&signature=2UG8AcnMaozL3BINdjgkJ%2BRzjEY%3D HTTP/1.1");
|
"GET http://localhost:8080/client/api?command=listZones&apiKey=apiKey&signature=2UG8AcnMaozL3BINdjgkJ%2BRzjEY%3D HTTP/1.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFilterTwice() {
|
void testFilterTwice() {
|
||||||
QuerySigner filter = INJECTOR.getInstance(QuerySigner.class);
|
QuerySigner filter = INJECTOR.getInstance(QuerySigner.class);
|
||||||
HttpRequest request = HttpRequest.builder().method("GET")
|
HttpRequest request = HttpRequest.builder().method("GET")
|
||||||
.endpoint(URI.create("http://localhost:8080/client/api?command=listZones")).build();
|
.endpoint("http://localhost:8080/client/api?command=listZones").build();
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
request = filter.filter(request);
|
request = filter.filter(request);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.cloudstack.filters;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
@ -52,7 +51,7 @@ public class ReEncodeQueryWithJavaNetURLEncoderTest {
|
||||||
String defaultEncodedRequest = "http://localhost?foo=" + URLEncoder.encode(input);
|
String defaultEncodedRequest = "http://localhost?foo=" + URLEncoder.encode(input);
|
||||||
assert !defaultJcloudsEncodedRequest.equals(defaultEncodedRequest);
|
assert !defaultJcloudsEncodedRequest.equals(defaultEncodedRequest);
|
||||||
|
|
||||||
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost?foo=" + Strings2.urlEncode(input)));
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost?foo=" + Strings2.urlEncode(input)).build();
|
||||||
request = Guice.createInjector(new AbstractModule() {
|
request = Guice.createInjector(new AbstractModule() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,18 +24,17 @@ import static org.testng.Assert.assertTrue;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncJob.Status;
|
||||||
import org.jclouds.cloudstack.domain.AsyncJobError;
|
import org.jclouds.cloudstack.domain.AsyncJobError;
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
|
||||||
import org.jclouds.cloudstack.domain.IPForwardingRule;
|
import org.jclouds.cloudstack.domain.IPForwardingRule;
|
||||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||||
import org.jclouds.cloudstack.domain.Template;
|
import org.jclouds.cloudstack.domain.Template;
|
||||||
import org.jclouds.cloudstack.domain.TemplateExtraction;
|
import org.jclouds.cloudstack.domain.TemplateExtraction;
|
||||||
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
|
|
||||||
import org.jclouds.cloudstack.domain.AsyncJob.Status;
|
|
||||||
import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode;
|
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.domain.JsonBall;
|
import org.jclouds.domain.JsonBall;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -70,8 +69,9 @@ public class ParseAsyncJobFromHttpResponseTest {
|
||||||
|
|
||||||
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
|
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(HttpResponse.builder()
|
||||||
Payloads.newStringPayload(input)));
|
.statusCode(200).message("ok")
|
||||||
|
.payload(input).build());
|
||||||
|
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,9 @@ public class ParseAsyncJobFromHttpResponseTest {
|
||||||
|
|
||||||
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
|
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(HttpResponse.builder()
|
||||||
Payloads.newStringPayload(input)));
|
.statusCode(200).message("ok")
|
||||||
|
.payload(input).build());
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,9 +109,9 @@ public class ParseAsyncJobFromHttpResponseTest {
|
||||||
|
|
||||||
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
|
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(HttpResponse.builder()
|
||||||
Payloads.newStringPayload(input)));
|
.statusCode(200).message("ok")
|
||||||
|
.payload(input).build());
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,9 +128,9 @@ public class ParseAsyncJobFromHttpResponseTest {
|
||||||
|
|
||||||
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
|
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(HttpResponse.builder()
|
||||||
Payloads.newStringPayload(input)));
|
.statusCode(200).message("ok")
|
||||||
|
.payload(input).build());
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,9 +151,9 @@ public class ParseAsyncJobFromHttpResponseTest {
|
||||||
|
|
||||||
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
|
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(HttpResponse.builder()
|
||||||
Payloads.newStringPayload(input)));
|
.statusCode(200).message("ok")
|
||||||
|
.payload(input).build());
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,9 +181,9 @@ public class ParseAsyncJobFromHttpResponseTest {
|
||||||
|
|
||||||
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(new HttpResponse(200, "ok",
|
AsyncJob<PublicIPAddress> response = (AsyncJob<PublicIPAddress>) parser.apply(HttpResponse.builder()
|
||||||
Payloads.newInputStreamPayload(is)));
|
.statusCode(200).message("ok")
|
||||||
|
.payload(is).build());
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,20 +203,20 @@ public class ParseAsyncJobFromHttpResponseTest {
|
||||||
|
|
||||||
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
AsyncJob<IPForwardingRule> response = (AsyncJob<IPForwardingRule>) parser.apply(new HttpResponse(200, "ok",
|
AsyncJob<IPForwardingRule> response = (AsyncJob<IPForwardingRule>) parser.apply(HttpResponse.builder()
|
||||||
Payloads.newInputStreamPayload(is)));
|
.statusCode(200).message("ok")
|
||||||
|
.payload(is).build());
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOverloadedKeyName() {
|
public void testOverloadedKeyName() {
|
||||||
InputStream is = getClass().getResourceAsStream("/queryasyncjobresultresponse-createtemplate.json");
|
InputStream is = getClass().getResourceAsStream("/queryasyncjobresultresponse-createtemplate.json");
|
||||||
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
AsyncJob<?> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
AsyncJob<?> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
assertTrue(response.getResult() instanceof Template, "response expected to be Template, actually is " + response.getResult().getClass());
|
assertTrue(response.getResult() instanceof Template, "response expected to be Template, actually is " + response.getResult().getClass());
|
||||||
|
|
||||||
is = getClass().getResourceAsStream("/queryasyncjobresultresponse-extracttemplate.json");
|
is = getClass().getResourceAsStream("/queryasyncjobresultresponse-extracttemplate.json");
|
||||||
response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
assertTrue(response.getResult() instanceof TemplateExtraction, "response expected to be TemplateExtraction, actually is " + response.getResult().getClass());
|
assertTrue(response.getResult() instanceof TemplateExtraction, "response expected to be TemplateExtraction, actually is " + response.getResult().getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ public class ParseAsyncJobsFromHttpResponseTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/listasyncjobsresponse.json");
|
InputStream is = getClass().getResourceAsStream("/listasyncjobsresponse.json");
|
||||||
|
|
||||||
ParseAsyncJobsFromHttpResponse parser = injector.getInstance(ParseAsyncJobsFromHttpResponse.class);
|
ParseAsyncJobsFromHttpResponse parser = injector.getInstance(ParseAsyncJobsFromHttpResponse.class);
|
||||||
Set<AsyncJob<?>> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
Set<AsyncJob<?>> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
|
||||||
|
|
||||||
assertEquals(response.size(), 77);
|
assertEquals(response.size(), 77);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,8 @@ import org.easymock.IArgumentMatcher;
|
||||||
import org.jclouds.http.HttpCommand;
|
import org.jclouds.http.HttpCommand;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
import org.jclouds.util.Strings2;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -118,9 +116,8 @@ public class CloudStackErrorHandlerTest {
|
||||||
CloudStackErrorHandler function = Guice.createInjector().getInstance(CloudStackErrorHandler.class);
|
CloudStackErrorHandler function = Guice.createInjector().getInstance(CloudStackErrorHandler.class);
|
||||||
|
|
||||||
HttpCommand command = createMock(HttpCommand.class);
|
HttpCommand command = createMock(HttpCommand.class);
|
||||||
HttpRequest request = new HttpRequest(method, uri);
|
HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
|
||||||
HttpResponse response = new HttpResponse(statusCode, message, Payloads.newInputStreamPayload(Strings2
|
HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
|
||||||
.toInputStream(content)));
|
|
||||||
response.getPayload().getContentMetadata().setContentType(contentType);
|
response.getPayload().getContentMetadata().setContentType(contentType);
|
||||||
|
|
||||||
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.cloudwatch.domain.GetMetricStatistics;
|
||||||
import org.jclouds.cloudwatch.domain.Statistics;
|
import org.jclouds.cloudwatch.domain.Statistics;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
@ -50,6 +49,7 @@ public class GetMetricStatisticsBinder implements org.jclouds.rest.Binder {
|
||||||
this.dateService = dateService;
|
this.dateService = dateService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
|
||||||
GetMetricStatistics getRequest = GetMetricStatistics.class.cast(checkNotNull(payload,
|
GetMetricStatistics getRequest = GetMetricStatistics.class.cast(checkNotNull(payload,
|
||||||
|
@ -84,7 +84,7 @@ public class GetMetricStatisticsBinder implements org.jclouds.rest.Binder {
|
||||||
formParameters.put("Unit", getRequest.getUnit().get().toString());
|
formParameters.put("Unit", getRequest.getUnit().get().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ModifyRequest.putFormParams(request, formParameters.build());
|
return (R) request.toBuilder().replaceFormParams(formParameters.build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,7 +25,6 @@ import org.jclouds.cloudwatch.domain.MetricDatum;
|
||||||
import org.jclouds.cloudwatch.domain.StatisticValues;
|
import org.jclouds.cloudwatch.domain.StatisticValues;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
@ -100,7 +99,7 @@ public class MetricDataBinder implements org.jclouds.rest.Binder {
|
||||||
metricDatumIndex++;
|
metricDatumIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ModifyRequest.putFormParams(request, formParameters.build());
|
return (R) request.toBuilder().replaceFormParams(formParameters.build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudwatch.binders;
|
package org.jclouds.cloudwatch.binders;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import java.util.Date;
|
||||||
import com.google.inject.Guice;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import org.jclouds.cloudwatch.domain.Dimension;
|
import org.jclouds.cloudwatch.domain.Dimension;
|
||||||
import org.jclouds.cloudwatch.domain.MetricDatum;
|
import org.jclouds.cloudwatch.domain.MetricDatum;
|
||||||
import org.jclouds.cloudwatch.domain.StatisticValues;
|
import org.jclouds.cloudwatch.domain.StatisticValues;
|
||||||
|
@ -29,8 +28,9 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.net.URI;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import java.util.Date;
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@link MetricDataBinder}.
|
* Tests behavior of {@link MetricDataBinder}.
|
||||||
|
@ -44,7 +44,7 @@ public class MetricDataBinderTest {
|
||||||
MetricDataBinder binder = injector.getInstance(MetricDataBinder.class);
|
MetricDataBinder binder = injector.getInstance(MetricDataBinder.class);
|
||||||
|
|
||||||
HttpRequest request() {
|
HttpRequest request() {
|
||||||
return HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
|
return HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMetricWithoutTimestamp() throws Exception {
|
public void testMetricWithoutTimestamp() throws Exception {
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.cloudwatch.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
@ -39,8 +38,6 @@ import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jeremy Whitlock, Adrian Cole
|
* @author Jeremy Whitlock, Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -53,10 +50,8 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
|
||||||
|
|
||||||
HttpRequest listMetrics = HttpRequest.builder()
|
HttpRequest listMetrics = HttpRequest.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.endpoint(URI.create("https://monitoring.us-east-1.amazonaws.com/"))
|
.endpoint("https://monitoring.us-east-1.amazonaws.com/")
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
.addHeader("Host", "monitoring.us-east-1.amazonaws.com")
|
||||||
.put("Host", "monitoring.us-east-1.amazonaws.com")
|
|
||||||
.build())
|
|
||||||
.payload(
|
.payload(
|
||||||
payloadFromStringWithContentType(
|
payloadFromStringWithContentType(
|
||||||
"Action=ListMetrics" +
|
"Action=ListMetrics" +
|
||||||
|
@ -97,10 +92,8 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
|
||||||
HttpRequest listMetricsWithOptions =
|
HttpRequest listMetricsWithOptions =
|
||||||
HttpRequest.builder()
|
HttpRequest.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.endpoint(URI.create("https://monitoring.us-east-1.amazonaws.com/"))
|
.endpoint("https://monitoring.us-east-1.amazonaws.com/")
|
||||||
.headers(ImmutableMultimap.<String, String>builder()
|
.addHeader("Host", "monitoring.us-east-1.amazonaws.com")
|
||||||
.put("Host", "monitoring.us-east-1.amazonaws.com")
|
|
||||||
.build())
|
|
||||||
.payload(payloadFromStringWithContentType(
|
.payload(payloadFromStringWithContentType(
|
||||||
"Action=ListMetrics" +
|
"Action=ListMetrics" +
|
||||||
"&Dimensions.member.1.Name=InstanceId" +
|
"&Dimensions.member.1.Name=InstanceId" +
|
||||||
|
@ -146,10 +139,8 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
|
||||||
|
|
||||||
HttpRequest getMetricStatistics = HttpRequest.builder()
|
HttpRequest getMetricStatistics = HttpRequest.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.endpoint(URI.create("https://monitoring.us-east-1.amazonaws.com/"))
|
.endpoint("https://monitoring.us-east-1.amazonaws.com/")
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
.addHeader("Host", "monitoring.us-east-1.amazonaws.com")
|
||||||
.put("Host", "monitoring.us-east-1.amazonaws.com")
|
|
||||||
.build())
|
|
||||||
.payload(
|
.payload(
|
||||||
payloadFromStringWithContentType(
|
payloadFromStringWithContentType(
|
||||||
"Action=GetMetricStatistics" +
|
"Action=GetMetricStatistics" +
|
||||||
|
@ -202,10 +193,8 @@ public class MetricClientExpectTest extends BaseCloudWatchClientExpectTest {
|
||||||
HttpRequest getMetricStatistics =
|
HttpRequest getMetricStatistics =
|
||||||
HttpRequest.builder()
|
HttpRequest.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.endpoint(URI.create("https://monitoring.us-east-1.amazonaws.com/"))
|
.endpoint("https://monitoring.us-east-1.amazonaws.com/")
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
.addHeader("Host", "monitoring.us-east-1.amazonaws.com")
|
||||||
.put("Host", "monitoring.us-east-1.amazonaws.com")
|
|
||||||
.build())
|
|
||||||
.payload(payloadFromStringWithContentType(
|
.payload(payloadFromStringWithContentType(
|
||||||
"Action=GetMetricStatistics" +
|
"Action=GetMetricStatistics" +
|
||||||
"&Dimensions.member.1.Name=InstanceId" +
|
"&Dimensions.member.1.Name=InstanceId" +
|
||||||
|
|
|
@ -93,8 +93,8 @@ public class InstanceHandler extends ParseSax.HandlerWithResult<Instance> {
|
||||||
try {
|
try {
|
||||||
Instance.Action action = Instance.Action.fromValue(attributes.get("rel"));
|
Instance.Action action = Instance.Action.fromValue(attributes.get("rel"));
|
||||||
if (action != Instance.Action.UNRECOGNIZED) {
|
if (action != Instance.Action.UNRECOGNIZED) {
|
||||||
HttpRequest request = new HttpRequest(attributes.get("method").toUpperCase(), URI.create(attributes
|
HttpRequest request = HttpRequest.builder().method(attributes.get("method").toUpperCase()).endpoint(attributes
|
||||||
.get("href")));
|
.get("href")).build();
|
||||||
actions.put(action, request);
|
actions.put(action, request);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
|
@ -232,7 +232,7 @@ public class DeltacloudAsyncClientTest extends BaseAsyncClientTest<DeltacloudAsy
|
||||||
public void testCreateInstance() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCreateInstance() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class,
|
Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class,
|
||||||
CreateInstanceOptions[].class);
|
CreateInstanceOptions[].class);
|
||||||
GeneratedHttpRequest<DeltacloudAsyncClient> httpRequest = processor.createRequest(method, "imageId-1");
|
GeneratedHttpRequest httpRequest = processor.createRequest(method, "imageId-1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\n");
|
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/xml\n");
|
||||||
|
@ -249,7 +249,7 @@ public class DeltacloudAsyncClientTest extends BaseAsyncClientTest<DeltacloudAsy
|
||||||
public void testCreateInstanceWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCreateInstanceWithOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class,
|
Method method = DeltacloudAsyncClient.class.getMethod("createInstance", String.class,
|
||||||
CreateInstanceOptions[].class);
|
CreateInstanceOptions[].class);
|
||||||
GeneratedHttpRequest<DeltacloudAsyncClient> httpRequest = processor.createRequest(method, "imageId-1",
|
GeneratedHttpRequest httpRequest = processor.createRequest(method, "imageId-1",
|
||||||
CreateInstanceOptions.Builder.named("foo"));
|
CreateInstanceOptions.Builder.named("foo"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1");
|
assertRequestLineEquals(httpRequest, "POST http://localhost:3001/api/instances HTTP/1.1");
|
||||||
|
@ -267,7 +267,7 @@ public class DeltacloudAsyncClientTest extends BaseAsyncClientTest<DeltacloudAsy
|
||||||
public void testPerformAction() throws IOException, SecurityException, NoSuchMethodException {
|
public void testPerformAction() throws IOException, SecurityException, NoSuchMethodException {
|
||||||
Method method = DeltacloudAsyncClient.class.getMethod("performAction", HttpRequest.class);
|
Method method = DeltacloudAsyncClient.class.getMethod("performAction", HttpRequest.class);
|
||||||
HttpRequest request = processor.createRequest(method,
|
HttpRequest request = processor.createRequest(method,
|
||||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://delta/instance1/reboot")).build());
|
HttpRequest.builder().method("POST").endpoint("https://delta/instance1/reboot").build());
|
||||||
|
|
||||||
assertRequestLineEquals(request, "POST https://delta/instance1/reboot HTTP/1.1");
|
assertRequestLineEquals(request, "POST https://delta/instance1/reboot HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Accept: application/xml\n");
|
assertNonPayloadHeadersEqual(request, "Accept: application/xml\n");
|
||||||
|
|
|
@ -30,10 +30,8 @@ import org.easymock.IArgumentMatcher;
|
||||||
import org.jclouds.http.HttpCommand;
|
import org.jclouds.http.HttpCommand;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
import org.jclouds.util.Strings2;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -91,9 +89,8 @@ public class DeltacloudErrorHandlerTest {
|
||||||
DeltacloudErrorHandler function = Guice.createInjector().getInstance(DeltacloudErrorHandler.class);
|
DeltacloudErrorHandler function = Guice.createInjector().getInstance(DeltacloudErrorHandler.class);
|
||||||
|
|
||||||
HttpCommand command = createMock(HttpCommand.class);
|
HttpCommand command = createMock(HttpCommand.class);
|
||||||
HttpRequest request = new HttpRequest(method, uri);
|
HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
|
||||||
HttpResponse response = new HttpResponse(statusCode, message, Payloads.newInputStreamPayload(Strings2
|
HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
|
||||||
.toInputStream(content)));
|
|
||||||
response.getPayload().getContentMetadata().setContentType(contentType);
|
response.getPayload().getContentMetadata().setContentType(contentType);
|
||||||
|
|
||||||
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
||||||
|
|
|
@ -23,8 +23,6 @@ import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.EasyMock.replay;
|
import static org.easymock.EasyMock.replay;
|
||||||
import static org.easymock.EasyMock.verify;
|
import static org.easymock.EasyMock.verify;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.jclouds.ContextBuilder;
|
import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.http.HttpCommand;
|
import org.jclouds.http.HttpCommand;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -46,8 +44,8 @@ public class DeltacloudRedirectionRetryHandlerTest {
|
||||||
public void test302DoesNotRetryOnDelete() {
|
public void test302DoesNotRetryOnDelete() {
|
||||||
|
|
||||||
HttpCommand command = createMock(HttpCommand.class);
|
HttpCommand command = createMock(HttpCommand.class);
|
||||||
HttpRequest request = HttpRequest.builder().method("DELETE").endpoint(URI.create("http://localhost")).build();
|
HttpRequest request = HttpRequest.builder().method("DELETE").endpoint("http://localhost").build();
|
||||||
HttpResponse response = new HttpResponse(302, "HTTP/1.1 302 Found", null);
|
HttpResponse response = HttpResponse.builder().statusCode(302).message("HTTP/1.1 302 Found").build();
|
||||||
|
|
||||||
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
||||||
|
|
||||||
|
@ -66,8 +64,8 @@ public class DeltacloudRedirectionRetryHandlerTest {
|
||||||
public void test302DoesRetryOnGET() {
|
public void test302DoesRetryOnGET() {
|
||||||
|
|
||||||
HttpCommand command = createMock(HttpCommand.class);
|
HttpCommand command = createMock(HttpCommand.class);
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
|
||||||
HttpResponse response = new HttpResponse(302, "HTTP/1.1 302 Found", null);
|
HttpResponse response = HttpResponse.builder().statusCode(302).message("HTTP/1.1 302 Found").build();
|
||||||
|
|
||||||
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
||||||
expect(command.incrementRedirectCount()).andReturn(1);
|
expect(command.incrementRedirectCount()).andReturn(1);
|
||||||
|
|
|
@ -89,9 +89,9 @@ public class InstanceHandlerTest {
|
||||||
URI.create("http://fancycloudprovider.com/api/hardware_profiles/m1-small"),
|
URI.create("http://fancycloudprovider.com/api/hardware_profiles/m1-small"),
|
||||||
URI.create("http://fancycloudprovider.com/api/realms/us"), Instance.State.RUNNING, ImmutableMap.of(
|
URI.create("http://fancycloudprovider.com/api/realms/us"), Instance.State.RUNNING, ImmutableMap.of(
|
||||||
Instance.Action.REBOOT,
|
Instance.Action.REBOOT,
|
||||||
new HttpRequest("POST", URI.create("http://fancycloudprovider.com/api/instances/inst1/reboot")),
|
HttpRequest.builder().method("POST").endpoint("http://fancycloudprovider.com/api/instances/inst1/reboot").build(),
|
||||||
Instance.Action.STOP,
|
Instance.Action.STOP,
|
||||||
new HttpRequest("POST", URI.create("http://fancycloudprovider.com/api/instances/inst1/stop"))),
|
HttpRequest.builder().method("POST").endpoint("http://fancycloudprovider.com/api/instances/inst1/stop").build()),
|
||||||
authentication, ImmutableSet.of("inst1.larry.fancycloudprovider.com"),
|
authentication, ImmutableSet.of("inst1.larry.fancycloudprovider.com"),
|
||||||
ImmutableSet.of("inst1.larry.internal"));
|
ImmutableSet.of("inst1.larry.internal"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,10 +49,8 @@ public class InstancesHandlerTest extends BaseHandlerTest {
|
||||||
"Production JBoss Instance", URI.create("http://fancycloudprovider.com/api/images/img3"), URI
|
"Production JBoss Instance", URI.create("http://fancycloudprovider.com/api/images/img3"), URI
|
||||||
.create("http://fancycloudprovider.com/api/hardware_profiles/m1-small"), URI
|
.create("http://fancycloudprovider.com/api/hardware_profiles/m1-small"), URI
|
||||||
.create("http://fancycloudprovider.com/api/realms/us"), Instance.State.RUNNING, ImmutableMap
|
.create("http://fancycloudprovider.com/api/realms/us"), Instance.State.RUNNING, ImmutableMap
|
||||||
.of(Instance.Action.REBOOT, new HttpRequest("POST", URI
|
.of(Instance.Action.REBOOT, HttpRequest.builder().method("POST").endpoint("http://fancycloudprovider.com/api/instances/inst1/reboot").build(),
|
||||||
.create("http://fancycloudprovider.com/api/instances/inst1/reboot")),
|
Instance.Action.STOP, HttpRequest.builder().method("POST").endpoint("http://fancycloudprovider.com/api/instances/inst1/stop").build()), null,
|
||||||
Instance.Action.STOP, new HttpRequest("POST", URI
|
|
||||||
.create("http://fancycloudprovider.com/api/instances/inst1/stop"))), null,
|
|
||||||
ImmutableSet.of("inst1.larry.fancycloudprovider.com"), ImmutableSet.of("inst1.larry.internal")));
|
ImmutableSet.of("inst1.larry.fancycloudprovider.com"), ImmutableSet.of("inst1.larry.internal")));
|
||||||
assertEquals(factory.create(injector.getInstance(InstancesHandler.class)).parse(is).toString(), expects.toString());
|
assertEquals(factory.create(injector.getInstance(InstancesHandler.class)).parse(is).toString(), expects.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.jclouds.ec2.domain.BlockDevice;
|
import org.jclouds.ec2.domain.BlockDevice;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -62,7 +61,7 @@ public class BindBlockDeviceMappingToIndexedFormParams implements Binder {
|
||||||
amazonOneBasedIndex++;
|
amazonOneBasedIndex++;
|
||||||
}
|
}
|
||||||
Multimap<String, String> forms = Multimaps.forMap(builder.build());
|
Multimap<String, String> forms = Multimaps.forMap(builder.build());
|
||||||
return forms.size() == 0 ? request : ModifyRequest.putFormParams(request, forms);
|
return forms.size() == 0 ? request : (R) request.toBuilder().replaceFormParams(forms).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import org.jclouds.ec2.domain.IpPermission;
|
import org.jclouds.ec2.domain.IpPermission;
|
||||||
import org.jclouds.ec2.util.IpPermissions;
|
import org.jclouds.ec2.util.IpPermissions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,11 +31,12 @@ import org.jclouds.rest.Binder;
|
||||||
*/
|
*/
|
||||||
public class BindIpPermissionToIndexedFormParams implements Binder {
|
public class BindIpPermissionToIndexedFormParams implements Binder {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
checkArgument(checkNotNull(input, "input") instanceof IpPermission, "this binder is only valid for IpPermission");
|
checkArgument(checkNotNull(input, "input") instanceof IpPermission, "this binder is only valid for IpPermission");
|
||||||
IpPermission perm = (IpPermission) input;
|
IpPermission perm = (IpPermission) input;
|
||||||
return ModifyRequest.putFormParams(request, IpPermissions.buildFormParametersForIndex(0, perm));
|
return (R) request.toBuilder().replaceFormParams(IpPermissions.buildFormParametersForIndex(0, perm)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import org.jclouds.ec2.domain.IpPermission;
|
import org.jclouds.ec2.domain.IpPermission;
|
||||||
import org.jclouds.ec2.util.IpPermissions;
|
import org.jclouds.ec2.util.IpPermissions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
@ -40,11 +39,12 @@ public class BindIpPermissionsToIndexedFormParams implements Binder {
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
checkArgument(checkNotNull(input, "input") instanceof Iterable,
|
checkArgument(checkNotNull(input, "input") instanceof Iterable,
|
||||||
"this binder is only valid for Iterable<IpPermission>");
|
"this binder is only valid for Iterable<IpPermission>");
|
||||||
Builder<String, String> headers = ImmutableMultimap.builder();
|
Builder<String, String> formBuilder = ImmutableMultimap.builder();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (IpPermission perm : (Iterable<IpPermission>) input)
|
for (IpPermission perm : (Iterable<IpPermission>) input)
|
||||||
headers.putAll(IpPermissions.buildFormParametersForIndex(index++, perm));
|
formBuilder.putAll(IpPermissions.buildFormParametersForIndex(index++, perm));
|
||||||
return ModifyRequest.putFormParams(request, headers.build());
|
ImmutableMultimap<String, String> forms = formBuilder.build();
|
||||||
|
return forms.size() == 0 ? request : (R) request.toBuilder().replaceFormParams(forms).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import javax.inject.Singleton;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.crypto.CryptoStreams;
|
import org.jclouds.crypto.CryptoStreams;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
@ -46,6 +45,7 @@ public class BindS3UploadPolicyAndSignature implements Binder {
|
||||||
this.signer = signer;
|
this.signer = signer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
String encodedJson = CryptoStreams.base64(checkNotNull(input, "json").toString().getBytes(Charsets.UTF_8));
|
String encodedJson = CryptoStreams.base64(checkNotNull(input, "json").toString().getBytes(Charsets.UTF_8));
|
||||||
|
@ -53,7 +53,7 @@ public class BindS3UploadPolicyAndSignature implements Binder {
|
||||||
builder.put("Storage.S3.UploadPolicy", encodedJson);
|
builder.put("Storage.S3.UploadPolicy", encodedJson);
|
||||||
String signature = signer.sign(encodedJson);
|
String signature = signer.sign(encodedJson);
|
||||||
builder.put("Storage.S3.UploadPolicySignature", signature);
|
builder.put("Storage.S3.UploadPolicySignature", signature);
|
||||||
return ModifyRequest.putFormParams(request, builder.build());
|
return (R) request.toBuilder().replaceFormParams(builder.build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.ec2.domain.UserIdGroupPair;
|
import org.jclouds.ec2.domain.UserIdGroupPair;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
@ -38,6 +37,7 @@ import com.google.common.collect.ImmutableMultimap.Builder;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindUserIdGroupPairToSourceSecurityGroupFormParams implements Binder {
|
public class BindUserIdGroupPairToSourceSecurityGroupFormParams implements Binder {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
checkArgument(checkNotNull(input, "input") instanceof UserIdGroupPair,
|
checkArgument(checkNotNull(input, "input") instanceof UserIdGroupPair,
|
||||||
|
@ -46,7 +46,6 @@ public class BindUserIdGroupPairToSourceSecurityGroupFormParams implements Binde
|
||||||
Builder<String, String> builder = ImmutableMultimap.builder();
|
Builder<String, String> builder = ImmutableMultimap.builder();
|
||||||
builder.put("SourceSecurityGroupOwnerId", pair.getUserId());
|
builder.put("SourceSecurityGroupOwnerId", pair.getUserId());
|
||||||
builder.put("SourceSecurityGroupName", pair.getGroupName());
|
builder.put("SourceSecurityGroupName", pair.getGroupName());
|
||||||
return ModifyRequest.putFormParams(request, builder.build());
|
return (R) request.toBuilder().replaceFormParams(builder.build()).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.utils.ModifyRequest;
|
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,11 +44,12 @@ public class IfNotNullBindAvailabilityZoneToFormParam implements Binder {
|
||||||
this.param = param;
|
this.param = param;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
checkArgument(input instanceof String, "this binder is only valid for String!");
|
checkArgument(input instanceof String, "this binder is only valid for String!");
|
||||||
return ModifyRequest.addFormParam(request, param, (String) input);
|
return (R) request.toBuilder().replaceFormParam(param, String.class.cast(input)).build();
|
||||||
}
|
}
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,19 +65,19 @@ import com.google.inject.Scopes;
|
||||||
public class EC2RestClientModule<S extends EC2Client, A extends EC2AsyncClient> extends
|
public class EC2RestClientModule<S extends EC2Client, A extends EC2AsyncClient> extends
|
||||||
WithZonesFormSigningRestClientModule<S, A> {
|
WithZonesFormSigningRestClientModule<S, A> {
|
||||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||||
.put(AMIClient.class, AMIAsyncClient.class)//
|
.put(AMIClient.class, AMIAsyncClient.class)//
|
||||||
.put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)//
|
.put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)//
|
||||||
.put(InstanceClient.class, InstanceAsyncClient.class)//
|
.put(InstanceClient.class, InstanceAsyncClient.class)//
|
||||||
.put(KeyPairClient.class, KeyPairAsyncClient.class)//
|
.put(KeyPairClient.class, KeyPairAsyncClient.class)//
|
||||||
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)//
|
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)//
|
||||||
.put(WindowsClient.class, WindowsAsyncClient.class)//
|
.put(WindowsClient.class, WindowsAsyncClient.class)//
|
||||||
.put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)//
|
.put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)//
|
||||||
.put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)//
|
.put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public EC2RestClientModule() {
|
public EC2RestClientModule() {
|
||||||
super((TypeToken) TypeToken.of(EC2Client.class), (TypeToken) TypeToken.of(EC2AsyncClient.class), DELEGATE_MAP);
|
super(TypeToken.class.cast(TypeToken.of(EC2Client.class)), TypeToken.class.cast(TypeToken.of(EC2AsyncClient.class)), DELEGATE_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EC2RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
protected EC2RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedReq
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest<?> gRequest, Set<String> zones) {
|
public static String findAvailabilityZoneInArgsOrNull(GeneratedHttpRequest gRequest, Set<String> zones) {
|
||||||
for (Object arg : gRequest.getArgs()) {
|
for (Object arg : gRequest.getArgs()) {
|
||||||
if (arg instanceof String) {
|
if (arg instanceof String) {
|
||||||
String zone = (String) arg;
|
String zone = (String) arg;
|
||||||
|
|
|
@ -21,12 +21,9 @@ package org.jclouds.ec2.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.ec2.domain.Attachment.Status;
|
import org.jclouds.ec2.domain.Attachment.Status;
|
||||||
import org.jclouds.ec2.domain.BlockDevice;
|
import org.jclouds.ec2.domain.BlockDevice;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -53,7 +50,7 @@ public class BindBlockDeviceMappingToIndexedFormParamsTest {
|
||||||
Date date = new Date(999999l);
|
Date date = new Date(999999l);
|
||||||
mapping.put("cranberry", new BlockDevice("cranberry", Status.ATTACHED, date, false));
|
mapping.put("cranberry", new BlockDevice("cranberry", Status.ATTACHED, date, false));
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, mapping);
|
request = binder.bindToRequest(request, mapping);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
request.getPayload().getRawContent(),
|
request.getPayload().getRawContent(),
|
||||||
|
@ -62,13 +59,13 @@ public class BindBlockDeviceMappingToIndexedFormParamsTest {
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustBeBlockDeviceMapping() {
|
public void testMustBeBlockDeviceMapping() {
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
binder.bindToRequest(request, new File("foo"));
|
binder.bindToRequest(request, new File("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNullIsBad() {
|
public void testNullIsBad() {
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ package org.jclouds.ec2.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -43,20 +40,20 @@ public class BindBundleIdsToIndexedFormParamsTest {
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
|
request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
|
||||||
assertEquals(request.getPayload().getRawContent(), "BundleId.1=alpha&BundleId.2=omega");
|
assertEquals(request.getPayload().getRawContent(), "BundleId.1=alpha&BundleId.2=omega");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustBeArray() {
|
public void testMustBeArray() {
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
binder.bindToRequest(request, new File("foo"));
|
binder.bindToRequest(request, new File("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNullIsBad() {
|
public void testNullIsBad() {
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ package org.jclouds.ec2.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -43,20 +40,20 @@ public class BindGroupNamesToIndexedFormParamsTest {
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
|
request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
|
||||||
assertEquals(request.getPayload().getRawContent(), "GroupName.1=alpha&GroupName.2=omega");
|
assertEquals(request.getPayload().getRawContent(), "GroupName.1=alpha&GroupName.2=omega");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustBeArray() {
|
public void testMustBeArray() {
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
binder.bindToRequest(request, new File("foo"));
|
binder.bindToRequest(request, new File("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNullIsBad() {
|
public void testNullIsBad() {
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ package org.jclouds.ec2.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -43,20 +40,20 @@ public class BindInstanceIdsToIndexedFormParamsTest {
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
|
request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
|
||||||
assertEquals(request.getPayload().getRawContent(), "InstanceId.1=alpha&InstanceId.2=omega");
|
assertEquals(request.getPayload().getRawContent(), "InstanceId.1=alpha&InstanceId.2=omega");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustBeArray() {
|
public void testMustBeArray() {
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
binder.bindToRequest(request, new File("foo"));
|
binder.bindToRequest(request, new File("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNullIsBad() {
|
public void testNullIsBad() {
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ package org.jclouds.ec2.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -43,20 +40,20 @@ public class BindKeyNamesToIndexedFormParamsTest {
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
|
request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
|
||||||
assertEquals(request.getPayload().getRawContent(), "KeyName.1=alpha&KeyName.2=omega");
|
assertEquals(request.getPayload().getRawContent(), "KeyName.1=alpha&KeyName.2=omega");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustBeArray() {
|
public void testMustBeArray() {
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
binder.bindToRequest(request, new File("foo"));
|
binder.bindToRequest(request, new File("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNullIsBad() {
|
public void testNullIsBad() {
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ package org.jclouds.ec2.binders;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.HttpMethod;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -44,20 +41,20 @@ public class BindProductCodesToIndexedFormParamsTest {
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("POST").endpoint(URI.create("http://localhost")).build();
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
|
||||||
request = binder.bindToRequest(request, ImmutableSet.of("alpha", "omega"));
|
request = binder.bindToRequest(request, ImmutableSet.of("alpha", "omega"));
|
||||||
assertEquals(request.getPayload().getRawContent(), "ProductCode.1=alpha&ProductCode.2=omega");
|
assertEquals(request.getPayload().getRawContent(), "ProductCode.1=alpha&ProductCode.2=omega");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustBeIterable() {
|
public void testMustBeIterable() {
|
||||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
|
||||||
binder.bindToRequest(request, new File("foo"));
|
binder.bindToRequest(request, new File("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNullIsBad() {
|
public void testNullIsBad() {
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue