public void testContextContents() throws Exception { Configuration configuration = getConfiguration(); configuration.addPlugInEventRepresentation( new URI("type://test/support"), SupportEventRepresentation.class.getName(), "abc"); epService = EPServiceProviderManager.getDefaultProvider(configuration); epService.initialize(); PlugInEventRepresentationContext initContext = SupportEventRepresentation.getInitContext(); assertEquals(new URI("type://test/support"), initContext.getEventRepresentationRootURI()); assertEquals("abc", initContext.getRepresentationInitializer()); assertNotNull(initContext.getEventAdapterService()); ConfigurationOperations runtimeConfig = epService.getEPAdministrator().getConfiguration(); runtimeConfig.addPlugInEventType( "TestTypeOne", new URI[] {new URI("type://test/support?a=b&c=d")}, "t1"); PlugInEventTypeHandlerContext context = SupportEventRepresentation.getAcceptTypeContext(); assertEquals(new URI("type://test/support?a=b&c=d"), context.getEventTypeResolutionURI()); assertEquals("t1", context.getTypeInitializer()); assertEquals("TestTypeOne", context.getEventTypeName()); context = SupportEventRepresentation.getEventTypeContext(); assertEquals(new URI("type://test/support?a=b&c=d"), context.getEventTypeResolutionURI()); assertEquals("t1", context.getTypeInitializer()); assertEquals("TestTypeOne", context.getEventTypeName()); epService.getEPRuntime().getEventSender(new URI[] {new URI("type://test/support?a=b")}); PlugInEventBeanReflectorContext contextBean = SupportEventRepresentation.getEventBeanContext(); assertEquals("type://test/support?a=b", contextBean.getResolutionURI().toString()); }
public void testRuntimeConfigStaticTypeResolution() throws Exception { Configuration configuration = getConfiguration(); epService = EPServiceProviderManager.getDefaultProvider(configuration); epService.initialize(); ConfigurationOperations runtimeConfig = epService.getEPAdministrator().getConfiguration(); runtimeConfig.addPlugInEventType( "TestTypeOne", new URI[] {new URI("type://properties/test1/testtype")}, "t1"); runtimeConfig.addPlugInEventType( "TestTypeTwo", new URI[] {new URI("type://properties/test2")}, "t2"); runtimeConfig.addPlugInEventType( "TestTypeThree", new URI[] {new URI("type://properties/test3")}, "t3"); runtimeConfig.addPlugInEventType( "TestTypeFour", new URI[] {new URI("type://properties/test2/x"), new URI("type://properties/test3")}, "t4"); runAssertionCaseStatic(epService); }
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 } }