Search in sources :

Example 81 with Callback

use of zipkin2.Callback in project Gradle-demo by Arisono.

the class testUASApi method saveFormData.

/**
 * 动态表单保存 接口
 */
public static void saveFormData() {
    String url = baseurl + "/mobile/oa/commonSaveAndSubmit.action";
    OkhttpUtils.println(url);
    RequestBody formBody = new FormBody.Builder().add("master", master).add("gridStore", "null").add("formStore", "{\"va_holidaytype\":\"按小时\",\"va_vacationtype\":\"事假\",\"va_status\":\"在录入\",\"va_emcode\":\"sunquan\",\"va_emname\":\"龚鹏明\",\"va_department\":\"测试\",\"va_position\":\"测试\",\"va_mankind\":\"副总及以上\",\"va_alldays\":\"12\",\"va_alltimes\":\"25\",\"va_startime\":\"2016-11-28 13:39:00\",\"va_remark\":\"测试\",\"va_recordor\":\"刘佳\",\"va_date\":\"2016-11-28 13:39:00\",\"va_endtime\":\"2016-12-28 13:39:00\"}").add("caller", "Ask4Leave").add("sessionId", sessionId).build();
    Request request = new Request.Builder().url(url).header("cookie", "JSESSIONID=" + sessionId).addHeader("sessionUser", emcode).addHeader("content-type", "text/html;charset:utf-8").post(formBody).build();
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            OkhttpUtils.println(OkhttpUtils.getResponseString(response));
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(e);
        }
    });
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Callback(okhttp3.Callback) Request(okhttp3.Request) IOException(java.io.IOException) RequestBody(okhttp3.RequestBody)

Example 82 with Callback

use of zipkin2.Callback in project Gradle-demo by Arisono.

the class testGithubApi method search_repositories.

/**
 * 查询github repositories
 */
public static void search_repositories() {
    search_repositories += "?q=" + q + "&sort=" + sort + "&order=" + order + "&page=" + page + "&per_page=" + per_page;
    Request request = new Request.Builder().url(search_repositories).build();
    OkhttpUtils.println(request.url().toString());
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            OkhttpUtils.println(OkhttpUtils.getResponseString(response));
            OkhttpUtils.println(search_repositories);
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(e);
        }
    });
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Callback(okhttp3.Callback) Request(okhttp3.Request) IOException(java.io.IOException)

Example 83 with Callback

use of zipkin2.Callback in project zipkin by openzipkin.

the class ScribeSpanConsumerTest method entriesWithoutSpansAreSkipped.

@Test
void entriesWithoutSpansAreSkipped() throws Exception {
    SpanConsumer consumer = (callback) -> {
        // as we shouldn't get here.
        throw new AssertionError();
    };
    ScribeSpanConsumer scribe = newScribeSpanConsumer("zipkin", consumer);
    LogEntry entry = new LogEntry();
    entry.category = "notzipkin";
    entry.message = "hello world";
    expectSuccess(scribe, entry);
    // Storage finishes after callback so wait for it.
    await().untilAsserted(() -> assertThat(scribeMetrics.messages()).isEqualTo(1));
    assertThat(scribeMetrics.messagesDropped()).isZero();
    assertThat(scribeMetrics.bytes()).isZero();
    assertThat(scribeMetrics.spans()).isZero();
    assertThat(scribeMetrics.spansDropped()).isZero();
}
Also used : LogEntry(zipkin2.collector.scribe.generated.LogEntry) InMemoryCollectorMetrics(zipkin2.collector.InMemoryCollectorMetrics) Arrays(java.util.Arrays) ForwardingStorageComponent(zipkin2.storage.ForwardingStorageComponent) Awaitility.await(org.awaitility.Awaitility.await) SpanConsumer(zipkin2.storage.SpanConsumer) InMemoryStorage(zipkin2.storage.InMemoryStorage) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) V1SpanConverter(zipkin2.v1.V1SpanConverter) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) Base64(java.util.Base64) Endpoint(zipkin2.Endpoint) Arrays.asList(java.util.Arrays.asList) SpanBytesEncoder(zipkin2.codec.SpanBytesEncoder) AsyncMethodCallback(org.apache.thrift.async.AsyncMethodCallback) Callback(zipkin2.Callback) StorageComponent(zipkin2.storage.StorageComponent) Call(zipkin2.Call) ResultCode(zipkin2.collector.scribe.generated.ResultCode) SpanConsumer(zipkin2.storage.SpanConsumer) LogEntry(zipkin2.collector.scribe.generated.LogEntry) Test(org.junit.jupiter.api.Test)

