mirror of https://github.com/apache/jclouds.git
adminCatalog expect/live tests w/ getCatalog
This commit is contained in:
parent
1e8841062b
commit
c711b7ed49
|
@ -0,0 +1,101 @@
|
||||||
|
/*
|
||||||
|
* 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.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.CatalogItems;
|
||||||
|
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.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the {@link CatalogClient} by observing its side effects.
|
||||||
|
*
|
||||||
|
* @author grkvlt@apache.org
|
||||||
|
*/
|
||||||
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "CatalogClientExpectTest")
|
||||||
|
public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetCatalog() {
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
|
new VcloudHttpRequestPrimer()
|
||||||
|
.apiCommand("GET", "/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4")
|
||||||
|
.acceptAnyMedia()
|
||||||
|
.httpRequestBuilder().build(),
|
||||||
|
new VcloudHttpResponsePrimer()
|
||||||
|
.xmlFilePayload("/admin/catalog/catalog.xml", VCloudDirectorMediaType.ADMIN_CATALOG)
|
||||||
|
.httpResponseBuilder().build());
|
||||||
|
|
||||||
|
AdminCatalog expected = catalog();
|
||||||
|
|
||||||
|
Reference catalogRef = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.href(URI.create(endpoint + "/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getCatalogClient().getCatalog(catalogRef), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final AdminCatalog catalog() {
|
||||||
|
return AdminCatalog.builder()
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.id("urn:vcloud:catalog:7212e451-76e1-4631-b2de-ba1dfd8080e4")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("add")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/catalogItems"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("down")
|
||||||
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
|
||||||
|
.build())
|
||||||
|
.catalogItems(CatalogItems.builder()
|
||||||
|
.item(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.name("ubuntu10")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
|
.build())
|
||||||
|
.item(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.name("imageTesting")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939"))
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
|
.description("Testing")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* 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.features;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_EXIST_FMT;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
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.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests live behavior of {@link AdminCatalogClient}.
|
||||||
|
*
|
||||||
|
* @author danikov
|
||||||
|
*/
|
||||||
|
@Test(groups = { "live", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest")
|
||||||
|
public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convenience references to API clients.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private AdminCatalogClient catalogClient;
|
||||||
|
private QueryClient queryClient;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shared state between dependant tests.
|
||||||
|
*/
|
||||||
|
private ReferenceType<?> catalogRef;
|
||||||
|
private AdminCatalog catalog;
|
||||||
|
|
||||||
|
@BeforeClass(inheritGroups = true)
|
||||||
|
public void setupRequiredClients() {
|
||||||
|
catalogClient = context.getApi().getAdminCatalogClient();
|
||||||
|
queryClient = context.getApi().getQueryClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(testName = "GET /catalog/{id}")
|
||||||
|
public void testGetCatalog() {
|
||||||
|
// TODO use property from default property set
|
||||||
|
CatalogReferences catalogReferences = queryClient.catalogReferencesQuery(String.format("name==%s", catalogName));
|
||||||
|
assertEquals(Iterables.size(catalogReferences.getReferences()), 1, String.format(MUST_EXIST_FMT, catalogName, "Catalog"));
|
||||||
|
catalogRef = Iterables.getOnlyElement(catalogReferences.getReferences());
|
||||||
|
catalog = catalogClient.getCatalog(catalogRef);
|
||||||
|
|
||||||
|
Checks.checkAdminCatalog(catalog);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue