Search in sources :

Example 61 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data 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/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) ExceptionData(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData) ExceptionDetails(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 62 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data 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());
}
Also used : Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) MetricData(com.microsoft.applicationinsights.smoketest.schemav2.MetricData) Test(org.junit.Test)

Example 63 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data 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");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RequestDataMatchers.hasDuration(com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration) Duration(com.microsoft.applicationinsights.smoketest.telemetry.Duration) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) PageViewData(com.microsoft.applicationinsights.smoketest.schemav2.PageViewData) Test(org.junit.Test)

Example 64 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data 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());
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) ExceptionData(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData) RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) MessageData(com.microsoft.applicationinsights.smoketest.schemav2.MessageData) PageViewData(com.microsoft.applicationinsights.smoketest.schemav2.PageViewData) ExceptionData(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData) MetricData(com.microsoft.applicationinsights.smoketest.schemav2.MetricData) EventData(com.microsoft.applicationinsights.smoketest.schemav2.EventData) Data(com.microsoft.applicationinsights.smoketest.schemav2.Data) ExceptionDetails(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Example 65 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ApplicationInsights-Java by microsoft.

the class CoreAndFilterTests method testAutoFailedRequestWithResultCode.

@Test
@TargetUri("/autoFailedRequestWithResultCode")
public void testAutoFailedRequestWithResultCode() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    assertEquals(false, rd.getSuccess());
    assertEquals("404", rd.getResponseCode());
    assertEquals("GET /CoreAndFilter/*", rdEnvelope.getTags().get("ai.operation.name"));
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)65 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)53 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 Data (org.geotoolkit.wps.xml.v200.Data)42 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)26 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)20 IOException (java.io.IOException)16 DataInput (org.geotoolkit.wps.xml.v200.DataInput)15 Format (org.geotoolkit.wps.xml.v200.Format)12 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)10 ComplexData (org.geotoolkit.wps.xml.v200.ComplexData)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 ReferenceProxy (org.geotoolkit.wps.xml.ReferenceProxy)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 DataStoreException (org.apache.sis.storage.DataStoreException)8 LiteralValue (org.geotoolkit.wps.xml.v200.LiteralValue)7 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)6