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);
}
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);
}
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());
}
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);
}
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());
}
Aggregations