@Test
  public void testContextInitializers() {
    AppInsightsConfigurationBuilder mockParser = createMockParser(true, true, false);
    ApplicationInsightsXmlConfiguration appConf = mockParser.build(null);
    appConf.setInstrumentationKey(MOCK_IKEY);

    ContextInitializersXmlElement contextInitializersXmlElement =
        new ContextInitializersXmlElement();
    ArrayList<AddTypeXmlElement> contexts = new ArrayList<AddTypeXmlElement>();
    AddTypeXmlElement addXmlElement = new AddTypeXmlElement();
    addXmlElement.setType(
        "com.microsoft.applicationinsights.extensibility.initializer.DeviceInfoContextInitializer");
    contexts.add(addXmlElement);
    contextInitializersXmlElement.setAdds(contexts);
    appConf.setContextInitializers(contextInitializersXmlElement);

    TelemetryConfiguration mockConfiguration = new TelemetryConfiguration();

    initializeWithFactory(mockParser, mockConfiguration);

    assertEquals(mockConfiguration.isTrackingDisabled(), false);
    assertEquals(mockConfiguration.getInstrumentationKey(), MOCK_IKEY);
    assertEquals(mockConfiguration.getContextInitializers().size(), 3);
    assertTrue(mockConfiguration.getTelemetryInitializers().isEmpty());
    assertTrue(mockConfiguration.getChannel() instanceof StdOutChannel);
  }
  @Test
  public void testWithEmptySections() {
    AppInsightsConfigurationBuilder mockParser =
        Mockito.mock(AppInsightsConfigurationBuilder.class);

    ApplicationInsightsXmlConfiguration appConf = new ApplicationInsightsXmlConfiguration();
    appConf.setInstrumentationKey(MOCK_IKEY);
    appConf.setTelemetryInitializers(null);
    appConf.setContextInitializers(null);
    appConf.setModules(null);
    appConf.setSdkLogger(null);
    Mockito.doReturn(appConf).when(mockParser).build(any(InputStream.class));

    TelemetryConfiguration mockConfiguration = new TelemetryConfiguration();

    initializeWithFactory(mockParser, mockConfiguration);

    assertEquals(mockConfiguration.isTrackingDisabled(), false);
    assertEquals(mockConfiguration.getInstrumentationKey(), MOCK_IKEY);
    assertEquals(mockConfiguration.getContextInitializers().size(), 2);
    assertTrue(mockConfiguration.getChannel() instanceof InProcessTelemetryChannel);
  }