create metadata for metadata testing

This commit is contained in:
danikov 2012-03-21 02:16:30 +00:00
parent b782fce5bf
commit 0e9ba3eb1e
18 changed files with 83 additions and 17 deletions

View File

@ -120,7 +120,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
.put(VAppTemplateClient.class, VAppTemplateAsyncClient.class)
.put(UploadClient.class, UploadAsyncClient.class)
.put(MetadataClient.Readable.class, MetadataAsyncClient.Readable.class)
.put(MetadataClient.Writeable.class, MetadataAsyncClient.Writable.class)
.put(MetadataClient.Writeable.class, MetadataAsyncClient.Writeable.class)
.put(GroupClient.class, GroupAsyncClient.class)
.put(UserClient.class, UserAsyncClient.class)
.put(AdminNetworkClient.class, AdminNetworkAsyncClient.class)

View File

@ -129,10 +129,10 @@ public interface AdminCatalogAsyncClient extends CatalogAsyncClient {
@BinderParam(BindToXMLPayload.class) PublishCatalogParams params);
/**
* @return synchronous access to {@link Metadata.Writable} features
* @return synchronous access to {@link Metadata.Writeable} features
*/
@Override
@Delegate
MetadataAsyncClient.Writable getMetadataClient();
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -116,7 +116,7 @@ public interface AdminCatalogClient extends CatalogClient {
//void publishCatalog(URI catalogRef)
/**
* @return synchronous access to {@link Metadata.Writable} features
* @return synchronous access to {@link Metadata.Writeable} features
*/
@Override
@Delegate

View File

@ -28,6 +28,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
@ -79,4 +80,11 @@ public interface AdminNetworkAsyncClient extends NetworkAsyncClient {
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> resetNetwork(@EndpointParam URI networkRef);
/**
* @return asynchronous access to admin {@link MetadataAsyncClient.Writeable} features
*/
@Override
@Delegate
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -22,6 +22,7 @@ import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.Network;
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.Task;
@ -81,5 +82,12 @@ public interface AdminNetworkClient extends NetworkClient {
* returned task status in order to check when it is completed.
*/
Task resetNetwork(URI networkRef);
/**
* @return synchronous access to admin {@link MetadataClient.Writeable} features
*/
@Override
@Delegate
MetadataClient.Writeable getMetadataClient();
}

View File

@ -27,6 +27,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
@ -217,4 +218,10 @@ public interface AdminOrgAsyncClient extends OrgAsyncClient {
@EndpointParam URI orgRef,
@BinderParam(BindToXMLPayload.class) OrgVAppTemplateLeaseSettings settings);
/**
* @return asynchronous access to admin {@link MetadataAsyncClient.Writeable} features
*/
@Override
@Delegate
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -22,6 +22,7 @@ import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings;
@ -216,5 +217,12 @@ public interface AdminOrgClient extends OrgClient {
*/
OrgVAppTemplateLeaseSettings updateVAppTemplateLeaseSettings(URI orgRef,
OrgVAppTemplateLeaseSettings newSettings);
/**
* @return synchronous access to admin {@link MetadataClient.Writeable} features
*/
@Override
@Delegate
MetadataClient.Writeable getMetadataClient();
}

View File

@ -36,7 +36,7 @@ import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writable;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
@ -86,8 +86,8 @@ public interface AdminVdcAsyncClient extends VdcAsyncClient {
ListenableFuture<Void> disableVdc(@EndpointParam URI vdcRef);
/**
* @return asynchronous access to {@link Writable} features
* @return asynchronous access to {@link Writeable} features
*/
@Delegate
MetadataAsyncClient.Writable getMetadataClient();
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -26,7 +26,7 @@ import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writable;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable;
/**
* Provides synchronous access to Network.
@ -78,7 +78,7 @@ public interface AdminVdcClient extends VdcClient {
void disableVdc(URI vdcRef);
/**
* @return synchronous access to {@link Writable} features
* @return synchronous access to {@link Writeable} features
*/
@Delegate
MetadataClient.Writeable getMetadataClient();

View File

@ -111,5 +111,5 @@ public interface CatalogAsyncClient {
* @return asynchronous access to {@link Metadata.Writeable} features for CatalogItems
*/
@Delegate
MetadataAsyncClient.Writable getCatalogItemMetadataClient();
MetadataAsyncClient.Writeable getCatalogItemMetadataClient();
}

View File

@ -119,5 +119,5 @@ public interface MediaAsyncClient {
* @return asynchronous access to {@link Metadata.Writeable} features
*/
@Delegate
MetadataAsyncClient.Writable getMetadataClient();
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -74,7 +74,7 @@ public interface MetadataAsyncClient {
}
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public static interface Writable extends Readable {
public static interface Writeable extends Readable {
/**
* @see MetadataClient.Writable#mergeMetadata(URI, Metadata))
*/

View File

@ -722,6 +722,6 @@ public interface VAppAsyncClient {
* @return asynchronous access to {@link Metadata} features
*/
@Delegate
MetadataAsyncClient.Writable getMetadataClient();
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -369,5 +369,5 @@ public interface VAppTemplateAsyncClient {
* @return asynchronous access to {@link Metadata} features
*/
@Delegate
MetadataAsyncClient.Writable getMetadataClient();
MetadataAsyncClient.Writeable getMetadataClient();
}

View File

@ -38,6 +38,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Network;
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.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -62,6 +63,14 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@BeforeClass(inheritGroups = true)
public void setupRequiredClients() {
networkClient = context.getApi().getNetworkClient();
context.getApi().getAdminNetworkClient().getMetadataClient().setMetadata(toAdminUri(networkURI),
"key", MetadataValue.builder().value("value").build());
}
@AfterClass(groups = { "live" })
public void cleanUp() throws Exception {
context.getApi().getAdminNetworkClient().getMetadataClient()
.deleteMetadataEntry(toAdminUri(networkURI), "key");
}
@Test(testName = "GET /network/{id}")

View File

@ -38,6 +38,7 @@ 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.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -62,6 +63,14 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public void setupRequiredClients() {
orgClient = context.getApi().getOrgClient();
}
@AfterClass(groups = { "live" })
public void cleanUp() throws Exception {
if (metadataSet) {
context.getApi().getAdminOrgClient().getMetadataClient()
.deleteMetadataEntry(toAdminUri(orgURI), "key");
}
}
/*
* Shared state between dependant tests.
@ -70,6 +79,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private OrgList orgList;
private URI orgURI;
private Org org;
private boolean metadataSet = false;
@Test(testName = "GET /org/")
public void testGetOrgList() {
@ -100,7 +110,14 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
checkOrg(org);
}
@Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testGetOrg" })
@Test(dependsOnMethods = { "testGetOrg" })
public void testSetupMetadata() {
context.getApi().getAdminOrgClient().getMetadataClient().setMetadata(toAdminUri(orgURI),
"KEY", MetadataValue.builder().value("VALUE").build());
metadataSet = true;
}
@Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testSetupMetadata" })
public void testGetOrgMetadata() {
// Call the method being tested
Metadata metadata = orgClient.getMetadataClient().getMetadata(orgURI);

View File

@ -87,7 +87,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /query")
public void testQuery() {
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
QueryResultRecords queryResult = queryClient.query("vAppTemplate", String.format("name==%s", vAppTemplate.getName()));
Set<URI> hrefs = toHrefs(queryResult);

View File

@ -104,6 +104,9 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
if (composedVApp != null) {
cleanUpVApp(composedVApp);
}
context.getApi().getAdminVdcClient().getMetadataClient()
.deleteMetadataEntry(toAdminUri(vdcURI), "key");
}
@Override
@ -304,7 +307,13 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
}
@Test(testName = "GET /network/{id}/metadata")
@Test(dependsOnMethods = { "testGetVdc" } )
public void testSetupMetadata() {
context.getApi().getAdminVdcClient().getMetadataClient().setMetadata(toAdminUri(vdcURI),
"key", MetadataValue.builder().value("value").build());
}
@Test(testName = "GET /network/{id}/metadata", dependsOnMethods = { "testSetupMetadata" } )
public void testGetMetadata() {
Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI);