Psalms - Chapter 26
Be Careful What You Ask For
David asks G-d to test him, as He did Abraham. This was an error in judgment, as we should not go looking for temptation. David was overconfident in his own righteousness and, sure enough, he stumbled in the matter of Bat-Sheva. Nevertheless, David invites G-d to test him, hopeful that the experience will elevate him spiritually and intellectually.
David says the reason he was not prone to stray from G-d is that he made it a point to always be aware of the goodness that G-d provides. He pursued Torah and avoided the influence of false people. He scorned the company of evil men and actively cleansed himself of sin so that he would be fit to serve G-d. He publicly thanked G-d for His kindnesses and told over all of His wondrous acts.
We learn an important lesson from David here. We must be confident that G-d will not give us a test that we cannot pass - but that doesn't mean that we should go looking for trouble!
David loves the Temple and even the Tabernacle, places where G-d's presence can be most intently felt. He prays that after death, his soul not reside in the same place as sinners who plot violence and conspire to cheat others. He plans to live a pure life, with G-d's help. He is on the straight path and he will praise G-d in the eyes of all.