Search in sources :

Example 1 with HttpRequestClass

use of com.example.http.HttpRequestClass in project newrelic-java-agent by newrelic.

the class HttpServerTest method testCatCallSetName.

@Test
public void testCatCallSetName() throws IOException, URISyntaxException {
    Introspector intro = InstrumentationTestRunner.getIntrospector();
    HttpRequestClass myClass = new HttpRequestClass();
    myClass.performCatHttp(server.getEndPoint());
    assertEquals(2, intro.getFinishedTransactionCount());
    Collection<String> names = intro.getTransactionNames();
    assertEquals(2, names.size());
    String txName1 = "OtherTransaction/Custom/com.example.http.HttpRequestClass/performCatHttp";
    String txName2 = "WebTransaction/Custom/ExternalHTTPServer";
    assertTrue(names.contains(txName1));
    assertTrue(names.contains(txName2));
    Collection<ExternalRequest> externals = intro.getExternalRequests(txName1);
    assertEquals(1, externals.size());
    ExternalRequest req = externals.iterator().next();
    assertEquals(1, req.getCount());
    assertEquals("localhost", req.getHostname());
    CatHelper.verifyOneSuccessfulCat(intro, txName1);
}
Also used : HttpRequestClass(com.example.http.HttpRequestClass) Introspector(com.newrelic.agent.introspec.Introspector) ExternalRequest(com.newrelic.agent.introspec.ExternalRequest) Test(org.junit.Test)

Example 2 with HttpRequestClass

use of com.example.http.HttpRequestClass in project newrelic-java-agent by newrelic.

the class HttpServerTest method testCatCallDefaultName.

// this one creates a new path hash at the end
@Test
public void testCatCallDefaultName() throws IOException, URISyntaxException {
    Introspector intro = InstrumentationTestRunner.getIntrospector();
    HttpRequestClass myClass = new HttpRequestClass();
    myClass.performCatHttpNoSetName(server.getEndPoint());
    assertEquals(2, intro.getFinishedTransactionCount());
    Collection<String> names = intro.getTransactionNames();
    assertEquals(2, names.size());
    String txName1 = "OtherTransaction/Custom/com.example.http.HttpRequestClass/performCatHttpNoSetName";
    String txName2 = "WebTransaction/Custom/ExternalHTTPServer";
    assertTrue(names.contains(txName1));
    assertTrue(names.contains(txName2));
    Collection<ExternalRequest> externals = intro.getExternalRequests(txName1);
    assertEquals(1, externals.size());
    ExternalRequest req = externals.iterator().next();
    assertEquals(1, req.getCount());
    assertEquals("localhost", req.getHostname());
    CatHelper.verifyOneSuccessfulCat(intro, txName1);
}
Also used : HttpRequestClass(com.example.http.HttpRequestClass) Introspector(com.newrelic.agent.introspec.Introspector) ExternalRequest(com.newrelic.agent.introspec.ExternalRequest) Test(org.junit.Test)

Example 3 with HttpRequestClass

use of com.example.http.HttpRequestClass in project newrelic-java-agent by newrelic.

the class HttpServerTest method testExternalCall.

@Test
public void testExternalCall() throws IOException, URISyntaxException {
    Introspector intro = InstrumentationTestRunner.getIntrospector();
    HttpRequestClass myClass = new HttpRequestClass();
    myClass.performHttp(server.getEndPoint());
    assertEquals(2, intro.getFinishedTransactionCount());
    Collection<String> names = intro.getTransactionNames();
    assertEquals(2, names.size());
    String txName1 = "OtherTransaction/Custom/com.example.http.HttpRequestClass/performHttp";
    String txName2 = "WebTransaction/Custom/ExternalHTTPServer";
    assertTrue(names.contains(txName1));
    assertTrue(names.contains(txName2));
    Collection<ExternalRequest> externals = intro.getExternalRequests(txName1);
    assertEquals(1, externals.size());
    ExternalRequest req = externals.iterator().next();
    assertEquals(1, req.getCount());
    assertEquals("localhost", req.getHostname());
    assertEquals("NewRelicApacheHttp", req.getLibrary());
}
Also used : HttpRequestClass(com.example.http.HttpRequestClass) Introspector(com.newrelic.agent.introspec.Introspector) ExternalRequest(com.newrelic.agent.introspec.ExternalRequest) Test(org.junit.Test)

Aggregations

HttpRequestClass (com.example.http.HttpRequestClass)3 ExternalRequest (com.newrelic.agent.introspec.ExternalRequest)3 Introspector (com.newrelic.agent.introspec.Introspector)3 Test (org.junit.Test)3