Example #1
0
 virtual void SetUp(){
     BaseTransactionFixture::SetUp();
     loadModule(&m_module, "ibmod_rules.so");
     ASSERT_IB_OK(ib_rule_create(ib_engine,
                                 ib_engine->ectx,
                                 __FILE__,
                                 __LINE__,
                                 true,
                                 &rule));
 }
Example #2
0
    virtual void SetUp()
    {
        ib_status_t rc;
        const char *s1 = "string 1";
        const char *s2 = "string 2";

        BaseTransactionFixture::SetUp();
        configureIronBee();
        performTx();

        ib_mm_t mm = ib_engine_mm_main_get(ib_engine);
        char* str1 = (char *)ib_mm_alloc(mm, (strlen(s1)+1));
        if (str1 == NULL) {
            throw std::runtime_error("Could not allocate string 1.");
        }
        strcpy(str1, s1);
        char* str2 = (char *)ib_mm_alloc(mm, (strlen(s2)+1));
        if (str1 == NULL) {
            throw std::runtime_error("Could not allocate string 2.");
        }
        strcpy(str2, s2);

        // Create field 1.
        rc = ib_field_create(&field1,
                             mm,
                             IB_S2SL("field1"),
                             IB_FTYPE_NULSTR,
                             ib_ftype_nulstr_in(str1));
        if (rc != IB_OK) {
            throw std::runtime_error("Could not initialize field1.");
        }

        // Create field 2.
        rc = ib_field_create(&field2,
                             mm,
                             IB_S2SL("field2"),
                             IB_FTYPE_NULSTR,
                             ib_ftype_nulstr_in(str2));
        if (rc != IB_OK) {
            throw std::runtime_error("Could not initialize field2.");
        }

        /* Create rule 1 */
        rc = ib_rule_create(ib_engine,
                            ib_context_engine(ib_engine),
                            __FILE__,
                            __LINE__,
                            true,
                            &rule1);
        if (rc != IB_OK) {
            throw std::runtime_error("Could not create rule1.");
        }
        rc = ib_rule_set_id(ib_engine, rule1, "rule1");
        if (rc != IB_OK) {
            throw std::runtime_error("Could not set ID for rule1.");
        }

        /* Create the rule execution object #1 */
        memset(&rule_exec1, 0, sizeof(rule_exec1));
        rule_exec1.ib = ib_engine;
        rule_exec1.tx = ib_tx;
        rule_exec1.rule = rule1;

        /* Create rule 2 */
        rc = (ib_rule_create(ib_engine,
                             ib_context_engine(ib_engine),
                             __FILE__,
                             __LINE__,
                             true,
                             &rule2));
        if (rc != IB_OK) {
            throw std::runtime_error("Could not create rule2.");
        }
        rc = ib_rule_set_id(ib_engine, rule2, "rule2");
        if (rc != IB_OK) {
            throw std::runtime_error("Could not set ID for rule2.");
        }
        rule2->flags |= IB_RULE_FLAG_CAPTURE;

        /* Create the rule execution object #1 */
        memset(&rule_exec2, 0, sizeof(rule_exec2));
        rule_exec2.ib = ib_engine;
        rule_exec2.tx = ib_tx;
        rule_exec2.rule = rule2;
    }