Unverified Commit b8fff8ce authored by Aaron Train's avatar Aaron Train Committed by GitHub
Browse files

For #8169 - Upgrade Mockwebserver (#16186)

Upgrades Mockwebserver to 4.9.0
parent b8d6dbd4
......@@ -110,7 +110,7 @@ class BaselinePingTest {
do {
attempts += 1
val request = server.takeRequest(20L, TimeUnit.SECONDS) ?: break
val docType = request.path.split("/")[3]
val docType = request.path!!.split("/")[3]
if (pingName == docType) {
val parsedPayload = JSONObject(request.getPlainBody())
if (pingReason == null) {
......
......@@ -39,11 +39,13 @@ object MockWebServerHelper {
*/
fun createAlwaysOkMockWebServer(): MockWebServer {
return MockWebServer().apply {
setDispatcher(object : Dispatcher() {
val dispatcher = object : Dispatcher() {
@Throws(InterruptedException::class)
override fun dispatch(request: RecordedRequest): MockResponse {
return MockResponse().setBody("OK")
}
})
}
this.dispatcher = dispatcher
}
}
}
......@@ -62,10 +64,10 @@ const val HTTP_NOT_FOUND = 404
class AndroidAssetDispatcher : Dispatcher() {
private val mainThreadHandler = Handler(Looper.getMainLooper())
override fun dispatch(request: RecordedRequest?): MockResponse {
override fun dispatch(request: RecordedRequest): MockResponse {
val assetManager = InstrumentationRegistry.getInstrumentation().context.assets
try {
val pathWithoutQueryParams = Uri.parse(request?.path?.drop(1)).path
val pathWithoutQueryParams = Uri.parse(request.path!!.drop(1)).path
assetManager.open(pathWithoutQueryParams!!).use { inputStream ->
return fileToResponse(pathWithoutQueryParams, inputStream)
}
......@@ -81,7 +83,7 @@ class AndroidAssetDispatcher : Dispatcher() {
private fun fileToResponse(path: String, file: InputStream): MockResponse {
return MockResponse()
.setResponseCode(HTTP_OK)
.setBody(fileToBytes(file))
.setBody(fileToBytes(file)!!)
.addHeader("content-type: " + contentType(path))
}
......
......@@ -43,7 +43,7 @@ class MenuScreenShotTest : ScreenshotTest() {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -44,7 +44,7 @@ class SyncIntegrationTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -49,7 +49,7 @@ class BookmarksTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -42,7 +42,7 @@ class ContextMenusTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -43,7 +43,7 @@ class DeepLinkTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -51,7 +51,7 @@ class DownloadTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -41,7 +41,7 @@ class HistoryTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -37,7 +37,7 @@ class MediaNotificationTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -38,7 +38,7 @@ class NavigationToolbarTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -41,7 +41,7 @@ class ReaderViewTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
......
......@@ -33,7 +33,7 @@ class SettingsAboutTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -39,7 +39,7 @@ class SettingsAddonsTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -32,7 +32,7 @@ class SettingsAdvancedTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -39,7 +39,7 @@ class SettingsBasicsTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -33,7 +33,7 @@ class SettingsDeveloperToolsTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -41,7 +41,7 @@ class SettingsPrivacyTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -32,7 +32,7 @@ class SettingsSyncTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
......@@ -32,7 +32,7 @@ class SettingsTest {
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
setDispatcher(AndroidAssetDispatcher())
dispatcher = AndroidAssetDispatcher()
start()
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment