Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update tests to not rely on intermediate asset file URLs

  • Loading branch information...
commit 0077ba059c0c472f382af9cdd04008e28e14a00c 1 parent ef728d0
@jcookems jcookems authored
View
9 ...soft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java
@@ -18,7 +18,6 @@
import static org.junit.Assert.*;
import java.io.InputStream;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@@ -111,8 +110,8 @@ public void downloadFiles() throws Exception {
wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles());
signalSetupFinished();
- Hashtable<String, URL> fileUrls = wrapper.createFileURLsFromAsset(asset, 10);
- validator.validateAssetFileUrls(fileUrls, getTestAssetFiles());
+ Hashtable<String, InputStream> actualFileStreams = wrapper.downloadFilesFromAsset(asset, 10);
+ validator.validateAssetFiles(getTestAssetFiles(), actualFileStreams);
}
@Test
@@ -166,8 +165,8 @@ public void transformEncryptedAsset() throws Exception {
validator.validateAssetFiles(outputAsset, getTestAssetFiles());
// Verify assets were decoded.
- Hashtable<String, URL> fileUrls = wrapper.createFileURLsFromAsset(outputAsset, 10);
- validator.validateAssetFileUrls(fileUrls, getTestAssetFiles());
+ Hashtable<String, InputStream> actualFileStreams = wrapper.downloadFilesFromAsset(outputAsset, 10);
+ validator.validateAssetFiles(getTestAssetFiles(), actualFileStreams);
}
private void waitForJobToFinish(JobInfo job) throws InterruptedException, ServiceException {
View
35 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java
@@ -19,7 +19,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Date;
@@ -139,12 +138,12 @@ public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> i
}
}
- public void validateAssetFileUrls(Hashtable<String, URL> fileUrls, Hashtable<String, InputStream> inputFiles)
- throws IOException, InterruptedException {
- assertEquals("fileUrls count", inputFiles.size(), fileUrls.keySet().size());
- for (String fileName : fileUrls.keySet()) {
+ public void validateAssetFiles(Hashtable<String, InputStream> inputFiles,
+ Hashtable<String, InputStream> actualFileStreams) throws IOException, InterruptedException {
+ assertEquals("fileUrls count", inputFiles.size(), actualFileStreams.size());
+ for (String fileName : actualFileStreams.keySet()) {
InputStream expected = inputFiles.get(fileName);
- InputStream actual = getInputStreamWithRetry(fileUrls.get(fileName));
+ InputStream actual = actualFileStreams.get(fileName);
assertStreamsEqual(expected, actual);
}
}
@@ -175,30 +174,6 @@ public void validateOutputAssets(List<AssetInfo> outputAssets, Enumeration<Strin
}
}
- // This method is needed because there can be a delay before a new read locator
- // is applied for the asset files.
- private InputStream getInputStreamWithRetry(URL file) throws InterruptedException, IOException {
- InputStream reader = null;
- for (int counter = 0; true; counter++) {
- try {
- reader = file.openConnection().getInputStream();
- break;
- }
- catch (IOException e) {
- System.out.println("Got error, wait a bit and try again");
- if (counter < 6) {
- Thread.sleep(10000);
- }
- else {
- // No more retries.
- throw e;
- }
- }
- }
-
- return reader;
- }
-
public void assertFileInfosEqual(String message, AssetFileInfo fi, AssetFileInfo match) {
assertNotNull(message + ":fi", fi);
assertNotNull(message + ":match", match);
View
4 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java
@@ -354,7 +354,7 @@ public void cancelJob(JobInfo job) throws ServiceException {
}
// Deliver
- public Hashtable<String, URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindowInMinutes)
+ private Hashtable<String, URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindowInMinutes)
throws ServiceException, MalformedURLException {
Hashtable<String, URL> ret = new Hashtable<String, URL>();
@@ -371,7 +371,7 @@ public void cancelJob(JobInfo job) throws ServiceException {
return ret;
}
- // Ingest
+ // Deliver
public Hashtable<String, InputStream> downloadFilesFromAsset(AssetInfo asset, int downloadWindowInMinutes)
throws Exception {
Hashtable<String, URL> urls = createFileURLsFromAsset(asset, downloadWindowInMinutes);
Please sign in to comment.
Something went wrong with that request. Please try again.