use of com.newrelic.api.agent.Response in project newrelic-java-agent by newrelic.
the class ApiTest method testSetProductName.
@Test
public void testSetProductName() {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
NewRelic.setProductName("prodName");
Assert.assertEquals("prodName", tx.getUserAttributes().get("product"));
}
use of com.newrelic.api.agent.Response in project newrelic-java-agent by newrelic.
the class ApiTest method testSetTxNameThenSetRequestAndResponse.
@Test
public void testSetTxNameThenSetRequestAndResponse() {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("blah"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
NewRelic.setTransactionName("Test", "Foo");
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
tracer.finish(0, null);
Assert.assertEquals("WebTransaction/Test/Foo", tx.getPriorityTransactionName().getName());
}
use of com.newrelic.api.agent.Response in project newrelic-java-agent by newrelic.
the class ApiTest method testSetAccountName.
@Test
public void testSetAccountName() {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
NewRelic.setAccountName("accountName");
Assert.assertEquals("accountName", tx.getUserAttributes().get("account"));
}
use of com.newrelic.api.agent.Response in project newrelic-java-agent by newrelic.
the class ApiTest method setRequestAndResponseFirstWins.
@Test
public void setRequestAndResponseFirstWins() throws Exception {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("otherRootTracer"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
Request firstRequest = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "firstWins", "", ""));
Response firstResponse = new FirstResponse(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(firstRequest, firstResponse);
Request secondRequest = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "thisIsABug", "", ""));
Response secondResponse = new SecondResponse(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(secondRequest, secondResponse);
tracer.finish(0, null);
Assert.assertEquals(firstRequest.getRequestURI(), tx.getDispatcher().getUri());
Assert.assertEquals(firstResponse.getStatus(), ((WebRequestDispatcher) tx.getDispatcher()).getStatus());
String name = tx.getPriorityTransactionName().getName();
Assert.assertNotEquals("WebTransaction/Uri/thisIsABug", name);
Assert.assertEquals("WebTransaction/Uri/firstWins", name);
}
use of com.newrelic.api.agent.Response in project newrelic-java-agent by newrelic.
the class ApiTest method testSetUserName.
@Test
public void testSetUserName() {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
NewRelic.setUserName("myname");
Assert.assertEquals("myname", tx.getUserAttributes().get("user"));
}
Aggregations