Search in sources :

Example 1 with HTTPBin

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";
}
Also used : HTTPBin(de.test.antennapod.util.service.download.HTTPBin) Before(org.junit.Before)

Example 2 with HTTPBin

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));
}
Also used : Context(android.content.Context) HTTPBin(de.test.antennapod.util.service.download.HTTPBin) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Before(org.junit.Before) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

HTTPBin (de.test.antennapod.util.service.download.HTTPBin)2 Before (org.junit.Before)2 Context (android.content.Context)1 UiThreadTest (androidx.test.annotation.UiThreadTest)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1