use of com.newrelic.api.agent.ExtendedRequest in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method testBlankHeader.
@Test
public void testBlankHeader() {
String encodingKey = "test";
ExtendedRequest request = createRequestFromStandardHeaders(null, null, null);
configureCatEnabled(encodingKey, null);
mockDispatcher(request);
mockConfigFromTransaction();
mockBasicTransactionMethods();
when(tx.acceptDistributedTracePayload(anyString())).thenReturn(true);
InboundHeaderState ihs = new InboundHeaderState(tx, request);
when(tx.getInboundHeaderState()).thenReturn(ihs);
when(tx.getTransactionActivity()).thenReturn(ta);
CrossProcessTransactionStateImpl crossProcessTransactionState = CrossProcessTransactionStateImpl.create(tx);
crossProcessTransactionState.writeResponseHeaders();
verify(response, never()).setHeader(anyString(), anyString());
assertNull(tx.getInboundHeaderState().getClientCrossProcessId());
}
use of com.newrelic.api.agent.ExtendedRequest in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method testCrossProcessTracingDisabled.
@Test
public void testCrossProcessTracingDisabled() {
ExtendedRequest request = createRequestFromStandardHeaders(null, null, null);
when(crossProcessConfig.getEncodingKey()).thenReturn(null);
when(crossProcessConfig.getCrossProcessId()).thenReturn(null);
when(crossProcessConfig.isCrossApplicationTracing()).thenReturn(false);
when(distributedTracingConfig.isEnabled()).thenReturn(false);
mockDispatcher(request);
mockConfigFromTransaction();
mockBasicTransactionMethods();
when(tx.acceptDistributedTracePayload(anyString())).thenReturn(true);
InboundHeaderState ihs = new InboundHeaderState(tx, request);
assertNull(ihs.getClientCrossProcessId());
}
use of com.newrelic.api.agent.ExtendedRequest in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method testAppDataHeader.
@Test
public void testAppDataHeader() {
String encodingKey = "test";
String incomingId = "1#23";
String txGuid = "5001D";
String obfuscatedAppData = Obfuscator.obfuscateNameUsingKey("[\"6#66\",\"WebTransaction\\/test\\/test\",1.0,0.2,12345,\"" + txGuid + "\",false]", encodingKey);
ExtendedRequest request = createRequestFromStandardHeaders(Obfuscator.obfuscateNameUsingKey(incomingId, encodingKey), null, "12345");
stats = new TransactionStats();
configureTestMocks(encodingKey, txGuid, obfuscatedAppData, request);
CrossProcessTransactionStateImpl crossProcessTransactionState = CrossProcessTransactionStateImpl.create(tx);
crossProcessTransactionState.writeResponseHeaders();
crossProcessTransactionState.writeResponseHeaders();
verifyMocks(obfuscatedAppData);
assertEquals(1, stats.getUnscopedStats().getSize());
ResponseTimeStats clientAppStats = stats.getUnscopedStats().getOrCreateResponseTimeStats("ClientApplication/" + incomingId + "/all");
assertEquals(1, clientAppStats.getCallCount());
assertEquals(incomingId, tx.getInboundHeaderState().getClientCrossProcessId());
assertNull(tx.getInboundHeaderState().getReferrerGuid());
}
use of com.newrelic.api.agent.ExtendedRequest in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method testNoContentLengthNoQueueTime.
@Test
public void testNoContentLengthNoQueueTime() {
String encodingKey = "test";
String incomingId = "1#23";
String txGuid = "5001D";
String obfuscatedAppData = Obfuscator.obfuscateNameUsingKey("[\"6#66\",\"WebTransaction\\/test\\/test\",0.0,0.2,-1,\"" + txGuid + "\",false]", encodingKey);
ExtendedRequest request = createRequestFromStandardHeaders(Obfuscator.obfuscateNameUsingKey(incomingId, encodingKey), null, null);
doNothing().when(response).setHeader("X-NewRelic-App-Data", obfuscatedAppData);
configureCatEnabled(encodingKey, true);
mockDispatcher(request);
mockConfigFromTransaction();
mockBasicTransactionMethods();
InboundHeaderState ihs = mock(InboundHeaderState.class);
when(ihs.getRequestContentLength()).thenReturn(-1L);
when(ihs.getReferrerGuid()).thenReturn(null);
when(ihs.isTrustedCatRequest()).thenReturn(true);
when(ihs.getClientCrossProcessId()).thenReturn(incomingId);
when(tx.getInboundHeaderState()).thenReturn(ihs);
doNothing().when(tx).freezeTransactionName();
when(tx.getExternalTime()).thenReturn(0L);
PriorityTransactionName txName = PriorityTransactionName.create("WebTransaction/test/test", null, TransactionNamePriority.JSP);
when(tx.getPriorityTransactionName()).thenReturn(txName);
when(tx.getTransactionActivity()).thenReturn(ta);
doNothing().when(ta).markAsResponseSender();
when(ta.getTransactionStats()).thenReturn(stats);
long durationInNanos = TimeUnit.NANOSECONDS.convert(200L, TimeUnit.MILLISECONDS);
when(tx.getRunningDurationInNanos()).thenReturn(durationInNanos);
when(tx.getGuid()).thenReturn(txGuid);
CrossProcessTransactionStateImpl crossProcessTransactionState = CrossProcessTransactionStateImpl.create(tx);
crossProcessTransactionState.writeResponseHeaders();
verifyMocks(obfuscatedAppData);
assertEquals(1, stats.getUnscopedStats().getSize());
ResponseTimeStats clientAppStats = stats.getUnscopedStats().getOrCreateResponseTimeStats("ClientApplication/" + incomingId + "/all");
assertEquals(1, clientAppStats.getCallCount());
assertEquals(incomingId, tx.getInboundHeaderState().getClientCrossProcessId());
}
use of com.newrelic.api.agent.ExtendedRequest in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method testUntrustedAccountId.
@Test
public void testUntrustedAccountId() {
String encodingKey = "test";
// Set up enough mocks that we can create a real InboundHeaderState instance
ExtendedRequest request = createRequestFromStandardHeaders(null, null, null);
configureCatEnabled(encodingKey, false);
mockDispatcher(request);
mockBasicTransactionMethods();
mockConfigFromTransaction();
when(tx.acceptDistributedTracePayload(anyString())).thenReturn(true);
InboundHeaderState ihs = new InboundHeaderState(tx, request);
when(tx.getInboundHeaderState()).thenReturn(ihs);
when(tx.getTransactionActivity()).thenReturn(ta);
CrossProcessTransactionStateImpl crossProcessTransactionState = CrossProcessTransactionStateImpl.create(tx);
crossProcessTransactionState.writeResponseHeaders();
verify(response, never()).setHeader(anyString(), anyString());
assertNull(tx.getInboundHeaderState().getClientCrossProcessId());
}
Aggregations