use of de.test.antennapod.util.service.download.HTTPBin in project AntennaPod by AntennaPod.
the class HttpDownloaderTest method setUp.
@Before
public void setUp() throws Exception {
UserPreferences.init(InstrumentationRegistry.getInstrumentation().getTargetContext());
destDir = InstrumentationRegistry.getInstrumentation().getTargetContext().getExternalFilesDir(DOWNLOAD_DIR);
assertNotNull(destDir);
assertTrue(destDir.exists());
httpServer = new HTTPBin();
httpServer.start();
url404 = httpServer.getBaseUrl() + "/status/404";
urlAuth = httpServer.getBaseUrl() + "/basic-auth/user/passwd";
}
use of de.test.antennapod.util.service.download.HTTPBin in project AntennaPod by AntennaPod.
the class PlaybackServiceMediaPlayerTest method setUp.
@Before
@UiThreadTest
public void setUp() throws Exception {
assertionError = null;
EspressoTestUtils.clearPreferences();
EspressoTestUtils.clearDatabase();
final Context context = getInstrumentation().getTargetContext();
httpServer = new HTTPBin();
httpServer.start();
playableFileUrl = httpServer.getBaseUrl() + "/files/0";
File cacheDir = context.getExternalFilesDir("testFiles");
if (cacheDir == null)
cacheDir = context.getExternalFilesDir("testFiles");
File dest = new File(cacheDir, PLAYABLE_DEST_URL);
assertNotNull(cacheDir);
assertTrue(cacheDir.canWrite());
assertTrue(cacheDir.canRead());
if (!dest.exists()) {
InputStream i = getInstrumentation().getTargetContext().getAssets().open("3sec.mp3");
OutputStream o = new FileOutputStream(new File(cacheDir, PLAYABLE_DEST_URL));
IOUtils.copy(i, o);
o.flush();
o.close();
i.close();
}
PLAYABLE_LOCAL_URL = dest.getAbsolutePath();
assertEquals(0, httpServer.serveFile(dest));
}
Aggregations