use more constants in cloudloadbalancers tests

This commit is contained in:
adriancole 2013-04-09 20:55:38 -07:00
parent e22be464d0
commit 091ef98dc9
13 changed files with 174 additions and 156 deletions

View File

@ -17,20 +17,21 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.POST;
import static javax.ws.rs.core.MediaType.WILDCARD;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.net.URI;
import java.util.List;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRule;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRuleWithId;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.AccessRuleApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test;
@ -47,7 +48,7 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/accesslist-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/accesslist-list.json")).build()
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
Iterable<AccessRuleWithId> accessList = api.list();
@ -59,8 +60,8 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
AccessRuleApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("POST").endpoint(endpoint).payload(payloadFromResource("/accesslist-create.json")).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(POST).endpoint(endpoint).payload(payloadFromResource("/accesslist-create.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
AccessRule accessRule1 = AccessRule.deny("206.160.163.21");
@ -76,8 +77,8 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
AccessRuleApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.delete(23));
@ -88,8 +89,8 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
AccessRuleApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
List<Integer> accessRuleIds = ImmutableList.<Integer> of(23, 24);
@ -101,8 +102,8 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
AccessRuleApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.deleteAll());

View File

@ -17,19 +17,20 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.PUT;
import static javax.ws.rs.core.MediaType.WILDCARD;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.net.URI;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.ConnectionThrottle;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.ConnectionApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test;
@ -44,7 +45,7 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/connectionthrottle-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/connectionthrottle-get.json")).build()
).getConnectionApiForZoneAndLoadBalancer("DFW", 2000);
ConnectionThrottle connectionThrottle = api.getConnectionThrottle();
@ -57,7 +58,7 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/connectionthrottle-get-deleted.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/connectionthrottle-get-deleted.json")).build()
).getConnectionApiForZoneAndLoadBalancer("DFW", 2000);
ConnectionThrottle connectionThrottle = api.getConnectionThrottle();
@ -69,8 +70,8 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
ConnectionApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/connectionthrottle-create.json")).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/connectionthrottle-create.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getConnectionApiForZoneAndLoadBalancer("DFW", 2000);
api.createOrUpdateConnectionThrottle(getConnectionThrottle());
@ -90,8 +91,8 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
ConnectionApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getConnectionApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.deleteConnectionThrottle());
@ -103,7 +104,7 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/connectionlogging-enable.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/connectionlogging-enable.json")).build()
).getConnectionApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.isConnectionLogging());
@ -114,8 +115,8 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
ConnectionApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/connectionlogging-enable.json")).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/connectionlogging-enable.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getConnectionApiForZoneAndLoadBalancer("DFW", 2000);
api.enableConnectionLogging();
@ -126,8 +127,8 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
ConnectionApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/connectionlogging-disable.json")).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/connectionlogging-disable.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getConnectionApiForZoneAndLoadBalancer("DFW", 2000);
api.disableConnectionLogging();

View File

@ -17,14 +17,14 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static javax.ws.rs.HttpMethod.PUT;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertTrue;
import java.net.URI;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.ContentCachingApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test;
@ -39,7 +39,7 @@ public class ContentCachingApiExpectTest extends BaseCloudLoadBalancerApiExpectT
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/contentcaching-enable.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/contentcaching-enable.json")).build()
).getContentCachingApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.isContentCaching());
@ -50,8 +50,8 @@ public class ContentCachingApiExpectTest extends BaseCloudLoadBalancerApiExpectT
ContentCachingApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/contentcaching-enable.json")).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/contentcaching-enable.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getContentCachingApiForZoneAndLoadBalancer("DFW", 2000);
api.enable();
@ -62,8 +62,8 @@ public class ContentCachingApiExpectTest extends BaseCloudLoadBalancerApiExpectT
ContentCachingApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/contentcaching-disable.json")).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/contentcaching-disable.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getContentCachingApiForZoneAndLoadBalancer("DFW", 2000);
api.disable();

View File

@ -17,18 +17,20 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.PUT;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.WILDCARD;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.io.IOException;
import java.net.URI;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.ErrorPageApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
@ -55,8 +57,8 @@ public class ErrorPageApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<C
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder()
.statusCode(200)
.payload(payloadFromStringWithContentType("{\"errorpage\":{\"content\":\"" + contentEscaped + "\"}}", MediaType.APPLICATION_JSON))
.statusCode(OK.getStatusCode())
.payload(payloadFromStringWithContentType("{\"errorpage\":{\"content\":\"" + contentEscaped + "\"}}", APPLICATION_JSON))
.build()
).getErrorPageApiForZoneAndLoadBalancer("DFW", 2000);
@ -70,12 +72,12 @@ public class ErrorPageApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<C
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET()
.method("PUT")
.method(PUT)
.endpoint(endpoint)
.replaceHeader("Accept", MediaType.WILDCARD)
.payload(payloadFromStringWithContentType("{\"errorpage\":{\"content\":\"" + contentEscaped + "\"}}", MediaType.APPLICATION_JSON))
.replaceHeader(ACCEPT, WILDCARD)
.payload(payloadFromStringWithContentType("{\"errorpage\":{\"content\":\"" + contentEscaped + "\"}}", APPLICATION_JSON))
.build(),
HttpResponse.builder().statusCode(200).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getErrorPageApiForZoneAndLoadBalancer("DFW", 2000);
api.create(contentEscaped);
@ -86,8 +88,8 @@ public class ErrorPageApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<C
ErrorPageApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getErrorPageApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.delete());

View File

@ -17,19 +17,20 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.PUT;
import static javax.ws.rs.core.MediaType.WILDCARD;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.net.URI;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.HealthMonitor;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.HealthMonitorApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test;
@ -44,7 +45,7 @@ public class HealthMonitorApiExpectTest extends BaseCloudLoadBalancerApiExpectTe
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/healthmonitor-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/healthmonitor-get.json")).build()
).getHealthMonitorApiForZoneAndLoadBalancer("DFW", 2000);
HealthMonitor healthMonitor = api.get();
@ -57,7 +58,7 @@ public class HealthMonitorApiExpectTest extends BaseCloudLoadBalancerApiExpectTe
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/healthmonitor-get-deleted.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/healthmonitor-get-deleted.json")).build()
).getHealthMonitorApiForZoneAndLoadBalancer("DFW", 2000);
HealthMonitor healthMonitor = api.get();
@ -69,8 +70,8 @@ public class HealthMonitorApiExpectTest extends BaseCloudLoadBalancerApiExpectTe
HealthMonitorApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/healthmonitor-create.json")).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/healthmonitor-create.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getHealthMonitorApiForZoneAndLoadBalancer("DFW", 2000);
api.createOrUpdate(getConnectHealthMonitor());
@ -81,8 +82,8 @@ public class HealthMonitorApiExpectTest extends BaseCloudLoadBalancerApiExpectTe
HealthMonitorApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getHealthMonitorApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.delete());

View File

@ -17,25 +17,29 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.POST;
import static javax.ws.rs.HttpMethod.PUT;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.WILDCARD;
import static javax.ws.rs.core.Response.Status.ACCEPTED;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.net.URI;
import java.util.Set;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.LoadBalancerApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseLoadBalancerTest;
import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseLoadBalancersTest;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
@ -56,7 +60,7 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancers-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/loadbalancers-list.json")).build()
).getLoadBalancerApiForZone("DFW");
Set<LoadBalancer> loadBalancers = api.list().concat().toSet();
@ -69,7 +73,7 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancer-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/loadbalancer-get.json")).build()
).getLoadBalancerApiForZone("DFW");
LoadBalancer loadBalancer = api.get(2000);
@ -82,11 +86,11 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET()
.method("POST")
.method(POST)
.payload(payloadFromResource("/loadbalancer-create.json"))
.endpoint(endpoint)
.build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancer-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/loadbalancer-get.json")).build()
).getLoadBalancerApiForZone("DFW");
AddNode addNode1 = AddNode.builder()
@ -122,8 +126,8 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
LoadBalancerApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").payload(payloadFromResource("/loadbalancer-update.json")).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(202).payload("").build()
authenticatedGET().method(PUT).payload(payloadFromResource("/loadbalancer-update.json")).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(ACCEPTED.getStatusCode()).payload("").build()
).getLoadBalancerApiForZone("DFW");
UpdateLoadBalancer updateLB = UpdateLoadBalancer.builder()
@ -142,11 +146,11 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET()
.method("DELETE")
.replaceHeader("Accept", MediaType.WILDCARD)
.method(DELETE)
.replaceHeader(ACCEPT, WILDCARD)
.endpoint(endpoint)
.build(),
HttpResponse.builder().statusCode(202).payload("").build()
HttpResponse.builder().statusCode(ACCEPTED.getStatusCode()).payload("").build()
).getLoadBalancerApiForZone("DFW");
api.delete(2000);
@ -158,7 +162,7 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/metadata-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/metadata-list.json")).build()
).getLoadBalancerApiForZone("DFW");
Metadata metadata = api.getMetadata(2000);
@ -171,10 +175,10 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET()
.method("POST")
.method(POST)
.endpoint(endpoint)
.payload(payloadFromResourceWithContentType("/metadata-create.json", MediaType.APPLICATION_JSON)).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/metadata-list.json")).build()
.payload(payloadFromResourceWithContentType("/metadata-create.json", APPLICATION_JSON)).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/metadata-list.json")).build()
).getLoadBalancerApiForZone("DFW");
Metadata metadata = api.createMetadata(2000, getExpectedMetadata());
@ -186,8 +190,8 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
LoadBalancerApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getLoadBalancerApiForZone("DFW");
assertTrue(api.deleteMetadatum(2000, 23));
@ -198,8 +202,8 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
LoadBalancerApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getLoadBalancerApiForZone("DFW");

View File

@ -17,22 +17,25 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.POST;
import static javax.ws.rs.HttpMethod.PUT;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.WILDCARD;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.net.URI;
import java.util.Set;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test;
@ -51,7 +54,7 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nodes-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/nodes-list.json")).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
Set<Node> nodes = api.list().concat().toSet();
@ -64,7 +67,7 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/node-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/node-get.json")).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
Node node = api.get(410);
@ -77,11 +80,11 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET()
.method("POST")
.payload(payloadFromResourceWithContentType("/nodes-add.json", MediaType.APPLICATION_JSON))
.method(POST)
.payload(payloadFromResourceWithContentType("/nodes-add.json", APPLICATION_JSON))
.endpoint(endpoint)
.build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nodes-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/nodes-list.json")).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
AddNode addNode1 = AddNode.builder()
@ -117,8 +120,8 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
NodeApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").payload(payloadFromResource("/node-update.json")).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(PUT).payload(payloadFromResource("/node-update.json")).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
UpdateNode updateNode = UpdateNode.builder()
@ -135,8 +138,8 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
NodeApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").replaceHeader("Accept", MediaType.WILDCARD).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).replaceHeader(ACCEPT, WILDCARD).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
api.remove(410);
@ -147,8 +150,8 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
NodeApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").replaceHeader("Accept", MediaType.WILDCARD).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).replaceHeader(ACCEPT, WILDCARD).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
Set<Integer> nodeIds = ImmutableSortedSet.<Integer> of(410, 411);
@ -162,7 +165,7 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/metadata-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/metadata-list.json")).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
Metadata metadata = api.getMetadata(410);
@ -175,10 +178,10 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET()
.method("POST")
.method(POST)
.endpoint(endpoint)
.payload(payloadFromResourceWithContentType("/metadata-create.json", MediaType.APPLICATION_JSON)).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/metadata-list.json")).build()
.payload(payloadFromResourceWithContentType("/metadata-create.json", APPLICATION_JSON)).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/metadata-list.json")).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
Metadata metadata = api.createMetadata(410, getExpectedMetadata());
@ -190,8 +193,8 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
NodeApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.deleteMetadatum(410, 23));
@ -202,8 +205,8 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
NodeApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000);

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import java.net.URI;
@ -31,7 +31,6 @@ import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerStats;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUsage;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Protocol;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.ReportApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.functions.DateParser;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test;
@ -62,7 +61,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<Clou
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/report-billable-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/report-billable-list.json")).build()
).getReportApiForZone("DFW");
FluentIterable<LoadBalancer> loadBalancers = api.listBillableLoadBalancers(aWeekAgo, today).concat();
@ -88,7 +87,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<Clou
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/report-historical-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/report-historical-get.json")).build()
).getReportApiForZone("DFW");
HistoricalUsage historicalUsage = api.getHistoricalUsage(aWeekAgo, today);
@ -116,7 +115,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<Clou
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/report-loadbalancerusage-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/report-loadbalancerusage-list.json")).build()
).getReportApiForZone("DFW");
FluentIterable<LoadBalancerUsage> loadBalancerUsages = api.listLoadBalancerUsage(2000, aWeekAgo, today).concat();
@ -130,7 +129,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<Clou
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/report-loadbalancerusage-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/report-loadbalancerusage-list.json")).build()
).getReportApiForZone("DFW");
FluentIterable<LoadBalancerUsage> loadBalancerUsages = api.listCurrentLoadBalancerUsage(2000).concat();
@ -144,7 +143,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<Clou
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/report-loadbalancerstats-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/report-loadbalancerstats-get.json")).build()
).getReportApiForZone("DFW");
LoadBalancerStats loadBalancerStats = api.getLoadBalancerStats(2000);
@ -163,7 +162,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<Clou
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/report-protocols-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/report-protocols-list.json")).build()
).getReportApiForZone("DFW");
Iterable<Protocol> protocols = api.listProtocols();
@ -177,7 +176,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<Clou
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/report-algorithms-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/report-algorithms-list.json")).build()
).getReportApiForZone("DFW");
Iterable<String> algorithms = api.listAlgorithms();

