use of com.squareup.okhttp.mockwebserver.MockWebServer in project hadoop by apache.
the class AdlMockWebServer method preTestSetup.
@Before
public void preTestSetup() throws IOException, URISyntaxException {
server = new MockWebServer();
// Start the server.
server.start();
// Ask the server for its URL. You'll need this to make HTTP requests.
URL baseUrl = server.getUrl("");
port = baseUrl.getPort();
// Exercise your application code, which should make those HTTP requests.
// Responses are returned in the same order that they are enqueued.
fs = new TestableAdlFileSystem();
conf.setClass(AZURE_AD_TOKEN_PROVIDER_CLASS_KEY, CustomMockTokenProvider.class, AzureADTokenProvider.class);
URI uri = new URI("adl://localhost:" + port);
fs.initialize(uri, conf);
}
use of com.squareup.okhttp.mockwebserver.MockWebServer in project Avengers by saulmm.
the class CharacterListActivityInstrumentationTest method setUp.
@Before
public void setUp() throws Exception {
mMockWebServer = new MockWebServer();
mMockWebServer.start();
RestDataSource.END_POINT = mMockWebServer.getUrl("/").toString();
}
use of com.squareup.okhttp.mockwebserver.MockWebServer in project enroscar by stanfy.
the class ImageRequestAndroidTest method prepareServer.
private MockWebServer prepareServer() throws IOException {
MockWebServer server = new MockWebServer();
server.start();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
testBitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes);
server.enqueue(new MockResponse().setResponseCode(200).setBody(new Buffer().write(bytes.toByteArray())));
return server;
}
use of com.squareup.okhttp.mockwebserver.MockWebServer in project enroscar by stanfy.
the class ImageRequestAndroidTest method testStoreToDiskSmallRatio.
public void testStoreToDiskSmallRatio() throws IOException {
MockWebServer server = prepareServer();
String url = server.getUrl("/image").toString();
//noinspection ConstantConditions
float smallRatio = (float) testBitmap.getWidth() / getContext().getResources().getDisplayMetrics().widthPixels;
ImageRequest request = new ImageRequest(imagesManager, url, smallRatio / 2);
assertThat(imagesManager.isPresentOnDisk(url)).isFalse();
request.storeToDisk();
assertThat(imagesManager.isPresentOnDisk(url)).isTrue();
server.shutdown();
}
use of com.squareup.okhttp.mockwebserver.MockWebServer in project enroscar by stanfy.
the class RetrofitClientTest method shouldWorkForHttpScheme.
// http
@Test
public void shouldWorkForHttpScheme() throws Exception {
MockWebServer server = new MockWebServer();
server.play();
server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponse));
RestAdapter adapter = getRestAdapter(server.getUrl("/").toString());
fetchAndTest(adapter);
server.shutdown();
}
Aggregations