/* * Copyright 2016 Naver Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.navercorp.pinpoint.plugin.jdk7.okhttp; import com.navercorp.pinpoint.bootstrap.plugin.test.Expectations; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier; import com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifierHolder; import com.navercorp.pinpoint.plugin.WebServer; import com.navercorp.pinpoint.test.plugin.Dependency; import com.navercorp.pinpoint.test.plugin.PinpointPluginTestSuite; import com.squareup.okhttp.*; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import java.lang.reflect.Method; /** * @author jaehong.kim */ @RunWith(PinpointPluginTestSuite.class) @Dependency({"com.squareup.okhttp:okhttp:[2.0.0],[2.1.0],[2.2.0],[2.3.0]", "org.nanohttpd:nanohttpd:2.3.1"}) public class OkHttpClientBackwardCompatibilityIT { private static WebServer webServer; @BeforeClass public static void BeforeClass() throws Exception { webServer = WebServer.newTestWebServer(); } @AfterClass public static void AfterClass() throws Exception { final WebServer copy = webServer; if (copy != null) { copy.stop(); webServer = null; } } @Test public void execute() throws Exception { Request request = new Request.Builder().url(webServer.getCallHttpUrl()).build(); OkHttpClient client = new OkHttpClient(); Response response = client.newCall(request).execute(); PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance(); verifier.printCache(); Method callMethod = Call.class.getDeclaredMethod("execute"); verifier.verifyTrace(Expectations.event("OK_HTTP_CLIENT_INTERNAL", callMethod)); } }