View File

@ -17,20 +17,23 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.PUT;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static javax.ws.rs.core.MediaType.WILDCARD;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import java.io.IOException;
import java.net.URI;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SSLTermination;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.SSLTerminationApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
@ -47,7 +50,7 @@ public class SSLTerminationApiExpectTest extends BaseCloudLoadBalancerApiExpectT
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/ssltermination-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/ssltermination-get.json")).build()
).getSSLTerminationApiForZoneAndLoadBalancer("DFW", 2000);
SSLTermination sslTermination = api.get();
@ -60,7 +63,7 @@ public class SSLTerminationApiExpectTest extends BaseCloudLoadBalancerApiExpectT
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(404).build()
HttpResponse.builder().statusCode(NOT_FOUND.getStatusCode()).build()
).getSSLTerminationApiForZoneAndLoadBalancer("DFW", 2000);
SSLTermination sslTermination = api.get();
@ -73,11 +76,11 @@ public class SSLTerminationApiExpectTest extends BaseCloudLoadBalancerApiExpectT
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET()
.method("PUT")
.method(PUT)
.endpoint(endpoint)
.payload(payloadFromResourceWithContentType("/ssltermination-create.json", MediaType.APPLICATION_JSON))
.payload(payloadFromResourceWithContentType("/ssltermination-create.json", APPLICATION_JSON))
.build(),
HttpResponse.builder().statusCode(200).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getSSLTerminationApiForZoneAndLoadBalancer("DFW", 2000);
api.createOrUpdate(getSSLTermination());
@ -88,8 +91,8 @@ public class SSLTerminationApiExpectTest extends BaseCloudLoadBalancerApiExpectT
SSLTerminationApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getSSLTerminationApiForZoneAndLoadBalancer("DFW", 2000);
assertTrue(api.delete());

View File

@ -17,7 +17,9 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.PUT;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
@ -26,7 +28,6 @@ import java.net.URI;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SessionPersistence;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.SessionPersistenceApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test;
@ -41,7 +42,7 @@ public class SessionPersistenceApiExpectTest extends BaseCloudLoadBalancerApiExp
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/sessionpersistence-get.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/sessionpersistence-get.json")).build()
).getSessionPersistenceApiForZoneAndLoadBalancer("DFW", 2000);
SessionPersistence sessionPersistence = api.get();
@ -54,7 +55,7 @@ public class SessionPersistenceApiExpectTest extends BaseCloudLoadBalancerApiExp
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/sessionpersistence-get-deleted.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/sessionpersistence-get-deleted.json")).build()
).getSessionPersistenceApiForZoneAndLoadBalancer("DFW", 2000);
SessionPersistence sessionPersistence = api.get();
@ -66,8 +67,8 @@ public class SessionPersistenceApiExpectTest extends BaseCloudLoadBalancerApiExp
SessionPersistenceApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/sessionpersistence-create.json")).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/sessionpersistence-create.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getSessionPersistenceApiForZoneAndLoadBalancer("DFW", 2000);
api.create(SessionPersistence.HTTP_COOKIE);
@ -78,8 +79,8 @@ public class SessionPersistenceApiExpectTest extends BaseCloudLoadBalancerApiExp
SessionPersistenceApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getSessionPersistenceApiForZoneAndLoadBalancer("DFW", 2000);
api.delete();

