mirror of
https://github.com/square/okhttp.git
synced 2025-11-27 18:21:14 +03:00
Return this from HttpLoggingInterceptor.setLevel()
This commit is contained in:
@@ -124,8 +124,9 @@ public final class HttpLoggingInterceptor implements Interceptor {
|
||||
private volatile Level level = Level.NONE;
|
||||
|
||||
/** Change the level at which this interceptor logs. */
|
||||
public void setLevel(Level level) {
|
||||
public HttpLoggingInterceptor setLevel(Level level) {
|
||||
this.level = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public Response intercept(Chain chain) throws IOException {
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public final class HttpLoggingInterceptorTest {
|
||||
@@ -53,6 +54,12 @@ public final class HttpLoggingInterceptorTest {
|
||||
client.setConnectionPool(null);
|
||||
}
|
||||
|
||||
@Test public void setLevelShouldReturnSameInstanceOfInterceptor() {
|
||||
for (Level level : Level.values()) {
|
||||
assertSame(interceptor, interceptor.setLevel(level));
|
||||
}
|
||||
}
|
||||
|
||||
@Test public void none() throws IOException {
|
||||
server.enqueue(new MockResponse());
|
||||
client.newCall(request().build()).execute();
|
||||
|
||||
Reference in New Issue
Block a user