mirror of https://github.com/apache/jclouds.git
Issue 112: better error handling and timeouts
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2614 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
1048f91c5c
commit
e0a875333f
|
@ -43,8 +43,9 @@ public class Credentials {
|
|||
|
||||
public static Credentials parse(URI uri) {
|
||||
checkNotNull(uri, "uri");
|
||||
List<String> userInfo = Lists.newArrayList(Splitter.on(':').split(uri.getUserInfo()));
|
||||
String account = checkNotNull(userInfo.get(0));
|
||||
List<String> userInfo = Lists.newArrayList(Splitter.on(':').split(
|
||||
checkNotNull(uri.getUserInfo(), "no userInfo in " + uri)));
|
||||
String account = checkNotNull(userInfo.get(0), "no username in " + uri.getUserInfo());
|
||||
if (HttpUtils.isUrlEncoded(account)) {
|
||||
account = HttpUtils.urlDecode(account);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.vcloud.terremark;
|
||||
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
||||
|
||||
|
@ -46,6 +47,7 @@ import org.jclouds.rest.annotations.ResponseParser;
|
|||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.InetAddressToHostAddress;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
|
@ -81,6 +83,7 @@ import org.jclouds.vcloud.terremark.xml.NodesHandler;
|
|||
import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler;
|
||||
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
||||
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
|
||||
/**
|
||||
* Provides access to VCloud resources via their REST API.
|
||||
|
@ -91,7 +94,7 @@ import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
|||
*/
|
||||
@RequestFilters(SetVCloudTokenCookie.class)
|
||||
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||
|
||||
|
||||
/**
|
||||
* @see TerremarkVCloudClient#getDefaultVDC
|
||||
*/
|
||||
|
@ -102,6 +105,15 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
|||
@Override
|
||||
Future<? extends VDC> getDefaultVDC();
|
||||
|
||||
/**
|
||||
* Terremark does not have multiple catalogs, so we ignore this parameter.
|
||||
*/
|
||||
@GET
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
|
||||
@XMLResponseParser(CatalogHandler.class)
|
||||
@Consumes(CATALOG_XML)
|
||||
Future<? extends Catalog> getCatalog(String catalogId);
|
||||
|
||||
/**
|
||||
* @see TerremarkVCloudClient#getVDC
|
||||
*/
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
|||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 45, timeUnit = TimeUnit.SECONDS)
|
||||
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
|
||||
public interface TerremarkVCloudClient extends VCloudClient {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,6 +65,7 @@ import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
|||
import org.jclouds.vcloud.terremark.xml.NodesHandler;
|
||||
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
||||
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
@ -79,6 +80,24 @@ import com.google.inject.TypeLiteral;
|
|||
*/
|
||||
@Test(groups = "unit", sequential = true, testName = "vcloud.TerremarkVCloudAsyncClientTest")
|
||||
public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVCloudAsyncClient> {
|
||||
/**
|
||||
* ignore parameter of catalog id since this doesn't work
|
||||
*/
|
||||
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("getCatalog", String.class);
|
||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||
"1");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "GET http://catalog HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||
assertPayloadEquals(httpMethod, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testGetIpAddressesForNetwork() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
|
|
Loading…
Reference in New Issue