Back to project page adventure.datetime.
The source code is released under:
MIT License
If you think the Android project adventure.datetime listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ca.cmput301f13t03.adventure_datetime.model; // w w w . ja v a2 s . co m import android.graphics.BitmapFactory; import android.test.AndroidTestCase; import ca.cmput301f13t03.adventure_datetime.R; import com.google.gson.Gson; import java.util.UUID; public class CommentTest extends AndroidTestCase { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public void testJson() { Comment comment = new Comment(UUID.randomUUID(), "Bad Author", "Bad Content"); comment.setImage(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.grumpy_cat)); assertNotNull(comment.getImage()); assertEquals(comment.getId(), comment.getImage().getId()); Gson gson = new Gson(); String json = gson.toJson(comment); Comment comment2 = gson.fromJson(json, Comment.class); assertEquals(comment, comment2); assertEquals(comment.getFormattedTimestamp(), comment2.getFormattedTimestamp()); assertNull(comment2.getImage()); } }