mirror of
https://github.com/square/okhttp.git
synced 2025-11-24 18:41:06 +03:00
Update MockWebServer README with gradle and fix code.
commit 8b19e590642290938f42871ecedbc9b6a6cba679 Author: Hugo Gresse <hugo.gresse@gmail.com> Date: Wed Apr 29 09:11:58 2015 +0200 Change MockWebServer readme start() to play() commit fb165671ca3a958d1dd2c8a431e20d9f3e0db6a7 Author: Hugo Gresse <hugo.gresse@gmail.com> Date: Mon Apr 27 21:33:54 2015 +0200 Change MockWebServer readme to not imply endorsement of Gradle commit 9d7b044141970aba3a6c2384184938570ce8c728 Author: Hugo Gresse <hugo.gresse@gmail.com> Date: Mon Apr 27 17:22:45 2015 +0200 Update MockWebServer README with gradle and fix code Add gradle as the recommanded download mode and remove unnecessary ")" for dispatcher example
This commit is contained in:
@@ -39,7 +39,7 @@ public void test() throws Exception {
|
|||||||
server.enqueue(new MockResponse().setBody("yo dog"));
|
server.enqueue(new MockResponse().setBody("yo dog"));
|
||||||
|
|
||||||
// Start the server.
|
// Start the server.
|
||||||
server.start();
|
server.play();
|
||||||
|
|
||||||
// Ask the server for its URL. You'll need this to make HTTP requests.
|
// Ask the server for its URL. You'll need this to make HTTP requests.
|
||||||
URL baseUrl = server.getUrl("/v1/chat/");
|
URL baseUrl = server.getUrl("/v1/chat/");
|
||||||
@@ -125,7 +125,7 @@ final Dispatcher dispatcher = new Dispatcher() {
|
|||||||
public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
|
public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
|
||||||
|
|
||||||
if (request.getPath().equals("/v1/login/auth/")){
|
if (request.getPath().equals("/v1/login/auth/")){
|
||||||
return new MockResponse().setResponseCode(200));
|
return new MockResponse().setResponseCode(200);
|
||||||
} else if (request.getPath().equals("v1/check/version/")){
|
} else if (request.getPath().equals("v1/check/version/")){
|
||||||
return new MockResponse().setResponseCode(200).setBody("version=9");
|
return new MockResponse().setResponseCode(200).setBody("version=9");
|
||||||
} else if (request.getPath().equals("/v1/profile/info")) {
|
} else if (request.getPath().equals("/v1/profile/info")) {
|
||||||
@@ -140,8 +140,7 @@ server.setDispatcher(dispatcher);
|
|||||||
|
|
||||||
### Download
|
### Download
|
||||||
|
|
||||||
The best way to get MockWebServer is via Maven:
|
Get MockWebServer via Maven:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp</groupId>
|
<groupId>com.squareup.okhttp</groupId>
|
||||||
@@ -151,6 +150,11 @@ The best way to get MockWebServer is via Maven:
|
|||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
or via Gradle
|
||||||
|
```groovy
|
||||||
|
testCompile 'com.squareup.okhttp:mockwebserver:(insert latest version)'
|
||||||
|
```
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|||||||
Reference in New Issue
Block a user