mirror of https://github.com/apache/jclouds.git
Add TemplateClientLiveTest.testExtractTemplate()
This commit is contained in:
parent
1e7592ac98
commit
75752db64c
|
@ -28,6 +28,9 @@ import org.testng.annotations.AfterGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -73,6 +76,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(enabled = true)
|
||||
public void testCreateTemplate() throws Exception {
|
||||
Zone zone = Iterables.getFirst(client.getZoneClient().listZones(), null);
|
||||
assertNotNull(zone);
|
||||
|
@ -121,4 +125,25 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
|
|||
super.tearDown();
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "testCreateTemplate")
|
||||
public void testExtractTemplate() throws Exception {
|
||||
// Initiate the extraction and wait for it to complete
|
||||
AsyncCreateResponse response = client.getTemplateClient().extractTemplate(template.getId(), ExtractMode.HTTP_DOWNLOAD, template.getZoneId());
|
||||
assert jobComplete.apply(response.getJobId()) : template;
|
||||
|
||||
// Get the result
|
||||
AsyncJob<TemplateExtraction> asyncJob = client.getAsyncJobClient().<TemplateExtraction>getAsyncJob(response.getJobId());
|
||||
TemplateExtraction extract = asyncJob.getResult();
|
||||
assertNotNull(extract);
|
||||
|
||||
// Check that the URL can be retrieved
|
||||
String extractUrl = extract.getUrl();
|
||||
assertNotNull(extractUrl);
|
||||
URL url = new URL(URLDecoder.decode(extractUrl, "utf-8"));
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.connect();
|
||||
assertEquals(connection.getResponseCode(), 200);
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue