Search in sources :

Example 51 with WebRequestDispatcher

use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.

the class BasicRequestDispatcherTracerTest method statusCodeLastPolicy.

@Test
public void statusCodeLastPolicy() throws Exception {
    MockHttpRequest httpRequest = new MockHttpRequest();
    WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
    dispatcher.setStatus(404);
    dispatcher.setStatus(200);
    Assert.assertEquals(200, dispatcher.getStatus());
}
Also used : WebRequestDispatcher(com.newrelic.agent.dispatchers.WebRequestDispatcher) Test(org.junit.Test)

Example 52 with WebRequestDispatcher

use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.

the class BasicRequestDispatcherTracerTest method noRequestXQueueHeaders.

@Test
public void noRequestXQueueHeaders() throws Exception {
    MockHttpRequest httpRequest = new MockHttpRequest();
    WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
    dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
    Assert.assertEquals(0, dispatcher.getQueueTime());
}
Also used : WebRequestDispatcher(com.newrelic.agent.dispatchers.WebRequestDispatcher) Test(org.junit.Test)

Example 53 with WebRequestDispatcher

use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.

the class BasicRequestDispatcherTracerTest method apdexFrustrating.

@Test
public void apdexFrustrating() throws Exception {
    MockHttpRequest httpRequest = new MockHttpRequest();
    WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
    dispatcher.setStatus(200);
    dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
    Assert.assertFalse(dispatcher.isApdexFrustrating());
}
Also used : WebRequestDispatcher(com.newrelic.agent.dispatchers.WebRequestDispatcher) Test(org.junit.Test)

Example 54 with WebRequestDispatcher

use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.

the class BasicRequestDispatcherTracerTest method createDispatcher.

private WebRequestDispatcher createDispatcher(Request httpRequest) throws Exception {
    Transaction tx = Transaction.getTransaction();
    Response httpResponse = new MockHttpResponse();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
    DefaultTracer tracer = new OtherRootTracer(tx, sig, this, new SimpleMetricNameFormat("test"));
    tx.getTransactionActivity().tracerStarted(tracer);
    WebRequestDispatcher dispatcher = new WebRequestDispatcher(httpRequest, httpResponse, tx);
    tx.setDispatcher(dispatcher);
    return dispatcher;
}
Also used : Response(com.newrelic.api.agent.Response) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) WebRequestDispatcher(com.newrelic.agent.dispatchers.WebRequestDispatcher) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer)

Example 55 with WebRequestDispatcher

use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.

the class BasicRequestDispatcherTracerTest method requestXQueueStartHeaderNanoMagnitude.

@Test
public void requestXQueueStartHeaderNanoMagnitude() throws Exception {
    MockHttpRequest httpRequest = new MockHttpRequest();
    long nowInNanos = TimeUnit.NANOSECONDS.convert(Transaction.getTransaction().getWallClockStartTimeMs(), TimeUnit.MILLISECONDS);
    long queueStartTimeInNanos = nowInNanos - 100000000l;
    httpRequest.setHeader(QueueTimeTracker.REQUEST_X_QUEUE_START_HEADER, "t=" + queueStartTimeInNanos);
    WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
    dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
    long queueStartTimeInMilliseconds = TimeUnit.MILLISECONDS.convert(queueStartTimeInNanos, TimeUnit.NANOSECONDS);
    long expectedQueueTime = dispatcher.getTransaction().getWallClockStartTimeMs() - queueStartTimeInMilliseconds;
    assertDelta(expectedQueueTime, dispatcher.getQueueTime(), 1);
}
Also used : WebRequestDispatcher(com.newrelic.agent.dispatchers.WebRequestDispatcher) Test(org.junit.Test)

Aggregations

WebRequestDispatcher (com.newrelic.agent.dispatchers.WebRequestDispatcher)55 Test (org.junit.Test)49 TransactionStats (com.newrelic.agent.stats.TransactionStats)11 Transaction (com.newrelic.agent.Transaction)10 ApdexStats (com.newrelic.agent.stats.ApdexStats)4 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)3 Response (com.newrelic.api.agent.Response)3 HashMap (java.util.HashMap)3 MockHttpServletRequest (org.apache.struts.mock.MockHttpServletRequest)3 ConnectionConfigListener (com.newrelic.agent.ConnectionConfigListener)2 MockRPMService (com.newrelic.agent.MockRPMService)2 WebResponse (com.newrelic.agent.bridge.WebResponse)2 Dispatcher (com.newrelic.agent.dispatchers.Dispatcher)2 StatsEngine (com.newrelic.agent.stats.StatsEngine)2 Request (com.newrelic.api.agent.Request)2 Trace (com.newrelic.api.agent.Trace)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 OutputStreamWriter (java.io.OutputStreamWriter)2 GenericServlet (javax.servlet.GenericServlet)2