diff --git a/apis/route53/src/test/java/org/jclouds/route53/Route53ApiExpectTest.java b/apis/route53/src/test/java/org/jclouds/route53/Route53ApiExpectTest.java
index 7157ceb168..65f63d8b5c 100644
--- a/apis/route53/src/test/java/org/jclouds/route53/Route53ApiExpectTest.java
+++ b/apis/route53/src/test/java/org/jclouds/route53/Route53ApiExpectTest.java
@@ -18,6 +18,10 @@
*/
package org.jclouds.route53;
+import static com.google.common.net.HttpHeaders.DATE;
+import static com.google.common.net.HttpHeaders.HOST;
+import static javax.ws.rs.HttpMethod.GET;
+import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
@@ -33,15 +37,14 @@ import org.testng.annotations.Test;
@Test(groups = "unit", testName = "Route53ApiExpectTest")
public class Route53ApiExpectTest extends BaseRoute53ApiExpectTest {
- HttpRequest getChange = HttpRequest.builder().method("GET")
+ HttpRequest getChange = HttpRequest.builder().method(GET)
.endpoint("https://route53.amazonaws.com/2012-02-29/change/C2682N5HXP0BZ4")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
-
.build();
- HttpResponse getChangeResponse = HttpResponse.builder().statusCode(200)
+ HttpResponse getChangeResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromResourceWithContentType("/change.xml", "text/xml")).build();
public void testGetChangeWhenResponseIs2xx() {
diff --git a/apis/route53/src/test/java/org/jclouds/route53/features/HostedZoneApiExpectTest.java b/apis/route53/src/test/java/org/jclouds/route53/features/HostedZoneApiExpectTest.java
index d336afe8eb..1aa50c0d0b 100644
--- a/apis/route53/src/test/java/org/jclouds/route53/features/HostedZoneApiExpectTest.java
+++ b/apis/route53/src/test/java/org/jclouds/route53/features/HostedZoneApiExpectTest.java
@@ -17,7 +17,11 @@
* under the License.
*/
package org.jclouds.route53.features;
-
+import static com.google.common.net.HttpHeaders.DATE;
+import static com.google.common.net.HttpHeaders.HOST;
+import static javax.ws.rs.HttpMethod.GET;
+import static javax.ws.rs.HttpMethod.POST;
+import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
@@ -39,17 +43,17 @@ import com.google.common.collect.ImmutableSet;
*/
@Test(groups = "unit", testName = "HostedZoneApiExpectTest")
public class HostedZoneApiExpectTest extends BaseRoute53ApiExpectTest {
- HttpRequest createWithReference = HttpRequest.builder().method("POST")
+ HttpRequest createWithReference = HttpRequest.builder().method(POST)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.payload(
payloadFromStringWithContentType(
"jclouds.org.expect",
"application/xml")).build();
- HttpResponse createResponse = HttpResponse.builder().statusCode(200)
+ HttpResponse createResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromResourceWithContentType("/new_zone.xml", "text/xml")).build();
public void testCreateWithReferenceWhenResponseIs2xx() {
@@ -58,10 +62,10 @@ public class HostedZoneApiExpectTest extends BaseRoute53ApiExpectTest {
new CreateHostedZoneResponseTest().expected().toString());
}
- HttpRequest createWithReferenceAndComment = HttpRequest.builder().method("POST")
+ HttpRequest createWithReferenceAndComment = HttpRequest.builder().method(POST)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.payload(
payloadFromStringWithContentType(
@@ -74,14 +78,14 @@ public class HostedZoneApiExpectTest extends BaseRoute53ApiExpectTest {
new CreateHostedZoneResponseTest().expected().toString());
}
- HttpRequest get = HttpRequest.builder().method("GET")
+ HttpRequest get = HttpRequest.builder().method(GET)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1XTHCPEFRWV1X")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.build();
- HttpResponse getResponse = HttpResponse.builder().statusCode(200)
+ HttpResponse getResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromResourceWithContentType("/hosted_zone.xml", "text/xml")).build();
public void testGetWhenResponseIs2xx() {
@@ -95,14 +99,14 @@ public class HostedZoneApiExpectTest extends BaseRoute53ApiExpectTest {
assertNull(fail.getHostedZoneApi().get("Z1XTHCPEFRWV1X"));
}
- HttpRequest list = HttpRequest.builder().method("GET")
+ HttpRequest list = HttpRequest.builder().method(GET)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.build();
- HttpResponse listResponse = HttpResponse.builder().statusCode(200)
+ HttpResponse listResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromResourceWithContentType("/hosted_zones.xml", "text/xml")).build();
public void testListWhenResponseIs2xx() {
@@ -118,10 +122,10 @@ public class HostedZoneApiExpectTest extends BaseRoute53ApiExpectTest {
assertEquals(fail.getHostedZoneApi().list().get(0).toSet(), ImmutableSet.of());
}
- HttpRequest listAt = HttpRequest.builder().method("GET")
+ HttpRequest listAt = HttpRequest.builder().method(GET)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone?marker=Z333333YYYYYYY")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.build();
@@ -132,7 +136,7 @@ public class HostedZoneApiExpectTest extends BaseRoute53ApiExpectTest {
}
public void testList2PagesWhenResponseIs2xx() {
- HttpResponse noMore = HttpResponse.builder().statusCode(200)
+ HttpResponse noMore = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromStringWithContentType("", "text/xml")).build();
Route53Api success = requestsSendResponses(list, listResponse, listAt, noMore);
@@ -142,12 +146,12 @@ public class HostedZoneApiExpectTest extends BaseRoute53ApiExpectTest {
HttpRequest delete = HttpRequest.builder().method("DELETE")
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1XTHCPEFRWV1X")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.build();
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromResourceWithContentType("/change.xml", "text/xml")).build();
public void testDeleteWhenResponseIs2xx() {
diff --git a/apis/route53/src/test/java/org/jclouds/route53/features/ResourceRecordSetApiExpectTest.java b/apis/route53/src/test/java/org/jclouds/route53/features/ResourceRecordSetApiExpectTest.java
index e0e6e1638a..58e692677a 100644
--- a/apis/route53/src/test/java/org/jclouds/route53/features/ResourceRecordSetApiExpectTest.java
+++ b/apis/route53/src/test/java/org/jclouds/route53/features/ResourceRecordSetApiExpectTest.java
@@ -17,7 +17,12 @@
* under the License.
*/
package org.jclouds.route53.features;
-
+import static com.google.common.net.HttpHeaders.DATE;
+import static com.google.common.net.HttpHeaders.HOST;
+import static javax.ws.rs.HttpMethod.GET;
+import static javax.ws.rs.HttpMethod.POST;
+import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
+import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import org.jclouds.http.HttpRequest;
@@ -41,14 +46,14 @@ import com.google.common.collect.ImmutableSet;
@Test(groups = "unit", testName = "ResourceResourceRecordSetApiExpectTest")
public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
- HttpRequest create = HttpRequest.builder().method("POST")
+ HttpRequest create = HttpRequest.builder().method(POST)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.payload(payloadFromResourceWithContentType("/create_rrs_request.xml", "application/xml")).build();
- HttpResponse jobResponse = HttpResponse.builder().statusCode(200)
+ HttpResponse jobResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromResourceWithContentType("/change.xml", "text/xml")).build();
public void testCreateWhenResponseIs2xx() {
@@ -57,10 +62,10 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
new GetChangeResponseTest().expected().toString());
}
- HttpRequest apply = HttpRequest.builder().method("POST")
+ HttpRequest apply = HttpRequest.builder().method(POST)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.payload(payloadFromResourceWithContentType("/batch_rrs_request.xml", "application/xml")).build();
@@ -76,7 +81,7 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
@Test(expectedExceptions = InvalidChangeBatchException.class, expectedExceptionsMessageRegExp = "\\[Tried to create resource record set duplicate.example.com. type A, but it already exists, Tried to delete resource record set noexist.example.com. type A, but it was not found\\]")
public void testApplyWhenResponseIs4xx() {
- HttpResponse batchErrorFound = HttpResponse.builder().statusCode(400)
+ HttpResponse batchErrorFound = HttpResponse.builder().statusCode(BAD_REQUEST.getStatusCode())
.payload(payloadFromResourceWithContentType("/invalid_change_batch.xml", "application/xml")).build();
Route53Api fails = requestSendsResponse(apply, batchErrorFound);
@@ -87,19 +92,19 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
.build());
}
- HttpRequest list = HttpRequest.builder().method("GET")
+ HttpRequest list = HttpRequest.builder().method(GET)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate).build();
- HttpResponse listResponse = HttpResponse.builder().statusCode(200)
+ HttpResponse listResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromResourceWithContentType("/rrsets.xml", "text/xml")).build();
public void testListWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(list, listResponse);
- assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().get(0).toString(), new ListResourceRecordSetsResponseTest().expected()
- .toString());
+ assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().get(0).toString(),
+ new ListResourceRecordSetsResponseTest().expected().toString());
}
// TODO: this should really be an empty set
@@ -109,10 +114,10 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
assertEquals(fail.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().get(0).toSet(), ImmutableSet.of());
}
- HttpRequest listAt = HttpRequest.builder().method("GET")
+ HttpRequest listAt = HttpRequest.builder().method(GET)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset?name=testdoc2.example.com")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate).build();
public void testListAtWhenResponseIs2xx() {
@@ -122,10 +127,10 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
new ListResourceRecordSetsResponseTest().expected().toString());
}
- HttpRequest listAtNameAndType = HttpRequest.builder().method("GET")
+ HttpRequest listAtNameAndType = HttpRequest.builder().method(GET)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset?name=testdoc2.example.com&type=NS")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate).build();
public void testListAtNameAndTypeWhenResponseIs2xx() {
@@ -136,24 +141,28 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
}
public void testList2PagesWhenResponseIs2xx() {
- HttpResponse noMore = HttpResponse.builder().statusCode(200)
+ HttpResponse noMore = HttpResponse.builder().statusCode(OK.getStatusCode())
.payload(payloadFromStringWithContentType("", "text/xml")).build();
Route53Api success = requestsSendResponses(list, listResponse, listAtNameAndType, noMore);
- assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().concat().toSet(), new ListResourceRecordSetsResponseTest().expected()
- .toSet());
+ assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().concat().toSet(),
+ new ListResourceRecordSetsResponseTest().expected().toSet());
}
- HttpRequest delete = HttpRequest.builder().method("POST")
+ HttpRequest delete = HttpRequest.builder().method(POST)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", authForDate)
.payload(payloadFromResourceWithContentType("/delete_rrs_request.xml", "application/xml")).build();
public void testDeleteWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(delete, jobResponse);
- assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").create(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").ttl(0).add("my texts").build()).toString(),
+ assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").create(ResourceRecordSet.builder()
+ .name("jclouds.org.")
+ .type("TXT")
+ .ttl(0)
+ .add("my texts").build()).toString(),
new GetChangeResponseTest().expected().toString());
}
}
diff --git a/apis/route53/src/test/java/org/jclouds/route53/handlers/Route53ErrorHandlerTest.java b/apis/route53/src/test/java/org/jclouds/route53/handlers/Route53ErrorHandlerTest.java
index 63d7db8ed8..f711acd0cc 100644
--- a/apis/route53/src/test/java/org/jclouds/route53/handlers/Route53ErrorHandlerTest.java
+++ b/apis/route53/src/test/java/org/jclouds/route53/handlers/Route53ErrorHandlerTest.java
@@ -18,8 +18,11 @@
*/
package org.jclouds.route53.handlers;
-
import static com.google.common.base.Throwables.propagate;
+import static com.google.common.net.HttpHeaders.DATE;
+import static com.google.common.net.HttpHeaders.HOST;
+import static javax.ws.rs.HttpMethod.POST;
+import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static org.jclouds.rest.internal.BaseRestApiExpectTest.payloadFromStringWithContentType;
import static org.jclouds.util.Strings2.toStringAndClose;
import static org.testng.Assert.assertEquals;
@@ -38,7 +41,6 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Guice;
-
/**
*
* @author Adrian Cole
@@ -47,17 +49,17 @@ import com.google.inject.Guice;
public class Route53ErrorHandlerTest {
Route53ErrorHandler function = Guice.createInjector(new SaxParserModule()).getInstance(Route53ErrorHandler.class);
- HttpRequest request = HttpRequest.builder().method("POST")
+ HttpRequest request = HttpRequest.builder().method(POST)
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset")
- .addHeader("Host", "route53.amazonaws.com")
- .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
+ .addHeader(HOST, "route53.amazonaws.com")
+ .addHeader(DATE, "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", "AWS3-HTTPS AWSAccessKeyId=identity,Algorithm=HmacSHA256,Signature=pylxNiLcrsjNRZOsxyT161JCwytVPHyc2rFfmNCuZKI=")
.payload(payloadFromResource("/batch_rrs_request.xml")).build();
HttpCommand command = new HttpCommand(request);
@Test
public void testInvalidChangeBatchException() throws IOException {
- HttpResponse response = HttpResponse.builder().statusCode(400)
+ HttpResponse response = HttpResponse.builder().statusCode(BAD_REQUEST.getStatusCode())
.payload(payloadFromResource("/invalid_change_batch.xml")).build();
function.handleError(command, response);
@@ -71,7 +73,7 @@ public class Route53ErrorHandlerTest {
@Test
public void testDeleteNotFound() throws IOException {
- HttpResponse response = HttpResponse.builder().statusCode(400)
+ HttpResponse response = HttpResponse.builder().statusCode(BAD_REQUEST.getStatusCode())
.payload(
payloadFromStringWithContentType(
"SenderInvalidChangeBatch
"
diff --git a/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ExpectTest.java b/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ExpectTest.java
index 3b0239982e..78f6f066ee 100644
--- a/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ExpectTest.java
+++ b/apis/route53/src/test/java/org/jclouds/route53/internal/BaseRoute53ExpectTest.java
@@ -18,6 +18,8 @@
*/
package org.jclouds.route53.internal;
+import static javax.ws.rs.core.Response.Status.NOT_FOUND;
+
import org.jclouds.date.DateService;
import org.jclouds.http.HttpResponse;
import org.jclouds.rest.ConfiguresRestClient;
@@ -25,7 +27,6 @@ import org.jclouds.rest.internal.BaseRestApiExpectTest;
import org.jclouds.route53.config.Route53RestClientModule;
import com.google.inject.Module;
-
/**
*
* @author Adrian Cole
@@ -45,7 +46,7 @@ public class BaseRoute53ExpectTest extends BaseRestApiExpectTest {
}
}
- protected final HttpResponse notFound = HttpResponse.builder().statusCode(404).build();
+ protected final HttpResponse notFound = HttpResponse.builder().statusCode(NOT_FOUND.getStatusCode()).build();
protected final String authForDate = "AWS3-HTTPS AWSAccessKeyId=identity,Algorithm=HmacSHA256,Signature=pylxNiLcrsjNRZOsxyT161JCwytVPHyc2rFfmNCuZKI=";
@Override