public void testObjectArrayInheritanceRuntime() { Configuration configuration = SupportConfigFactory.getConfiguration(); EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration); epService.initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.startTest(epService, this.getClass(), getName()); } ConfigurationOperations configOps = epService.getEPAdministrator().getConfiguration(); configOps.addEventType("RootEvent", new String[] {"base"}, new Object[] {String.class}); configOps.addEventType( "Sub1Event", new String[] {"sub1"}, new Object[] {String.class}, new ConfigurationEventTypeObjectArray(Collections.singleton("RootEvent"))); configOps.addEventType( "Sub2Event", new String[] {"sub2"}, new Object[] {String.class}, new ConfigurationEventTypeObjectArray(Collections.singleton("RootEvent"))); configOps.addEventType( "SubAEvent", new String[] {"suba"}, new Object[] {String.class}, new ConfigurationEventTypeObjectArray(Collections.singleton("Sub1Event"))); configOps.addEventType( "SubBEvent", new String[] {"subb"}, new Object[] {String.class}, new ConfigurationEventTypeObjectArray(Collections.singleton("SubAEvent"))); runObjectArrInheritanceAssertion(epService); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.endTest(); } }
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 } }