@author Adrian Cole
}
public void testError() {
InputStream is = getClass().getResourceAsStream("/task-error.xml");
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), null, TaskStatus.ERROR,
dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"),
dateService.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new ReferenceTypeImpl("testapp1",
TerremarkVCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), new ErrorImpl(
"Error processing job", 500, MinorCode.UNRECOGNIZED,
" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00", null));
}
public void testInstantiated() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/instantiatedvapp.xml");
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
VApp expects = new VAppImpl("centos53", URI
.create("http://10.150.4.49/api/v0.8/vApp/10"), Status.RESOLVED, 123456789l, new ReferenceTypeImpl(null,
"application/vnd.vmware.vcloud.vdc+xml", URI.create("http://10.150.4.49/api/v0.8/vdc/4")),
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet
.<ResourceAllocationSettingData> of());
assertEquals(result, expects);
}
public void testDefault() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/vapp.xml");
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
"10.150.4.93");
VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName(
"Virtual Hardware Family").virtualSystemIdentifier("centos53").virtualSystemType("vmx-07").build();
Set<ResourceAllocationSettingData> resourceAllocations = ImmutableSet.<ResourceAllocationSettingData> of(
ResourceAllocationSettingData.builder().instanceID("1").elementName("1 virtual CPU(s)").description(
"Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR).virtualQuantity(1l)
.allocationUnits("hertz * 10^6").virtualQuantityUnits("count").build(),
ResourceAllocationSettingData.builder().instanceID("2").elementName("16MB of memory").description(
"Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(16l).allocationUnits(
"byte * 2^20").virtualQuantityUnits("byte * 2^20").build(),
ResourceAllocationSettingData.builder().instanceID("3").elementName("SCSI Controller 0").description(
"SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic")
.address("0").build(),
ResourceAllocationSettingData.builder().instanceID("8").elementName("Network Adapter 1").description(
"PCNet32 ethernet adapter on \"Internal\" network").resourceType(ResourceType.ETHERNET_ADAPTER)
.resourceSubType("PCNet32").addressOnParent("7").connection("Internal").automaticAllocation(
true).build(),
ResourceAllocationSettingData.builder().instanceID("9").elementName("Hard Disk 1").resourceType(
ResourceType.DISK_DRIVE).hostResource("104857").addressOnParent("0").parent("3")
.virtualQuantity(104857l).build());
VApp expects = new VAppImpl("centos53", URI
.create("http://10.150.4.49/api/v0.8/vApp/10"), Status.ON, Long.valueOf(104857), new ReferenceTypeImpl(null,
"application/vnd.vmware.vcloud.vdc+xml", URI.create("http://10.150.4.49/api/v0.8/vdc/4")),
networkToAddresses, null, "Other Linux (32-bit)", system, resourceAllocations);
assertEquals(result.getHref(), expects.getHref());
assertEquals(result.getName(), expects.getName());
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
assertEquals(result.getResourceAllocations().toString(), expects.getResourceAllocations().toString());
assertEquals(result.getSize(), expects.getSize());
assertEquals(result.getStatus(), expects.getStatus());
assertEquals(result.getSystem().toString(), expects.getSystem().toString());
assertEquals(result.getType(), expects.getType());
assertEquals(result.getVDC(), expects.getVDC());
}
}
public void testLatest() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/vapp2.xml");
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
"10.23.119.221");
VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName(
"Virtual Hardware Family").virtualSystemIdentifier("m1").virtualSystemType("vmx-07").build();
Set<ResourceAllocationSettingData> resourceAllocations = ImmutableSet.<ResourceAllocationSettingData> of(
ResourceAllocationSettingData.builder().instanceID("1").elementName("1 virtual CPU(s)").description(
"Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR).virtualQuantity(1l)
.allocationUnits("hertz * 10^6").virtualQuantityUnits("count").build(),
ResourceAllocationSettingData.builder().instanceID("2").elementName("512MB of memory").description(
"Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(512l).allocationUnits(
"byte * 2^20").virtualQuantityUnits("byte * 2^20").build(),
ResourceAllocationSettingData.builder().instanceID("3").elementName("SCSI Controller 0").description(
"SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic")
.address("0").build(),
ResourceAllocationSettingData.builder().instanceID("8").elementName("Network Adapter 1").description(
"PCNet32 ethernet adapter on \"Internal\" network").resourceType(ResourceType.ETHERNET_ADAPTER)
.resourceSubType("PCNet32").addressOnParent("7").connection("Internal").automaticAllocation(
true).build(),
ResourceAllocationSettingData.builder().instanceID("9").elementName("Hard Disk 1").resourceType(
ResourceType.DISK_DRIVE).hostResource("10485760").addressOnParent("0").parent("3")
.virtualQuantity(10485760l).build());
VApp expects = new VAppImpl("m1", URI.create("http://localhost:8000/api/v0.8/vApp/80"),
Status.ON, Long.valueOf(10485760), new ReferenceTypeImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI
.create("http://localhost:8000/api/v0.8/vdc/28")), networkToAddresses, null,
"Microsoft Windows XP Professional (32-bit)", system, resourceAllocations);
assertEquals(result.getHref(), expects.getHref());
assertEquals(result.getName(), expects.getName());
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
assertEquals(result.getResourceAllocations().toString(), expects.getResourceAllocations().toString());
assertEquals(result.getSize(), expects.getSize());
assertEquals(result.getStatus(), expects.getStatus());
assertEquals(result.getSystem().toString(), expects.getSystem().toString());
assertEquals(result.getType(), expects.getType());
assertEquals(result.getVDC(), expects.getVDC());
}
public class VAppExtendedInfoHandlerTest extends BaseHandlerTest {
public void test() {
InputStream is = getClass().getResourceAsStream("/vapp-ext.xml");
VAppExtendedInfo result = factory.create(injector.getInstance(VAppExtendedInfoHandler.class)).parse(is);
assertEquals(
result,
VAppExtendedInfo
.builder()
.id("392992")
public void testTerremark() {
InputStream is = getClass().getResourceAsStream("/vAppTemplate-trmk.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
assertEquals(result, new VAppTemplateImpl("CentOS 5.3 (32-bit)", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vAppTemplate/5"),
"description of CentOS 5.3 (32-bit)", null));
}
try {
final String token = parseTokenFromHeaders(from);
final Map<String, ReferenceType> org = factory.create(orgHandlerProvider.get()).parse(
checkNotNull(from.getPayload().getInput(), "no payload in http response to login request %s", from));
return new VCloudSession() {
@VCloudToken
public String getVCloudToken() {
return token;
}
}
@Override
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
AtomicReference<AuthorizationException> authException, TerremarkVCloudLoginClient login) {
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
@Override
public Map<String, ReferenceType> getOrgs() {
return ImmutableMap.<String, ReferenceType> of(ORG_REF.getName(), ORG_REF);
}
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/vdc.xml");
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
assertEquals(result.getName(), "Miami Environment 1");
assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
assertEquals(result.getResourceEntities(), ImmutableMap.<String, ReferenceType> of(
"adriantest",
new ReferenceTypeImpl("adriantest", TerremarkVCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15124")),
"centos-53",
new ReferenceTypeImpl("centos-53", TerremarkVCloudMediaType.VAPP_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15120"))));
assertEquals(result.getAvailableNetworks(), ImmutableMap.of(
"10.114.34.128/26",
new ReferenceTypeImpl("10.114.34.128/26", "application/vnd.vmware.vcloud.network+xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
assertEquals(
result.getCatalog(),
new ReferenceTypeImpl("Miami Environment 1", CATALOG_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
assertEquals(
result.getPublicIps(),
new ReferenceTypeImpl("Public IPs", "application/xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps")));
assertEquals(
result.getInternetServices(),
new ReferenceTypeImpl("Internet Services", "application/xml", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices")));
}
@Override
public Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Catalog>> get() {
return ImmutableMap.<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Catalog>> of(ORG_REF
.getName(), ImmutableMap.<String, org.jclouds.trmk.vcloud_0_8.domain.Catalog> of(
CATALOG_REF.getName(),
new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null,
ImmutableMap.<String, ReferenceType> of(
"item",
new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")),
"template",
Related Classes of org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions$Builder
Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.