Search in sources :

Example 1 with InboundHeaders

use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.

the class TransactionInboundHeadersTest method TestEmptyRequestHeaders.

@Test
public void TestEmptyRequestHeaders() {
    Transaction tx = Transaction.getTransaction();
    Dispatcher dispatcher = Mockito.mock(Dispatcher.class);
    Request request = Mockito.mock(Request.class);
    Mockito.when(dispatcher.getRequest()).thenReturn(request);
    tx.setDispatcher(dispatcher);
    InboundHeaders requestHeaders = Transaction.getRequestHeaders(tx);
    // Non-null request headers should be deobfuscated.
    Assert.assertEquals(requestHeaders.getClass(), DeobfuscatedInboundHeaders.class);
}
Also used : Request(com.newrelic.api.agent.Request) InboundHeaders(com.newrelic.api.agent.InboundHeaders) Dispatcher(com.newrelic.agent.dispatchers.Dispatcher) Test(org.junit.Test)

Example 2 with InboundHeaders

use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.

the class TransactionInboundHeadersTest method TestNullRequestRequestHeaders.

@Test
public void TestNullRequestRequestHeaders() {
    Transaction tx = Transaction.getTransaction();
    Dispatcher dispatcher = Mockito.mock(Dispatcher.class);
    Mockito.when(dispatcher.getRequest()).thenReturn(null);
    tx.setDispatcher(dispatcher);
    InboundHeaderState inboundHeaderState = tx.getInboundHeaderState();
    Assert.assertTrue(inboundHeaderState != null);
    Assert.assertNull(inboundHeaderState.getClientCrossProcessId());
    Assert.assertNull(inboundHeaderState.getUnparsedSyntheticsHeader());
    Assert.assertNull(inboundHeaderState.getReferrerGuid());
    InboundHeaders requestHeaders = Transaction.getRequestHeaders(tx);
    Assert.assertNull(requestHeaders);
}
Also used : InboundHeaders(com.newrelic.api.agent.InboundHeaders) Dispatcher(com.newrelic.agent.dispatchers.Dispatcher) Test(org.junit.Test)

Example 3 with InboundHeaders

use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.

the class TransactionInboundHeadersTest method testEmptyCatApiProvidedHeaders.

@Test
public void testEmptyCatApiProvidedHeaders() {
    Transaction tx = Transaction.getTransaction();
    InboundHeaders headers = createEmptyMessageInboundHeaders();
    tx.provideRawHeaders(headers);
    InboundHeaderState inboundHeaderState = tx.getInboundHeaderState();
    Assert.assertTrue(inboundHeaderState != null);
    Assert.assertNull(inboundHeaderState.getClientCrossProcessId());
    Assert.assertNull(inboundHeaderState.getUnparsedSyntheticsHeader());
    Assert.assertNull(inboundHeaderState.getReferrerGuid());
}
Also used : InboundHeaders(com.newrelic.api.agent.InboundHeaders) Test(org.junit.Test)

Example 4 with InboundHeaders

use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.

the class CrossProcessStateCatApiTest method setUpTransaction.

private void setUpTransaction(Transaction tx, TransactionActivity txa, Object lock, Dispatcher dispatcher, CrossProcessConfig config, String guid) {
    when(txa.getTransaction()).thenReturn(tx);
    when(tx.getLock()).thenReturn(lock);
    when(tx.getDispatcher()).thenReturn(dispatcher);
    when(tx.getCrossProcessConfig()).thenReturn(config);
    DistributedTracePayloadImpl distributedTracePayload = DistributedTracePayloadImpl.createDistributedTracePayload("", "", "", 0f);
    when(tx.createDistributedTracePayload(guid)).thenReturn(distributedTracePayload);
    TransactionStats transactionStats = Mockito.mock(TransactionStats.class);
    SimpleStatsEngine stats = Mockito.mock(SimpleStatsEngine.class);
    when(stats.getOrCreateResponseTimeStats(anyString())).thenReturn(Mockito.mock(ResponseTimeStats.class));
    when(transactionStats.getUnscopedStats()).thenReturn(stats);
    when(txa.getTransactionStats()).thenReturn(transactionStats);
    when(tx.getTransactionActivity()).thenReturn(txa);
    InboundHeaders headers = Mockito.mock(InboundHeaders.class);
    InboundHeaderState inboundHeaderState = new InboundHeaderState(tx, headers);
    when(tx.getInboundHeaderState()).thenReturn(inboundHeaderState);
    PriorityTransactionName priorityTransactionName = PriorityTransactionName.create("Something/Or/other", "category", TransactionNamePriority.FRAMEWORK);
    when(tx.getPriorityTransactionName()).thenReturn(priorityTransactionName);
    TransactionCounts txnCounts = Mockito.mock(TransactionCounts.class);
    when(txnCounts.isOverTracerSegmentLimit()).thenReturn(false);
    when(tx.getTransactionCounts()).thenReturn(txnCounts);
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) TransactionStats(com.newrelic.agent.stats.TransactionStats) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) InboundHeaders(com.newrelic.api.agent.InboundHeaders) SimpleStatsEngine(com.newrelic.agent.stats.SimpleStatsEngine) TransactionCounts(com.newrelic.agent.transaction.TransactionCounts) DistributedTracePayloadImpl(com.newrelic.agent.tracing.DistributedTracePayloadImpl)

Example 5 with InboundHeaders

use of com.newrelic.api.agent.InboundHeaders in project newrelic-java-agent by newrelic.

the class InboundHeaderStateTest method setup.

@Before
public void setup() {
    serviceManager.setConfigService(new MockConfigService(AgentConfigFactory.createAgentConfig(Collections.emptyMap(), Collections.emptyMap(), null)));
    ServiceFactory.setServiceManager(serviceManager);
    OutboundHeaders outboundHeaders = mock(OutboundHeaders.class);
    InboundHeaders inboundHeaders = mock(InboundHeaders.class);
    request = mock(ExtendedRequest.class);
    agentConfig = mock(AgentConfig.class);
    crossProcessConfig = mock(CrossProcessConfig.class);
    distributedTracingConfig = mock(DistributedTracingConfig.class);
    tx = mock(Transaction.class);
    when(inboundHeaders.getHeaderType()).thenReturn(HeaderType.HTTP);
    when(outboundHeaders.getHeaderType()).thenReturn(HeaderType.HTTP);
    when(crossProcessConfig.getEncodingKey()).thenReturn(encodingKey);
    when(crossProcessConfig.isCrossApplicationTracing()).thenReturn(true);
    when(distributedTracingConfig.isEnabled()).thenReturn(false);
    when(agentConfig.getDistributedTracingConfig()).thenReturn(distributedTracingConfig);
    when(tx.isIgnore()).thenReturn(false);
    when(tx.getDispatcher()).thenReturn(mock(Dispatcher.class));
    when(tx.getDispatcher().getRequest()).thenReturn(request);
    when(tx.getDispatcher().getRequest().getHeaderType()).thenReturn(HeaderType.HTTP);
    when(tx.getCrossProcessConfig()).thenReturn(crossProcessConfig);
    when(tx.getAgentConfig()).thenReturn(agentConfig);
    when(tx.getPriorityTransactionName()).thenReturn(PriorityTransactionName.create("Test", "TEST", TransactionNamePriority.NONE));
    when(tx.getApplicationName()).thenReturn("TestApp");
    when(tx.getLock()).thenReturn(new Object());
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) DistributedTracingConfig(com.newrelic.agent.config.DistributedTracingConfig) ExtendedRequest(com.newrelic.api.agent.ExtendedRequest) InboundHeaders(com.newrelic.api.agent.InboundHeaders) CrossProcessConfig(com.newrelic.agent.config.CrossProcessConfig) OutboundHeaders(com.newrelic.api.agent.OutboundHeaders) Dispatcher(com.newrelic.agent.dispatchers.Dispatcher) Before(org.junit.Before)

Aggregations

InboundHeaders (com.newrelic.api.agent.InboundHeaders)10 Test (org.junit.Test)4 Dispatcher (com.newrelic.agent.dispatchers.Dispatcher)3 Transaction (com.newrelic.agent.Transaction)1 AgentConfig (com.newrelic.agent.config.AgentConfig)1 CrossProcessConfig (com.newrelic.agent.config.CrossProcessConfig)1 DistributedTracingConfig (com.newrelic.agent.config.DistributedTracingConfig)1 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)1 SimpleStatsEngine (com.newrelic.agent.stats.SimpleStatsEngine)1 TransactionStats (com.newrelic.agent.stats.TransactionStats)1 CrossProcessNameFormat (com.newrelic.agent.tracers.CrossProcessNameFormat)1 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)1 Tracer (com.newrelic.agent.tracers.Tracer)1 DistributedTracePayloadImpl (com.newrelic.agent.tracing.DistributedTracePayloadImpl)1 PriorityTransactionName (com.newrelic.agent.transaction.PriorityTransactionName)1 TransactionCounts (com.newrelic.agent.transaction.TransactionCounts)1 DestinationType (com.newrelic.api.agent.DestinationType)1 ExtendedRequest (com.newrelic.api.agent.ExtendedRequest)1 HttpParameters (com.newrelic.api.agent.HttpParameters)1 MessageConsumeParameters (com.newrelic.api.agent.MessageConsumeParameters)1