void testUpdateExistingBinding() { UtlSList bindings; RegistrationBinding* binding; RegistrationDbTestContext testDbContext(TEST_DATA_DIR "/regdbdata", TEST_WORK_DIR "/regdbdata" ); testDbContext.inputFile("updateBindings.xml"); RegistrationDB* regDb = RegistrationDB::getInstance(); // Get an existing binding Int64 seqOneUpdates = regDb->getNewUpdatesForRegistrar("seqOne", 2, bindings); CPPUNIT_ASSERT_EQUAL(1LL, seqOneUpdates); binding = (RegistrationBinding*)bindings.first(); // Increment the CSeq number int newCseq = binding->getCseq() + 1; binding->setCseq(newCseq); regDb->updateBinding(*binding); binding->setCseq(0); // Get the same binding bindings.destroyAll(); seqOneUpdates = regDb->getNewUpdatesForRegistrar("seqOne", 2, bindings); CPPUNIT_ASSERT_EQUAL(1LL, seqOneUpdates); // Test if the new CSeq number got updated binding = (RegistrationBinding*)bindings.first(); CPPUNIT_ASSERT_EQUAL(newCseq, binding->getCseq()); }
RegistrationBinding* RegistrationDB::copyRowToRegistrationBinding(dbCursor<RegistrationRow>& cursor) const { RegistrationBinding *reg = new RegistrationBinding(); reg->setUri(* new UtlString(cursor->uri)); reg->setCallId(* new UtlString(cursor->callid)); reg->setContact(* new UtlString(cursor->contact)); reg->setQvalue(* new UtlString(cursor->qvalue)); reg->setInstanceId(* new UtlString(cursor->instance_id)); reg->setGruu(* new UtlString(cursor->gruu)); reg->setPath(* new UtlString(cursor->path)); reg->setCseq(cursor->cseq); reg->setExpires(cursor->expires); reg->setPrimary(* new UtlString(cursor->primary)); reg->setUpdateNumber(cursor->update_number); return reg; }