/// <summary>Constructor - takes the services context as argument. </summary> /// <param name="adminContext">administrative context</param> public EPAdministratorImpl(EPAdministratorContext adminContext) { _services = adminContext.Services; _configurationOperations = adminContext.ConfigurationOperations; _defaultStreamSelector = adminContext.DefaultStreamSelector; ConfigurationEngineDefaults.AlternativeContext alternativeContext = adminContext.Services.ConfigSnapshot.EngineDefaults.AlternativeContextConfig; StatementIdGenerator statementIdGenerator = null; if (alternativeContext != null && alternativeContext.StatementIdGeneratorFactory != null) { var statementIdGeneratorFactory = TypeHelper.Instantiate <StatementIdGeneratorFactory>(alternativeContext.StatementIdGeneratorFactory); statementIdGenerator = statementIdGeneratorFactory.Invoke(new StatementIdGeneratorFactoryContext(_services.EngineURI)); } _deploymentAdminService = new EPDeploymentAdminImpl( this, adminContext.Services.DeploymentStateService, adminContext.Services.StatementEventTypeRefService, adminContext.Services.EventAdapterService, adminContext.Services.StatementIsolationService, statementIdGenerator, adminContext.Services.FilterService, _services.ConfigSnapshot.EngineDefaults.ExpressionConfig.TimeZone); }
public override void Run(EPServiceProvider epService) { PlugInEventRepresentationContext initContext = SupportEventRepresentation.InitContext; Assert.AreEqual(new Uri("type://test/support"), initContext.EventRepresentationRootURI); Assert.AreEqual("abc", initContext.RepresentationInitializer); Assert.IsNotNull(initContext.EventAdapterService); ConfigurationOperations runtimeConfig = epService.EPAdministrator.Configuration; runtimeConfig.AddPlugInEventType("TestTypeOne", new Uri[] { new Uri("type://test/support?a=b&c=d") }, "t1"); PlugInEventTypeHandlerContext plugincontext = SupportEventRepresentation.AcceptTypeContext; Assert.AreEqual(new Uri("type://test/support?a=b&c=d"), plugincontext.EventTypeResolutionURI); Assert.AreEqual("t1", plugincontext.TypeInitializer); Assert.AreEqual("TestTypeOne", plugincontext.EventTypeName); plugincontext = SupportEventRepresentation.EventTypeContext; Assert.AreEqual(new Uri("type://test/support?a=b&c=d"), plugincontext.EventTypeResolutionURI); Assert.AreEqual("t1", plugincontext.TypeInitializer); Assert.AreEqual("TestTypeOne", plugincontext.EventTypeName); epService.EPRuntime.GetEventSender(new Uri[] { new Uri("type://test/support?a=b") }); PlugInEventBeanReflectorContext contextBean = SupportEventRepresentation.EventBeanContext; Assert.AreEqual("type://test/support?a=b", contextBean.ResolutionURI.ToString()); }
public void TestRuntimeConfigStaticTypeResolution() { Configuration configuration = GetConfiguration(); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } ConfigurationOperations runtimeConfig = _epService.EPAdministrator.Configuration; 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); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestClassLoader() { EPServiceProvider epService = GetDefaultEngine(); ConfigurationOperations ops = epService.EPAdministrator.Configuration; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, this.GetType(), this.GetType().FullName); } MyClassLoaderProvider.SetInvoked(false); MyFastClassClassLoaderProvider.Clazz = null; ops.TransientConfiguration.Put(ClassLoaderProviderConstants.NAME, new MyClassLoaderProvider()); ops.TransientConfiguration.Put(FastClassClassLoaderProviderConstants.NAME, new MyFastClassClassLoaderProvider()); ops.AddImport(typeof(MyAnnotationSimpleAttribute)); ops.AddEventType(typeof(SupportBean)); string epl = "@MyAnnotationSimple select System.Environment.Exit(-1) from SupportBean"; epService.EPAdministrator.CreateEPL(epl); Assert.IsTrue(MyClassLoaderProvider.IsInvoked); //Assert.AreEqual(typeof(System.Console), MyFastClassClassLoaderProvider.Clazz); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void SetUp() { _testListener = new SupportUpdateListener(); _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration()); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _configOps = _epService.EPAdministrator.Configuration; }
/// <summary> /// Ctor. /// </summary> /// <param name="runtimeSPI">The runtime SPI.</param> /// <param name="services">engine services</param> /// <param name="configurationOperations">configuration snapshot</param> /// <param name="defaultStreamSelector">default stream selection</param> public EPAdministratorContext(EPRuntimeSPI runtimeSPI, EPServicesContext services, ConfigurationOperations configurationOperations, SelectClauseStreamSelectorEnum defaultStreamSelector ) { RuntimeSPI = runtimeSPI; ConfigurationOperations = configurationOperations; DefaultStreamSelector = defaultStreamSelector; Services = services; }
public DeviceApiClient(Guid deviceId, Guid deviceKey, string baseUri) { var client = new ApiClient(new Uri(baseUri)); var tokenFactory = new TokenFactory(deviceId, deviceKey); ApplicationDownloadInfo = new ApplicationDownloadInfoOperations(client, tokenFactory); ApplicationLogs = new ApplicationLogOperations(client, tokenFactory); Configuration = new ConfigurationOperations(client, tokenFactory); Heartbeat = new HeartbeatOperations(client, tokenFactory); AgentDownloadInfo = new AgentDownloadInfoOperations(client, tokenFactory); }
public override void Run(EPServiceProvider epService) { ConfigurationOperations configOps = epService.EPAdministrator.Configuration; configOps.AddEventType("RootEvent", new string[] { "base" }, new object[] { typeof(string) }); configOps.AddEventType("Sub1Event", new string[] { "sub1" }, new object[] { typeof(string) }, new ConfigurationEventTypeObjectArray(Collections.SingletonSet("RootEvent"))); configOps.AddEventType("Sub2Event", new string[] { "sub2" }, new object[] { typeof(string) }, new ConfigurationEventTypeObjectArray(Collections.SingletonSet("RootEvent"))); configOps.AddEventType("SubAEvent", new string[] { "suba" }, new object[] { typeof(string) }, new ConfigurationEventTypeObjectArray(Collections.SingletonSet("Sub1Event"))); configOps.AddEventType("SubBEvent", new string[] { "subb" }, new object[] { typeof(string) }, new ConfigurationEventTypeObjectArray(Collections.SingletonSet("SubAEvent"))); ExecEventObjectArrayInheritanceConfigInit.RunObjectArrInheritanceAssertion(epService); }
public static void AddPlugInSingleRowFunction( this ConfigurationOperations configuration, string functionName, Type clazz, string methodName, ValueCacheEnum valueCache, FilterOptimizableEnum filterOptimizable, bool rethrowExceptions) { configuration.AddPlugInSingleRowFunction( functionName, clazz.AssemblyQualifiedName, methodName, valueCache, filterOptimizable, rethrowExceptions); }
public static void AddPlugInSingleRowFunction( this ConfigurationOperations configuration, string functionName, Type clazz, string methodName, FilterOptimizableEnum filterOptimizable) { configuration.AddPlugInSingleRowFunction( functionName, clazz.AssemblyQualifiedName, methodName, filterOptimizable); }
public override void Run(EPServiceProvider epService) { if (SupportConfigFactory.SkipTest(typeof(ExecEventPlugInConfigRuntimeTypeResolution))) { return; } ConfigurationOperations ops = epService.EPAdministrator.Configuration; ops.AddPlugInEventType("TestTypeOne", new Uri[] { new Uri("type://properties/test1/testtype") }, "t1"); ops.AddPlugInEventType("TestTypeTwo", new Uri[] { new Uri("type://properties/test2") }, "t2"); ops.AddPlugInEventType("TestTypeThree", new Uri[] { new Uri("type://properties/test3") }, "t3"); ops.AddPlugInEventType("TestTypeFour", new Uri[] { new Uri("type://properties/test2/x"), new Uri("type://properties/test3") }, "t4"); ExecEventPlugInConfigStaticTypeResolution.RunAssertionCaseStatic(epService); }
/// <summary>Constructor - takes the services context as argument. </summary> /// <param name="adminContext">administrative context</param> public EPAdministratorImpl(EPAdministratorContext adminContext) { _services = adminContext.Services; _configurationOperations = adminContext.ConfigurationOperations; _defaultStreamSelector = adminContext.DefaultStreamSelector; _deploymentAdminService = new EPDeploymentAdminImpl( this, adminContext.Services.DeploymentStateService, adminContext.Services.StatementEventTypeRefService, adminContext.Services.EventAdapterService, adminContext.Services.StatementIsolationService, adminContext.Services.FilterService, _services.ConfigSnapshot.EngineDefaults.ExpressionConfig.TimeZone, _services.ConfigSnapshot.EngineDefaults.ExceptionHandlingConfig.UndeployRethrowPolicy); }
private void RunAssertionClassLoader(EPServiceProvider epService) { ConfigurationOperations ops = epService.EPAdministrator.Configuration; MyClassLoaderProvider.IsInvoked = false; MyFastClassClassLoaderProvider.Clazz = null; ops.TransientConfiguration.Put(ClassLoaderProviderConstants.NAME, new MyClassLoaderProvider()); ops.TransientConfiguration.Put(FastClassClassLoaderProviderConstants.NAME, new MyFastClassClassLoaderProvider()); ops.AddImport(typeof(MyAnnotationSimpleAttribute)); ops.AddEventType <SupportBean>(); string epl = "@MyAnnotationSimple select System.Environment.Exit(-1) from SupportBean"; epService.EPAdministrator.CreateEPL(epl); Assert.IsTrue(MyClassLoaderProvider.IsInvoked); //Assert.AreEqual(typeof(System), MyFastClassClassLoaderProvider.Clazz); }
public void TestTypeReference() { ConfigurationOperations configOps = _epService.EPAdministrator.Configuration; _epService.EPAdministrator.CreateEPL("@Name('ces') create schema EventSchema(in1 string, in2 int)"); _epService.EPAdministrator.CreateEPL("@Name('cnws') create schema WindowSchema(in1 string, in2 int)"); EPAssertionUtil.AssertEqualsAnyOrder(new string[]{"ces"}, configOps.GetEventTypeNameUsedBy("EventSchema").ToArray()); EPAssertionUtil.AssertEqualsAnyOrder(new string[]{"cnws"}, configOps.GetEventTypeNameUsedBy("WindowSchema").ToArray()); _epService.EPAdministrator.CreateEPL("@Name('cnw') create window MyWindow.win:keepall() as WindowSchema"); EPAssertionUtil.AssertEqualsAnyOrder("cnws,cnw".Split(','), configOps.GetEventTypeNameUsedBy("WindowSchema").ToArray()); EPAssertionUtil.AssertEqualsAnyOrder(new string[]{"cnw"}, configOps.GetEventTypeNameUsedBy("MyWindow").ToArray()); _epService.EPAdministrator.CreateEPL("@Name('om') on EventSchema merge into MyWindow " + "when not matched then insert select in1, in2"); EPAssertionUtil.AssertEqualsAnyOrder("ces,om".Split(','), configOps.GetEventTypeNameUsedBy("EventSchema").ToArray()); EPAssertionUtil.AssertEqualsAnyOrder("cnws,cnw".Split(','), configOps.GetEventTypeNameUsedBy("WindowSchema").ToArray()); }
public void TestContextContents() { Configuration configuration = GetConfiguration(); configuration.AddPlugInEventRepresentation(new Uri("type://test/support"), typeof(SupportEventRepresentation).FullName, "abc"); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } PlugInEventRepresentationContext initContext = SupportEventRepresentation.InitContext; Assert.AreEqual(new Uri("type://test/support"), initContext.EventRepresentationRootURI); Assert.AreEqual("abc", initContext.RepresentationInitializer); Assert.NotNull(initContext.EventAdapterService); ConfigurationOperations runtimeConfig = _epService.EPAdministrator.Configuration; runtimeConfig.AddPlugInEventType("TestTypeOne", new Uri[] { new Uri("type://test/support?a=b&c=d") }, "t1"); PlugInEventTypeHandlerContext context = SupportEventRepresentation.AcceptTypeContext; Assert.AreEqual(new Uri("type://test/support?a=b&c=d"), context.EventTypeResolutionURI); Assert.AreEqual("t1", context.TypeInitializer); Assert.AreEqual("TestTypeOne", context.EventTypeName); context = SupportEventRepresentation.EventTypeContext; Assert.AreEqual(new Uri("type://test/support?a=b&c=d"), context.EventTypeResolutionURI); Assert.AreEqual("t1", context.TypeInitializer); Assert.AreEqual("TestTypeOne", context.EventTypeName); _epService.EPRuntime.GetEventSender(new Uri[] { new Uri("type://test/support?a=b") }); PlugInEventBeanReflectorContext contextBean = SupportEventRepresentation.EventBeanContext; Assert.AreEqual("type://test/support?a=b", contextBean.ResolutionURI.ToString()); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestAddRemoveType() { // test remove type with statement used (no force) ConfigurationOperations configOps = _epService.EPAdministrator.Configuration; EPStatement stmt = _epService.EPAdministrator.CreateEPL("select MyInt from MyMapEvent", "stmtOne"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("MyMapEvent").ToArray(), new String[] { "stmtOne" }); Assert.AreEqual(1, _epService.EPAdministrator.Configuration.EventTypes.Count); Assert.AreEqual("MyMapEvent", _epService.EPAdministrator.Configuration.GetEventType("MyMapEvent").Name); try { configOps.RemoveEventType("MyMapEvent", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("MyMapEvent")); } // destroy statement and type stmt.Dispose(); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyMapEvent").IsEmpty()); Assert.IsTrue(configOps.IsEventTypeExists("MyMapEvent")); Assert.IsTrue(configOps.RemoveEventType("MyMapEvent", false)); Assert.IsFalse(configOps.RemoveEventType("MyMapEvent", false)); // try double-remove Assert.IsFalse(configOps.IsEventTypeExists("MyMapEvent")); Assert.AreEqual(0, _epService.EPAdministrator.Configuration.EventTypes.Count); Assert.AreEqual(null, _epService.EPAdministrator.Configuration.GetEventType("MyMapEvent")); try { _epService.EPAdministrator.CreateEPL("select MyInt from MyMapEvent"); Assert.Fail(); } catch (EPException ex) { // expected } // add back the type var properties = new Properties(); properties["p01"] = "string"; configOps.AddEventType("MyMapEvent", properties); Assert.IsTrue(configOps.IsEventTypeExists("MyMapEvent")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyMapEvent").IsEmpty()); Assert.AreEqual(1, _epService.EPAdministrator.Configuration.EventTypes.Count); Assert.AreEqual("MyMapEvent", _epService.EPAdministrator.Configuration.GetEventType("MyMapEvent").Name); // compile _epService.EPAdministrator.CreateEPL("select p01 from MyMapEvent", "stmtTwo"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("MyMapEvent").ToArray(), new String[] { "stmtTwo" }); try { _epService.EPAdministrator.CreateEPL("select MyInt from MyMapEvent"); Assert.Fail(); } catch (EPException ex) { // expected } // remove with force try { configOps.RemoveEventType("MyMapEvent", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("MyMapEvent")); } Assert.IsTrue(configOps.RemoveEventType("MyMapEvent", true)); Assert.IsFalse(configOps.IsEventTypeExists("MyMapEvent")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyMapEvent").IsEmpty()); // add back the type properties = new Properties(); properties["newprop"] = "string"; configOps.AddEventType("MyMapEvent", properties); Assert.IsTrue(configOps.IsEventTypeExists("MyMapEvent")); // compile _epService.EPAdministrator.CreateEPL("select newprop from MyMapEvent"); try { _epService.EPAdministrator.CreateEPL("select p01 from MyMapEvent"); Assert.Fail(); } catch (EPException ex) { // expected } }
/// <summary>Destroys an engine instance. </summary> public void Dispose() { _services = null; _configurationOperations = null; }
public override void Run(EPServiceProvider epService) { ConfigurationOperations configOps = epService.EPAdministrator.Configuration; // test remove type with statement used (no force) configOps.AddEventType("MyXMLEvent", GetConfigTestType("p01", false)); EPStatement stmt = epService.EPAdministrator.CreateEPL("select p01 from MyXMLEvent", "stmtOne"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("MyXMLEvent").ToArray(), new string[] { "stmtOne" }); try { configOps.RemoveEventType("MyXMLEvent", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("MyXMLEvent")); } // destroy statement and type stmt.Dispose(); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyXMLEvent").IsEmpty()); Assert.IsTrue(configOps.IsEventTypeExists("MyXMLEvent")); Assert.IsTrue(configOps.RemoveEventType("MyXMLEvent", false)); Assert.IsFalse(configOps.RemoveEventType("MyXMLEvent", false)); // try double-remove Assert.IsFalse(configOps.IsEventTypeExists("MyXMLEvent")); try { epService.EPAdministrator.CreateEPL("select p01 from MyXMLEvent"); Assert.Fail(); } catch (EPException) { // expected } // add back the type configOps.AddEventType("MyXMLEvent", GetConfigTestType("p20", false)); Assert.IsTrue(configOps.IsEventTypeExists("MyXMLEvent")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyXMLEvent").IsEmpty()); // compile epService.EPAdministrator.CreateEPL("select p20 from MyXMLEvent", "stmtTwo"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("MyXMLEvent").ToArray(), new string[] { "stmtTwo" }); try { epService.EPAdministrator.CreateEPL("select p01 from MyXMLEvent"); Assert.Fail(); } catch (EPException) { // expected } // remove with force try { configOps.RemoveEventType("MyXMLEvent", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("MyXMLEvent")); } Assert.IsTrue(configOps.RemoveEventType("MyXMLEvent", true)); Assert.IsFalse(configOps.IsEventTypeExists("MyXMLEvent")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyXMLEvent").IsEmpty()); // add back the type configOps.AddEventType("MyXMLEvent", GetConfigTestType("p03", false)); Assert.IsTrue(configOps.IsEventTypeExists("MyXMLEvent")); // compile epService.EPAdministrator.CreateEPL("select p03 from MyXMLEvent"); try { epService.EPAdministrator.CreateEPL("select p20 from MyXMLEvent"); Assert.Fail(); } catch (EPException) { // expected } }
public void TestAddRemoveType() { ConfigurationOperations configOps = _epService.EPAdministrator.Configuration; // test remove type with statement used (no force) EPStatement stmt = _epService.EPAdministrator.CreateEPL("create window MyWindowEventType.win:keepall() (a int, b string)", "stmtOne"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("MyWindowEventType").ToArray(), new string[] { "stmtOne" }); try { configOps.RemoveEventType("MyWindowEventType", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("MyWindowEventType")); } // destroy statement and type stmt.Dispose(); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyWindowEventType").IsEmpty()); Assert.IsTrue(configOps.IsEventTypeExists("MyWindowEventType")); Assert.IsTrue(configOps.RemoveEventType("MyWindowEventType", false)); Assert.IsFalse(configOps.RemoveEventType("MyWindowEventType", false)); // try double-remove Assert.IsFalse(configOps.IsEventTypeExists("MyWindowEventType")); try { _epService.EPAdministrator.CreateEPL("select a from MyWindowEventType"); Assert.Fail(); } catch (EPException ex) { // expected } // add back the type stmt = _epService.EPAdministrator.CreateEPL("create window MyWindowEventType.win:keepall() (c int, d string)", "stmtOne"); Assert.IsTrue(configOps.IsEventTypeExists("MyWindowEventType")); Assert.IsFalse(configOps.GetEventTypeNameUsedBy("MyWindowEventType").IsEmpty()); // compile _epService.EPAdministrator.CreateEPL("select d from MyWindowEventType", "stmtTwo"); object[] usedBy = configOps.GetEventTypeNameUsedBy("MyWindowEventType").ToArray(); EPAssertionUtil.AssertEqualsAnyOrder(new string[] { "stmtOne", "stmtTwo" }, usedBy); try { _epService.EPAdministrator.CreateEPL("select a from MyWindowEventType"); Assert.Fail(); } catch (EPException ex) { // expected } // remove with force try { configOps.RemoveEventType("MyWindowEventType", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("MyWindowEventType")); } Assert.IsTrue(configOps.RemoveEventType("MyWindowEventType", true)); Assert.IsFalse(configOps.IsEventTypeExists("MyWindowEventType")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyWindowEventType").IsEmpty()); // add back the type stmt.Dispose(); stmt = _epService.EPAdministrator.CreateEPL("create window MyWindowEventType.win:keepall() (f int)", "stmtOne"); Assert.IsTrue(configOps.IsEventTypeExists("MyWindowEventType")); // compile _epService.EPAdministrator.CreateEPL("select f from MyWindowEventType"); try { _epService.EPAdministrator.CreateEPL("select c from MyWindowEventType"); Assert.Fail(); } catch (EPException ex) { // expected } }
private void RunAssertionAddRemoveType(EPServiceProvider epService) { epService.EPAdministrator.DestroyAllStatements(); // test remove type with statement used (no force) ConfigurationOperations configOps = epService.EPAdministrator.Configuration; EPStatement stmt = epService.EPAdministrator.CreateEPL("select myInt from myMapEvent", "stmtOne"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("myMapEvent").ToArray(), new[] { "stmtOne" }); int numTypes = epService.EPAdministrator.Configuration.EventTypes.Count; Assert.AreEqual("myMapEvent", epService.EPAdministrator.Configuration.GetEventType("myMapEvent").Name); try { configOps.RemoveEventType("myMapEvent", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("myMapEvent")); } // destroy statement and type stmt.Dispose(); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("myMapEvent").IsEmpty()); Assert.IsTrue(configOps.IsEventTypeExists("myMapEvent")); Assert.IsTrue(configOps.RemoveEventType("myMapEvent", false)); Assert.IsFalse(configOps.RemoveEventType("myMapEvent", false)); // try double-remove Assert.IsFalse(configOps.IsEventTypeExists("myMapEvent")); Assert.AreEqual(numTypes - 1, epService.EPAdministrator.Configuration.EventTypes.Count); Assert.AreEqual(null, epService.EPAdministrator.Configuration.GetEventType("myMapEvent")); try { epService.EPAdministrator.CreateEPL("select myInt from myMapEvent"); Assert.Fail(); } catch (EPException) { // expected } // add back the type var properties = new Properties(); properties.Put("p01", "string"); configOps.AddEventType("myMapEvent", properties); Assert.IsTrue(configOps.IsEventTypeExists("myMapEvent")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("myMapEvent").IsEmpty()); Assert.AreEqual(numTypes, epService.EPAdministrator.Configuration.EventTypes.Count); Assert.AreEqual("myMapEvent", epService.EPAdministrator.Configuration.GetEventType("myMapEvent").Name); // compile epService.EPAdministrator.CreateEPL("select p01 from myMapEvent", "stmtTwo"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("myMapEvent").ToArray(), new[] { "stmtTwo" }); try { epService.EPAdministrator.CreateEPL("select myInt from myMapEvent"); Assert.Fail(); } catch (EPException) { // expected } // remove with force try { configOps.RemoveEventType("myMapEvent", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("myMapEvent")); } Assert.IsTrue(configOps.RemoveEventType("myMapEvent", true)); Assert.IsFalse(configOps.IsEventTypeExists("myMapEvent")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("myMapEvent").IsEmpty()); // add back the type properties = new Properties(); properties.Put("newprop", "string"); configOps.AddEventType("myMapEvent", properties); Assert.IsTrue(configOps.IsEventTypeExists("myMapEvent")); // compile epService.EPAdministrator.CreateEPL("select newprop from myMapEvent"); try { epService.EPAdministrator.CreateEPL("select p01 from myMapEvent"); Assert.Fail(); } catch (EPException) { // expected } epService.EPAdministrator.DestroyAllStatements(); }
public int Execute() { ConfigurationOperations configurationOperations = new ConfigurationOperations(); return(configurationOperations.SetDatabaseFilePath(databaseFilePath)); }
public void TestAddRemoveType() { _epService = EPServiceProviderManager.GetProvider("TestSchemaXML", GetConfig(false)); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); ConfigurationOperations configOps = _epService.EPAdministrator.Configuration; // test remove type with statement used (no force) configOps.AddEventType("MyXMLEvent", GetConfigTestType("p01", false)); EPStatement stmt = _epService.EPAdministrator.CreateEPL("select p01 from MyXMLEvent", "stmtOne"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("MyXMLEvent").ToArray(), new String[] { "stmtOne" }); try { configOps.RemoveEventType("MyXMLEvent", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("MyXMLEvent")); } // destroy statement and type stmt.Dispose(); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyXMLEvent").IsEmpty()); Assert.IsTrue(configOps.IsEventTypeExists("MyXMLEvent")); Assert.IsTrue(configOps.RemoveEventType("MyXMLEvent", false)); Assert.IsFalse(configOps.RemoveEventType("MyXMLEvent", false)); // try double-remove Assert.IsFalse(configOps.IsEventTypeExists("MyXMLEvent")); try { _epService.EPAdministrator.CreateEPL("select p01 from MyXMLEvent"); Assert.Fail(); } catch (EPException ex) { // expected } // add back the type configOps.AddEventType("MyXMLEvent", GetConfigTestType("p20", false)); Assert.IsTrue(configOps.IsEventTypeExists("MyXMLEvent")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyXMLEvent").IsEmpty()); // compile _epService.EPAdministrator.CreateEPL("select p20 from MyXMLEvent", "stmtTwo"); EPAssertionUtil.AssertEqualsExactOrder(configOps.GetEventTypeNameUsedBy("MyXMLEvent").ToArray(), new String[] { "stmtTwo" }); try { _epService.EPAdministrator.CreateEPL("select p01 from MyXMLEvent"); Assert.Fail(); } catch (EPException ex) { // expected } // remove with force try { configOps.RemoveEventType("MyXMLEvent", false); } catch (ConfigurationException ex) { Assert.IsTrue(ex.Message.Contains("MyXMLEvent")); } Assert.IsTrue(configOps.RemoveEventType("MyXMLEvent", true)); Assert.IsFalse(configOps.IsEventTypeExists("MyXMLEvent")); Assert.IsTrue(configOps.GetEventTypeNameUsedBy("MyXMLEvent").IsEmpty()); // add back the type configOps.AddEventType("MyXMLEvent", GetConfigTestType("p03", false)); Assert.IsTrue(configOps.IsEventTypeExists("MyXMLEvent")); // compile _epService.EPAdministrator.CreateEPL("select p03 from MyXMLEvent"); try { _epService.EPAdministrator.CreateEPL("select p20 from MyXMLEvent"); Assert.Fail(); } catch (EPException ex) { // expected } }