1
0
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:
Artem Zinnatullin
2015-11-23 00:29:06 +03:00
parent 1cb70c9efc
commit c664d1864b
2 changed files with 9 additions and 1 deletions

View File

@@ -124,8 +124,9 @@ public final class HttpLoggingInterceptor implements Interceptor {
private volatile Level level = Level.NONE; private volatile Level level = Level.NONE;
/** Change the level at which this interceptor logs. */ /** Change the level at which this interceptor logs. */
public void setLevel(Level level) { public HttpLoggingInterceptor setLevel(Level level) {
this.level = level; this.level = level;
return this;
} }
@Override public Response intercept(Chain chain) throws IOException { @Override public Response intercept(Chain chain) throws IOException {

View File

@@ -31,6 +31,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
public final class HttpLoggingInterceptorTest { public final class HttpLoggingInterceptorTest {
@@ -53,6 +54,12 @@ public final class HttpLoggingInterceptorTest {
client.setConnectionPool(null); client.setConnectionPool(null);
} }
@Test public void setLevelShouldReturnSameInstanceOfInterceptor() {
for (Level level : Level.values()) {
assertSame(interceptor, interceptor.setLevel(level));
}
}
@Test public void none() throws IOException { @Test public void none() throws IOException {
server.enqueue(new MockResponse()); server.enqueue(new MockResponse());
client.newCall(request().build()).execute(); client.newCall(request().build()).execute();