mirror of https://github.com/apache/jclouds.git
Issue 112: stabalizing vcloud support
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2365 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
638c80e58d
commit
1173689417
1
pom.xml
1
pom.xml
|
@ -48,6 +48,7 @@
|
|||
<module>nirvanix</module>
|
||||
<module>twitter</module>
|
||||
<module>rimuhosting</module>
|
||||
<module>vcloud</module>
|
||||
<module>scriptbuilder</module>
|
||||
</modules>
|
||||
<build>
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.config;
|
||||
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTNETWORK;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
@ -55,7 +57,8 @@ import com.google.inject.AbstractModule;
|
|||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||
* Configures the VCloud authentication service connection, including logging
|
||||
* and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -63,86 +66,96 @@ import com.google.inject.Provides;
|
|||
@ConfiguresRestClient
|
||||
public class VCloudRestClientModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected VCloudAsyncClient provideAsyncClient(RestClientFactory factory) {
|
||||
return factory.create(VCloudAsyncClient.class);
|
||||
}
|
||||
@Provides
|
||||
@Singleton
|
||||
protected VCloudAsyncClient provideAsyncClient(RestClientFactory factory) {
|
||||
return factory.create(VCloudAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public VCloudClient provideClient(VCloudAsyncClient client) throws IllegalArgumentException,
|
||||
SecurityException, NoSuchMethodException {
|
||||
return SyncProxy.create(VCloudClient.class, client);
|
||||
}
|
||||
@Provides
|
||||
@Singleton
|
||||
public VCloudClient provideClient(VCloudAsyncClient client)
|
||||
throws IllegalArgumentException, SecurityException,
|
||||
NoSuchMethodException {
|
||||
return SyncProxy.create(VCloudClient.class, client);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@CatalogItemRoot
|
||||
@Singleton
|
||||
String provideCatalogItemRoot(@VCloudLogin URI vcloudUri) {
|
||||
return vcloudUri.toASCIIString().replace("/login", "/catalogItem");
|
||||
}
|
||||
@Provides
|
||||
@CatalogItemRoot
|
||||
@Singleton
|
||||
String provideCatalogItemRoot(@VCloudLogin URI vcloudUri) {
|
||||
return vcloudUri.toASCIIString().replace("/login", "/catalogItem");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@VAppRoot
|
||||
@Singleton
|
||||
String provideVAppRoot(@VCloudLogin URI vcloudUri) {
|
||||
return vcloudUri.toASCIIString().replace("/login", "/vapp");
|
||||
}
|
||||
@Provides
|
||||
@VAppRoot
|
||||
@Singleton
|
||||
String provideVAppRoot(@VCloudLogin URI vcloudUri) {
|
||||
return vcloudUri.toASCIIString().replace("/login", "/vapp");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@VAppTemplateRoot
|
||||
@Singleton
|
||||
String provideVAppTemplateRoot(@VCloudLogin URI vcloudUri) {
|
||||
return vcloudUri.toASCIIString().replace("/login", "/vAppTemplate");
|
||||
}
|
||||
@Provides
|
||||
@VAppTemplateRoot
|
||||
@Singleton
|
||||
String provideVAppTemplateRoot(@VCloudLogin URI vcloudUri) {
|
||||
return vcloudUri.toASCIIString().replace("/login", "/vAppTemplate");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Organization provideOrganization(VCloudDiscovery discovery) throws ExecutionException,
|
||||
TimeoutException, InterruptedException {
|
||||
return discovery.getOrganization().get(90, TimeUnit.SECONDS);
|
||||
}
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Organization provideOrganization(VCloudDiscovery discovery)
|
||||
throws ExecutionException, TimeoutException, InterruptedException {
|
||||
return discovery.getOrganization().get(90, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@VDC
|
||||
@Singleton
|
||||
protected URI provideDefaultVDC(Organization org) {
|
||||
return org.getVDCs().values().iterator().next().getLocation();
|
||||
}
|
||||
@Provides
|
||||
@VDC
|
||||
@Singleton
|
||||
protected URI provideDefaultVDC(Organization org) {
|
||||
return org.getVDCs().values().iterator().next().getLocation();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Catalog
|
||||
@Singleton
|
||||
protected URI provideCatalog(Organization org) {
|
||||
return org.getCatalog().getLocation();
|
||||
}
|
||||
@Provides
|
||||
@Catalog
|
||||
@Singleton
|
||||
protected URI provideCatalog(Organization org) {
|
||||
return org.getCatalog().getLocation();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("InstantiateVAppTemplateParams")
|
||||
protected String provideInstantiateVAppTemplateParams() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream("/InstantiateVAppTemplateParams.xml");
|
||||
return Utils.toStringAndClose(is);
|
||||
}
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("InstantiateVAppTemplateParams")
|
||||
protected String provideInstantiateVAppTemplateParams() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream(
|
||||
"/InstantiateVAppTemplateParams.xml");
|
||||
return Utils.toStringAndClose(is);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Network
|
||||
@Singleton
|
||||
protected URI provideDefaultNetwork(VCloudAsyncClient client) throws InterruptedException,
|
||||
ExecutionException, TimeoutException {
|
||||
return client.getDefaultVDC().get(60, TimeUnit.SECONDS).getAvailableNetworks().values()
|
||||
.iterator().next().getLocation();
|
||||
}
|
||||
@Provides
|
||||
@Network
|
||||
@Singleton
|
||||
protected URI provideDefaultNetwork(VCloudAsyncClient client)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return client.getDefaultVDC().get(60, TimeUnit.SECONDS)
|
||||
.getAvailableNetworks().values().iterator().next()
|
||||
.getLocation();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TasksList
|
||||
@Singleton
|
||||
protected URI provideDefaultTasksList(Organization org) {
|
||||
return org.getTasksLists().values().iterator().next().getLocation();
|
||||
}
|
||||
@Provides
|
||||
@Named(PROPERTY_VCLOUD_DEFAULTNETWORK)
|
||||
@Singleton
|
||||
String provideDefaultNetworkString(@Network URI network) {
|
||||
return network.toASCIIString();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TasksList
|
||||
@Singleton
|
||||
protected URI provideDefaultTasksList(Organization org) {
|
||||
return org.getTasksLists().values().iterator().next().getLocation();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,53 +41,93 @@ import com.google.inject.util.Providers;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.BindInstantiateVAppTemplateParamsToXmlEntityTest")
|
||||
public class BindInstantiateVAppTemplateParamsToXmlEntityTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(Jsr330.named(PROPERTY_VCLOUD_DEFAULTCPUCOUNT))
|
||||
.toProvider(Providers.<String> of(null));
|
||||
bind(String.class).annotatedWith(Jsr330.named(PROPERTY_VCLOUD_DEFAULTMEMORY)).toProvider(
|
||||
Providers.<String> of(null));
|
||||
bind(String.class).annotatedWith(Jsr330.named(PROPERTY_VCLOUD_DEFAULTNETWORK)).toProvider(
|
||||
Providers.<String> of(null));
|
||||
}
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTCPUCOUNT)).toProvider(
|
||||
Providers.<String> of("1"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTMEMORY)).toProvider(
|
||||
Providers.<String> of("512"));
|
||||
bind(String.class)
|
||||
.annotatedWith(Jsr330.named(PROPERTY_VCLOUD_DEFAULTNETWORK))
|
||||
.toProvider(
|
||||
Providers
|
||||
.<String> of("https://vcloud.safesecureweb.com/network/1990"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("InstantiateVAppTemplateParams")
|
||||
String provideInstantiateVAppTemplateParams() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream("/InstantiateVAppTemplateParams.xml");
|
||||
return Utils.toStringAndClose(is);
|
||||
}
|
||||
});
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("InstantiateVAppTemplateParams")
|
||||
String provideInstantiateVAppTemplateParams() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream(
|
||||
"/InstantiateVAppTemplateParams.xml");
|
||||
return Utils.toStringAndClose(is);
|
||||
}
|
||||
});
|
||||
|
||||
public void testApplyInputStream() throws IOException {
|
||||
String expected = IOUtils.toString(getClass().getResourceAsStream("/newvapp-hosting.xml"));
|
||||
Multimap<String, String> headers = Multimaps.synchronizedMultimap(HashMultimap
|
||||
.<String, String> create());
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null).atLeastOnce();
|
||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||
request.setEntity(expected);
|
||||
replay(request);
|
||||
public void testApplyInputStream1() throws IOException {
|
||||
String expected = IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/newvapp-hosting.xml"));
|
||||
Multimap<String, String> headers = Multimaps
|
||||
.synchronizedMultimap(HashMultimap.<String, String> create());
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(
|
||||
URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null)
|
||||
.atLeastOnce();
|
||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||
request.setEntity(expected);
|
||||
replay(request);
|
||||
|
||||
BindInstantiateVAppTemplateParamsToXmlEntity binder = injector
|
||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlEntity.class);
|
||||
BindInstantiateVAppTemplateParamsToXmlEntity binder = injector
|
||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlEntity.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "CentOS 01");
|
||||
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
||||
map.put("count", "1");
|
||||
map.put("megabytes", "512");
|
||||
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
|
||||
binder.bindToRequest(request, map);
|
||||
assertEquals(headers.get(HttpHeaders.CONTENT_TYPE), Collections
|
||||
.singletonList("application/unknown"));
|
||||
assertEquals(headers.get(HttpHeaders.CONTENT_LENGTH), Collections.singletonList("901"));
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "CentOS 01");
|
||||
map.put("template",
|
||||
"https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
||||
map.put("count", "1");
|
||||
map.put("megabytes", "512");
|
||||
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
|
||||
binder.bindToRequest(request, map);
|
||||
assertEquals(headers.get(HttpHeaders.CONTENT_TYPE), Collections
|
||||
.singletonList("application/unknown"));
|
||||
assertEquals(headers.get(HttpHeaders.CONTENT_LENGTH), Collections
|
||||
.singletonList("901"));
|
||||
}
|
||||
|
||||
}
|
||||
public void testApplyInputStream2() throws IOException {
|
||||
String expected = IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/newvapp-hosting.xml"));
|
||||
Multimap<String, String> headers = Multimaps
|
||||
.synchronizedMultimap(HashMultimap.<String, String> create());
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(
|
||||
URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null)
|
||||
.atLeastOnce();
|
||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||
request.setEntity(expected);
|
||||
replay(request);
|
||||
|
||||
BindInstantiateVAppTemplateParamsToXmlEntity binder = injector
|
||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlEntity.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "CentOS 01");
|
||||
map.put("template",
|
||||
"https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
||||
binder.bindToRequest(request, map);
|
||||
assertEquals(headers.get(HttpHeaders.CONTENT_TYPE), Collections
|
||||
.singletonList("application/unknown"));
|
||||
assertEquals(headers.get(HttpHeaders.CONTENT_LENGTH), Collections
|
||||
.singletonList("901"));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.hostingdotcom;
|
||||
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTNETWORK;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -41,8 +40,6 @@ public class HostingDotComVCloudPropertiesBuilder extends VCloudPropertiesBuilde
|
|||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_VCLOUD_ENDPOINT, "https://vcloud.safesecureweb.com/api");
|
||||
properties.setProperty(PROPERTY_VCLOUD_DEFAULTNETWORK,
|
||||
"https://vcloud.safesecureweb.com/network/1990");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ public class HostingDotComVCloudRestClientModule extends VCloudRestClientModule
|
|||
SecurityException, NoSuchMethodException {
|
||||
return SyncProxy.create(HostingDotComVCloudClient.class, client);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideDefaultNetwork(VCloudAsyncClient client) {
|
||||
return URI.create("https://vcloud.safesecureweb.com/network/1990");
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
package org.jclouds.vcloud.terremark;
|
||||
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTGROUP;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTPASSWORD;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTROW;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
@ -36,19 +39,23 @@ import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class TerremarkVCloudPropertiesBuilder extends VCloudPropertiesBuilder {
|
||||
@Override
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_TERREMARK_DEFAULTGROUP, "group");
|
||||
properties.setProperty(PROPERTY_TERREMARK_DEFAULTROW, "row");
|
||||
properties.setProperty((PROPERTY_TERREMARK_DEFAULTPASSWORD), "password");
|
||||
properties.setProperty(PROPERTY_VCLOUD_ENDPOINT,
|
||||
"https://services.vcloudexpress.terremark.com/api");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public TerremarkVCloudPropertiesBuilder(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
public TerremarkVCloudPropertiesBuilder(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public TerremarkVCloudPropertiesBuilder(String id, String secret) {
|
||||
super(URI.create("https://services.vcloudexpress.terremark.com/api"), id, secret);
|
||||
}
|
||||
public TerremarkVCloudPropertiesBuilder(String id, String secret) {
|
||||
super(URI.create("https://services.vcloudexpress.terremark.com/api"),
|
||||
id, secret);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class BindAddInternetServiceToXmlEntity implements MapBinder {
|
|||
entity = entity.replaceAll("\\{port\\}", port);
|
||||
entity = entity.replaceAll("\\{enabled\\}", enabled);
|
||||
entity = entity.replaceAll("\\{description\\}", description == null ? "" : String.format(
|
||||
"%n <Description>%s</Description>", description));
|
||||
"\n <Description>%s</Description>", description));
|
||||
|
||||
stringBinder.bindToRequest(request, entity);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class BindAddNodeServiceToXmlEntity implements MapBinder {
|
|||
entity = entity.replaceAll("\\{port\\}", port);
|
||||
entity = entity.replaceAll("\\{enabled\\}", enabled);
|
||||
entity = entity.replaceAll("\\{description\\}", description == null ? "" : String.format(
|
||||
"%n <Description>%s</Description>", description));
|
||||
"\n <Description>%s</Description>", description));
|
||||
|
||||
stringBinder.bindToRequest(request, entity);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,14 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.terremark;
|
||||
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTCPUCOUNT;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTMEMORY;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTNETWORK;
|
||||
import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Builder.disabled;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.cpuCount;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTGROUP;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTPASSWORD;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTROW;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -45,6 +51,7 @@ import org.jclouds.logging.Logger.LoggerFactory;
|
|||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.util.Jsr330;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.jclouds.vcloud.endpoints.Catalog;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
|
@ -53,9 +60,9 @@ import org.jclouds.vcloud.endpoints.VDC;
|
|||
import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
|
||||
import org.jclouds.vcloud.endpoints.internal.VAppRoot;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
||||
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
||||
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
||||
|
@ -66,6 +73,7 @@ import com.google.inject.AbstractModule;
|
|||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.util.Providers;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code TerremarkVCloudAsyncClient}
|
||||
|
@ -73,320 +81,400 @@ import com.google.inject.TypeLiteral;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", sequential = true, testName = "vcloud.TerremarkVCloudAsyncClientTest")
|
||||
public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVCloudAsyncClient> {
|
||||
public class TerremarkVCloudAsyncClientTest extends
|
||||
RestClientTest<TerremarkVCloudAsyncClient> {
|
||||
|
||||
public void testGetDefaultVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("getDefaultVDC");
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method);
|
||||
public void testGetDefaultVDC() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class
|
||||
.getMethod("getDefaultVDC");
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpMethod, "GET http://vdc HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
assertRequestLineEquals(httpMethod, "GET http://vdc HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TerremarkVDCHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TerremarkVDCHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testInstantiateVAppTemplate() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("instantiateVAppTemplate",
|
||||
String.class, String.class, Array.newInstance(TerremarkInstantiateVAppTemplateOptions.class,
|
||||
0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
"name", 3 + "");
|
||||
public void testInstantiateVAppTemplate() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"instantiateVAppTemplate", String.class, String.class, Array
|
||||
.newInstance(InstantiateVAppTemplateOptions.class, 0)
|
||||
.getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, "name", 3 + "");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST http://vdc/action/instantiatevAppTemplate HTTP/1.1");
|
||||
assertHeadersEqual(
|
||||
httpMethod,
|
||||
"Content-Length: 2245\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-test.xml")));
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vdc/action/instantiatevAppTemplate HTTP/1.1");
|
||||
assertHeadersEqual(
|
||||
httpMethod,
|
||||
"Content-Length: 2270\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
||||
.getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-test.xml")));
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testInstantiateVAppTemplateOptions() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("instantiateVAppTemplate",
|
||||
String.class, String.class, Array.newInstance(TerremarkInstantiateVAppTemplateOptions.class,
|
||||
0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
"name", 3 + "", cpuCount(4).megabytes(1024).inNetwork(URI.create("http://newnet")));
|
||||
public void testInstantiateVAppTemplateOptions() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"instantiateVAppTemplate", String.class, String.class, Array
|
||||
.newInstance(
|
||||
InstantiateVAppTemplateOptions.class,
|
||||
0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, "name", 3 + "", cpuCount(4).megabytes(
|
||||
1024).inNetwork(URI.create("http://newnet")));
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST http://vdc/action/instantiatevAppTemplate HTTP/1.1");
|
||||
assertHeadersEqual(
|
||||
httpMethod,
|
||||
"Content-Length: 2245\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-options-test.xml")));
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vdc/action/instantiatevAppTemplate HTTP/1.1");
|
||||
assertHeadersEqual(
|
||||
httpMethod,
|
||||
"Content-Length: 2239\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
||||
assertEntityEquals(
|
||||
httpMethod,
|
||||
IOUtils
|
||||
.toString(getClass()
|
||||
.getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-options-test.xml")));
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TerremarkVAppHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testAddInternetService() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetService",
|
||||
String.class, String.class, int.class, Array.newInstance(
|
||||
AddInternetServiceOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
"name", "tcp", 22);
|
||||
public void testAddInternetService() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"addInternetService", String.class, String.class, int.class,
|
||||
Array.newInstance(AddInternetServiceOptions.class, 0)
|
||||
.getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, "name", "tcp", 22);
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST http://vdc/internetServices HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Content-Length: 303\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/CreateInternetService-test2.xml")));
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vdc/internetServices HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 303\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
||||
.getResourceAsStream(
|
||||
"/terremark/CreateInternetService-test2.xml")));
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testAddInternetServiceOptions() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetService",
|
||||
String.class, String.class, int.class, Array.newInstance(
|
||||
AddInternetServiceOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
"name", "tcp", 22, disabled().withDescription("yahoo"));
|
||||
public void testAddInternetServiceOptions() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"addInternetService", String.class, String.class, int.class,
|
||||
Array.newInstance(AddInternetServiceOptions.class, 0)
|
||||
.getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, "name", "tcp", 22, disabled()
|
||||
.withDescription("yahoo"));
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST http://vdc/internetServices HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Content-Length: 341\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/CreateInternetService-options-test.xml")));
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vdc/internetServices HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 341\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
||||
.getResourceAsStream(
|
||||
"/terremark/CreateInternetService-options-test.xml")));
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testGetInternetService() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class
|
||||
.getMethod("getInternetService", String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
12);
|
||||
public void testGetInternetService() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"getInternetService", String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, 12);
|
||||
|
||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/internetServices/12 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"GET http://vcloud/internetServices/12 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testDeleteInternetService() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("deleteInternetService",
|
||||
String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
12);
|
||||
public void testDeleteInternetService() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"deleteInternetService", String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, 12);
|
||||
|
||||
assertRequestLineEquals(httpMethod, "DELETE http://vcloud/internetServices/12 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"DELETE http://vcloud/internetServices/12 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod,
|
||||
ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testAddInternetServiceToExistingIp() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToExistingIp",
|
||||
String.class, String.class, String.class, int.class, Array.newInstance(
|
||||
AddInternetServiceOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
12, "name", "tcp", 22);
|
||||
public void testAddInternetServiceToExistingIp() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"addInternetServiceToExistingIp", String.class, String.class,
|
||||
String.class, int.class, Array.newInstance(
|
||||
AddInternetServiceOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, 12, "name", "tcp", 22);
|
||||
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Content-Length: 303\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/CreateInternetService-test2.xml")));
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 303\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
||||
.getResourceAsStream(
|
||||
"/terremark/CreateInternetService-test2.xml")));
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testAddInternetServiceToExistingIpOptions() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToExistingIp",
|
||||
String.class, String.class, String.class, int.class, Array.newInstance(
|
||||
AddInternetServiceOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
12, "name", "tcp", 22, disabled().withDescription("yahoo"));
|
||||
public void testAddInternetServiceToExistingIpOptions()
|
||||
throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"addInternetServiceToExistingIp", String.class, String.class,
|
||||
String.class, int.class, Array.newInstance(
|
||||
AddInternetServiceOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, 12, "name", "tcp", 22, disabled()
|
||||
.withDescription("yahoo"));
|
||||
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Content-Length: 341\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/CreateInternetService-options-test.xml")));
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 341\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
||||
.getResourceAsStream(
|
||||
"/terremark/CreateInternetService-options-test.xml")));
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testAddNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode", String.class,
|
||||
InetAddress.class, String.class, int.class, Array.newInstance(AddNodeOptions.class,
|
||||
0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
12, InetAddress.getByName("10.2.2.2"), "name", 22);
|
||||
public void testAddNode() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode",
|
||||
String.class, InetAddress.class, String.class, int.class, Array
|
||||
.newInstance(AddNodeOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, 12, InetAddress.getByName("10.2.2.2"),
|
||||
"name", 22);
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/internetServices/12/nodes HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Content-Length: 298\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/CreateNodeService-test2.xml")));
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vcloud/internetServices/12/nodes HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 298\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
||||
.getResourceAsStream("/terremark/CreateNodeService-test2.xml")));
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testAddNodeOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode", String.class,
|
||||
InetAddress.class, String.class, int.class, Array.newInstance(AddNodeOptions.class,
|
||||
0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
12, InetAddress.getByName("10.2.2.2"), "name", 22, AddNodeOptions.Builder.disabled()
|
||||
.withDescription("yahoo"));
|
||||
public void testAddNodeOptions() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode",
|
||||
String.class, InetAddress.class, String.class, int.class, Array
|
||||
.newInstance(AddNodeOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, 12, InetAddress.getByName("10.2.2.2"),
|
||||
"name", 22, AddNodeOptions.Builder.disabled()
|
||||
.withDescription("yahoo"));
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/internetServices/12/nodes HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Content-Length: 336\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/CreateNodeService-options-test.xml")));
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"POST http://vcloud/internetServices/12/nodes HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 336\nContent-Type: application/xml\n");
|
||||
assertEntityEquals(httpMethod, IOUtils.toString(getClass()
|
||||
.getResourceAsStream(
|
||||
"/terremark/CreateNodeService-options-test.xml")));
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testGetNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNode", String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
12);
|
||||
public void testGetNode() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNode",
|
||||
String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, 12);
|
||||
|
||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/nodeServices/12 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"GET http://vcloud/nodeServices/12 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testDeleteNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("deleteNode", String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
12);
|
||||
public void testDeleteNode() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod(
|
||||
"deleteNode", String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor
|
||||
.createRequest(method, 12);
|
||||
|
||||
assertRequestLineEquals(httpMethod, "DELETE http://vcloud/nodeServices/12 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
assertRequestLineEquals(httpMethod,
|
||||
"DELETE http://vcloud/nodeServices/12 HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "");
|
||||
assertEntityEquals(httpMethod, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod,
|
||||
ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkFilters(GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod) {
|
||||
assertEquals(httpMethod.getFilters().size(), 1);
|
||||
assertEquals(httpMethod.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
|
||||
}
|
||||
@Override
|
||||
protected void checkFilters(
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod) {
|
||||
assertEquals(httpMethod.getFilters().size(), 1);
|
||||
assertEquals(httpMethod.getFilters().get(0).getClass(),
|
||||
SetVCloudTokenCookie.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<TerremarkVCloudAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<TerremarkVCloudAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<TerremarkVCloudAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<TerremarkVCloudAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Module createModule() {
|
||||
return new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(URI.class).annotatedWith(Catalog.class).toInstance(URI.create("http://catalog"));
|
||||
bind(String.class).annotatedWith(CatalogItemRoot.class)
|
||||
.toInstance("http://catalogItem");
|
||||
bind(URI.class).annotatedWith(VCloudApi.class).toInstance(URI.create("http://vcloud"));
|
||||
bind(String.class).annotatedWith(VAppRoot.class).toInstance("http://vapp");
|
||||
bind(URI.class).annotatedWith(VDC.class).toInstance(URI.create("http://vdc"));
|
||||
bind(URI.class).annotatedWith(Network.class).toInstance(URI.create("http://network"));
|
||||
bind(SetVCloudTokenCookie.class).toInstance(
|
||||
new SetVCloudTokenCookie(new Provider<String>() {
|
||||
@Override
|
||||
protected Module createModule() {
|
||||
return new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTGROUP))
|
||||
.toProvider(Providers.<String> of("group"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTROW))
|
||||
.toProvider(Providers.<String> of("row"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTPASSWORD))
|
||||
.toProvider(Providers.<String> of("password"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTCPUCOUNT))
|
||||
.toProvider(Providers.<String> of("1"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTMEMORY))
|
||||
.toProvider(Providers.<String> of("512"));
|
||||
bind(String.class)
|
||||
.annotatedWith(
|
||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTNETWORK))
|
||||
.toProvider(
|
||||
Providers
|
||||
.<String> of("https://vcloud.safesecureweb.com/network/1990"));
|
||||
bind(URI.class).annotatedWith(Catalog.class).toInstance(
|
||||
URI.create("http://catalog"));
|
||||
bind(String.class).annotatedWith(CatalogItemRoot.class)
|
||||
.toInstance("http://catalogItem");
|
||||
bind(URI.class).annotatedWith(VCloudApi.class).toInstance(
|
||||
URI.create("http://vcloud"));
|
||||
bind(String.class).annotatedWith(VAppRoot.class).toInstance(
|
||||
"http://vapp");
|
||||
bind(URI.class).annotatedWith(VDC.class).toInstance(
|
||||
URI.create("http://vdc"));
|
||||
bind(URI.class).annotatedWith(Network.class).toInstance(
|
||||
URI.create("http://network"));
|
||||
bind(SetVCloudTokenCookie.class).toInstance(
|
||||
new SetVCloudTokenCookie(new Provider<String>() {
|
||||
|
||||
public String get() {
|
||||
return "token";
|
||||
}
|
||||
public String get() {
|
||||
return "token";
|
||||
}
|
||||
|
||||
}));
|
||||
}));
|
||||
|
||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||
public Logger getLogger(String category) {
|
||||
return Logger.NULL;
|
||||
}
|
||||
});
|
||||
}
|
||||
bind(Logger.LoggerFactory.class).toInstance(
|
||||
new LoggerFactory() {
|
||||
public Logger getLogger(String category) {
|
||||
return Logger.NULL;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("InstantiateVAppTemplateParams")
|
||||
String provideInstantiateVAppTemplateParams() throws IOException {
|
||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams.xml"));
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("InstantiateVAppTemplateParams")
|
||||
String provideInstantiateVAppTemplateParams() throws IOException {
|
||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams.xml"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("CreateInternetService")
|
||||
String provideCreateInternetService() throws IOException {
|
||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/CreateInternetService.xml"));
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("CreateInternetService")
|
||||
String provideCreateInternetService() throws IOException {
|
||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/CreateInternetService.xml"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("CreateNodeService")
|
||||
String provideCreateNodeService() throws IOException {
|
||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/CreateNodeService.xml"));
|
||||
}
|
||||
};
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("CreateNodeService")
|
||||
String provideCreateNodeService() throws IOException {
|
||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/CreateNodeService.xml"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,15 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.terremark.binders;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTCPUCOUNT;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTMEMORY;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTNETWORK;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTGROUP;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTPASSWORD;
|
||||
import static org.jclouds.vcloud.terremark.reference.TerremarkVCloudConstants.PROPERTY_TERREMARK_DEFAULTROW;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -32,63 +40,124 @@ import java.util.Map;
|
|||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.util.Jsr330;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.util.Providers;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code TerremarkBindInstantiateVAppTemplateParamsToXmlEntity}
|
||||
* Tests behavior of {@code
|
||||
* TerremarkBindInstantiateVAppTemplateParamsToXmlEntity}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.TerremarkBindInstantiateVAppTemplateParamsToXmlEntityTest")
|
||||
public class TerremarkBindInstantiateVAppTemplateParamsToXmlEntityTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTGROUP)).toProvider(
|
||||
Providers.<String> of("group"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTROW)).toProvider(
|
||||
Providers.<String> of("row"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_TERREMARK_DEFAULTPASSWORD))
|
||||
.toProvider(Providers.<String> of("password"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTCPUCOUNT)).toProvider(
|
||||
Providers.<String> of("1"));
|
||||
bind(String.class).annotatedWith(
|
||||
Jsr330.named(PROPERTY_VCLOUD_DEFAULTMEMORY)).toProvider(
|
||||
Providers.<String> of("512"));
|
||||
bind(String.class)
|
||||
.annotatedWith(Jsr330.named(PROPERTY_VCLOUD_DEFAULTNETWORK))
|
||||
.toProvider(
|
||||
Providers
|
||||
.<String> of("https://vcloud.safesecureweb.com/network/1990"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("InstantiateVAppTemplateParams")
|
||||
String provideInstantiateVAppTemplateParams() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams.xml");
|
||||
return Utils.toStringAndClose(is);
|
||||
}
|
||||
});
|
||||
@SuppressWarnings("unused")
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named("InstantiateVAppTemplateParams")
|
||||
String provideInstantiateVAppTemplateParams() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams.xml");
|
||||
return Utils.toStringAndClose(is);
|
||||
}
|
||||
});
|
||||
|
||||
public void testApplyInputStream() throws IOException {
|
||||
String expected = IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-test-2.xml"));
|
||||
HttpRequest request = new HttpRequest("GET", URI.create("http://test"));
|
||||
TerremarkBindInstantiateVAppTemplateParamsToXmlEntity binder = injector
|
||||
.getInstance(TerremarkBindInstantiateVAppTemplateParamsToXmlEntity.class);
|
||||
public void testApplyInputStream() throws IOException {
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "name");
|
||||
map.put("password", "password");
|
||||
map.put("row", "row");
|
||||
map.put("group", "group");
|
||||
map.put("template", "http://catalogItem/3");
|
||||
map.put("count", "1");
|
||||
map.put("megabytes", "512");
|
||||
map.put("network", "http://network");
|
||||
binder.bindToRequest(request, map);
|
||||
assertEquals(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE), "application/unknown");
|
||||
assertEquals(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_LENGTH), "2239");
|
||||
assertEquals(request.getEntity(), expected);
|
||||
String expected = IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-test-2.xml"));
|
||||
Multimap<String, String> headers = Multimaps
|
||||
.synchronizedMultimap(HashMultimap.<String, String> create());
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(
|
||||
URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(
|
||||
"application/unknown").atLeastOnce();
|
||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||
request.setEntity(expected);
|
||||
replay(request);
|
||||
|
||||
}
|
||||
TerremarkBindInstantiateVAppTemplateParamsToXmlEntity binder = injector
|
||||
.getInstance(TerremarkBindInstantiateVAppTemplateParamsToXmlEntity.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "name");
|
||||
map.put("password", "password");
|
||||
map.put("row", "row");
|
||||
map.put("group", "group");
|
||||
map.put("template", "http://catalogItem/3");
|
||||
map.put("count", "1");
|
||||
map.put("megabytes", "512");
|
||||
map.put("network", "http://network");
|
||||
binder.bindToRequest(request, map);
|
||||
}
|
||||
|
||||
public void testApplyInputStream2() throws IOException {
|
||||
|
||||
String expected = IOUtils.toString(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-test-2.xml"));
|
||||
Multimap<String, String> headers = Multimaps
|
||||
.synchronizedMultimap(HashMultimap.<String, String> create());
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(
|
||||
URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(
|
||||
"application/unknown").atLeastOnce();
|
||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||
request.setEntity(expected);
|
||||
replay(request);
|
||||
|
||||
TerremarkBindInstantiateVAppTemplateParamsToXmlEntity binder = injector
|
||||
.getInstance(TerremarkBindInstantiateVAppTemplateParamsToXmlEntity.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "name");
|
||||
map.put("template", "http://catalogItem/3");
|
||||
map.put("count", "1");
|
||||
map.put("megabytes", "512");
|
||||
map.put("network", "http://network");
|
||||
binder.bindToRequest(request, map);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,6 @@ public class TerremarkInstantiateVAppTemplateOptionsTest {
|
|||
|
||||
Injector injector = Guice.createInjector(new ParserModule());
|
||||
|
||||
@Test
|
||||
public void testInGroupDefault() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
assertEquals(options.getGroup(), "default");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInGroup() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
|
@ -45,12 +39,6 @@ public class TerremarkInstantiateVAppTemplateOptionsTest {
|
|||
assertEquals(options.getGroup(), "group1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInRowDefault() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
assertEquals(options.getRow(), "default");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInRow() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
|
@ -64,12 +52,6 @@ public class TerremarkInstantiateVAppTemplateOptionsTest {
|
|||
assertEquals(options.getRow(), "row1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithPasswordDefault() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
assertEquals(options.getPassword(), "getPassword()");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithPassword() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
|
@ -98,9 +80,7 @@ public class TerremarkInstantiateVAppTemplateOptionsTest {
|
|||
|
||||
@Test
|
||||
public void testCpuCount() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
cpuCount(3);
|
||||
assertEquals(options.getCpuCount(), "3");
|
||||
assertEquals(cpuCount(3).getCpuCount(), "3");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -32,8 +32,9 @@ import java.net.URI;
|
|||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.jclouds.rest.domain.NamedLink;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.rest.domain.internal.NamedLinkImpl;
|
||||
import org.jclouds.rest.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.endpoints.VCloudApi;
|
||||
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -52,50 +53,66 @@ import com.google.inject.Provides;
|
|||
@Test(groups = "unit", testName = "vcloud.TerremarkVDCHandlerTest")
|
||||
public class TerremarkVDCHandlerTest {
|
||||
|
||||
public void testApplyInputStream() {
|
||||
InputStream is = getClass().getResourceAsStream("/terremark/vdc.xml");
|
||||
Injector injector = Guice.createInjector(new ParserModule(), new AbstractModule() {
|
||||
public void testApplyInputStream() {
|
||||
InputStream is = getClass().getResourceAsStream("/terremark/vdc.xml");
|
||||
Injector injector = Guice.createInjector(new ParserModule(),
|
||||
new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@VCloudApi
|
||||
URI provide() {
|
||||
return URI.create("https://services.vcloudexpress.terremark.com/api/v0.8");
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@VCloudApi
|
||||
URI provide() {
|
||||
return URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8");
|
||||
}
|
||||
|
||||
});
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
});
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
|
||||
TerremarkVDC result = (TerremarkVDC) factory.create(
|
||||
injector.getInstance(TerremarkVDCHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "Miami Environment 1");
|
||||
assertEquals(result.getLocation(), URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
|
||||
assertEquals(result.getResourceEntities(), ImmutableMap.<String, NamedLink> of());
|
||||
assertEquals(
|
||||
result.getAvailableNetworks(),
|
||||
ImmutableMap
|
||||
.of(
|
||||
"10.114.34.128/26",
|
||||
new NamedLinkImpl(
|
||||
"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 NamedLinkImpl("Miami Environment 1", CATALOG_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
|
||||
assertEquals(result.getPublicIps(), new NamedLinkImpl("Public IPs", "application/xml", URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps")));
|
||||
assertEquals(
|
||||
result.getInternetServices(),
|
||||
new NamedLinkImpl(
|
||||
"Internet Services",
|
||||
"application/xml",
|
||||
URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices")));
|
||||
}
|
||||
TerremarkVDC result = (TerremarkVDC) factory.create(
|
||||
injector.getInstance(TerremarkVDCHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "Miami Environment 1");
|
||||
assertEquals(
|
||||
result.getLocation(),
|
||||
URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
|
||||
assertEquals(result.getResourceEntities(), ImmutableMap
|
||||
.<String, NamedResource> of());
|
||||
assertEquals(
|
||||
result.getAvailableNetworks(),
|
||||
ImmutableMap
|
||||
.of(
|
||||
"10.114.34.128/26",
|
||||
new NamedResourceImpl(
|
||||
"1708",
|
||||
"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 NamedLinkImpl(
|
||||
"Miami Environment 1",
|
||||
CATALOG_XML,
|
||||
URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")));
|
||||
assertEquals(
|
||||
result.getPublicIps(),
|
||||
new NamedLinkImpl(
|
||||
"Public IPs",
|
||||
"application/xml",
|
||||
URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/publicIps")));
|
||||
assertEquals(
|
||||
result.getInternetServices(),
|
||||
new NamedLinkImpl(
|
||||
"Internet Services",
|
||||
"application/xml",
|
||||
URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/internetServices")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
ovf:key="password" ovf:value="password" />
|
||||
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
ovf:key="row" ovf:value="default" />
|
||||
ovf:key="row" ovf:value="row" />
|
||||
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
ovf:key="group" ovf:value="default" />
|
||||
ovf:key="group" ovf:value="group" />
|
||||
</ProductSection>
|
||||
<VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v1">
|
||||
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1">
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</VirtualHardwareSection>
|
||||
<NetworkConfigSection>
|
||||
<NetworkConfig>
|
||||
<NetworkAssociation href="http://network" />
|
||||
<NetworkAssociation href="https://vcloud.safesecureweb.com/network/1990" />
|
||||
</NetworkConfig>
|
||||
</NetworkConfigSection>
|
||||
</InstantiationParams>
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
ovf:key="password" ovf:value="password" />
|
||||
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
ovf:key="row" ovf:value="default" />
|
||||
ovf:key="row" ovf:value="row" />
|
||||
<Property xmlns="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
ovf:key="group" ovf:value="default" />
|
||||
ovf:key="group" ovf:value="group" />
|
||||
</ProductSection>
|
||||
<VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v1">
|
||||
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1">
|
||||
|
@ -31,7 +31,7 @@
|
|||
</VirtualHardwareSection>
|
||||
<NetworkConfigSection>
|
||||
<NetworkConfig>
|
||||
<NetworkAssociation href="http://network" />
|
||||
<NetworkAssociation href="https://vcloud.safesecureweb.com/network/1990" />
|
||||
</NetworkConfig>
|
||||
</NetworkConfigSection>
|
||||
</InstantiationParams>
|
||||
|
|
Loading…
Reference in New Issue