expect test and most of the live test for deleteCatalog

This commit is contained in:
danikov 2012-03-06 15:34:05 +00:00
parent d85e8ca587
commit b671d043f2
2 changed files with 44 additions and 2 deletions

View File

@ -118,6 +118,19 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
client.getAdminCatalogClient().setOwner(catalogRef.getURI(), newOwner); client.getAdminCatalogClient().setOwner(catalogRef.getURI(), newOwner);
} }
@Test
public void testDeleteCatalog() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("DELETE", "/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.httpResponseBuilder().statusCode(204).build());
client.getAdminCatalogClient().deleteCatalog(catalogRef.getURI());
}
public static final AdminCatalog catalog() { public static final AdminCatalog catalog() {
return AdminCatalog.builder() return AdminCatalog.builder()
.name("QunyingTestCatalog") .name("QunyingTestCatalog")

View File

@ -19,18 +19,21 @@
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.GETTER_RETURNS_SAME_OBJ; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.net.URI; import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.domain.Error;
import org.jclouds.vcloud.director.v1_5.domain.Owner; 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.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
@ -145,4 +148,30 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
catalog = catalogClient.updateCatalog(catalog.getURI(), catalog); catalog = catalogClient.updateCatalog(catalog.getURI(), catalog);
} }
} }
@Test(testName = "DELETE /admin/catalog/{id}",
dependsOnMethods = { "testUpdateCatalog" }, enabled = false )
public void testDeleteCatalog() {
catalogClient.deleteCatalog(catalogRef.getURI());
Error expected = Error.builder()
.message("???")
.majorErrorCode(403)
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
.build();
try {
catalog = catalogClient.getCatalog(catalogRef.getURI());
fail("Should give HTTP 403 error");
} catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected);
catalog = null;
} catch (Exception e) {
fail("Should have thrown a VCloudDirectorException");
}
if (catalog != null) { // guard against NPE on the .toStrings
assertNull(catalog, String.format(OBJ_DEL, CATALOG, catalog.toString()));
}
}
} }