backfilled tests for case where traffic controller record in UltraDNS doesn't exist

This commit is contained in:
adriancole 2013-03-24 10:38:30 -07:00
parent 9555e552a0
commit 179a0ea30a
6 changed files with 47 additions and 1 deletions

View File

@ -81,6 +81,7 @@ public class UltraDNSWSErrorHandler implements HttpErrorHandler {
case 2103:
case 2401:
case 2911:
case 3101:
return new ResourceNotFoundException(exception.getError().getDescription(), exception);
case 1802:
case 2111:

View File

@ -103,7 +103,7 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
HttpResponse poolDoesntExist = HttpResponse.builder().message("Server Epoolor").statusCode(500)
.payload(payloadFromResource("/lbpool_doesnt_exist.xml")).build();
public void testDeleteWhenResponseRRNotFound() {
public void testDeleteWhenResponseNotFound() {
UltraDNSWSApi notFound = requestSendsResponse(delete, poolDoesntExist);
notFound.getTrafficControllerPoolApiForZone("jclouds.org.").delete("04053D8E57C7931F");
}
@ -129,4 +129,25 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
UltraDNSWSApi already = requestSendsResponse(createRecord, recordAlreadyCreated);
already.getTrafficControllerPoolApiForZone("jclouds.org.").addRecordToPoolWithTTL("1.2.3.4", "04053D8E57C7931F", 300);
}
HttpRequest deleteRecord = HttpRequest.builder().method("POST")
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
.addHeader("Host", "ultra-api.ultradns.com:8443")
.payload(payloadFromResourceWithContentType("/delete_tcrecord.xml", "application/xml")).build();
HttpResponse deleteRecordResponse = HttpResponse.builder().statusCode(404)
.payload(payloadFromResourceWithContentType("/tcrecord_deleted.xml", "application/xml")).build();
public void testDeleteRecordWhenResponseIs2xx() {
UltraDNSWSApi success = requestSendsResponse(deleteRecord, deleteRecordResponse);
success.getTrafficControllerPoolApiForZone("jclouds.org.").deleteRecord("04053D8E57C7931F");
}
HttpResponse recordDoesntExist = HttpResponse.builder().message("Server Error").statusCode(500)
.payload(payloadFromResource("/tcrecord_doesnt_exist.xml")).build();
public void testDeleteRecordWhenResponseNotFound() {
UltraDNSWSApi notFound = requestSendsResponse(deleteRecord, recordDoesntExist);
notFound.getTrafficControllerPoolApiForZone("jclouds.org.").deleteRecord("04053D8E57C7931F");
}
}

View File

@ -221,6 +221,27 @@ public class UltraDNSWSErrorHandlerTest {
assertEquals(exception.getError().getCode(), 2912);
}
@Test
public void testCode3101SetsResourceNotFoundException() throws IOException {
HttpRequest request = HttpRequest.builder().method("POST")
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
.addHeader("Host", "ultra-api.ultradns.com:8443").payload(payloadFromResource("/delete_tcrecord.xml")).build();
HttpCommand command = new HttpCommand(request);
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
.payload(payloadFromResource("/tcrecord_doesnt_exist.xml")).build();
function.handleError(command, response);
assertEquals(command.getException().getClass(), ResourceNotFoundException.class);
assertEquals(command.getException().getMessage(), "Pool Record does not exist.");
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
assertEquals(exception.getMessage(), "Error 3101: Pool Record does not exist.");
assertEquals(exception.getError().getDescription(), "Pool Record does not exist.");
assertEquals(exception.getError().getCode(), 3101);
}
private Payload payloadFromResource(String resource) {
try {
return payloadFromStringWithContentType(toStringAndClose(getClass().getResourceAsStream(resource)),

View File

@ -0,0 +1 @@
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v01="http://webservice.api.ultra.neustar.com/v01/"><soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken><wsse:Username>identity</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">credential</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body><v01:deletePoolRecord><transactionID /><poolRecordID>04053D8E57C7931F</poolRecordID><parentPoolId /><childPoolId /></v01:deletePoolRecord></soapenv:Body></soapenv:Envelope>

View File

@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:deletePoolRecordResponse xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/"><result xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">Successful</result></ns1:deletePoolRecordResponse></soap:Body></soap:Envelope>

View File

@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Fault occurred while processing.</faultstring><detail><ns1:UltraWSException xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/"><errorCode xmlns:ns2="http://schema.ultraservice.neustar.com/v01/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:int">3101</errorCode><errorDescription xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">Pool Record does not exist.</errorDescription></ns1:UltraWSException></detail></soap:Fault></soap:Body></soap:Envelope>