"Joy" is not an ideal translation of the original Greek here because it doesn't quite cover the original meaning.
A better translation would be "rejoice" or "rejoicefullness" (if that were a word).
Let's take a look...
Greek
The Greek word used in these passages is chara (also transliterated khara).
If we look at Vines Expository Dictionary of the New Testament, we see that this word means "gladness". While Strong's Concordance shows that this word is often translated (in the KJV) as "joy".

However, if we look at the root word, we see word chairō (or khiro). Vines has this word meaning "rejoice, be glad". Also, Strong's Concordance shows that (in the KJV) the word is usually translated as "rejoice".
English
The translation of this word as "joy" is not a poor choice, by any means. However, the English definition falls short:
joy
1.
a. Intense and especially ecstatic or exultant happiness.
b. The expression or manifestation of such feeling.
2. A source or an object of pleasure or satisfaction: their child was their pride and joy
This definition falls short of the original meaning of "rejoice, be glad". A more accurate translation of this would be "gladness".
glad
1. a. Experiencing or exhibiting joy and pleasure.
b. Appreciative
We can see that there is definitely a component of happiness here, but there's also a sense of appreciation.
If we compare this to the Greek root "rejoice", we can clearly see that a better translation would not be "joy" as in happiness, but "joy" as in appreciation, thanksgiving, and rejoicing (or more accurately, a combination of those words). "Rejoicefullness", if that were a word, would be the best translation.
In context
We also see this word being used here:
Matthew 5:11-12 (NIV)emphases added
11 “Blessed are you when people insult you and persecute you, and falsely say all kinds of evil against you because of Me. 12 Rejoice and be glad, for your reward in heaven is great; for in the same way they persecuted the prophets who were before you.
In verse 12 there, we see the word translated as "Rejoice".
This very clearly shows that while we may not be happy, we can still rejoice. The "joy" that God will give us is not entirely based on happiness, but it is based on rejoicing.
Summary
The original Greek word used here does not always mean that we will be happy. Rather, it means that we will find appreciation and rejoicing. "Rejoicefullness" would be a better, more accurate translation, if that were even a word.
Essentially, it means that the fruit of the spirit will be a spirit of rejoicing.