Exemplo n.º 1
0
        private void RunAssertionOutputRowConversion(EPServiceProvider epService)
        {
            SupportSQLColumnTypeConversion.Reset();
            epService.EPAdministrator.Configuration.AddVariable("myvariableORC", typeof(int), 10);

            string[] fields   = "TheString,IntPrimitive".Split(',');
            string   stmtText = "@Hook(Type=HookType.SQLROW, Hook='" + typeof(SupportSQLOutputRowConversion).FullName + "')" +
                                "select * from sql:MyDB ['select * from mytesttable where myint = ${myvariableORC}']";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(stmtText);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            Assert.AreEqual(typeof(SupportBean), stmt.EventType.UnderlyingType);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { ">10<", 99010 } });

            SQLOutputRowTypeContext type = SupportSQLOutputRowConversion.TypeContexts[0];

            Assert.AreEqual("MyDB", type.Db);
            Assert.AreEqual("select * from mytesttable where myint = ${myvariableORC}", type.Sql);
            Assert.AreEqual(typeof(int?), type.Fields.Get("myint"));

            SQLOutputRowValueContext val = SupportSQLOutputRowConversion.ValueContexts[0];

            Assert.AreEqual(10, val.Values.Get("myint"));

            epService.EPRuntime.SetVariableValue("myvariableORC", 60);    // greater 50 turns true
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { ">60<", 99060 } });

            epService.EPRuntime.SetVariableValue("myvariableORC", 90);    // greater 50 turns true
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            stmt.Dispose();
        }
Exemplo n.º 2
0
 public void TearDown()
 {
     if (InstrumentationHelper.ENABLED)
     {
         InstrumentationHelper.EndTest();
     }
     _listener = null;
     _epService.Dispose();
     SupportSQLColumnTypeConversion.Reset();
 }
Exemplo n.º 3
0
        private void RunAssertionInputParameterConversion(EPServiceProvider epService)
        {
            SupportSQLColumnTypeConversion.Reset();
            epService.EPAdministrator.Configuration.AddVariable("myvariableIPC", typeof(Object), "x10");

            var    fields   = new string[] { "myint" };
            string stmtText = "@Hook(Type=HookType.SQLCOL, Hook='" + typeof(SupportSQLColumnTypeConversion).FullName + "')" +
                              "select * from sql:MyDB ['select myint from mytesttable where myint = ${myvariableIPC}']";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(stmtText);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SetVariableValue("myvariableIPC", "x60");    // greater 50 turns true
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { true } });

            SQLInputParameterContext param = SupportSQLColumnTypeConversion.ParamContexts[0];

            Assert.AreEqual(1, param.ParameterNumber);
            Assert.AreEqual("x60", param.ParameterValue);

            stmt.Dispose();
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            var configDB = new ConfigurationDBRef();

            configDB.SetDatabaseDriver(SupportDatabaseService.DbDriverFactoryNative);
            configDB.ConnectionLifecycle            = ConnectionLifecycleEnum.RETAIN;
            configDB.ConnectionCatalog              = "test";
            configDB.ConnectionTransactionIsolation = IsolationLevel.Serializable;
            configDB.ConnectionAutoCommit           = true;

            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddDatabaseReference("MyDB", configDB);

            _epService = EPServiceProviderManager.GetProvider("TestDatabaseJoinRetained", configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            SupportSQLColumnTypeConversion.Reset();
        }
Exemplo n.º 5
0
        //@Hook(type=HookType.SQLCOL, hook="this is a sample and not used")
        private void RunAssertionOutputColumnConversion(EPServiceProvider epService)
        {
            SupportSQLColumnTypeConversion.Reset();
            epService.EPAdministrator.Configuration.AddVariable("myvariableOCC", typeof(int), 10);

            var    fields   = new string[] { "myint" };
            string stmtText = "@Hook(Type=HookType.SQLCOL, Hook='" + typeof(SupportSQLColumnTypeConversion).FullName + "')" +
                              "select * from sql:MyDB ['select myint from mytesttable where myint = ${myvariableOCC}']";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(stmtText);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            Assert.AreEqual(typeof(bool?), stmt.EventType.GetPropertyType("myint"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { false } });

            // assert contexts
            SQLColumnTypeContext type = SupportSQLColumnTypeConversion.TypeContexts[0];

            Assert.AreEqual("System.Int32", type.ColumnSqlType);
            Assert.AreEqual("MyDB", type.Db);
            Assert.AreEqual("select myint from mytesttable where myint = ${myvariableOCC}", type.Sql);
            Assert.AreEqual("myint", type.ColumnName);
            Assert.AreEqual(1, type.ColumnNumber);
            Assert.AreEqual(typeof(int?), type.ColumnClassType);

            SQLColumnValueContext val = SupportSQLColumnTypeConversion.ValueContexts[0];

            Assert.AreEqual(10, val.ColumnValue);
            Assert.AreEqual("myint", val.ColumnName);
            Assert.AreEqual(1, val.ColumnNumber);

            epService.EPRuntime.SetVariableValue("myvariableOCC", 60);    // greater 50 turns true
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { true } });

            stmt.Dispose();
        }