private void testJsonMarshalling(final List<Video> videos) throws Exception {
    final JsonPath json = toJson(populateJaxbVideos(new JaxbVideosJson(), videos));

    // test generated json
    assertEquals(0, json.getInt("start"));
    assertEquals(videos.size(), json.getInt("limit"));
    assertEquals(videos.size() * 2, json.getInt("total"));

    // test for videos in the generated json
    assertTrue("videos is not an array", json.get("videos") instanceof List);
    assertEquals(videos.size(), json.getInt("videos.size()"));
    for (int i = 0; i < videos.size(); i++) {
      final String base = "videos[" + Integer.valueOf(i).toString() + "]";
      final Video video = videos.get(i);
      assertEquals(video.getId(), json.getLong(base + ".id"));
    }
  }
  @Test
  public void testXmlMarshalling() throws Exception {
    // generate xml for multiple videos
    final List<Video> videos = generateVideos();
    final XmlPath xml = toXml(populateJaxbVideos(new JaxbVideosXml(), videos));

    // test generated xml
    assertEquals("videos", xml.getString("videos.name()"));
    assertEquals(0, xml.getInt("videos.@start"));
    assertEquals(videos.size(), xml.getInt("videos.@limit"));
    assertEquals(videos.size() * 2, xml.getInt("videos.@total"));

    // test for videos in the generated xml
    assertEquals(videos.size(), xml.getInt("videos.video.size()"));
    for (int i = 0; i < videos.size(); i++) {
      final String base = "videos.video[" + Integer.valueOf(i).toString() + "]";
      final Video video = videos.get(i);
      assertEquals(video.getId(), xml.getLong(base + ".@id"));
    }
  }