mirror of https://github.com/apache/jclouds.git
workaround for error handling on deltacloud
This commit is contained in:
parent
eb4a8393fb
commit
12d927f40d
|
@ -50,10 +50,8 @@
|
|||
</repositories>
|
||||
|
||||
<properties>
|
||||
<!-- when instances are hung, open a ticket and add here -->
|
||||
<jclouds.compute.blacklist-nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist-nodes>
|
||||
<test.deltacloud.endpoint>http://localhost:3001/api</test.deltacloud.endpoint>
|
||||
<test.deltacloud.apiversion>0.1.2</test.deltacloud.apiversion>
|
||||
<test.deltacloud.apiversion>0.3.0</test.deltacloud.apiversion>
|
||||
<test.deltacloud.identity>mockuser</test.deltacloud.identity>
|
||||
<test.deltacloud.credential>mockpassword</test.deltacloud.credential>
|
||||
</properties>
|
||||
|
@ -127,10 +125,6 @@
|
|||
<name>test.deltacloud.credential</name>
|
||||
<value>${test.deltacloud.credential}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jclouds.compute.blacklist-nodes</name>
|
||||
<value>${jclouds.compute.blacklist-nodes}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -34,7 +34,7 @@ public class DeltacloudPropertiesBuilder extends PropertiesBuilder {
|
|||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_API_VERSION, "0.1.2");
|
||||
properties.setProperty(PROPERTY_API_VERSION, "0.3.0");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ public class DeltacloudErrorHandler implements HttpErrorHandler {
|
|||
try {
|
||||
message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
|
||||
response.getStatusLine());
|
||||
if (message.indexOf("ItemNotFound") != -1) {
|
||||
exception = new ResourceNotFoundException(message, exception);
|
||||
} else {
|
||||
switch (response.getStatusCode()) {
|
||||
case 400:
|
||||
exception = new IllegalArgumentException(message, exception);
|
||||
|
@ -73,6 +76,7 @@ public class DeltacloudErrorHandler implements HttpErrorHandler {
|
|||
exception = new IllegalStateException(message, exception);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (response.getPayload() != null)
|
||||
Closeables.closeQuietly(response.getPayload().getInput());
|
||||
|
|
|
@ -64,6 +64,12 @@ public class DeltacloudErrorHandlerTest {
|
|||
ResourceNotFoundException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItemNotFoundMakesResourceNotFoundException() {
|
||||
assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 500, "", "ItemNotFound",
|
||||
ResourceNotFoundException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test405MakesIllegalArgumentException() {
|
||||
assertCodeMakes("GET", URI.create("https://deltacloud.com/foo"), 405, "", "Method Not Allowed",
|
||||
|
|
Loading…
Reference in New Issue