Search in sources :

Example 91 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class NingAsyncHttpClientIT method test.

@Test
public void test() throws Exception {
    AsyncHttpClient client = new AsyncHttpClient();
    try {
        Future<Response> f = client.preparePost("http://www.naver.com/").addParameter("param1", "value1").execute();
        Response response = f.get();
    } finally {
        client.close();
    }
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event("ASYNC_HTTP_CLIENT", AsyncHttpClient.class.getMethod("executeRequest", Request.class, AsyncHandler.class), null, null, "www.naver.com", annotation("http.url", "http://www.naver.com"), annotation("http.param", "param1=value1")));
    verifier.verifyTraceCount(0);
}
Also used : Response(com.ning.http.client.Response) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) Test(org.junit.Test)

Example 92 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class AbstractAutowireCapableBeanFactoryModifierIT method test.

@Test
public void test() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("spring-beans-test.xml");
    Maru maru = context.getBean(Maru.class);
    maru.publicMethod();
    maru.protectedMethod();
    Morae morae = (Morae) context.getBean("morae");
    morae.doSomething();
    Morae duplicatedMorae = (Morae) context.getBean("duplicatedMorae");
    duplicatedMorae.doSomething();
    Mozzi mozzi = (Mozzi) context.getBean("mozzi");
    mozzi.doSomething();
    Excluded excluded = (Excluded) context.getBean("excluded");
    excluded.doSomething();
    Outer outer = (Outer) context.getBean("outer");
    outer.doSomething();
    Inner inner = outer.getInner();
    inner.doSomething();
    ProxyTarget proxyTarget = context.getBean(ProxyTarget.class);
    proxyTarget.doSomething();
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Outer.class.getMethod("setInner", Inner.class)));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Maru.class.getMethod("publicMethod")));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Morae.class.getMethod("doSomething")));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Morae.class.getMethod("doSomething")));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Mozzi.class.getMethod("doSomething")));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Outer.class.getMethod("doSomething")));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Outer.class.getMethod("getInner")));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Inner.class.getMethod("doSomething")));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", ProxyTarget.class.getMethod("doSomething")));
    verifier.verifyTraceCount(0);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 93 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class CassandraDatastaxITBase method test.

@Test
public void test() throws Exception {
    final int testId = 99;
    final String testValue = "testValue";
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    Session myKeyspaceSession = null;
    try {
        myKeyspaceSession = cluster.connect(TEST_KEYSPACE);
        // ===============================================
        // Insert Data (PreparedStatement, BoundStatement)
        PreparedStatement preparedStatement = myKeyspaceSession.prepare(CQL_INSERT);
        BoundStatement boundStatement = new BoundStatement(preparedStatement);
        boundStatement.bind(testId, testValue);
        myKeyspaceSession.execute(boundStatement);
        verifier.printCache();
        // Cluster#connect(String)
        Class<?> clusterClass = Class.forName("com.datastax.driver.core.Cluster");
        Method connect = clusterClass.getDeclaredMethod("connect", String.class);
        verifier.verifyTrace(event(CASSANDRA, connect, null, CASSANDRA_ADDRESS, TEST_KEYSPACE));
        // SessionManager#prepare(String) OR AbstractSession#prepare(String)
        Class<?> sessionClass;
        try {
            sessionClass = Class.forName("com.datastax.driver.core.AbstractSession");
        } catch (ClassNotFoundException e) {
            sessionClass = Class.forName("com.datastax.driver.core.SessionManager");
        }
        Method prepare = sessionClass.getDeclaredMethod("prepare", String.class);
        verifier.verifyTrace(event(CASSANDRA, prepare, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(CQL_INSERT, null)));
        // SessionManager#execute(Statement) OR AbstractSession#execute(Statement)
        Method execute = sessionClass.getDeclaredMethod("execute", Statement.class);
        verifier.verifyTrace(event(CASSANDRA_EXECUTE_QUERY, execute, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(CQL_INSERT, null)));
        // ====================
        // Select Data (String)
        final String cqlSelect = String.format("SELECT %s, %s FROM %s WHERE %s = %d", TEST_COL_ID, TEST_COL_VALUE, TEST_TABLE, TEST_COL_ID, testId);
        verifySelect(myKeyspaceSession.execute(cqlSelect), testId, testValue);
        verifier.printCache();
        // SessionManager#execute(String) OR AbstractSession#execute(String)
        execute = sessionClass.getDeclaredMethod("execute", String.class);
        String normalizedSelectSql = SQL_PARSER.normalizedSql(cqlSelect).getNormalizedSql();
        verifier.verifyTrace(event(CASSANDRA_EXECUTE_QUERY, execute, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(normalizedSelectSql, String.valueOf(testId))));
        // ====================
        // Delete Data (String)
        final String cqlDelete = String.format("DELETE FROM %s.%s WHERE %s = ?", TEST_KEYSPACE, TEST_TABLE, TEST_COL_ID);
        myKeyspaceSession.execute(cqlDelete, testId);
        verifier.printCache();
        // SessionManager#execute(String, Object[]) OR AbstractSession#execute(String, Object[])
        execute = sessionClass.getDeclaredMethod("execute", String.class, Object[].class);
        String normalizedDeleteSql = SQL_PARSER.normalizedSql(cqlDelete).getNormalizedSql();
        verifier.verifyTrace(event(CASSANDRA_EXECUTE_QUERY, execute, null, CASSANDRA_ADDRESS, TEST_KEYSPACE, sql(normalizedDeleteSql, null)));
    } finally {
        closeSession(myKeyspaceSession);
    }
}
Also used : PreparedStatement(com.datastax.driver.core.PreparedStatement) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) BoundStatement(com.datastax.driver.core.BoundStatement) Session(com.datastax.driver.core.Session) Test(org.junit.Test)

