Search in sources :

Example 6 with Response

use of org.openclinica.ns.response.v31.Response in project buck by facebook.

the class HttpArtifactCacheTest method testFetchWrongKey.

@Test
public void testFetchWrongKey() throws Exception {
    FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
    final RuleKey ruleKey = new RuleKey("00000000000000000000000000000000");
    final RuleKey otherRuleKey = new RuleKey("11111111111111111111111111111111");
    final String data = "data";
    argsBuilder.setFetchClient(withMakeRequest(((path, requestBuilder) -> {
        Request request = requestBuilder.url(SERVER + path).build();
        Response response = new Response.Builder().request(request).protocol(Protocol.HTTP_1_1).code(HttpURLConnection.HTTP_OK).body(createResponseBody(ImmutableSet.of(otherRuleKey), ImmutableMap.of(), ByteSource.wrap(data.getBytes(Charsets.UTF_8)), data)).build();
        return new OkHttpResponseWrapper(response);
    })));
    HttpArtifactCache cache = new HttpArtifactCache(argsBuilder.build());
    Path output = Paths.get("output/file");
    CacheResult result = cache.fetch(ruleKey, LazyPath.ofInstance(output));
    assertEquals(CacheResultType.ERROR, result.getType());
    assertEquals(Optional.empty(), filesystem.readFileIfItExists(output));
    cache.close();
}
Also used : Response(okhttp3.Response) HttpResponse(com.facebook.buck.slb.HttpResponse) Path(java.nio.file.Path) LazyPath(com.facebook.buck.io.LazyPath) RuleKey(com.facebook.buck.rules.RuleKey) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Request(okhttp3.Request) OkHttpResponseWrapper(com.facebook.buck.slb.OkHttpResponseWrapper) Test(org.junit.Test)

Example 7 with Response

use of org.openclinica.ns.response.v31.Response in project Parse-SDK-Android by ParsePlatform.

the class ParseOkHttpClient method executeInternal.

@Override
/* package */
ParseHttpResponse executeInternal(ParseHttpRequest parseRequest) throws IOException {
    Request okHttpRequest = getRequest(parseRequest);
    Call okHttpCall = okHttpClient.newCall(okHttpRequest);
    Response okHttpResponse = okHttpCall.execute();
    return getResponse(okHttpResponse);
}
Also used : Response(okhttp3.Response) ParseHttpResponse(com.parse.http.ParseHttpResponse) Call(okhttp3.Call) Request(okhttp3.Request) ParseHttpRequest(com.parse.http.ParseHttpRequest)

Example 8 with Response

use of org.openclinica.ns.response.v31.Response in project BigImageViewer by Piasy.

the class GlideProgressSupport method createInterceptor.

private static Interceptor createInterceptor(final ResponseProgressListener listener) {
    return new Interceptor() {

        @Override
        public Response intercept(Chain chain) throws IOException {
            Request request = chain.request();
            Response response = chain.proceed(request);
            return response.newBuilder().body(new OkHttpProgressResponseBody(request.url(), response.body(), listener)).build();
        }
    };
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Interceptor(okhttp3.Interceptor)

Example 9 with Response

use of org.openclinica.ns.response.v31.Response in project sonarqube by SonarSource.

the class HttpHeadersTest method verify_headers_of_js_provided_by_plugins.

@Test
public void verify_headers_of_js_provided_by_plugins() throws Exception {
    Response response = call(orchestrator.getServer().getUrl() + "/static/uiextensionsplugin/extension.js");
    verifySecurityHeaders(response);
    verifyContentType(response, "application/javascript");
}
Also used : Response(okhttp3.Response) Test(org.junit.Test)

Example 10 with Response

use of org.openclinica.ns.response.v31.Response in project sonarqube by SonarSource.

the class SsoAuthenticationTest method display_message_in_ui_but_not_in_log_when_unauthorized_exception.

@Test
public void display_message_in_ui_but_not_in_log_when_unauthorized_exception() throws Exception {
    Response response = doCall("invalid login $", null, null, null);
    assertThat(response.code()).isEqualTo(200);
    assertThat(response.request().url().toString()).contains("sessions/unauthorized");
    List<String> logsLines = FileUtils.readLines(orchestrator.getServer().getWebLogs(), UTF_8);
    assertThat(logsLines).doesNotContain("org.sonar.server.exceptions.BadRequestException: Use only letters, numbers, and .-_@ please.");
    USER_RULE.verifyUserDoesNotExist(USER_LOGIN);
}
Also used : Response(okhttp3.Response) Test(org.junit.Test)

Aggregations

Response (okhttp3.Response)444 Request (okhttp3.Request)320 Test (org.junit.Test)209 IOException (java.io.IOException)158 Response (retrofit2.Response)150 ResponseBody (okhttp3.ResponseBody)128 ServiceResponse (com.microsoft.rest.ServiceResponse)114 Observable (rx.Observable)98 Call (okhttp3.Call)97 MockResponse (okhttp3.mockwebserver.MockResponse)76 RequestBody (okhttp3.RequestBody)65 OkHttpClient (okhttp3.OkHttpClient)60 Callback (okhttp3.Callback)41 List (java.util.List)39 TestClients.clientRequest (keywhiz.TestClients.clientRequest)37 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)32 HttpUrl (okhttp3.HttpUrl)25 ANResponse (com.androidnetworking.common.ANResponse)23 Interceptor (okhttp3.Interceptor)23 MediaType (okhttp3.MediaType)23