public void testAddRemoveType() {
    epService = EPServiceProviderManager.getProvider("TestSchemaXML", getConfig(false));
    epService.initialize();
    updateListener = new SupportUpdateListener();
    ConfigurationOperations configOps = epService.getEPAdministrator().getConfiguration();

    // test remove type with statement used (no force)
    configOps.addEventType("MyXMLEvent", getConfigTestType("p01", false));
    EPStatement stmt =
        epService.getEPAdministrator().createEPL("select p01 from MyXMLEvent", "stmtOne");
    EPAssertionUtil.assertEqualsExactOrder(
        configOps.getEventTypeNameUsedBy("MyXMLEvent").toArray(), new String[] {"stmtOne"});

    try {
      configOps.removeEventType("MyXMLEvent", false);
    } catch (ConfigurationException ex) {
      assertTrue(ex.getMessage().contains("MyXMLEvent"));
    }

    // destroy statement and type
    stmt.destroy();
    assertTrue(configOps.getEventTypeNameUsedBy("MyXMLEvent").isEmpty());
    assertTrue(configOps.isEventTypeExists("MyXMLEvent"));
    assertTrue(configOps.removeEventType("MyXMLEvent", false));
    assertFalse(configOps.removeEventType("MyXMLEvent", false)); // try double-remove
    assertFalse(configOps.isEventTypeExists("MyXMLEvent"));
    try {
      epService.getEPAdministrator().createEPL("select p01 from MyXMLEvent");
      fail();
    } catch (EPException ex) {
      // expected
    }

    // add back the type
    configOps.addEventType("MyXMLEvent", getConfigTestType("p20", false));
    assertTrue(configOps.isEventTypeExists("MyXMLEvent"));
    assertTrue(configOps.getEventTypeNameUsedBy("MyXMLEvent").isEmpty());

    // compile
    epService.getEPAdministrator().createEPL("select p20 from MyXMLEvent", "stmtTwo");
    EPAssertionUtil.assertEqualsExactOrder(
        configOps.getEventTypeNameUsedBy("MyXMLEvent").toArray(), new String[] {"stmtTwo"});
    try {
      epService.getEPAdministrator().createEPL("select p01 from MyXMLEvent");
      fail();
    } catch (EPException ex) {
      // expected
    }

    // remove with force
    try {
      configOps.removeEventType("MyXMLEvent", false);
    } catch (ConfigurationException ex) {
      assertTrue(ex.getMessage().contains("MyXMLEvent"));
    }
    assertTrue(configOps.removeEventType("MyXMLEvent", true));
    assertFalse(configOps.isEventTypeExists("MyXMLEvent"));
    assertTrue(configOps.getEventTypeNameUsedBy("MyXMLEvent").isEmpty());

    // add back the type
    configOps.addEventType("MyXMLEvent", getConfigTestType("p03", false));
    assertTrue(configOps.isEventTypeExists("MyXMLEvent"));

    // compile
    epService.getEPAdministrator().createEPL("select p03 from MyXMLEvent");
    try {
      epService.getEPAdministrator().createEPL("select p20 from MyXMLEvent");
      fail();
    } catch (EPException ex) {
      // expected
    }
  }