Example 94 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class OkHttpClientIT method enqueue.

@Test
public void enqueue() throws Exception {
    Request request = new Request.Builder().url("http://google.com").build();
    OkHttpClient client = new OkHttpClient();
    final CountDownLatch latch = new CountDownLatch(1);
    client.newCall(request).enqueue(new Callback() {

        @Override
        public void onFailure(Request request, IOException e) {
            latch.countDown();
        }

        @Override
        public void onResponse(Response response) throws IOException {
            latch.countDown();
        }
    });
    latch.await(3, TimeUnit.SECONDS);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method enqueueMethod = Call.class.getDeclaredMethod("enqueue", com.squareup.okhttp.Callback.class);
    verifier.verifyTrace(Expectations.event("OK_HTTP_CLIENT_INTERNAL", enqueueMethod));
}
Also used : com.squareup.okhttp(com.squareup.okhttp) IOException(java.io.IOException) Method(java.lang.reflect.Method) CountDownLatch(java.util.concurrent.CountDownLatch) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 95 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class JsonLibJSONArrayIT method arrayToJsonTest.

@Test
public void arrayToJsonTest() throws Exception {
    Method fromObject = JSONArray.class.getMethod("fromObject", Object.class);
    Method toString = JSONArray.class.getMethod("toString");
    JSONArray jsonArray = JSONArray.fromObject(new Object[] { "pinpoint", "json-lib" });
    String json = jsonArray.toString();
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(event(SERVICE_TYPE, fromObject));
    verifier.verifyTrace(event(SERVICE_TYPE, toString, Expectations.annotation(ANNOTATION_KEY, json.length())));
    verifier.verifyTraceCount(0);
}
Also used : JSONArray(net.sf.json.JSONArray) Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Aggregations

PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)101 Method (java.lang.reflect.Method)80 Test (org.junit.Test)80 SqlSession (org.apache.ibatis.session.SqlSession)8 SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)8 IOException (java.io.IOException)5 RpcException (com.alibaba.dubbo.rpc.RpcException)4 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)3 Gson (com.google.gson.Gson)3 ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)3 HttpURLConnection (java.net.HttpURLConnection)3 URI (java.net.URI)3 URL (java.net.URL)3 FailoverClusterInvoker (com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker)2 AbstractProxyInvoker (com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)2 GenericUrl (com.google.api.client.http.GenericUrl)2 HttpRequest (com.google.api.client.http.HttpRequest)2 HttpRequestFactory (com.google.api.client.http.HttpRequestFactory)2