Search in sources :

Example 6 with MockHttpRequest

use of com.newrelic.agent.tracers.servlet.MockHttpRequest in project newrelic-java-agent by newrelic.

the class TransactionNamingTest method startWebTransaction.

private void startWebTransaction(String uri) throws Exception {
    Transaction tx = Transaction.getTransaction();
    MockHttpRequest httpRequest = new MockHttpRequest();
    httpRequest.setRequestURI(uri);
    MockHttpResponse httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
    Tracer tracer = new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
    tx.getTransactionActivity().tracerStarted(tracer);
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Example 7 with MockHttpRequest

use of com.newrelic.agent.tracers.servlet.MockHttpRequest in project newrelic-java-agent by newrelic.

the class WebRequestDispatcherTest method runTransactionAndGetAttributes.

private Map<String, Object> runTransactionAndGetAttributes() throws Exception {
    // setup request
    MockHttpRequest httpRequest = new MockHttpRequest().setHeader("Referer", "Referer value").setHeader("Accept", "Accept value").setHeader("Host", "Host value").setHeader("User-Agent", "User-Agent value").setHeader("Content-Length", "Content-Length value").setHeader(HEADER_WITH_ALIAS, "123456").setHeader(HEADER_WITHOUT_ALIAS, "234567");
    WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
    dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
    dispatcher.getTransaction().getTransactionActivity().markAsResponseSender();
    dispatcher.getTransaction().getRootTracer().finish(0, null);
    return dispatcher.getTransaction().getUserAttributes();
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest)

Example 8 with MockHttpRequest

use of com.newrelic.agent.tracers.servlet.MockHttpRequest in project newrelic-java-agent by newrelic.

the class AsyncTimeoutTransactionTest method createDispatcherTracer.

// Create a Tracer for tests that require one.
private BasicRequestRootTracer createDispatcherTracer() {
    Transaction tx = Transaction.getTransaction();
    MockHttpRequest httpRequest = new MockHttpRequest();
    MockHttpResponse httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
    return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Example 9 with MockHttpRequest

use of com.newrelic.agent.tracers.servlet.MockHttpRequest in project newrelic-java-agent by newrelic.

the class AsyncTransactionTest method createDispatcherTracer.

// Create a Tracer for tests that require one.
private BasicRequestRootTracer createDispatcherTracer(String methodName) {
    Transaction tx = Transaction.getTransaction();
    MockHttpRequest httpRequest = new MockHttpRequest();
    MockHttpResponse httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), methodName, "()V");
    BasicRequestRootTracer brrt = new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
    tx.setDispatcher(brrt.createDispatcher());
    return brrt;
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Example 10 with MockHttpRequest

use of com.newrelic.agent.tracers.servlet.MockHttpRequest in project newrelic-java-agent by newrelic.

the class ApiTest method createDispatcherTracer.

private BasicRequestRootTracer createDispatcherTracer() {
    Transaction tx = Transaction.getTransaction();
    MockHttpRequest httpRequest = new MockHttpRequest();
    MockHttpResponse httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
    return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Aggregations

MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)22 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)19 Transaction (com.newrelic.agent.Transaction)16 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)15 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)15 Test (org.junit.Test)5 Tracer (com.newrelic.agent.tracers.Tracer)4 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)3 Dispatcher (com.newrelic.agent.dispatchers.Dispatcher)2 WebRequestDispatcher (com.newrelic.agent.dispatchers.WebRequestDispatcher)1 SpanEvent (com.newrelic.agent.model.SpanEvent)1 TransactionEvent (com.newrelic.agent.service.analytics.TransactionEvent)1 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)1 OtherRootSqlTracer (com.newrelic.agent.tracers.OtherRootSqlTracer)1 SqlTracer (com.newrelic.agent.tracers.SqlTracer)1 SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)1 HeaderType (com.newrelic.api.agent.HeaderType)1 Response (com.newrelic.api.agent.Response)1 Trace (com.newrelic.api.agent.Trace)1 JSONArray (org.json.simple.JSONArray)1