public void Run(RegressionEnvironment env) { // Test substitution parameter and inheritance in key matching var path = new RegressionPath(); var types = "create schema MyEventOne as " + typeof(MyEventOne).MaskTypeName() + ";\n" + "create schema MyEventTwo as " + typeof(MyEventTwo).MaskTypeName() + ";\n"; env.CompileDeployWBusPublicType(types, path); var epl = "select * from MyEventOne(Key = ?::IKey)"; var compiled = env.Compile(epl, path); var lKey = new MyObjectKeyInterface(); DeployWithResolver(env, compiled, "s0", prepared => prepared.SetObject(1, lKey)); env.AddListener("s0"); env.SendEventBean(new MyEventOne(lKey)); Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked()); // Test substitution parameter and concrete subclass in key matching epl = "select * from MyEventTwo where Key = ?::MyObjectKeyConcrete"; compiled = env.Compile(epl, path); var cKey = new MyObjectKeyConcrete(); DeployWithResolver(env, compiled, "s1", prepared => prepared.SetObject(1, cKey)); env.AddListener("s1"); env.SendEventBean(new MyEventTwo(cKey)); Assert.IsTrue(env.Listener("s1").GetAndClearIsInvoked()); env.UndeployAll(); }
private void RunAssertionSimpleOneParameter(EPServiceProvider epService) { string stmt = "select * from " + typeof(SupportBean).FullName + "(TheString=?)"; EPPreparedStatement prepared = epService.EPAdministrator.PrepareEPL(stmt); prepared.SetObject(1, "e1"); EPStatement statement = epService.EPAdministrator.Create(prepared); var listenerOne = new SupportUpdateListener(); statement.Events += listenerOne.Update; Assert.AreEqual("select * from " + typeof(SupportBean).FullName + "(TheString=\"e1\")", statement.Text); prepared.SetObject(1, "e2"); statement = epService.EPAdministrator.Create(prepared); var listenerTwo = new SupportUpdateListener(); statement.Events += listenerTwo.Update; Assert.AreEqual("select * from com.espertech.esper.supportregression.bean.SupportBean(TheString=\"e2\")", statement.Text); epService.EPRuntime.SendEvent(new SupportBean("e2", 10)); Assert.IsFalse(listenerOne.IsInvoked); Assert.IsTrue(listenerTwo.GetAndClearIsInvoked()); epService.EPRuntime.SendEvent(new SupportBean("e1", 10)); Assert.IsFalse(listenerTwo.IsInvoked); Assert.IsTrue(listenerOne.GetAndClearIsInvoked()); // Test substitution parameter and inheritance in key matching epService.EPAdministrator.Configuration.AddEventType("MyEventOne", typeof(MyEventOne)); string epl = "select * from MyEventOne(key = ?)"; EPPreparedStatement preparedStatement = epService.EPAdministrator.PrepareEPL(epl); var lKey = new MyObjectKeyInterface(); preparedStatement.SetObject(1, lKey); statement = epService.EPAdministrator.Create(preparedStatement); statement.Events += listenerOne.Update; epService.EPRuntime.SendEvent(new MyEventOne(lKey)); Assert.IsTrue(listenerOne.GetAndClearIsInvoked()); // Test substitution parameter and concrete subclass in key matching epService.EPAdministrator.Configuration.AddEventType("MyEventTwo", typeof(MyEventTwo)); epl = "select * from MyEventTwo where key = ?"; preparedStatement = epService.EPAdministrator.PrepareEPL(epl); var cKey = new MyObjectKeyConcrete(); preparedStatement.SetObject(1, cKey); statement = epService.EPAdministrator.Create(preparedStatement); statement.Events += listenerOne.Update; epService.EPRuntime.SendEvent(new MyEventTwo(cKey)); Assert.IsTrue(listenerOne.GetAndClearIsInvoked()); epService.EPAdministrator.DestroyAllStatements(); }
public void TestSimpleOneParameter() { String stmt = "select * from " + typeof(SupportBean).FullName + "(TheString=?)"; EPPreparedStatement prepared = _epService.EPAdministrator.PrepareEPL(stmt); prepared.SetObject(1, "e1"); EPStatement statement = _epService.EPAdministrator.Create(prepared); statement.Events += _listenerOne.Update; Assert.AreEqual("select * from " + Name.Of <SupportBean>() + "(TheString=\"e1\")", statement.Text); prepared.SetObject(1, "e2"); statement = _epService.EPAdministrator.Create(prepared); statement.Events += _listenerTwo.Update; Assert.AreEqual("select * from " + Name.Of <SupportBean>() + "(TheString=\"e2\")", statement.Text); _epService.EPRuntime.SendEvent(new SupportBean("e2", 10)); Assert.IsFalse(_listenerOne.IsInvoked); Assert.IsTrue(_listenerTwo.GetAndClearIsInvoked()); _epService.EPRuntime.SendEvent(new SupportBean("e1", 10)); Assert.IsFalse(_listenerTwo.IsInvoked); Assert.IsTrue(_listenerOne.GetAndClearIsInvoked()); // Test substitution parameter and inheritance in key matching _epService.EPAdministrator.Configuration.AddEventType("MyEventOne", typeof(MyEventOne)); String epl = "select * from MyEventOne(key = ?)"; EPPreparedStatement preparedStatement = _epService.EPAdministrator.PrepareEPL(epl); MyObjectKeyInterface lKey = new MyObjectKeyInterface(); preparedStatement.SetObject(1, lKey); statement = _epService.EPAdministrator.Create(preparedStatement); statement.Events += _listenerOne.Update; _epService.EPRuntime.SendEvent(new MyEventOne(lKey)); Assert.IsTrue(_listenerOne.GetAndClearIsInvoked()); // Test substitution parameter and concrete subclass in key matching _epService.EPAdministrator.Configuration.AddEventType("MyEventTwo", typeof(MyEventTwo)); epl = "select * from MyEventTwo where key = ?"; preparedStatement = _epService.EPAdministrator.PrepareEPL(epl); MyObjectKeyConcrete cKey = new MyObjectKeyConcrete(); preparedStatement.SetObject(1, cKey); statement = _epService.EPAdministrator.Create(preparedStatement); statement.Events += _listenerOne.Update; _epService.EPRuntime.SendEvent(new MyEventTwo(cKey)); Assert.IsTrue(_listenerOne.GetAndClearIsInvoked()); }