mirror of https://github.com/apache/jclouds.git
Cloudstack uses the JSON key "template" to mean a different type in different contexts, confusing ParseAsyncJobFromHttpResponse. Add a (currently failing) unit test to reproduce this issue.
This commit is contained in:
parent
b31c589462
commit
a2b6eac75f
|
@ -19,13 +19,11 @@
|
||||||
package org.jclouds.cloudstack.functions;
|
package org.jclouds.cloudstack.functions;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
import org.jclouds.cloudstack.domain.*;
|
||||||
import org.jclouds.cloudstack.domain.AsyncJobError;
|
|
||||||
import org.jclouds.cloudstack.domain.IPForwardingRule;
|
|
||||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.domain.JsonBall;
|
import org.jclouds.domain.JsonBall;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
|
@ -187,4 +185,14 @@ public class ParseAsyncJobFromHttpResponseTest {
|
||||||
assertEquals(response, expects);
|
assertEquals(response, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testOverloadedKeyName() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/queryasyncjobresultresponse-createtemplate.json");
|
||||||
|
ParseAsyncJobFromHttpResponse parser = i.getInstance(ParseAsyncJobFromHttpResponse.class);
|
||||||
|
AsyncJob response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||||
|
assertTrue(response.getResult() instanceof Template, "response expected to be Template, actually is "+response.getResult().getClass());
|
||||||
|
|
||||||
|
is = getClass().getResourceAsStream("/queryasyncjobresultresponse-extracttemplate.json");
|
||||||
|
response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||||
|
assertTrue(response.getResult() instanceof TemplateExtraction, "response expected to be TemplateExtraction, actually is "+response.getResult().getClass());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{ "queryasyncjobresultresponse" : {"jobid":2716,"jobstatus":1,"jobprocstatus":0,"jobresultcode":0,"jobresulttype":"object","jobresult":{"template":{"id":249,"name":"jclouds-c5c7dce0","displaytext":"jclouds live testCreateTemplate","ispublic":false,"created":"2011-11-16T06:43:00-0800","isready":true,"passwordenabled":false,"format":"VHD","isfeatured":false,"crossZones":false,"ostypeid":12,"ostypename":"CentOS 5.3 (64-bit)","account":"jcloud2","zoneid":1,"zonename":"Demo5","status":"Download Complete","size":8589934592,"templatetype":"USER","hypervisor":"XenServer","domain":"jCloud","domainid":11,"isextractable":true,"checksum":"bdc1c2c49b747694f97be5042323a1fa","sourcetemplateid":202}}} }
|
|
@ -0,0 +1 @@
|
||||||
|
{ "queryasyncjobresultresponse" : {"jobid":2720,"jobstatus":1,"jobprocstatus":0,"jobresultcode":0,"jobresulttype":"object","jobresult":{"template":{"id":249,"name":"jclouds-c5c7dce0","extractId":6,"accountid":19,"state":"DOWNLOAD_URL_CREATED","zoneid":1,"zonename":"Demo5","extractMode":"HTTP_DOWNLOAD","url":"https:%2F%2F72-52-126-96.realhostip.com%2Fuserdata%2Ff52f8e7d-7c89-4cf7-8e5a-b5ea17366d73.vhd"}}} }
|
Loading…
Reference in New Issue