mirror of https://github.com/apache/jclouds.git
expect test structure for new admin client
This commit is contained in:
parent
73ec8a66ff
commit
b5ae8073da
|
@ -200,6 +200,16 @@ public interface VAppTemplateAsyncClient {
|
|||
ListenableFuture<Task> modifyLeaseSettingsSection(@EndpointParam URI templateURI,
|
||||
@BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection);
|
||||
|
||||
/**
|
||||
* @see VAppTemplateClient#getNetworkConnectionSection(URI)
|
||||
*/
|
||||
@GET
|
||||
@Consumes(NETWORK_CONFIG_SECTION)
|
||||
@Path("/networkConnectionSection")
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<NetworkConnectionSection> getNetworkConnectionSection(@EndpointParam URI templateURI);
|
||||
|
||||
/**
|
||||
* @see VAppTemplateClient#getNetworkConfigSection(URI)
|
||||
*/
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.login.SessionClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -29,7 +29,7 @@ import org.testng.annotations.Test;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "VCloudDirectorClient")
|
||||
public class VCloudDirectorClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class VCloudDirectorClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
public void testRestClientModuleWorksProperly() throws Exception {
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -41,7 +42,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Test(groups = { "unit", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest")
|
||||
public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorAdminClient> {
|
||||
public class AdminCatalogClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
private Reference catalogRef = Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.jclouds.vcloud.director.v1_5.domain.Link;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.features.admin.GroupClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "admin", "network"}, singleThreaded = true, testName = "AdminNetworkClientExpectTest")
|
||||
public class AdminNetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorAdminClient> {
|
||||
public class AdminNetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
Reference networkRef = Reference.builder()
|
||||
.href(URI.create(endpoint+"/admin/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1"))
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.features.admin.AdminOrgClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ import org.testng.annotations.Test;
|
|||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "org"}, singleThreaded = true, testName = "AdminOrgClientExpectTest")
|
||||
public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorAdminClient> {
|
||||
public class AdminOrgClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
private Reference orgRef = Reference.builder()
|
||||
.href(URI.create(endpoint + "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Link;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRoleRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.features.admin.AdminQueryClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableMultimap;
|
|||
* @author Aled Sage
|
||||
*/
|
||||
@Test(groups = { "unit", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientExpectTest")
|
||||
public class AdminQueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorAdminClient> {
|
||||
public class AdminQueryClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
// TODO Write expect tests for all other admin-query operations
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
|||
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +36,7 @@ import org.testng.annotations.Test;
|
|||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientExpectTest")
|
||||
public class AdminVdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorAdminClient> {
|
||||
public class AdminVdcClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
private Reference vdcRef = Reference.builder()
|
||||
.href(URI.create(endpoint + "???"))
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.net.URI;
|
|||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||
|
@ -34,7 +34,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
@ -46,7 +46,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest")
|
||||
public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorAdminClient> {
|
||||
public class CatalogClientExpectTest extends VCloudDirectorClientExpectTest {
|
||||
|
||||
@Test
|
||||
public void testGetCatalog() {
|
||||
|
@ -64,7 +64,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/catalog.xml", VCloudDirectorMediaType.CATALOG + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||
|
||||
CatalogType expected = catalog();
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/createdCatalogItem.xml", VCloudDirectorMediaType.CATALOG_ITEM + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogURI = URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4");
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/catalogMetadata.xml", VCloudDirectorMediaType.METADATA))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||
|
||||
URI catalogURI = URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4");
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/catalogMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||
|
||||
URI catalogURI = URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4");
|
||||
|
||||
|
@ -179,7 +179,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/catalogItem.xml", VCloudDirectorMediaType.CATALOG_ITEM))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogItemURI = URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df");
|
||||
|
||||
|
@ -205,7 +205,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/updateCatalogItem.xml", VCloudDirectorMediaType.CATALOG_ITEM + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogItemURI = URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df");
|
||||
CatalogItem expected = catalogItem();
|
||||
|
@ -228,7 +228,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.statusCode(200)
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogItemURI = URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df");
|
||||
|
||||
|
@ -251,7 +251,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/catalogItemMetadata.xml", VCloudDirectorMediaType.METADATA))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogItemURI = URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df");
|
||||
|
||||
|
@ -286,7 +286,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/mergeMetadataTask.xml", VCloudDirectorMediaType.TASK + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogItemURI = URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df");
|
||||
|
||||
|
@ -313,7 +313,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/catalogItemMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogItemURI = URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df");
|
||||
|
||||
|
@ -339,7 +339,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/setMetadataValueTask.xml", VCloudDirectorMediaType.TASK + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogItemURI = URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df");
|
||||
|
||||
|
@ -366,7 +366,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.payload(payloadFromResourceWithContentType("/catalog/deleteMetadataEntryTask.xml", VCloudDirectorMediaType.TASK))
|
||||
.build();
|
||||
|
||||
VCloudDirectorAdminClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
||||
URI catalogItemURI = URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df");
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.features.admin.GroupClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ import org.testng.annotations.Test;
|
|||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "admin", "group"}, singleThreaded = true, testName = "GroupClientExpectTest")
|
||||
public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorAdminClient> {
|
||||
public class GroupClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
private Reference groupRef = Reference.builder()
|
||||
.type("application/vnd.vmware.admin.group+xml")
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -49,7 +49,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "media" }, singleThreaded = true, testName = "MediaClientExpectTest")
|
||||
public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
@Test
|
||||
public void testCreateMedia() {
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -53,7 +53,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "network" }, singleThreaded = true, testName = "NetworkClientExpectTest")
|
||||
public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class NetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
@Test
|
||||
public void testGetNetwork() {
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -47,7 +47,7 @@ import com.google.common.collect.Iterables;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "org" }, singleThreaded = true, testName = "OrgClientExpectTest")
|
||||
public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class OrgClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
@Test
|
||||
public void testGetOrgList() {
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Link;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultCatalogRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -42,7 +42,7 @@ import com.google.common.collect.ImmutableMultimap;
|
|||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "query" }, singleThreaded = true, testName = "QueryClientExpectTest")
|
||||
public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class QueryClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
@Test
|
||||
public void testQueryAllCatalogs() {
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Error;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.TasksList;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableMultimap;
|
|||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "task" }, singleThreaded = true, testName = "TaskClientExpectTest")
|
||||
public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class TaskClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
@Test
|
||||
public void testTaskListForValidOrg() {
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Link;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.User;
|
||||
import org.jclouds.vcloud.director.v1_5.features.admin.UserClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ import org.testng.annotations.Test;
|
|||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "admin", "adminUser"}, singleThreaded = true, testName = "UserClientExpectTest")
|
||||
public class UserClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorAdminClient> {
|
||||
public class UserClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
private Reference orgRef = Reference.builder()
|
||||
.href(URI.create(endpoint + "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||
|
|
|
@ -50,7 +50,7 @@ import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -65,7 +65,7 @@ import com.google.common.collect.Multimaps;
|
|||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "vapp" }, singleThreaded = true, testName = "VAppClientExpectTest")
|
||||
public class VAppClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
private String vAppId = "vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be";
|
||||
private URI vAppURI = URI.create(endpoint + vAppId);
|
||||
|
|
|
@ -66,8 +66,7 @@ import org.jclouds.vcloud.director.v1_5.domain.RelocateParams;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -78,7 +77,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "vapptemplate" }, testName = "VAppTemplateClientExpectTest")
|
||||
public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
public VAppTemplateClientExpectTest() {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -56,7 +56,7 @@ import org.testng.annotations.Test;
|
|||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "vdc" }, singleThreaded = true, testName = "VdcClientExpectTest")
|
||||
public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest<VCloudDirectorClient> {
|
||||
public class VdcClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||
|
||||
private URI vdcURI;
|
||||
|
||||
|
|
|
@ -0,0 +1,261 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.rest.RestContextFactory.createContext;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.BaseRestClientExpectTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.BaseRestClientExpectTest.ExpectModule;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.LinkedListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Base class for writing KeyStone Rest Client Expect tests
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class BaseVCloudDirectorExpectTest<T> extends BaseRestClientExpectTest<T> {
|
||||
|
||||
public BaseVCloudDirectorExpectTest() {
|
||||
provider = "vcloud-director";
|
||||
identity = String.format("%s@%s", user, org);
|
||||
credential = password;
|
||||
}
|
||||
|
||||
public static final String user = "adrian@jclouds.org";
|
||||
public static final String org = "JClouds";
|
||||
public static final String password = "password";
|
||||
public static final String token = "mIaR3/6Lna8DWImd7/JPR5rK8FcUHabt+G/UCJV5pJQ=";
|
||||
public static final String endpoint = "https://vcloudbeta.bluelock.com/api";
|
||||
|
||||
protected static DateService dateService;
|
||||
|
||||
@BeforeGroups("unit")
|
||||
protected static void setupDateService() {
|
||||
dateService = Guice.createInjector().getInstance(DateService.class);
|
||||
assertNotNull(dateService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties setupProperties() {
|
||||
Properties props = new Properties();
|
||||
props.put(Constants.PROPERTY_MAX_RETRIES, 1);
|
||||
return props;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
|
||||
if (input.getPayload() == null || input.getPayload().getContentMetadata().getContentLength() == 0) {
|
||||
return HttpRequestComparisonType.DEFAULT;
|
||||
}
|
||||
return HttpRequestComparisonType.XML;
|
||||
}
|
||||
|
||||
protected HttpRequest loginRequest = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create(endpoint + "/sessions"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "*/*")
|
||||
.put("Authorization", "Basic YWRyaWFuQGpjbG91ZHMub3JnQEpDbG91ZHM6cGFzc3dvcmQ=")
|
||||
.build())
|
||||
.build();
|
||||
|
||||
protected HttpResponse sessionResponse = HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("x-vcloud-authorization", token)
|
||||
.put("Set-Cookie", String.format("vcloud-token=%s; Secure; Path=/", token))
|
||||
.build())
|
||||
.payload(payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, String path) {
|
||||
return getStandardRequest(method, path, VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, URI uri) {
|
||||
return getStandardRequest(method, uri, VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, String path, String mediaType) {
|
||||
return getStandardRequest(method, URI.create(endpoint + path), VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardPayloadRequest(String method, String command, String relativeFilePath,
|
||||
String postMediaType) {
|
||||
return getStandardPayloadRequest(method, URI.create(endpoint + command), relativeFilePath, postMediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardPayloadRequest(String method, URI uri, String relativeFilePath,
|
||||
String postMediaType) {
|
||||
return getStandardRequestWithPayload(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, postMediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, URI uri, String mediaType) {
|
||||
return HttpRequest.builder()
|
||||
.method(method)
|
||||
.endpoint(uri)
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", mediaType)
|
||||
.put("x-vcloud-authorization", token)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, String path, String relativeFilePath, String mediaType) {
|
||||
return getStandardRequestWithPayload(method, path, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, URI uri, String relativeFilePath, String mediaType) {
|
||||
return getStandardRequestWithPayload(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, String path, String acceptType, String relativeFilePath, String mediaType) {
|
||||
URI uri = URI.create(endpoint + path);
|
||||
return getStandardRequestWithPayload(method, uri, acceptType, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, URI uri, String acceptType, String relativeFilePath, String mediaType) {
|
||||
return HttpRequest.builder()
|
||||
.method(method)
|
||||
.endpoint(uri)
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", acceptType)
|
||||
.put("x-vcloud-authorization", token)
|
||||
.build())
|
||||
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) {
|
||||
return getStandardPayloadResponse(200, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpResponse getStandardPayloadResponse(int statusCode, String relativeFilePath, String mediaType) {
|
||||
return HttpResponse.builder()
|
||||
.statusCode(statusCode)
|
||||
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType + ";version=1.5"))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implicitly adds x-vcloud-authorization header with token.
|
||||
* Provides convenience methods for priming a HttpRequest.Builder for vCloud testing
|
||||
*
|
||||
* @author danikov
|
||||
*/
|
||||
public class VcloudHttpRequestPrimer {
|
||||
private Multimap<String, String> headers = LinkedListMultimap.create();
|
||||
private HttpRequest.Builder builder = HttpRequest.builder();
|
||||
|
||||
public VcloudHttpRequestPrimer() {
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer apiCommand(String method, String command) {
|
||||
builder.method(method).endpoint(URI.create(endpoint + command));
|
||||
return this;
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer xmlFilePayload(String relativeFilePath, String mediaType) {
|
||||
builder.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType));
|
||||
return this;
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer headers(Multimap<String, String> headers) {
|
||||
this.headers.putAll(ImmutableMultimap.copyOf(checkNotNull(headers, "headers")));
|
||||
return this;
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer acceptAnyMedia() {
|
||||
return acceptMedia(VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer acceptMedia(String media) {
|
||||
return header("Accept", media);
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer header(String name, String value) {
|
||||
headers.put(checkNotNull(name, "header.name"), checkNotNull(value, "header.value"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpRequest.Builder httpRequestBuilder() {
|
||||
header("x-vcloud-authorization", token);
|
||||
builder.headers(headers);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
protected class VcloudHttpResponsePrimer {
|
||||
private HttpResponse.Builder builder = HttpResponse.builder();
|
||||
|
||||
public VcloudHttpResponsePrimer() {
|
||||
}
|
||||
|
||||
public VcloudHttpResponsePrimer xmlFilePayload(String relativeFilePath, String mediaType) {
|
||||
builder.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType));
|
||||
return this;
|
||||
}
|
||||
public HttpResponse.Builder httpResponseBuilder() {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
public URI toAdminUri(Reference ref) {
|
||||
return toAdminUri(ref.getHref());
|
||||
}
|
||||
|
||||
public URI toAdminUri(URI uri) {
|
||||
return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref();
|
||||
}
|
||||
}
|
|
@ -18,237 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.rest.BaseRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.LinkedListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.inject.Guice;
|
||||
|
||||
/**
|
||||
* Base class for writing KeyStone Rest Client Expect tests
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class BaseVCloudDirectorRestClientExpectTest<T extends VCloudDirectorClient>
|
||||
extends BaseRestClientExpectTest<T> {
|
||||
public abstract class BaseVCloudDirectorRestClientExpectTest extends BaseVCloudDirectorExpectTest<VCloudDirectorClient> {
|
||||
|
||||
public static final String user = "adrian@jclouds.org";
|
||||
public static final String org = "JClouds";
|
||||
public static final String password = "password";
|
||||
public static final String token = "mIaR3/6Lna8DWImd7/JPR5rK8FcUHabt+G/UCJV5pJQ=";
|
||||
public static final String endpoint = "https://vcloudbeta.bluelock.com/api";
|
||||
|
||||
protected static DateService dateService;
|
||||
|
||||
@BeforeGroups("unit")
|
||||
protected static void setupDateService() {
|
||||
dateService = Guice.createInjector().getInstance(DateService.class);
|
||||
assertNotNull(dateService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties setupProperties() {
|
||||
Properties props = new Properties();
|
||||
props.put(Constants.PROPERTY_MAX_RETRIES, 1);
|
||||
return props;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
|
||||
if (input.getPayload() == null || input.getPayload().getContentMetadata().getContentLength() == 0) {
|
||||
return HttpRequestComparisonType.DEFAULT;
|
||||
}
|
||||
return HttpRequestComparisonType.XML;
|
||||
}
|
||||
|
||||
protected HttpRequest loginRequest = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create(endpoint + "/sessions"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "*/*")
|
||||
.put("Authorization", "Basic YWRyaWFuQGpjbG91ZHMub3JnQEpDbG91ZHM6cGFzc3dvcmQ=")
|
||||
.build())
|
||||
.build();
|
||||
|
||||
protected HttpResponse sessionResponse = HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("x-vcloud-authorization", token)
|
||||
.put("Set-Cookie", String.format("vcloud-token=%s; Secure; Path=/", token))
|
||||
.build())
|
||||
.payload(payloadFromResourceWithContentType("/session.xml", VCloudDirectorMediaType.SESSION + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
public BaseVCloudDirectorRestClientExpectTest() {
|
||||
provider = "vcloud-director";
|
||||
identity = String.format("%s@%s", user, org);
|
||||
credential = password;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, String path) {
|
||||
return getStandardRequest(method, path, VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, URI uri) {
|
||||
return getStandardRequest(method, uri, VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, String path, String mediaType) {
|
||||
return getStandardRequest(method, URI.create(endpoint + path), VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardPayloadRequest(String method, String command, String relativeFilePath,
|
||||
String postMediaType) {
|
||||
return getStandardPayloadRequest(method, URI.create(endpoint + command), relativeFilePath, postMediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardPayloadRequest(String method, URI uri, String relativeFilePath,
|
||||
String postMediaType) {
|
||||
return getStandardRequestWithPayload(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, postMediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, URI uri, String mediaType) {
|
||||
return HttpRequest.builder()
|
||||
.method(method)
|
||||
.endpoint(uri)
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", mediaType)
|
||||
.put("x-vcloud-authorization", token)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, String path, String relativeFilePath, String mediaType) {
|
||||
return getStandardRequestWithPayload(method, path, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, URI uri, String relativeFilePath, String mediaType) {
|
||||
return getStandardRequestWithPayload(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, String path, String acceptType, String relativeFilePath, String mediaType) {
|
||||
URI uri = URI.create(endpoint + path);
|
||||
return getStandardRequestWithPayload(method, uri, acceptType, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, URI uri, String acceptType, String relativeFilePath, String mediaType) {
|
||||
return HttpRequest.builder()
|
||||
.method(method)
|
||||
.endpoint(uri)
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", acceptType)
|
||||
.put("x-vcloud-authorization", token)
|
||||
.build())
|
||||
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) {
|
||||
return getStandardPayloadResponse(200, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpResponse getStandardPayloadResponse(int statusCode, String relativeFilePath, String mediaType) {
|
||||
return HttpResponse.builder()
|
||||
.statusCode(statusCode)
|
||||
.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType + ";version=1.5"))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implicitly adds x-vcloud-authorization header with token.
|
||||
* Provides convenience methods for priming a HttpRequest.Builder for vCloud testing
|
||||
*
|
||||
* @author danikov
|
||||
*/
|
||||
public class VcloudHttpRequestPrimer {
|
||||
private Multimap<String, String> headers = LinkedListMultimap.create();
|
||||
private HttpRequest.Builder builder = HttpRequest.builder();
|
||||
|
||||
public VcloudHttpRequestPrimer() {
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer apiCommand(String method, String command) {
|
||||
builder.method(method).endpoint(URI.create(endpoint + command));
|
||||
return this;
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer xmlFilePayload(String relativeFilePath, String mediaType) {
|
||||
builder.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType));
|
||||
return this;
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer headers(Multimap<String, String> headers) {
|
||||
this.headers.putAll(ImmutableMultimap.copyOf(checkNotNull(headers, "headers")));
|
||||
return this;
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer acceptAnyMedia() {
|
||||
return acceptMedia(VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer acceptMedia(String media) {
|
||||
return header("Accept", media);
|
||||
}
|
||||
|
||||
public VcloudHttpRequestPrimer header(String name, String value) {
|
||||
headers.put(checkNotNull(name, "header.name"), checkNotNull(value, "header.value"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpRequest.Builder httpRequestBuilder() {
|
||||
header("x-vcloud-authorization", token);
|
||||
builder.headers(headers);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
protected class VcloudHttpResponsePrimer {
|
||||
private HttpResponse.Builder builder = HttpResponse.builder();
|
||||
|
||||
public VcloudHttpResponsePrimer() {
|
||||
}
|
||||
|
||||
public VcloudHttpResponsePrimer xmlFilePayload(String relativeFilePath, String mediaType) {
|
||||
builder.payload(payloadFromResourceWithContentType(relativeFilePath, mediaType));
|
||||
return this;
|
||||
}
|
||||
public HttpResponse.Builder httpResponseBuilder() {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
public URI toAdminUri(Reference ref) {
|
||||
return toAdminUri(ref.getHref());
|
||||
}
|
||||
|
||||
public URI toAdminUri(URI uri) {
|
||||
return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.internal;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext;
|
||||
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class VCloudDirectorAdminClientExpectTest extends
|
||||
BaseVCloudDirectorExpectTest<VCloudDirectorAdminClient> implements
|
||||
Function<VCloudDirectorContext, VCloudDirectorAdminClient> {
|
||||
|
||||
@Override
|
||||
public VCloudDirectorAdminClient createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
|
||||
return apply(createVCloudDirectorContext(fn, module, props));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VCloudDirectorAdminClient apply(VCloudDirectorContext input) {
|
||||
return input.getAdminContext().getApi();
|
||||
}
|
||||
|
||||
private VCloudDirectorContext createVCloudDirectorContext(Function<HttpRequest, HttpResponse> fn, Module module,
|
||||
Properties props) {
|
||||
return VCloudDirectorContext.class.cast(new RestContextFactory(setupRestProperties()).createContext(provider,
|
||||
identity, credential, ImmutableSet.<Module> of(new ExpectModule(fn), new NullLoggingModule(), module), props));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue