My brothers and sisters, whenever you face trials of any kind, consider it nothing but joy, because you know that the testing of your faith produces endurance, and let endurance have its full effect, so that you may be mature and complete, lacking in nothing.
This letter from James is probably one of the earliest documents in the NT. The early years of the church were marked by periodic bursts of persecution (e.g. Acts 5:17-42; 7:54-8:3; 9:23-5; 12:1-5; etc) and I think it fair to assume that even without overt acts of persecution the new sect of Christians would have been treated with suspicion by both Jews and Gentiles. The 'testing of your faith' is exactly that, your faith being put on trial. Because we in the western world so seldom (if ever) are put on trial for our faith we miss out on the benefit of developing endurance/staying power. For James, to be under suspicion, to be discriminated against or persecuted because of the faith is the path to maturity in the faith.
I'm reminded of an old anecdote of uncertain provenance (might have originated in the old soviet union?), but which makes the point. A masked gun man walks into a church meeting and tells everyone who isn't ready to die for Christ to get out of the building now. After half the people leave he takes of the mask and asks to be told about Jesus. Fair enough, after all you want to know that the people sharing the Gospel with you are the genuine article and not someone who might change their mind later and tell the authorities about you.
We tend to quote this verse ('count it all as joy') when we get a parking ticket or have a unpleasant colleague at work but these things are not a result of our faith but just part of everyday life. At the risk of over translating, 'mature and complete' (τέλειοι καὶ ὁλόκληροι) could be rendered 'having reached the purpose and goal of your existence and being a completely integrated and complete person.' So are we disqualified from reaching that maturity and completeness without persecution? Well James allows us a way in by refering not just to 'trials' but 'trials of any kind.' Parking tickets and grumpy work colleagues are not in themselves trials of our faith, but they can become so if we use them as oportunities for our faith to come into action: To test how much better it is to confess your sins - rather than try to wriggle out of the ticket, or to love our enemies - rather than bad-mouth them to the boss. The greatest tests for us perhaps come when we encounter death, illness, failure, or dissapointment in our own lives. Those times when we need God the most are also those times when it is most possible to decide that God can't exist if God allows such things to happen to us or those we love. And yet James says to us that these are the times to grow, these are the times when our faith will be strengthened, these are the times when our faith has the most potential to change us into who we are meant to be. These are times to prove that we are God's and God is ours. These are times of joy.