use of org.prebid.mobile.rendering.networking.BaseNetworkTask.GetUrlResult in project prebid-mobile-android by prebid.
the class GetOriginalUrlTaskTest method getUrlNullParamsTest.
@Test
public void getUrlNullParamsTest() throws Exception {
GetOriginalUrlTask getOriginalUrlNetworkTask = new GetOriginalUrlTask(null);
mParams = null;
GetUrlResult result = (GetUrlResult) WhiteBox.method(GetOriginalUrlTask.class, "getUrl", BaseNetworkTask.GetUrlParams.class).invoke(getOriginalUrlNetworkTask, mParams);
assertNotNull("A null params object should generate a result object with Exception", result.getException());
}
use of org.prebid.mobile.rendering.networking.BaseNetworkTask.GetUrlResult in project prebid-mobile-android by prebid.
the class GetOriginalUrlTaskTest method getUrlTest.
@Test
public void getUrlTest() throws Exception {
mServer.enqueue(new MockResponse().setResponseCode(200).setBody("this is a success response"));
GetOriginalUrlTask getOriginalUrlNetworkTask = new GetOriginalUrlTask(null);
HttpUrl baseUrl = mServer.url("/first");
mParams.url = baseUrl.url().toString();
BaseNetworkTask.GetUrlParams[] params = { mParams };
GetUrlResult result = (GetUrlResult) WhiteBox.method(GetOriginalUrlTask.class, "getUrl", BaseNetworkTask.GetUrlParams[].class).invoke(getOriginalUrlNetworkTask, (Object) new BaseNetworkTask.GetUrlParams[] { mParams });
Assert.assertEquals("A successful response should yile a result object with status code 200", result.statusCode, 200);
}
use of org.prebid.mobile.rendering.networking.BaseNetworkTask.GetUrlResult in project prebid-mobile-android by prebid.
the class GetOriginalUrlTaskTest method getUrlOriginalUrlShouldBeSetTest.
@Test
public void getUrlOriginalUrlShouldBeSetTest() throws Exception {
mServer.enqueue(new MockResponse().setResponseCode(301).addHeader("Location: " + mServer.url("/new-path")).setBody("This page has moved!"));
mServer.enqueue(new MockResponse().setResponseCode(200).setBody("This is the new location"));
GetOriginalUrlTask getOriginalUrlNetworkTask = new GetOriginalUrlTask(null);
HttpUrl baseUrl = mServer.url("/first");
mParams.url = baseUrl.url().toString();
GetUrlResult result = (GetUrlResult) WhiteBox.method(GetOriginalUrlTask.class, "getUrl", BaseNetworkTask.GetUrlParams[].class).invoke(getOriginalUrlNetworkTask, (Object) new BaseNetworkTask.GetUrlParams[] { mParams });
Assert.assertNotNull("Original url should not be null", result.originalUrl);
}
use of org.prebid.mobile.rendering.networking.BaseNetworkTask.GetUrlResult in project prebid-mobile-android by prebid.
the class GetOriginalUrlTaskTest method processRedirectsMaxOf3RedirectsTest.
@Test
public void processRedirectsMaxOf3RedirectsTest() throws Exception {
mServer.enqueue(new MockResponse().setResponseCode(301).addHeader("Location: " + mServer.url("/second")).setBody("This page has moved!"));
mServer.enqueue(new MockResponse().setResponseCode(301).addHeader("Location: " + mServer.url("/third")).setBody("This page has moved!"));
mServer.enqueue(new MockResponse().setResponseCode(301).addHeader("Location: " + mServer.url("/fourth")).setBody("This page has moved!"));
mServer.enqueue(new MockResponse().setResponseCode(301).addHeader("Location: " + mServer.url("/fifth")).setBody("This page has moved!"));
mServer.enqueue(new MockResponse().setResponseCode(200).setBody("This is the new location"));
GetOriginalUrlTask getOriginalUrlNetworkTask = new GetOriginalUrlTask(null);
HttpUrl baseUrl = mServer.url("/first");
mParams.url = baseUrl.url().toString();
mParams.name = REDIRECT_TASK;
WhiteBox.method(GetOriginalUrlTask.class, "processRedirects", BaseNetworkTask.GetUrlParams.class).invoke(getOriginalUrlNetworkTask, mParams);
GetUrlResult result = (GetUrlResult) WhiteBox.getInternalState(getOriginalUrlNetworkTask, "mResult");
Assert.assertNull("Should not have a valid result.response if over max redirects ", result.responseString);
}
Aggregations