miner configuration – How do I compute the coinbase in for a stratum pool?

I searched around Google and didn’t get a correct answer, some one says I should use:

hashed_coinbase_ = coinbase1 + extranonce + extranonce2 + coinbase2;

And some other pages says:

hashed_coinbase_ = coinbase1 + extranonce2 + coinbase2;
  1. Which one is correct?

  2. If the first one is correct, is the coinbase1, coinbase2, extranonce are all hex represent values that I received from the stratum server? for extranonce2, should I also use its hex and concat all these hex strings together, and the hash it to get the hashed_coinbase?

  3. Seems all received hex values are big-endian, should I change them into little-endian before computing the coinbase?

  4. Is there any existing test case (values) that I can test my algorithm to make sure everything works fine?