use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationEight.
@Test
@TargetUri("/customInstrumentationEight")
public void customInstrumentationEight() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 2);
Envelope rdEnvelope = rdList.get(0);
Envelope rddEnvelope1 = rddList.get(0);
Envelope rddEnvelope2 = rddList.get(1);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
RemoteDependencyData rdd2 = (RemoteDependencyData) ((Data<?>) rddEnvelope2.getData()).getBaseData();
assertTrue(rd.getSuccess());
assertEquals(rdd1.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.eight");
assertEquals(rdd1.getType(), "OTHER");
assertEquals(rdd1.getSuccess(), true);
assertParentChild(rd, rdEnvelope, rddEnvelope1, "GET /CustomInstrumentation/*");
assertEquals(rdd2.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.eight");
assertEquals(rdd2.getType(), "OTHER");
assertEquals(rdd2.getSuccess(), true);
assertParentChild(rd, rdEnvelope, rddEnvelope2, "GET /CustomInstrumentation/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationThree.
@Test
@TargetUri("/customInstrumentationThree")
public void customInstrumentationThree() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
List<Envelope> edList = mockedIngestion.waitForItemsInRequest("ExceptionData", 1);
Envelope rdEnvelope = rdList.get(0);
Envelope rddEnvelope = rddList.get(0);
Envelope edEnvelope = edList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
ExceptionData ed = (ExceptionData) ((Data<?>) edEnvelope.getData()).getBaseData();
assertTrue(rd.getSuccess());
assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.three");
assertEquals(rdd.getType(), "OTHER");
assertEquals(rdd.getSuccess(), false);
List<ExceptionDetails> exceptions = ed.getExceptions();
assertEquals(exceptions.size(), 1);
assertEquals(exceptions.get(0).getMessage(), "Three");
assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
assertParentChild(rd, rdEnvelope, edEnvelope, "GET /CustomInstrumentation/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class HeartBeatTest method testHeartBeat.
@Test
@TargetUri(value = "/index.jsp")
public void testHeartBeat() throws Exception {
List<Envelope> metrics = mockedIngestion.waitForItems(getMetricPredicate("HeartbeatState"), 2, 70, TimeUnit.SECONDS);
assertEquals(2, metrics.size());
MetricData data = (MetricData) ((Data<?>) metrics.get(0).getData()).getBaseData();
assertNotNull(data.getProperties().get("jreVersion"));
assertNotNull(data.getProperties().get("sdkVersion"));
assertNotNull(data.getProperties().get("osVersion"));
assertNotNull(data.getProperties().get("processSessionId"));
assertNotNull(data.getProperties().get("osType"));
assertEquals(5, data.getProperties().size());
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method testTrackPageViewJsp.
@Test
@TargetUri("/doPageView.jsp")
public void testTrackPageViewJsp() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
String operationId = rdEnvelope.getTags().get("ai.operation.id");
List<Envelope> pvdList = mockedIngestion.waitForItemsInOperation("PageViewData", 1, operationId);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Envelope pvdEnvelope = pvdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
PageViewData pv = (PageViewData) ((Data<?>) pvdEnvelope.getData()).getBaseData();
assertEquals("doPageView", pv.getName());
assertEquals(new Duration(0), pv.getDuration());
assertParentChild(rd, rdEnvelope, pvdEnvelope, "GET /CoreAndFilter/doPageView.jsp");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method testAutoExceptionWithFailedRequest.
@Test
@TargetUri("/autoExceptionWithFailedRequest")
public void testAutoExceptionWithFailedRequest() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
String operationId = rdEnvelope.getTags().get("ai.operation.id");
List<Envelope> edList = mockedIngestion.waitForItems(new Predicate<Envelope>() {
@Override
public boolean test(Envelope input) {
if (!"ExceptionData".equals(input.getData().getBaseType())) {
return false;
}
if (!operationId.equals(input.getTags().get("ai.operation.id"))) {
return false;
}
// lastly, filter out ExceptionData captured from tomcat logger
ExceptionData data = (ExceptionData) ((Data<?>) input.getData()).getBaseData();
return !data.getProperties().containsKey("LoggerName");
}
}, 1, 10, TimeUnit.SECONDS);
Envelope edEnvelope = edList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
ExceptionData ed = (ExceptionData) ((Data<?>) edEnvelope.getData()).getBaseData();
assertFalse(rd.getSuccess());
ExceptionDetails details = getExceptionDetails(ed);
assertEquals("This is a auto thrown exception !", details.getMessage());
}
Aggregations