If test.example.com is not staying alive, then there's no worries. You just create all the rewrite rules you need on test.example.com to rewrite to test2.example.com
So if you've got requests coming in on test for page?id=1 and that needs to be rewritten to come in on test2 for, I don't know, index.php?n=1 that can be captured with a single condition + rule like
RewriteCond %{HTTP_HOST} ^test\.example\.com [NC]
RewriteRule ^page\?id=(.\d+)$ [
test2.example.com...] [R=301,L]
That's an Apache rewrite of course, but I know you can do similar on MS servers as well with certain modules added on. If the mappings are less precise, you'd need to do a rewrite rule for each page that didn't match the general rule or some such.
But in any case, you would want to both
- update the links on your Sharepoint server (update, not redirect - a link isn't redirected on the outbound server). Eventually, these should be pointing to the right places without redirecting. I have no idea how MOSS works, but for this sort of thing, I usually grep for the URL in question and change it where needed and then reupload the database (or use sed to change the files if that's more appropriate). I have no idea what the Microsoft equivalent would be to do doing that, but things like PowerGREP can handle that sort of text manipulation on a Windows machine. But maybe it's just a setting (like I say, I don't know MOSS).
- redirect the target links on test.example.com so that old links around the web to your test.example.com domain don't go bad. Ideally, you'd try some general rule that would handle most cases and you'd look at your sever logs and at least get the top 100 pages redirected to their equivalent on the new site.