fixed rackspace loadbalancers where DELETE requires Accept */*

This commit is contained in:
Adrian Cole 2011-05-09 15:54:04 -07:00
parent a850330599
commit 6548fe1212
6 changed files with 33 additions and 29 deletions

View File

@ -141,7 +141,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
}
@Override
public Builder port(int port) {
public Builder port(Integer port) {
return Builder.class.cast(super.port(port));
}
@ -218,7 +218,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
private final Date updated;
private final boolean connectionLoggingEnabled;
public LoadBalancer(String region, int id, String name, String protocol, int port, String algorithm, Status status,
public LoadBalancer(String region, int id, String name, String protocol, Integer port, String algorithm, Status status,
Iterable<VirtualIP> virtualIPs, Iterable<Node> nodes, String sessionPersistenceType, String clusterName,
Date created, Date updated, boolean connectionLoggingEnabled) {
super(name, protocol, port, algorithm, nodes);

View File

@ -105,7 +105,7 @@ public class LoadBalancerRequest extends BaseLoadBalancer<NodeRequest, LoadBalan
}
@Override
public Builder port(int port) {
public Builder port(Integer port) {
return Builder.class.cast(super.port(port));
}

View File

@ -18,7 +18,6 @@
*/
package org.jclouds.cloudloadbalancers.domain.internal;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
@ -50,7 +49,7 @@ public class BaseLoadBalancer<N extends BaseNode<N>, T extends BaseLoadBalancer<
public static class Builder<N extends BaseNode<N>, T extends BaseLoadBalancer<N, T>> {
protected String name;
protected String protocol;
protected int port = -1;
protected Integer port;
protected String algorithm;
protected Set<N> nodes = Sets.newLinkedHashSet();
@ -64,7 +63,7 @@ public class BaseLoadBalancer<N extends BaseNode<N>, T extends BaseLoadBalancer<
return this;
}
public Builder<N, T> port(int port) {
public Builder<N, T> port(Integer port) {
this.port = port;
return this;
}
@ -103,17 +102,16 @@ public class BaseLoadBalancer<N extends BaseNode<N>, T extends BaseLoadBalancer<
protected String name;
protected String protocol;
protected int port;
protected Integer port;
protected String algorithm;
// so tests will come out consistently
protected SortedSet<N> nodes = ImmutableSortedSet.of();
public BaseLoadBalancer(String name, String protocol, int port, String algorithm, Iterable<N> nodes) {
public BaseLoadBalancer(String name, String protocol, Integer port, String algorithm, Iterable<N> nodes) {
this.name = checkNotNull(name, "name");
this.protocol = checkNotNull(protocol, "protocol");
checkArgument(port != -1, "port must be specified");
this.port = port;
this.algorithm = algorithm;
this.protocol = protocol;// null on deleted LB
this.port = port;// null on deleted LB
this.algorithm = algorithm;// null on deleted LB
this.nodes = ImmutableSortedSet.copyOf(checkNotNull(nodes, "nodes"));
}
@ -130,7 +128,7 @@ public class BaseLoadBalancer<N extends BaseNode<N>, T extends BaseLoadBalancer<
return protocol;
}
public int getPort() {
public Integer getPort() {
return port;
}
@ -144,8 +142,8 @@ public class BaseLoadBalancer<N extends BaseNode<N>, T extends BaseLoadBalancer<
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
final Integer prime = 31;
Integer result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}

View File

@ -106,6 +106,7 @@ public interface LoadBalancerAsyncClient {
@DELETE
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
@Path("/loadbalancers/{id}")
@Consumes("*/*")
ListenableFuture<Void> removeLoadBalancer(@PathParam("id") int id);
}

View File

@ -147,7 +147,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClie
assertRequestLineEquals(httpRequest,
"DELETE https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers/5 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "");
assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);

View File

@ -44,7 +44,6 @@ import com.google.common.collect.Sets;
public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
private Set<LoadBalancer> lbs = Sets.newLinkedHashSet();
// ticket 130960 getting 500 errors deleting load balancers
@AfterGroups(groups = "live")
protected void tearDown() {
for (LoadBalancer lb : lbs) {
@ -60,6 +59,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
assert null != response;
assertTrue(response.size() >= 0);
for (LoadBalancer lb : response) {
if (lb.getStatus() == LoadBalancer.Status.DELETED)
continue;
assert lb.getRegion() != null : lb;
assert lb.getName() != null : lb;
assert lb.getId() != -1 : lb;
@ -73,17 +74,21 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
assert lb.getNodes().size() == 0 : lb;
LoadBalancer getDetails = client.getLoadBalancerClient(region).getLoadBalancer(lb.getId());
assertEquals(getDetails.getRegion(), lb.getRegion());
assertEquals(getDetails.getName(), lb.getName());
assertEquals(getDetails.getId(), lb.getId());
assertEquals(getDetails.getProtocol(), lb.getProtocol());
assertEquals(getDetails.getPort(), lb.getPort());
assertEquals(getDetails.getStatus(), lb.getStatus());
assertEquals(getDetails.getCreated(), lb.getCreated());
assertEquals(getDetails.getUpdated(), lb.getUpdated());
assertEquals(getDetails.getVirtualIPs(), lb.getVirtualIPs());
// node info not available during list;
assert getDetails.getNodes().size() > 0 : lb;
try {
assertEquals(getDetails.getRegion(), lb.getRegion());
assertEquals(getDetails.getName(), lb.getName());
assertEquals(getDetails.getId(), lb.getId());
assertEquals(getDetails.getProtocol(), lb.getProtocol());
assertEquals(getDetails.getPort(), lb.getPort());
assertEquals(getDetails.getStatus(), lb.getStatus());
assertEquals(getDetails.getCreated(), lb.getCreated());
assertEquals(getDetails.getUpdated(), lb.getUpdated());
assertEquals(getDetails.getVirtualIPs(), lb.getVirtualIPs());
// node info not available during list;
assert getDetails.getNodes().size() > 0 : lb;
} catch (AssertionError e) {
throw new AssertionError(String.format("%s\n%s - %s", e.getMessage(),getDetails, lb));
}
}
}
}
@ -122,7 +127,7 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
assertEquals(lb.getRegion(), region);
assertEquals(lb.getName(), name);
assertEquals(lb.getProtocol(), "HTTP");
assertEquals(lb.getPort(), 80);
assertEquals(lb.getPort(), new Integer(80));
assertEquals(Iterables.get(lb.getVirtualIPs(), 0).getType(), Type.PUBLIC);
}