View File

@ -17,19 +17,20 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.features;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.DELETE;
import static javax.ws.rs.HttpMethod.POST;
import static javax.ws.rs.core.MediaType.WILDCARD;
import static javax.ws.rs.core.Response.Status.OK;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import java.util.List;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIPWithId;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.VirtualIPApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test;
@ -46,7 +47,7 @@ public class VirtualIPApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<C
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().endpoint(endpoint).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/virtualips-list.json")).build()
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/virtualips-list.json")).build()
).getVirtualIPApiForZoneAndLoadBalancer("DFW", 2000);
Iterable<VirtualIPWithId> virtualIPs = api.list();
@ -58,8 +59,8 @@ public class VirtualIPApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<C
VirtualIPApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("POST").endpoint(endpoint).payload(payloadFromResource("/virtualips-create.json")).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/virtualips-create-response.json")).build()
authenticatedGET().method(POST).endpoint(endpoint).payload(payloadFromResource("/virtualips-create.json")).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/virtualips-create-response.json")).build()
).getVirtualIPApiForZoneAndLoadBalancer("DFW", 2000);
api.create(VirtualIP.publicIPv6());
@ -70,8 +71,8 @@ public class VirtualIPApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<C
VirtualIPApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getVirtualIPApiForZoneAndLoadBalancer("DFW", 2000);
api.delete(23);
@ -82,8 +83,8 @@ public class VirtualIPApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<C
VirtualIPApi api = requestsSendResponses(
rackspaceAuthWithUsernameAndApiKey,
responseWithAccess,
authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(),
HttpResponse.builder().statusCode(200).build()
authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(),
HttpResponse.builder().statusCode(OK.getStatusCode()).build()
).getVirtualIPApiForZoneAndLoadBalancer("DFW", 2000);
List<Integer> virtualIPIds = ImmutableList.<Integer> of(23, 24);

View File

@ -17,11 +17,12 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.handlers;
import static javax.ws.rs.HttpMethod.GET;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import java.net.URI;
import org.jclouds.http.handlers.BaseHttpErrorHandlerTest;
import org.jclouds.rackspace.cloudloadbalancers.v1.handlers.ParseCloudLoadBalancersErrorFromHttpResponse;
import org.jclouds.rest.ResourceNotFoundException;
import org.testng.annotations.Test;
@ -33,11 +34,11 @@ import org.testng.annotations.Test;
public class ParseCloudLoadBalancersErrorFromHttpResponseTest extends
BaseHttpErrorHandlerTest<ParseCloudLoadBalancersErrorFromHttpResponse> {
@Test
public void test404NotFound() {
public void testNotFound() {
assertCodeMakes(
"GET",
GET,
URI.create("https://ord.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers/2000"),
404,
NOT_FOUND.getStatusCode(),
"Not Found",
"<itemNotFound code=\"404\" xmlns=\"http://docs.openstack.org/loadbalancers/api/v1.0\">\n <message>Object not Found</message>\n</itemNotFound>",
ResourceNotFoundException.class, "loadbalancers 2000 not found");

View File

@ -17,8 +17,9 @@
* under the License.
*/
package org.jclouds.rackspace.cloudloadbalancers.v1.internal;
import javax.ws.rs.core.MediaType;
import static com.google.common.net.HttpHeaders.ACCEPT;
import static javax.ws.rs.HttpMethod.GET;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
@ -53,8 +54,8 @@ public class BaseCloudLoadBalancerApiExpectTest<T> extends BaseRestApiExpectTest
protected HttpRequest.Builder<?> authenticatedGET() {
return HttpRequest.builder()
.method("GET")
.addHeader("Accept", MediaType.APPLICATION_JSON)
.method(GET)
.addHeader(ACCEPT, APPLICATION_JSON)
.addHeader("X-Auth-Token", authToken);
}
}