finish network test

This commit is contained in:
danikov 2012-02-09 02:10:06 +00:00
parent 24bd9f72e3
commit e5eea32e69
1 changed files with 29 additions and 30 deletions

View File

@ -24,16 +24,16 @@ import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.IpAddresses;
import org.jclouds.vcloud.director.v1_5.domain.IpRange;
import org.jclouds.vcloud.director.v1_5.domain.IpRanges;
import org.jclouds.vcloud.director.v1_5.domain.IpScope; import org.jclouds.vcloud.director.v1_5.domain.IpScope;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.VAppNetwork; import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings;
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.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -45,18 +45,12 @@ import org.testng.annotations.Test;
@Test(groups = "unit", singleThreaded = true, testName = "NetworkClientExpectTest") @Test(groups = "unit", singleThreaded = true, testName = "NetworkClientExpectTest")
public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
/*
GET /network/{id}
GET /network/{id}/metadata
GET /network/{id}/metadata/{key}
*/
@Test @Test
public void testWhenResponseIs2xxLoginReturnsValidNetwork() { public void testWhenResponseIs2xxLoginReturnsValidNetwork() {
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY"); URI networkRef = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", orgRef), getStandardRequest("GET", networkRef),
getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK_XML)); getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK_XML));
OrgNetwork expected = OrgNetwork OrgNetwork expected = OrgNetwork
@ -68,37 +62,41 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
.link(Link.builder() .link(Link.builder()
.rel("up") .rel("up")
.type("application/vnd.vmware.vcloud.org+xml") .type("application/vnd.vmware.vcloud.org+xml")
.name("Cluster01-JClouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build()) .build())
.link(Link.builder() .link(Link.builder()
.rel("down") .rel("down")
.type("application/vnd.vmware.vcloud.metadata+xml") .type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadat")) .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"))
.build()) .build())
.description("") .description("")
.configuration(NetworkConfiguration.builder() .configuration(NetworkConfiguration.builder()
.IpScope(IpScope.builder() .ipScope(IpScope.builder()
.isInherited(true) .isInherited(true)
.gateway("") .gateway("173.240.107.49")
.netmask("") .netmask("255.255.255.240")
.dns1("") .dns1("173.240.111.52")
.dns2("") .dns2("173.240.111.53")
.ipRange("", "") .ipRanges(IpRanges.builder()
.ipRange(IpRange.builder()
.startAddress("173.240.107.50")
.endAddress("173.240.107.62")
.build())
.build())
.build()) .build())
.fenceMode("bridged") .fenceMode("bridged")
.retainNetInfoAcrossDeployments(false) .retainNetInfoAcrossDeployments(false)
.syslogServerSettings(null) .syslogServerSettings(SyslogServerSettings.builder().build())
.build()) .build())
.allowedExternalIpAddresses(null) .allowedExternalIpAddresses(IpAddresses.builder().build())
.build(); .build();
assertEquals(client.getNetworkClient().getNetwork(networkRef), expected); assertEquals(client.getNetworkClient().getNetwork(networkRef), expected);
} }
@Test @Test
public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY"); URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c");
URI metaRef = URI.create(orgRef.toASCIIString()+"/metadata/"); URI metaRef = URI.create(orgRef.toASCIIString()+"/metadata/");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -107,11 +105,11 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
Metadata expected = Metadata.builder() Metadata expected = Metadata.builder()
.type("application/vnd.vmware.vcloud.metadata+xml") .type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY/metadata")) .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"))
.link(Link.builder() .link(Link.builder()
.rel("up") .rel("up")
.type("????????") .type("application/vnd.vmware.vcloud.network+xml")
.href(URI.create("??????")) .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
.build()) .build())
.build(); .build();
@ -119,8 +117,9 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
} }
@Test(enabled=false) // No metadata in exemplar xml... @Test(enabled=false) // No metadata in exemplar xml...
public void testWhenResponseIs2xxLoginReturnsValidMetadata() { public void testWhenResponseIs2xxLoginReturnsValidMetadataEntry() {
URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY/metadata/KEY"); URI metadataRef = URI.create(
"https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/KEY");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", metadataRef), getStandardRequest("GET", metadataRef),