Search in sources :

Example 41 with BasicRequestRootTracer

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

the class ApiTest method testGetBrowserTimingHeaderForIgnoredTransaction.

@Test
public void testGetBrowserTimingHeaderForIgnoredTransaction() throws Exception {
    ApiTestHelper.mockOutServiceManager();
    Transaction tx = Transaction.getTransaction();
    BasicRequestRootTracer tracer = createDispatcherTracer();
    tx.getTransactionActivity().tracerStarted(tracer);
    tx.setIgnore(true);
    String browserTimingHeader = NewRelic.getBrowserTimingHeader();
    Assert.assertEquals("Incorrect header", "", browserTimingHeader);
    tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Also used : Transaction(com.newrelic.agent.Transaction) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 42 with BasicRequestRootTracer

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

the class ApiTest method testNoticeErrorMsgParamsInsideTransaction.

@Test
public void testNoticeErrorMsgParamsInsideTransaction() {
    Transaction tx = Transaction.getTransaction();
    BasicRequestRootTracer tracer = createDispatcherTracer();
    tx.getTransactionActivity().tracerStarted(tracer);
    NewRelic.noticeError("boom", new HashMap<String, String>());
    try {
        Class<? extends Transaction> c = tx.getClass();
        Method m = c.getDeclaredMethod("getThrowable");
        TransactionThrowable transactionThrowable = (TransactionThrowable) m.invoke(tx);
        Assert.assertEquals("boom", transactionThrowable.throwable.getMessage());
    } catch (SecurityException | InvocationTargetException | IllegalArgumentException | NoSuchMethodException | IllegalAccessException e) {
    }
    tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) Transaction(com.newrelic.agent.Transaction) TransactionThrowable(com.newrelic.agent.transaction.TransactionThrowable) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 43 with BasicRequestRootTracer

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

the class ApiTest method testNoticeErrorNullMsgParamsInsideTransaction.

@Test
public void testNoticeErrorNullMsgParamsInsideTransaction() {
    Transaction tx = Transaction.getTransaction();
    BasicRequestRootTracer tracer = createDispatcherTracer();
    tx.getTransactionActivity().tracerStarted(tracer);
    NewRelic.noticeError((String) null, new HashMap<String, String>());
    try {
        Class<? extends Transaction> c = tx.getClass();
        Method m = c.getDeclaredMethod("getThrowable");
        TransactionThrowable transactionThrowable = (TransactionThrowable) m.invoke(tx);
        Assert.assertNull(transactionThrowable.throwable.getMessage());
    } catch (SecurityException | InvocationTargetException | IllegalArgumentException | NoSuchMethodException | IllegalAccessException e) {
    }
    tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) Transaction(com.newrelic.agent.Transaction) TransactionThrowable(com.newrelic.agent.transaction.TransactionThrowable) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 44 with BasicRequestRootTracer

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

the class ApiTest method testGetBrowserTimingHeaderTwice.

@Test
public void testGetBrowserTimingHeaderTwice() throws Exception {
    ApiTestHelper.mockOutServiceManager();
    Transaction tx = Transaction.getTransaction();
    BasicRequestRootTracer tracer = createDispatcherTracer();
    tx.getTransactionActivity().tracerStarted(tracer);
    String browserTimingHeader = NewRelic.getBrowserTimingHeader();
    browserTimingHeader = NewRelic.getBrowserTimingHeader();
    Assert.assertEquals("Incorrect header", "", browserTimingHeader);
    tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Also used : Transaction(com.newrelic.agent.Transaction) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 45 with BasicRequestRootTracer

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

the class ApiTest method testGetBrowserTimingFooterNoBeaconConfiguration.

@Test
public void testGetBrowserTimingFooterNoBeaconConfiguration() {
    Transaction tx = Transaction.getTransaction();
    BasicRequestRootTracer tracer = createDispatcherTracer();
    tx.getTransactionActivity().tracerStarted(tracer);
    String browserTimingFooter = NewRelic.getBrowserTimingFooter();
    Assert.assertEquals("No beacon configuration, the timing footer should be empty", "", browserTimingFooter);
    tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Also used : Transaction(com.newrelic.agent.Transaction) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Aggregations

BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)85 Test (org.junit.Test)67 Transaction (com.newrelic.agent.Transaction)64 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)33 HashMap (java.util.HashMap)22 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)18 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)16 TransactionThrowable (com.newrelic.agent.transaction.TransactionThrowable)16 Method (java.lang.reflect.Method)16 MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)15 SegmentTest (com.newrelic.agent.transaction.SegmentTest)15 TransactionNamePriority (com.newrelic.agent.bridge.TransactionNamePriority)14 PriorityTransactionName (com.newrelic.agent.transaction.PriorityTransactionName)14 TransactionService (com.newrelic.agent.TransactionService)8 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)8 NewRelicApiImplementation (com.newrelic.api.agent.NewRelicApiImplementation)8 ArrayList (java.util.ArrayList)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 Tracer (com.newrelic.agent.tracers.Tracer)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)7