Example 84 with Callback

use of zipkin2.Callback in project zipkin by openzipkin.

the class ScribeSpanConsumerTest method consumerExceptionBeforeCallbackDoesntSetFutureException.

@Test
void consumerExceptionBeforeCallbackDoesntSetFutureException() {
    consumer = (input) -> {
        throw new NullPointerException("endpoint was null");
    };
    ScribeSpanConsumer scribe = newScribeSpanConsumer("zipkin", consumer);
    LogEntry entry = new LogEntry();
    entry.category = "zipkin";
    entry.message = encodedSpan;
    CaptureAsyncMethodCallback callback = new CaptureAsyncMethodCallback();
    scribe.Log(asList(entry), callback);
    // Storage related exceptions are not propagated to the caller. Only marshalling ones are.
    assertThat(callback.error).isNull();
    // Storage finishes after callback so wait for it.
    await().untilAsserted(() -> assertThat(scribeMetrics.messages()).isEqualTo(1));
    assertThat(scribeMetrics.messagesDropped()).isZero();
    assertThat(scribeMetrics.bytes()).isEqualTo(bytes.length);
    assertThat(scribeMetrics.spans()).isEqualTo(1);
    assertThat(scribeMetrics.spansDropped()).isEqualTo(1);
}
Also used : LogEntry(zipkin2.collector.scribe.generated.LogEntry) Test(org.junit.jupiter.api.Test)

Example 85 with Callback

use of zipkin2.Callback in project zipkin by openzipkin.

the class ScribeSpanConsumerTest method malformedDataIsDropped.

@Test
void malformedDataIsDropped() {
    ScribeSpanConsumer scribe = newScribeSpanConsumer("zipkin", consumer);
    LogEntry entry = new LogEntry();
    entry.category = "zipkin";
    entry.message = "notbase64";
    CaptureAsyncMethodCallback callback = new CaptureAsyncMethodCallback();
    scribe.Log(asList(entry), callback);
    assertThat(callback.error).isInstanceOf(IllegalArgumentException.class);
    // Storage finishes after callback so wait for it.
    await().untilAsserted(() -> assertThat(scribeMetrics.messages()).isEqualTo(1));
    assertThat(scribeMetrics.messagesDropped()).isEqualTo(1);
    assertThat(scribeMetrics.bytes()).isZero();
    assertThat(scribeMetrics.spans()).isZero();
    assertThat(scribeMetrics.spansDropped()).isZero();
}
Also used : LogEntry(zipkin2.collector.scribe.generated.LogEntry) Test(org.junit.jupiter.api.Test)

Aggregations

Callback (okhttp3.Callback)173 IOException (java.io.IOException)137 Call (okhttp3.Call)132 Response (okhttp3.Response)132 Request (okhttp3.Request)110 Callback (retrofit2.Callback)42 Call (retrofit2.Call)41 Test (org.junit.Test)39 Response (retrofit2.Response)39 RequestBody (okhttp3.RequestBody)37 OkHttpClient (okhttp3.OkHttpClient)34 File (java.io.File)27 Context (android.content.Context)24 JSONObject (org.json.JSONObject)20 FormBody (okhttp3.FormBody)19 ArrayList (java.util.ArrayList)18 View (android.view.View)16 Intent (android.content.Intent)14 TextView (android.widget.TextView)14 GsonBuilder (com.google.gson.GsonBuilder)14