Pain and suffering is part of the landscape we find in the "wilderness" motif of life. What are we to do? How are we to respond? "Pure joy" is how James puts it. He says, "Consider it pure joy." The Christian expects troubles and has a deep joy even in the face of them, but it's not the masochistic "no-pain-no-gain" enjoyment of suffering, nor the hedonistic "this- too-shall-pass' avoidance or even "count-your-blessings / it's-all-in-your-mind" denial of suffering.
Christians rejoice IN suffering, not FOR the suffering, or rejoice in the anticipation of getting OUT of the suffering. But how do we do that? Deep suffering often leads us to question God's character, as opposed to being comforted by it. Truth is, we don't have the intellectual capacity to reconcile real, intense, suffering with the goodness of God. James knows this. We begin to wrestle with the thought that maybe God is not good. Perhaps what I thought were "tests" are actually temptations from a God who is actually evil - or at least evil sometimes?
It makes sense that James encourages us to begin by praying for wisdom - wisdom to persevere and endure in suffering, not wisdom to fix or escape from it. Wisdom to apprehend what we cannot comprehend. Wisdom to trust, versus wisdom to understand. Wisdom to trust that the tests/trials come from a Father, who does not change like shifting shadows, who consistently works all things TOGETHER for our good, unearthing what we really trust in, so we can replant ourselves in the 'lap' of the One we long for - who is good and generous with his love.