当前位置: 首页>>代码示例>>Java>>正文


Java Level类代码示例

本文整理汇总了Java中okhttp3.logging.HttpLoggingInterceptor.Level的典型用法代码示例。如果您正苦于以下问题:Java Level类的具体用法?Java Level怎么用?Java Level使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Level类属于okhttp3.logging.HttpLoggingInterceptor包,在下文中一共展示了Level类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: basicGet

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicGet() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse());
  client.newCall(request().build()).execute();

  applicationLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:HttpLoggingInterceptorTest.java

示例2: basicPost

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicPost() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse());
  client.newCall(request().post(RequestBody.create(PLAIN, "Hi?")).build()).execute();

  applicationLogs
      .assertLogEqual("--> POST " + url + " http/1.1 (3-byte body)")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> POST " + url + " http/1.1 (3-byte body)")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:HttpLoggingInterceptorTest.java

示例3: basicResponseBody

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicResponseBody() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse()
      .setBody("Hello!")
      .setHeader("Content-Type", PLAIN));
  Response response = client.newCall(request().build()).execute();
  response.body().close();

  applicationLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 6-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 6-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:HttpLoggingInterceptorTest.java

示例4: basicChunkedResponseBody

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicChunkedResponseBody() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse()
      .setChunkedBody("Hello!", 2)
      .setHeader("Content-Type", PLAIN));
  Response response = client.newCall(request().build()).execute();
  response.body().close();

  applicationLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, unknown-length body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, unknown-length body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:HttpLoggingInterceptorTest.java

示例5: connectFail

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void connectFail() throws IOException {
  setLevel(Level.BASIC);
  client = new OkHttpClient.Builder()
      .dns(new Dns() {
        @Override public List<InetAddress> lookup(String hostname) throws UnknownHostException {
          throw new UnknownHostException("reason");
        }
      })
      .addInterceptor(applicationInterceptor)
      .build();

  try {
    client.newCall(request().build()).execute();
    fail();
  } catch (UnknownHostException expected) {
  }

  applicationLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogEqual("<-- HTTP FAILED: java.net.UnknownHostException: reason")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:HttpLoggingInterceptorTest.java

示例6: basicGet

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicGet() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse());
  client.newCall(request().build()).execute();

  applicationLogs
      .assertLogEqual("--> GET " + url)
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:HttpLoggingInterceptorTest.java

示例7: basicPost

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicPost() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse());
  client.newCall(request().post(RequestBody.create(PLAIN, "Hi?")).build()).execute();

  applicationLogs
      .assertLogEqual("--> POST " + url + " (3-byte body)")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> POST " + url + " http/1.1 (3-byte body)")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:HttpLoggingInterceptorTest.java

示例8: basicResponseBody

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicResponseBody() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse()
      .setBody("Hello!")
      .setHeader("Content-Type", PLAIN));
  Response response = client.newCall(request().build()).execute();
  response.body().close();

  applicationLogs
      .assertLogEqual("--> GET " + url)
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 6-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 6-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:HttpLoggingInterceptorTest.java

示例9: basicChunkedResponseBody

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicChunkedResponseBody() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse()
      .setChunkedBody("Hello!", 2)
      .setHeader("Content-Type", PLAIN));
  Response response = client.newCall(request().build()).execute();
  response.body().close();

  applicationLogs
      .assertLogEqual("--> GET " + url)
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, unknown-length body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " http/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, unknown-length body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:HttpLoggingInterceptorTest.java

示例10: connectFail

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void connectFail() throws IOException {
  setLevel(Level.BASIC);
  client = new OkHttpClient.Builder()
      .dns(new Dns() {
        @Override public List<InetAddress> lookup(String hostname) throws UnknownHostException {
          throw new UnknownHostException("reason");
        }
      })
      .addInterceptor(applicationInterceptor)
      .build();

  try {
    client.newCall(request().build()).execute();
    fail();
  } catch (UnknownHostException expected) {
  }

  applicationLogs
      .assertLogEqual("--> GET " + url)
      .assertLogEqual("<-- HTTP FAILED: java.net.UnknownHostException: reason")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:HttpLoggingInterceptorTest.java

示例11: http2

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void http2() throws Exception {
  server.useHttps(sslClient.socketFactory, false);
  url = server.url("/");

  setLevel(Level.BASIC);

  server.enqueue(new MockResponse());
  Response response = client.newCall(request().build()).execute();
  assumeThat(response.protocol(), equalTo(Protocol.HTTP_2));

  applicationLogs
      .assertLogEqual("--> GET " + url)
      .assertLogMatch("<-- 200 " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " h2")
      .assertLogMatch("<-- 200 " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:HttpLoggingInterceptorTest.java

示例12: getHeader

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
public static Builder getHeader(String userName, String password) {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(Level.BASIC);
    OkHttpClient.Builder okBuilder = new OkHttpClient.Builder();
    okBuilder.authenticator(new Authenticator() {

        @Override
        public Request authenticate(Route route, Response response) throws IOException {
            String credential = Credentials.basic(userName, password);
            if (credential.equals(response.request().header("Authorization"))) {
                try {
                    FortifyExceptionUtil.verifyFortifyResponseCode(response.code(), "Unauthorized access of Fortify Api");
                } catch (IntegrationException e) {
                    throw new IOException(e);
                }
                return null;
            }
            return response.request().newBuilder().header("Authorization", credential).build();
        }
    });

    okBuilder.addInterceptor(logging);
    return okBuilder;
}
 
开发者ID:blackducksoftware,项目名称:hub-fortify-ssc-integration-service,代码行数:25,代码来源:FortifyService.java

示例13: basicGet

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicGet() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse());
  client.newCall(request().build()).execute();

  applicationLogs
      .assertLogEqual("--> GET " + url + " HTTP/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " HTTP/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:lizhangqu,项目名称:PriorityOkHttp,代码行数:17,代码来源:HttpLoggingInterceptorTest.java

示例14: basicPost

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicPost() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse());
  client.newCall(request().post(RequestBody.create(PLAIN, "Hi?")).build()).execute();

  applicationLogs
      .assertLogEqual("--> POST " + url + " HTTP/1.1 (3-byte body)")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> POST " + url + " HTTP/1.1 (3-byte body)")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 0-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:lizhangqu,项目名称:PriorityOkHttp,代码行数:17,代码来源:HttpLoggingInterceptorTest.java

示例15: basicResponseBody

import okhttp3.logging.HttpLoggingInterceptor.Level; //导入依赖的package包/类
@Test public void basicResponseBody() throws IOException {
  setLevel(Level.BASIC);

  server.enqueue(new MockResponse()
      .setBody("Hello!")
      .setHeader("Content-Type", PLAIN));
  Response response = client.newCall(request().build()).execute();
  response.body().close();

  applicationLogs
      .assertLogEqual("--> GET " + url + " HTTP/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 6-byte body\\)")
      .assertNoMoreLogs();

  networkLogs
      .assertLogEqual("--> GET " + url + " HTTP/1.1")
      .assertLogMatch("<-- 200 OK " + url + " \\(\\d+ms, 6-byte body\\)")
      .assertNoMoreLogs();
}
 
开发者ID:lizhangqu,项目名称:PriorityOkHttp,代码行数:20,代码来源:HttpLoggingInterceptorTest.java


注:本文中的okhttp3.logging.HttpLoggingInterceptor.Level类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。