mirror of https://github.com/apache/jclouds.git
use more constants in ultradns-ws tests
This commit is contained in:
parent
d37484f127
commit
2855cacc6d
|
@ -17,7 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.HOST;
|
||||
import static javax.ws.rs.HttpMethod.POST;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -32,12 +34,12 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit", testName = "UltraDNSWSApiExpectTest")
|
||||
public class UltraDNSWSApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
||||
|
||||
HttpRequest getCurrentAccount = HttpRequest.builder().method("POST")
|
||||
HttpRequest getCurrentAccount = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/get_current_account.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse getCurrentAccountResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse getCurrentAccountResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/account.xml", "application/xml")).build();
|
||||
|
||||
public void testGetCurrentAccountWhenResponseIs2xx() {
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.HOST;
|
||||
import static javax.ws.rs.HttpMethod.POST;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.jclouds.ultradns.ws.domain.ResourceRecord.rrBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -32,17 +35,18 @@ import org.jclouds.ultradns.ws.parse.GetResourceRecordsOfResourceRecordResponseT
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ResourceRecordApiExpectTest")
|
||||
public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
||||
HttpRequest create = HttpRequest.builder().method("POST")
|
||||
HttpRequest create = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/create_rr.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/rr_created.xml", "application/xml")).build();
|
||||
|
||||
ResourceRecord record = rrBuilder().name("mail.jclouds.org.")
|
||||
|
@ -56,7 +60,7 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
success.getResourceRecordApiForZone("jclouds.org.").create(record);
|
||||
}
|
||||
|
||||
HttpResponse alreadyCreated = HttpResponse.builder().statusCode(500)
|
||||
HttpResponse alreadyCreated = HttpResponse.builder().statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/rr_already_exists.xml", "application/xml")).build();
|
||||
|
||||
@Test(expectedExceptions = ResourceAlreadyExistsException.class, expectedExceptionsMessageRegExp = "Resource Record of type 15 with these attributes already exists in the system.")
|
||||
|
@ -65,12 +69,12 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
already.getResourceRecordApiForZone("jclouds.org.").create(record);
|
||||
}
|
||||
|
||||
HttpRequest update = HttpRequest.builder().method("POST")
|
||||
HttpRequest update = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/update_rr.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse updateResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse updateResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/rr_updated.xml", "application/xml")).build();
|
||||
|
||||
public void testUpdateWhenResponseIs2xx() {
|
||||
|
@ -78,12 +82,12 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
success.getResourceRecordApiForZone("jclouds.org.").update("04053D8E57C7931F", record);
|
||||
}
|
||||
|
||||
HttpRequest list = HttpRequest.builder().method("POST")
|
||||
HttpRequest list = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_records.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/records.xml", "application/xml")).build();
|
||||
|
||||
public void testListWhenResponseIs2xx() {
|
||||
|
@ -94,7 +98,7 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
new GetResourceRecordsOfResourceRecordResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpResponse zoneDoesntExist = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
HttpResponse zoneDoesntExist = HttpResponse.builder().message("Server Error").statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/zone_doesnt_exist.xml")).build();
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Zone does not exist in the system.")
|
||||
|
@ -103,9 +107,9 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
notFound.getResourceRecordApiForZone("jclouds.org.").list();
|
||||
}
|
||||
|
||||
HttpRequest listByName = HttpRequest.builder().method("POST")
|
||||
HttpRequest listByName = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_records_by_name.xml", "application/xml")).build();
|
||||
|
||||
public void testListByNameWhenResponseIs2xx() {
|
||||
|
@ -116,9 +120,9 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
new GetResourceRecordsOfResourceRecordResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest listByNameAndType = HttpRequest.builder().method("POST")
|
||||
HttpRequest listByNameAndType = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_records_by_name_and_type.xml", "application/xml")).build();
|
||||
|
||||
public void testListByNameAndTypeWhenResponseIs2xx() {
|
||||
|
@ -133,9 +137,9 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
new GetResourceRecordsOfResourceRecordResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder().method("POST")
|
||||
HttpRequest delete = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/delete_rr.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404)
|
||||
|
@ -146,7 +150,7 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
success.getZoneApi().delete("04053D8E57C7931F");
|
||||
}
|
||||
|
||||
HttpResponse rrDoesntExist = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
HttpResponse rrDoesntExist = HttpResponse.builder().message("Server Error").statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/rr_doesnt_exist.xml")).build();
|
||||
|
||||
public void testDeleteWhenResponseRRNotFound() {
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.HOST;
|
||||
import static javax.ws.rs.HttpMethod.POST;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -34,17 +37,17 @@ import org.testng.annotations.Test;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "RoundRobinPoolApiExpectTest")
|
||||
public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
||||
HttpRequest createA = HttpRequest.builder().method("POST")
|
||||
HttpRequest createA = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/create_rrpool_a.xml", "application/xml")).build();
|
||||
|
||||
HttpRequest createAAAA = HttpRequest.builder().method("POST")
|
||||
HttpRequest createAAAA = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/create_rrpool_aaaa.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/rrpool_created.xml", "application/xml")).build();
|
||||
|
||||
public void testCreateAWhenResponseIs2xx() {
|
||||
|
@ -57,7 +60,7 @@ public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
assertEquals(success.getRoundRobinPoolApiForZone("jclouds.org.").createAAAAPoolForHostname("www.jclouds.org.", "foo"), "060339AA04175655");
|
||||
}
|
||||
|
||||
HttpResponse alreadyCreated = HttpResponse.builder().statusCode(500)
|
||||
HttpResponse alreadyCreated = HttpResponse.builder().statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/lbpool_already_exists.xml", "application/xml")).build();
|
||||
|
||||
@Test(expectedExceptions = ResourceAlreadyExistsException.class, expectedExceptionsMessageRegExp = "Pool already created for this host name : www.rrpool.adrianc.rrpool.ultradnstest.jclouds.org.")
|
||||
|
@ -66,12 +69,12 @@ public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
already.getRoundRobinPoolApiForZone("jclouds.org.").createAPoolForHostname("www.jclouds.org.", "foo");
|
||||
}
|
||||
|
||||
HttpRequest list = HttpRequest.builder().method("POST")
|
||||
HttpRequest list = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_rrpools.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/rrpools.xml", "application/xml")).build();
|
||||
|
||||
public void testListWhenResponseIs2xx() {
|
||||
|
@ -82,12 +85,12 @@ public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
new GetRRLoadBalancingPoolsByZoneResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest listRecords = HttpRequest.builder().method("POST")
|
||||
HttpRequest listRecords = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_rrrecords.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listRecordsResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse listRecordsResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/records.xml", "application/xml")).build();
|
||||
|
||||
public void testListRecordsWhenResponseIs2xx() {
|
||||
|
@ -98,9 +101,9 @@ public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
new GetResourceRecordsOfResourceRecordResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder().method("POST")
|
||||
HttpRequest delete = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/delete_lbpool.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404)
|
||||
|
@ -111,7 +114,7 @@ public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
success.getRoundRobinPoolApiForZone("jclouds.org.").delete("04053D8E57C7931F");
|
||||
}
|
||||
|
||||
HttpResponse poolDoesntExist = HttpResponse.builder().message("Server Epoolor").statusCode(500)
|
||||
HttpResponse poolDoesntExist = HttpResponse.builder().message("Server Epoolor").statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/lbpool_doesnt_exist.xml")).build();
|
||||
|
||||
public void testDeleteWhenResponseRRNotFound() {
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.HOST;
|
||||
import static javax.ws.rs.HttpMethod.POST;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
|
@ -28,18 +31,17 @@ import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiExpectTest;
|
|||
import org.jclouds.ultradns.ws.parse.GetAllTasksResponseTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetStatusForTaskResponseResponseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "TaskApiExpectTest")
|
||||
public class TaskApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
||||
HttpRequest runTest = HttpRequest.builder().method("POST")
|
||||
HttpRequest runTest = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/run_test.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse runTestResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse runTestResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/taskid.xml", "application/xml")).build();
|
||||
|
||||
public void testRunTestWhenResponseIs2xx() {
|
||||
|
@ -48,12 +50,12 @@ public class TaskApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
assertEquals(success.getTaskApi().runTest("foo").toString(), "8d7a1725-4f4a-4b70-affa-f01dcce1526e");
|
||||
}
|
||||
|
||||
HttpRequest get = HttpRequest.builder().method("POST")
|
||||
HttpRequest get = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/get_task.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/task.xml", "application/xml")).build();
|
||||
|
||||
public void testGetWhenResponseIs2xx() {
|
||||
|
@ -64,7 +66,7 @@ public class TaskApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
new GetStatusForTaskResponseResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpResponse taskDoesntExist = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
HttpResponse taskDoesntExist = HttpResponse.builder().message("Server Error").statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/task_doesnt_exist.xml")).build();
|
||||
|
||||
public void testGetWhenResponseError2401() {
|
||||
|
@ -72,12 +74,12 @@ public class TaskApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
assertNull(notFound.getTaskApi().get("0b40c7dd-748d-4c49-8506-26f0c7d2ea9c"));
|
||||
}
|
||||
|
||||
HttpRequest clear = HttpRequest.builder().method("POST")
|
||||
HttpRequest clear = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/clear_task.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse clearResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse clearResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/task.xml", "application/xml")).build();
|
||||
|
||||
public void testClearWhenResponseIs2xx() {
|
||||
|
@ -90,12 +92,12 @@ public class TaskApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
notFound.getTaskApi().clear("0b40c7dd-748d-4c49-8506-26f0c7d2ea9c");
|
||||
}
|
||||
|
||||
HttpRequest list = HttpRequest.builder().method("POST")
|
||||
HttpRequest list = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_tasks.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/tasks.xml", "application/xml")).build();
|
||||
|
||||
public void testListWhenResponseIs2xx() {
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.HOST;
|
||||
import static javax.ws.rs.HttpMethod.POST;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
|
@ -32,18 +35,17 @@ import org.jclouds.ultradns.ws.parse.GetPoolRecordSpecResponseTest;
|
|||
import org.jclouds.ultradns.ws.parse.GetTCLoadBalancingPoolsByZoneResponseTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetTCPoolRecordsResponseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "TrafficControllerPoolApiExpectTest")
|
||||
public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
||||
HttpRequest create = HttpRequest.builder().method("POST")
|
||||
HttpRequest create = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/create_tcpool.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/tcpool_created.xml", "application/xml")).build();
|
||||
|
||||
public void testCreateWhenResponseIs2xx() {
|
||||
|
@ -51,7 +53,7 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
assertEquals(success.getTrafficControllerPoolApiForZone("jclouds.org.").createPoolForHostname("www.jclouds.org.", "foo"), "060339AA0417567A");
|
||||
}
|
||||
|
||||
HttpResponse alreadyCreated = HttpResponse.builder().statusCode(500)
|
||||
HttpResponse alreadyCreated = HttpResponse.builder().statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/lbpool_already_exists.xml", "application/xml")).build();
|
||||
|
||||
@Test(expectedExceptions = ResourceAlreadyExistsException.class, expectedExceptionsMessageRegExp = "Pool already created for this host name : www.rrpool.adrianc.rrpool.ultradnstest.jclouds.org.")
|
||||
|
@ -60,12 +62,12 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
already.getTrafficControllerPoolApiForZone("jclouds.org.").createPoolForHostname("www.jclouds.org.", "foo");
|
||||
}
|
||||
|
||||
HttpRequest list = HttpRequest.builder().method("POST")
|
||||
HttpRequest list = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_tcpools.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/tcpools.xml", "application/xml")).build();
|
||||
|
||||
public void testListWhenResponseIs2xx() {
|
||||
|
@ -75,12 +77,12 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
new GetTCLoadBalancingPoolsByZoneResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest listRecords = HttpRequest.builder().method("POST")
|
||||
HttpRequest listRecords = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_tcrecords.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listRecordsResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse listRecordsResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/tcrecords.xml", "application/xml")).build();
|
||||
|
||||
public void testListRecordsWhenResponseIs2xx() {
|
||||
|
@ -91,12 +93,12 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
new GetTCPoolRecordsResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest getNameByDName = HttpRequest.builder().method("POST")
|
||||
HttpRequest getNameByDName = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/get_tcpool_by_dname.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse getNameByDNameResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse getNameByDNameResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/tcpool_name.xml", "application/xml")).build();
|
||||
|
||||
public void testGetNameByDNameWhenResponseIs2xx() {
|
||||
|
@ -104,7 +106,7 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
assertEquals(success.getTrafficControllerPoolApiForZone("jclouds.org.").getNameByDName("www.foo.com."), "foo");
|
||||
}
|
||||
|
||||
HttpResponse poolDoesntExist = HttpResponse.builder().message("Server Epoolor").statusCode(500)
|
||||
HttpResponse poolDoesntExist = HttpResponse.builder().message("Server Epoolor").statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/lbpool_doesnt_exist.xml")).build();
|
||||
|
||||
public void testGetNameByDNameWhenResponseNotFound() {
|
||||
|
@ -112,9 +114,9 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
assertNull(notFound.getTrafficControllerPoolApiForZone("jclouds.org.").getNameByDName("www.foo.com."));
|
||||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder().method("POST")
|
||||
HttpRequest delete = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/delete_lbpool.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404)
|
||||
|
@ -130,12 +132,12 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
notFound.getTrafficControllerPoolApiForZone("jclouds.org.").delete("04053D8E57C7931F");
|
||||
}
|
||||
|
||||
HttpRequest createRecord = HttpRequest.builder().method("POST")
|
||||
HttpRequest createRecord = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/create_tcrecord.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse createRecordResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse createRecordResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/tcrecord_created.xml", "application/xml")).build();
|
||||
|
||||
public void testCreateRecordWhenResponseIs2xx() {
|
||||
|
@ -143,9 +145,9 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
assertEquals(success.getTrafficControllerPoolApiForZone("jclouds.org.").addRecordToPoolWithTTL("1.2.3.4", "04053D8E57C7931F", 300), "06063DAC54F8D3D9");
|
||||
}
|
||||
|
||||
HttpRequest createRecordWithWeight = HttpRequest.builder().method("POST")
|
||||
HttpRequest createRecordWithWeight = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/create_tcrecord_weight.xml", "application/xml")).build();
|
||||
|
||||
public void testCreateRecordWithWeightWhenResponseIs2xx() {
|
||||
|
@ -155,7 +157,7 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
"04053D8E57C7931F", 300, 0), "06063DAC54F8D3D9");
|
||||
}
|
||||
|
||||
HttpResponse recordAlreadyCreated = HttpResponse.builder().statusCode(500)
|
||||
HttpResponse recordAlreadyCreated = HttpResponse.builder().statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/tcrecord_already_exists.xml", "application/xml")).build();
|
||||
|
||||
@Test(expectedExceptions = ResourceAlreadyExistsException.class, expectedExceptionsMessageRegExp = "Resource Record of type 1 with these attributes already exists in the system.")
|
||||
|
@ -164,12 +166,12 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
already.getTrafficControllerPoolApiForZone("jclouds.org.").addRecordToPoolWithTTL("1.2.3.4", "04053D8E57C7931F", 300);
|
||||
}
|
||||
|
||||
HttpRequest getRecordSpec = HttpRequest.builder().method("POST")
|
||||
HttpRequest getRecordSpec = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/get_poolrecordspec.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse getRecordSpecResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse getRecordSpecResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/poolrecordspec.xml", "application/xml")).build();
|
||||
|
||||
public void testGetRecordSpecWhenResponseIs2xx() {
|
||||
|
@ -178,7 +180,7 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
new GetPoolRecordSpecResponseTest().expected());
|
||||
}
|
||||
|
||||
HttpResponse recordDoesntExist = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
HttpResponse recordDoesntExist = HttpResponse.builder().message("Server Error").statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/tcrecord_doesnt_exist.xml")).build();
|
||||
|
||||
public void testGetRecordSpecWhenResponseNotFound() {
|
||||
|
@ -192,14 +194,14 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
.weight(98)
|
||||
.failOverDelay(0)
|
||||
.threshold(1)
|
||||
.ttl(200).build();
|
||||
.ttl(OK.getStatusCode()).build();
|
||||
|
||||
HttpRequest updateRecord = HttpRequest.builder().method("POST")
|
||||
HttpRequest updateRecord = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/update_poolrecord.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse updateRecordResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse updateRecordResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/poolrecord_updated.xml", "application/xml")).build();
|
||||
|
||||
public void testUpdateRecordWhenResponseIs2xx() {
|
||||
|
@ -213,9 +215,9 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
notFound.getTrafficControllerPoolApiForZone("jclouds.org.").updateRecord("04053D8E57C7931F", update);
|
||||
}
|
||||
|
||||
HttpRequest deleteRecord = HttpRequest.builder().method("POST")
|
||||
HttpRequest deleteRecord = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/delete_tcrecord.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse deleteRecordResponse = HttpResponse.builder().statusCode(404)
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.HOST;
|
||||
import static javax.ws.rs.HttpMethod.POST;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static javax.ws.rs.core.Response.Status.OK;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
|
@ -31,18 +34,17 @@ import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiExpectTest;
|
|||
import org.jclouds.ultradns.ws.parse.GetGeneralPropertiesForZoneResponseTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetZonesOfAccountResponseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ZoneApiExpectTest")
|
||||
public class ZoneApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
||||
HttpRequest create = HttpRequest.builder().method("POST")
|
||||
HttpRequest create = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/create_zone.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/zone_created.xml", "application/xml")).build();
|
||||
|
||||
public void testCreateWhenResponseIs2xx() {
|
||||
|
@ -50,7 +52,7 @@ public class ZoneApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
success.getZoneApi().createInAccount("jclouds.org.", "AAAAAAAAAAAAAAAA");
|
||||
}
|
||||
|
||||
HttpResponse alreadyCreated = HttpResponse.builder().statusCode(500)
|
||||
HttpResponse alreadyCreated = HttpResponse.builder().statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/zone_already_exists.xml", "application/xml")).build();
|
||||
|
||||
@Test(expectedExceptions = ResourceAlreadyExistsException.class, expectedExceptionsMessageRegExp = "Zone already exists in the system.")
|
||||
|
@ -59,12 +61,12 @@ public class ZoneApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
already.getZoneApi().createInAccount("jclouds.org.", "AAAAAAAAAAAAAAAA");
|
||||
}
|
||||
|
||||
HttpRequest get = HttpRequest.builder().method("POST")
|
||||
HttpRequest get = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/get_zone.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/zoneproperties.xml", "application/xml")).build();
|
||||
|
||||
public void testGetWhenResponseIs2xx() {
|
||||
|
@ -75,7 +77,7 @@ public class ZoneApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
new GetGeneralPropertiesForZoneResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpResponse zoneDoesntExist = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
HttpResponse zoneDoesntExist = HttpResponse.builder().message("Server Error").statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/zone_doesnt_exist.xml")).build();
|
||||
|
||||
public void testGetWhenResponseError2401() {
|
||||
|
@ -83,12 +85,12 @@ public class ZoneApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
assertNull(notFound.getZoneApi().get("jclouds.org."));
|
||||
}
|
||||
|
||||
HttpRequest listByAccount = HttpRequest.builder().method("POST")
|
||||
HttpRequest listByAccount = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_zones_by_account.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listByAccountResponse = HttpResponse.builder().statusCode(200)
|
||||
HttpResponse listByAccountResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||
.payload(payloadFromResourceWithContentType("/zones.xml", "application/xml")).build();
|
||||
|
||||
public void testListByAccountWhenResponseIs2xx() {
|
||||
|
@ -99,7 +101,7 @@ public class ZoneApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
new GetZonesOfAccountResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpResponse accountDoesntExist = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
HttpResponse accountDoesntExist = HttpResponse.builder().message("Server Error").statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/account_doesnt_exist.xml")).build();
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Account not found in the system. ID: AAAAAAAAAAAAAAAA")
|
||||
|
@ -108,9 +110,9 @@ public class ZoneApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
notFound.getZoneApi().listByAccount("AAAAAAAAAAAAAAAA");
|
||||
}
|
||||
|
||||
HttpRequest listByAccountAndType = HttpRequest.builder().method("POST")
|
||||
HttpRequest listByAccountAndType = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_zones_by_account_and_type.xml", "application/xml")).build();
|
||||
|
||||
public void testListByAccountAndTypeWhenResponseIs2xx() {
|
||||
|
@ -127,9 +129,9 @@ public class ZoneApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
notFound.getZoneApi().listByAccountAndType("AAAAAAAAAAAAAAAA", Type.PRIMARY);
|
||||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder().method("POST")
|
||||
HttpRequest delete = HttpRequest.builder().method(POST)
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.addHeader(HOST, "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/delete_zone.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404)
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.handlers;
|
||||
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static com.google.common.net.HttpHeaders.HOST;
|
||||
import static javax.ws.rs.HttpMethod.POST;
|
||||
import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
|
||||
import static org.jclouds.rest.internal.BaseRestApiExpectTest.payloadFromStringWithContentType;
|
||||
import static org.jclouds.util.Strings2.toStringAndClose;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -36,7 +38,6 @@ import org.jclouds.ultradns.ws.UltraDNSWSResponseException;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -48,12 +49,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode0SetsUltraDNSWSResponseException() 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("/list_tasks.xml")).build();
|
||||
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("/list_tasks.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/server_fault.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/server_fault.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -67,12 +71,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode0ForDescriptionMatchingCannotFindSetsResourceNotFoundException() 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("/list_tasks.xml")).build();
|
||||
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("/list_tasks.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/task_doesnt_exist.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/task_doesnt_exist.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -88,13 +95,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode2401SetsResourceNotFoundException() 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("/list_zones_by_account.xml")).build();
|
||||
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("/list_zones_by_account.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/account_doesnt_exist.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/account_doesnt_exist.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -110,12 +119,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode1801SetsResourceNotFoundException() 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("/get_zone.xml")).build();
|
||||
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("/get_zone.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/zone_doesnt_exist.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/zone_doesnt_exist.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -131,12 +143,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode2103SetsResourceNotFoundException() 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_rr.xml")).build();
|
||||
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_rr.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/rr_doesnt_exist.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/rr_doesnt_exist.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -152,12 +167,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode1802SetsResourceAlreadyExistsException() 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("/create_zone.xml")).build();
|
||||
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("/create_zone.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/zone_already_exists.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/zone_already_exists.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -173,12 +191,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode2111SetsResourceAlreadyExistsException() 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("/create_rr.xml")).build();
|
||||
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("/create_rr.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/rr_already_exists.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/rr_already_exists.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -197,12 +218,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode2911SetsResourceNotFoundException() 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_lbpool.xml")).build();
|
||||
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_lbpool.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/lbpool_doesnt_exist.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/lbpool_doesnt_exist.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -218,12 +242,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@Test
|
||||
public void testCode2912SetsResourceAlreadyExistsException() 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("/create_rrpool_a.xml")).build();
|
||||
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("/create_rrpool_a.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/lbpool_already_exists.xml")).build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/lbpool_already_exists.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
@ -242,12 +269,15 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
@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();
|
||||
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();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.message(INTERNAL_SERVER_ERROR.getReasonPhrase())
|
||||
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode())
|
||||
.payload(payloadFromResource("/tcrecord_doesnt_exist.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
|
|
Loading…
Reference in New Issue