mirror of https://github.com/apache/jclouds.git
use more constants in dynect tests
This commit is contained in:
parent
b2f0f3dc71
commit
e22be464d0
|
@ -17,8 +17,8 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3.handlers;
|
package org.jclouds.dynect.v3.handlers;
|
||||||
|
|
||||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||||
|
import static javax.ws.rs.HttpMethod.GET;
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -55,7 +55,7 @@ public class GetJobRedirectionRetryHandler extends RedirectionRetryHandler {
|
||||||
String location = response.getFirstHeaderOrNull(LOCATION);
|
String location = response.getFirstHeaderOrNull(LOCATION);
|
||||||
if (location != null && location.indexOf("Job") != -1) {
|
if (location != null && location.indexOf("Job") != -1) {
|
||||||
HttpRequest getRequest = command.getCurrentRequest().toBuilder()
|
HttpRequest getRequest = command.getCurrentRequest().toBuilder()
|
||||||
.method("GET")
|
.method(GET)
|
||||||
.payload((Payload) null).build();
|
.payload((Payload) null).build();
|
||||||
command.setCurrentRequest(getRequest);
|
command.setCurrentRequest(getRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.dynect.v3;
|
package org.jclouds.dynect.v3;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
|
import static javax.ws.rs.core.Response.Status.OK;
|
||||||
import static org.jclouds.Constants.PROPERTY_MAX_RETRIES;
|
import static org.jclouds.Constants.PROPERTY_MAX_RETRIES;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -35,7 +36,6 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.mockwebserver.MockResponse;
|
import com.google.mockwebserver.MockResponse;
|
||||||
import com.google.mockwebserver.MockWebServer;
|
import com.google.mockwebserver.MockWebServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -64,8 +64,8 @@ public class DynectApiMockTest {
|
||||||
@Test(expectedExceptions = JobStillRunningException.class, expectedExceptionsMessageRegExp = "This session already has a job running")
|
@Test(expectedExceptions = JobStillRunningException.class, expectedExceptionsMessageRegExp = "This session already has a job running")
|
||||||
public void test200OnFailureThrowsExceptionWithoutRetryWhenJobRunning() throws IOException, InterruptedException {
|
public void test200OnFailureThrowsExceptionWithoutRetryWhenJobRunning() throws IOException, InterruptedException {
|
||||||
MockWebServer server = new MockWebServer();
|
MockWebServer server = new MockWebServer();
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(session));
|
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(running));
|
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(running));
|
||||||
server.play();
|
server.play();
|
||||||
|
|
||||||
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
||||||
|
@ -83,8 +83,8 @@ public class DynectApiMockTest {
|
||||||
public void test200OnFailureThrowsExceptionWithoutRetryWhenOperationBlocked() throws IOException,
|
public void test200OnFailureThrowsExceptionWithoutRetryWhenOperationBlocked() throws IOException,
|
||||||
InterruptedException {
|
InterruptedException {
|
||||||
MockWebServer server = new MockWebServer();
|
MockWebServer server = new MockWebServer();
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(session));
|
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(taskBlocking));
|
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(taskBlocking));
|
||||||
server.play();
|
server.play();
|
||||||
|
|
||||||
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
||||||
|
@ -101,8 +101,8 @@ public class DynectApiMockTest {
|
||||||
@Test(expectedExceptions = TargetExistsException.class, expectedExceptionsMessageRegExp = "Name already exists")
|
@Test(expectedExceptions = TargetExistsException.class, expectedExceptionsMessageRegExp = "Name already exists")
|
||||||
public void test200OnFailureThrowsExceptionWithoutRetryOnNameExists() throws IOException, InterruptedException {
|
public void test200OnFailureThrowsExceptionWithoutRetryOnNameExists() throws IOException, InterruptedException {
|
||||||
MockWebServer server = new MockWebServer();
|
MockWebServer server = new MockWebServer();
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(session));
|
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(session));
|
||||||
server.enqueue(new MockResponse().setResponseCode(200).setBody(targetExists));
|
server.enqueue(new MockResponse().setResponseCode(OK.getStatusCode()).setBody(targetExists));
|
||||||
server.play();
|
server.play();
|
||||||
|
|
||||||
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
DynECTApi api = mockDynectApi(server.getUrl("/").toString());
|
||||||
|
|
|
@ -17,10 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3.features;
|
package org.jclouds.dynect.v3.features;
|
||||||
|
|
||||||
import static com.google.common.net.HttpHeaders.ACCEPT;
|
import static com.google.common.net.HttpHeaders.ACCEPT;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||||
|
import static javax.ws.rs.HttpMethod.DELETE;
|
||||||
|
import static javax.ws.rs.HttpMethod.GET;
|
||||||
|
import static javax.ws.rs.HttpMethod.POST;
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
import static javax.ws.rs.core.Response.Status.OK;
|
||||||
import static org.jclouds.dynect.v3.domain.RecordId.recordIdBuilder;
|
import static org.jclouds.dynect.v3.domain.RecordId.recordIdBuilder;
|
||||||
import static org.jclouds.dynect.v3.domain.rdata.AData.a;
|
import static org.jclouds.dynect.v3.domain.rdata.AData.a;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -55,13 +58,13 @@ import org.testng.annotations.Test;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "RecordApiExpectTest")
|
@Test(groups = "unit", testName = "RecordApiExpectTest")
|
||||||
public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
HttpRequest getSOA = HttpRequest.builder().method("GET")
|
HttpRequest getSOA = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/SOARecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/SOARecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse soaResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse soaResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_soa.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_soa.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId soaId = recordIdBuilder()
|
RecordId soaId = recordIdBuilder()
|
||||||
|
@ -81,13 +84,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getRecordApiForZone("jclouds.org").get(soaId));
|
assertNull(fail.getRecordApiForZone("jclouds.org").get(soaId));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getAAAA = HttpRequest.builder().method("GET")
|
HttpRequest getAAAA = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/AAAARecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/AAAARecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse aaaaResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse aaaaResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_aaaa.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_aaaa.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId aaaaId = recordIdBuilder()
|
RecordId aaaaId = recordIdBuilder()
|
||||||
|
@ -107,13 +110,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getRecordApiForZone("jclouds.org").getAAAA(aaaaId.getFQDN(), aaaaId.getId()));
|
assertNull(fail.getRecordApiForZone("jclouds.org").getAAAA(aaaaId.getFQDN(), aaaaId.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getA = HttpRequest.builder().method("GET")
|
HttpRequest getA = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse aResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse aResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_a.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_a.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId aId = recordIdBuilder()
|
RecordId aId = recordIdBuilder()
|
||||||
|
@ -133,13 +136,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getRecordApiForZone("jclouds.org").getA(aId.getFQDN(), aId.getId()));
|
assertNull(fail.getRecordApiForZone("jclouds.org").getA(aId.getFQDN(), aId.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getCNAME = HttpRequest.builder().method("GET")
|
HttpRequest getCNAME = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/CNAMERecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/CNAMERecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse cnameResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse cnameResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_cname.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_cname.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId cnameId = recordIdBuilder()
|
RecordId cnameId = recordIdBuilder()
|
||||||
|
@ -159,13 +162,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getRecordApiForZone("jclouds.org").getCNAME(cnameId.getFQDN(), cnameId.getId()));
|
assertNull(fail.getRecordApiForZone("jclouds.org").getCNAME(cnameId.getFQDN(), cnameId.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getMX = HttpRequest.builder().method("GET")
|
HttpRequest getMX = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/MXRecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/MXRecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse mxResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse mxResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_mx.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_mx.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId mxId = recordIdBuilder()
|
RecordId mxId = recordIdBuilder()
|
||||||
|
@ -185,13 +188,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getRecordApiForZone("jclouds.org").getMX(mxId.getFQDN(), mxId.getId()));
|
assertNull(fail.getRecordApiForZone("jclouds.org").getMX(mxId.getFQDN(), mxId.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getNS = HttpRequest.builder().method("GET")
|
HttpRequest getNS = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/NSRecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/NSRecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse nsResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse nsResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_ns.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_ns.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId nsId = recordIdBuilder()
|
RecordId nsId = recordIdBuilder()
|
||||||
|
@ -211,13 +214,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getRecordApiForZone("jclouds.org").getNS(nsId.getFQDN(), nsId.getId()));
|
assertNull(fail.getRecordApiForZone("jclouds.org").getNS(nsId.getFQDN(), nsId.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getPTR = HttpRequest.builder().method("GET")
|
HttpRequest getPTR = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/PTRRecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/PTRRecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse ptrResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse ptrResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_ptr.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_ptr.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId ptrId = recordIdBuilder()
|
RecordId ptrId = recordIdBuilder()
|
||||||
|
@ -248,13 +251,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getRecordApiForZone("jclouds.org").getSOA(soaId.getFQDN(), soaId.getId()));
|
assertNull(fail.getRecordApiForZone("jclouds.org").getSOA(soaId.getFQDN(), soaId.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getSPF = HttpRequest.builder().method("GET")
|
HttpRequest getSPF = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/SPFRecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/SPFRecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse spfResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse spfResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_spf.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_spf.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId spfId = recordIdBuilder()
|
RecordId spfId = recordIdBuilder()
|
||||||
|
@ -269,13 +272,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new GetSPFRecordResponseTest().expected().toString());
|
new GetSPFRecordResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getSRV = HttpRequest.builder().method("GET")
|
HttpRequest getSRV = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/SRVRecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/SRVRecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse srvResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse srvResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_srv.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_srv.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId srvId = recordIdBuilder()
|
RecordId srvId = recordIdBuilder()
|
||||||
|
@ -290,13 +293,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new GetSRVRecordResponseTest().expected().toString());
|
new GetSRVRecordResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getSSHFP = HttpRequest.builder().method("GET")
|
HttpRequest getSSHFP = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/SSHFPRecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/SSHFPRecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse sshfpResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse sshfpResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_sshfp.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_sshfp.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId sshfpId = recordIdBuilder()
|
RecordId sshfpId = recordIdBuilder()
|
||||||
|
@ -311,13 +314,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new GetSSHFPRecordResponseTest().expected().toString());
|
new GetSSHFPRecordResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest getTXT = HttpRequest.builder().method("GET")
|
HttpRequest getTXT = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/TXTRecord/jclouds.org/jclouds.org/50976579")
|
.endpoint("https://api2.dynect.net/REST/TXTRecord/jclouds.org/jclouds.org/50976579")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse txtResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse txtResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_record_txt.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_record_txt.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId txtId = recordIdBuilder()
|
RecordId txtId = recordIdBuilder()
|
||||||
|
@ -337,13 +340,13 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getRecordApiForZone("jclouds.org").getTXT(txtId.getFQDN(), txtId.getId()));
|
assertNull(fail.getRecordApiForZone("jclouds.org").getTXT(txtId.getFQDN(), txtId.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest list = HttpRequest.builder().method("GET")
|
HttpRequest list = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/AllRecord/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/AllRecord/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse listResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/list_records.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/list_records.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
public void testListWhenResponseIs2xx() {
|
public void testListWhenResponseIs2xx() {
|
||||||
|
@ -352,7 +355,7 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new ListRecordsResponseTest().expected().toString());
|
new ListRecordsResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest listByFQDN = HttpRequest.builder().method("GET")
|
HttpRequest listByFQDN = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/AllRecord/jclouds.org/www.foo.com")
|
.endpoint("https://api2.dynect.net/REST/AllRecord/jclouds.org/www.foo.com")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
|
@ -369,7 +372,7 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertTrue(fail.getRecordApiForZone("jclouds.org").listByFQDN("www.foo.com").isEmpty());
|
assertTrue(fail.getRecordApiForZone("jclouds.org").listByFQDN("www.foo.com").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest listByFQDNAndType = HttpRequest.builder().method("GET")
|
HttpRequest listByFQDNAndType = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.foo.com")
|
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.foo.com")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
|
@ -386,7 +389,7 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertTrue(fail.getRecordApiForZone("jclouds.org").listByFQDNAndType("www.foo.com", "A").isEmpty());
|
assertTrue(fail.getRecordApiForZone("jclouds.org").listByFQDNAndType("www.foo.com", "A").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest create = HttpRequest.builder().method("POST")
|
HttpRequest create = HttpRequest.builder().method(POST)
|
||||||
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
|
@ -394,7 +397,7 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
.payload(stringPayload("{\"rdata\":{\"address\":\"1.1.1.1\"},\"ttl\":86400}"))
|
.payload(stringPayload("{\"rdata\":{\"address\":\"1.1.1.1\"},\"ttl\":86400}"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpResponse createResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse createResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/new_record.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/new_record.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
public void testCreateWhenResponseIs2xx() {
|
public void testCreateWhenResponseIs2xx() {
|
||||||
|
@ -408,14 +411,14 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertEquals(success.getRecordApiForZone("jclouds.org").scheduleCreate(record), Job.success(285372440l));
|
assertEquals(success.getRecordApiForZone("jclouds.org").scheduleCreate(record), Job.success(285372440l));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest delete = HttpRequest.builder().method("DELETE")
|
HttpRequest delete = HttpRequest.builder().method(DELETE)
|
||||||
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.jclouds.org/285372440")
|
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.jclouds.org/285372440")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse deleteResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/delete_record.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/delete_record.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
RecordId id = recordIdBuilder()
|
RecordId id = recordIdBuilder()
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3.features;
|
package org.jclouds.dynect.v3.features;
|
||||||
|
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||||
|
import static javax.ws.rs.HttpMethod.DELETE;
|
||||||
|
import static javax.ws.rs.HttpMethod.GET;
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
import static javax.ws.rs.core.Response.Status.OK;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
@ -31,7 +33,6 @@ import org.jclouds.dynect.v3.parse.CreateSessionResponseTest;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -47,13 +48,13 @@ public class SessionApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new CreateSessionResponseTest().expected().toString());
|
new CreateSessionResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest isValid = HttpRequest.builder().method("GET")
|
HttpRequest isValid = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/Session")
|
.endpoint("https://api2.dynect.net/REST/Session")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse validResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse validResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/session_valid.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/session_valid.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
HttpResponse invalidResponse = HttpResponse.builder().statusCode(400)
|
HttpResponse invalidResponse = HttpResponse.builder().statusCode(400)
|
||||||
|
@ -69,13 +70,13 @@ public class SessionApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertFalse(apiWhenInvalid.getSessionApi().isValid(authToken));
|
assertFalse(apiWhenInvalid.getSessionApi().isValid(authToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest logout = HttpRequest.builder().method("DELETE")
|
HttpRequest logout = HttpRequest.builder().method(DELETE)
|
||||||
.endpoint("https://api2.dynect.net/REST/Session")
|
.endpoint("https://api2.dynect.net/REST/Session")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse logoutResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse logoutResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/logout.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/logout.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
public void testLogout() {
|
public void testLogout() {
|
||||||
|
|
|
@ -17,10 +17,14 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3.features;
|
package org.jclouds.dynect.v3.features;
|
||||||
|
|
||||||
import static com.google.common.net.HttpHeaders.ACCEPT;
|
import static com.google.common.net.HttpHeaders.ACCEPT;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||||
|
import static javax.ws.rs.HttpMethod.DELETE;
|
||||||
|
import static javax.ws.rs.HttpMethod.GET;
|
||||||
|
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.APPLICATION_JSON;
|
||||||
|
import static javax.ws.rs.core.Response.Status.OK;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
|
|
||||||
|
@ -35,19 +39,18 @@ import org.jclouds.dynect.v3.parse.ListZonesResponseTest;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ZoneApiExpectTest")
|
@Test(groups = "unit", testName = "ZoneApiExpectTest")
|
||||||
public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
HttpRequest get = HttpRequest.builder().method("GET")
|
HttpRequest get = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse getResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse getResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/get_zone.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/get_zone.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
public void testGetWhenResponseIs2xx() {
|
public void testGetWhenResponseIs2xx() {
|
||||||
|
@ -56,7 +59,7 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new GetZoneResponseTest().expected().toString());
|
new GetZoneResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest create = HttpRequest.builder().method("POST")
|
HttpRequest create = HttpRequest.builder().method(POST)
|
||||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
|
@ -64,7 +67,7 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
.payload(stringPayload("{\"rname\":\"jimmy@jclouds.org\",\"serial_style\":\"increment\",\"ttl\":3600}"))
|
.payload(stringPayload("{\"rname\":\"jimmy@jclouds.org\",\"serial_style\":\"increment\",\"ttl\":3600}"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpResponse createResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse createResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/new_zone.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/new_zone.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
public void testCreateWhenResponseIs2xx() {
|
public void testCreateWhenResponseIs2xx() {
|
||||||
|
@ -85,13 +88,13 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getZoneApi().get("jclouds.org"));
|
assertNull(fail.getZoneApi().get("jclouds.org"));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest list = HttpRequest.builder().method("GET")
|
HttpRequest list = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/Zone")
|
.endpoint("https://api2.dynect.net/REST/Zone")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse listResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/list_zones.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/list_zones.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
public void testListWhenResponseIs2xx() {
|
public void testListWhenResponseIs2xx() {
|
||||||
|
@ -100,14 +103,14 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new ListZonesResponseTest().expected().toString());
|
new ListZonesResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest deleteChanges = HttpRequest.builder().method("DELETE")
|
HttpRequest deleteChanges = HttpRequest.builder().method(DELETE)
|
||||||
.endpoint("https://api2.dynect.net/REST/ZoneChanges/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/ZoneChanges/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse deleteChangesResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse deleteChangesResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/delete_zone_changes.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/delete_zone_changes.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
public void testDeleteChangesWhenResponseIs2xx() {
|
public void testDeleteChangesWhenResponseIs2xx() {
|
||||||
|
@ -116,14 +119,14 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new DeleteZoneChangesResponseTest().expected().toString());
|
new DeleteZoneChangesResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest delete = HttpRequest.builder().method("DELETE")
|
HttpRequest delete = HttpRequest.builder().method(DELETE)
|
||||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||||
.addHeader("Auth-Token", authToken).build();
|
.addHeader("Auth-Token", authToken).build();
|
||||||
|
|
||||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
|
HttpResponse deleteResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/delete_zone.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/delete_zone.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
public void testDeleteWhenResponseIs2xx() {
|
public void testDeleteWhenResponseIs2xx() {
|
||||||
|
@ -137,7 +140,7 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
assertNull(fail.getZoneApi().delete("jclouds.org"));
|
assertNull(fail.getZoneApi().delete("jclouds.org"));
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest publish = HttpRequest.builder().method("PUT")
|
HttpRequest publish = HttpRequest.builder().method(PUT)
|
||||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader("Auth-Token", authToken)
|
.addHeader("Auth-Token", authToken)
|
||||||
|
@ -150,7 +153,7 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new GetZoneResponseTest().expected().toString());
|
new GetZoneResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest freeze = HttpRequest.builder().method("PUT")
|
HttpRequest freeze = HttpRequest.builder().method(PUT)
|
||||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
|
@ -164,7 +167,7 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||||
new DeleteZoneResponseTest().expected().toString());
|
new DeleteZoneResponseTest().expected().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest thaw = HttpRequest.builder().method("PUT")
|
HttpRequest thaw = HttpRequest.builder().method(PUT)
|
||||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3.filters;
|
package org.jclouds.dynect.v3.filters;
|
||||||
|
|
||||||
|
import static javax.ws.rs.core.Response.Status.FORBIDDEN;
|
||||||
|
import static javax.ws.rs.core.Response.Status.UNAUTHORIZED;
|
||||||
import static org.easymock.EasyMock.createMock;
|
import static org.easymock.EasyMock.createMock;
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.EasyMock.expectLastCall;
|
import static org.easymock.EasyMock.expectLastCall;
|
||||||
|
@ -38,14 +40,16 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "SessionManagerTest")
|
@Test(groups = "unit", testName = "SessionManagerTest")
|
||||||
public class SessionManagerTest {
|
public class SessionManagerTest {
|
||||||
SessionCredentials creds = SessionCredentials.builder().customerName("customer").userName("robbie")
|
SessionCredentials creds = SessionCredentials.builder()
|
||||||
|
.customerName("customer")
|
||||||
|
.userName("robbie")
|
||||||
.password("password").build();
|
.password("password").build();
|
||||||
|
|
||||||
Session session = Session.forTokenAndVersion("token", "version");
|
Session session = Session.forTokenAndVersion("token", "version");
|
||||||
|
|
||||||
public void testAlreadySessionCredentials() {
|
public void testAlreadySessionCredentials() {
|
||||||
|
@ -68,7 +72,7 @@ public class SessionManagerTest {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void test401ShouldInvalidateSessionAndRetry() {
|
public void testUnauthorizedShouldInvalidateSessionAndRetry() {
|
||||||
HttpCommand command = createMock(HttpCommand.class);
|
HttpCommand command = createMock(HttpCommand.class);
|
||||||
Supplier<Credentials> creds = createMock(Supplier.class);
|
Supplier<Credentials> creds = createMock(Supplier.class);
|
||||||
LoadingCache<Credentials, Session> sessionCache = createMock(LoadingCache.class);
|
LoadingCache<Credentials, Session> sessionCache = createMock(LoadingCache.class);
|
||||||
|
@ -82,7 +86,7 @@ public class SessionManagerTest {
|
||||||
|
|
||||||
replay(creds, sessionCache, sessionApi, command);
|
replay(creds, sessionCache, sessionApi, command);
|
||||||
|
|
||||||
HttpResponse response = HttpResponse.builder().statusCode(401).build();
|
HttpResponse response = HttpResponse.builder().statusCode(UNAUTHORIZED.getStatusCode()).build();
|
||||||
|
|
||||||
SessionManager retry = new SessionManager(creds, sessionCache, sessionApi);
|
SessionManager retry = new SessionManager(creds, sessionCache, sessionApi);
|
||||||
|
|
||||||
|
@ -93,7 +97,7 @@ public class SessionManagerTest {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void test403ShouldNotInvalidateSessionOrRetry() {
|
public void testForbiddenShouldNotInvalidateSessionOrRetry() {
|
||||||
HttpCommand command = createMock(HttpCommand.class);
|
HttpCommand command = createMock(HttpCommand.class);
|
||||||
Supplier<Credentials> creds = createMock(Supplier.class);
|
Supplier<Credentials> creds = createMock(Supplier.class);
|
||||||
LoadingCache<Credentials, Session> sessionCache = createMock(LoadingCache.class);
|
LoadingCache<Credentials, Session> sessionCache = createMock(LoadingCache.class);
|
||||||
|
@ -101,7 +105,7 @@ public class SessionManagerTest {
|
||||||
|
|
||||||
replay(creds, sessionCache, sessionApi, command);
|
replay(creds, sessionCache, sessionApi, command);
|
||||||
|
|
||||||
HttpResponse response = HttpResponse.builder().statusCode(403).build();
|
HttpResponse response = HttpResponse.builder().statusCode(FORBIDDEN.getStatusCode()).build();
|
||||||
|
|
||||||
SessionManager retry = new SessionManager(creds, sessionCache, sessionApi);
|
SessionManager retry = new SessionManager(creds, sessionCache, sessionApi);
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3.handlers;
|
package org.jclouds.dynect.v3.handlers;
|
||||||
|
|
||||||
import static com.google.common.net.HttpHeaders.ACCEPT;
|
import static com.google.common.net.HttpHeaders.ACCEPT;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||||
|
import static javax.ws.rs.HttpMethod.GET;
|
||||||
|
import static javax.ws.rs.HttpMethod.PUT;
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
import static javax.ws.rs.core.Response.Status.TEMPORARY_REDIRECT;
|
||||||
|
|
||||||
import org.jclouds.dynect.v3.DynECTApi;
|
import org.jclouds.dynect.v3.DynECTApi;
|
||||||
import org.jclouds.dynect.v3.internal.BaseDynECTApiExpectTest;
|
import org.jclouds.dynect.v3.internal.BaseDynECTApiExpectTest;
|
||||||
|
@ -38,7 +40,7 @@ public class GetJobRedirectionRetryHandlerExpectTest extends BaseDynECTApiExpect
|
||||||
|
|
||||||
public void testRedirectOnJobLocationSwitchesToGETAndNoPayload() {
|
public void testRedirectOnJobLocationSwitchesToGETAndNoPayload() {
|
||||||
|
|
||||||
HttpRequest thaw = HttpRequest.builder().method("PUT")
|
HttpRequest thaw = HttpRequest.builder().method(PUT)
|
||||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
|
@ -47,11 +49,11 @@ public class GetJobRedirectionRetryHandlerExpectTest extends BaseDynECTApiExpect
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpResponse redirectResponse = HttpResponse.builder()
|
HttpResponse redirectResponse = HttpResponse.builder()
|
||||||
.statusCode(317)
|
.statusCode(TEMPORARY_REDIRECT.getStatusCode())
|
||||||
.addHeader(LOCATION, "https://api2.dynect.net/REST/Job/1234")
|
.addHeader(LOCATION, "https://api2.dynect.net/REST/Job/1234")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpRequest job = HttpRequest.builder().method("GET")
|
HttpRequest job = HttpRequest.builder().method(GET)
|
||||||
.endpoint("https://api2.dynect.net/REST/Job/1234")
|
.endpoint("https://api2.dynect.net/REST/Job/1234")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||||
|
|
|
@ -17,8 +17,10 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3.internal;
|
package org.jclouds.dynect.v3.internal;
|
||||||
|
import static javax.ws.rs.HttpMethod.POST;
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
|
||||||
|
import static javax.ws.rs.core.Response.Status.OK;
|
||||||
|
|
||||||
import org.jclouds.dynect.v3.config.DynECTRestClientModule;
|
import org.jclouds.dynect.v3.config.DynECTRestClientModule;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -70,9 +72,8 @@ public class BaseDynECTExpectTest<T> extends BaseRestApiExpectTest<T> {
|
||||||
|
|
||||||
protected String authToken = "FFFFFFFFFF";
|
protected String authToken = "FFFFFFFFFF";
|
||||||
|
|
||||||
protected HttpRequest createSession = HttpRequest
|
protected HttpRequest createSession = HttpRequest.builder()
|
||||||
.builder()
|
.method(POST)
|
||||||
.method("POST")
|
|
||||||
.endpoint("https://api2.dynect.net/REST/Session")
|
.endpoint("https://api2.dynect.net/REST/Session")
|
||||||
.addHeader("API-Version", "3.3.8")
|
.addHeader("API-Version", "3.3.8")
|
||||||
.payload(
|
.payload(
|
||||||
|
@ -80,8 +81,8 @@ public class BaseDynECTExpectTest<T> extends BaseRestApiExpectTest<T> {
|
||||||
"{\"customer_name\":\"jclouds\",\"user_name\":\"joe\",\"password\":\"letmein\"}", APPLICATION_JSON))
|
"{\"customer_name\":\"jclouds\",\"user_name\":\"joe\",\"password\":\"letmein\"}", APPLICATION_JSON))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
protected HttpResponse createSessionResponse = HttpResponse.builder().statusCode(200)
|
protected HttpResponse createSessionResponse = HttpResponse.builder().statusCode(OK.getStatusCode())
|
||||||
.payload(payloadFromResourceWithContentType("/create_session.json", APPLICATION_JSON)).build();
|
.payload(payloadFromResourceWithContentType("/create_session.json", APPLICATION_JSON)).build();
|
||||||
|
|
||||||
protected HttpResponse notFound = HttpResponse.builder().statusCode(404).build();
|
protected HttpResponse notFound = HttpResponse.builder().statusCode(NOT_FOUND.getStatusCode()).build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue