Gists are great for longer code. For something this short, it is ok to just post it inline.
The code in the gist is:
As far as how to test it, think about what it does. I see two paths through the code.
Exception case If you pass null or a file that doesn't exist, you expect the error path to be executed. You could test that an exception isn't thrown to the caller. Or you could test that something is written to System.err if you want to be particularly thorough about it. (To do this, save System.err in an instance variable and change it to a stream you control.)
Happy path The goal is to test a file is created with certain content. One way is to create a sample serializable object. Run it through your method. Then try to do the opposite - read in the file and see if you get the same object.