@Test
public void testExtractImageContentType() throws Exception {

  String mediaPackageId = "mp";
  String image = "element1";
  InputStream in = null;
  InputStream responseIn = null;
  try {
    in = getClass().getResourceAsStream("/opencast_header.gif");
    endpoint.put(mediaPackageId, image, "opencast_header.gif", in);
  } finally {
    IOUtils.closeQuietly(in);
  }
  // execute gets, and ensure that the content types are correct
  Response response = endpoint.restGet(mediaPackageId, image, null);
  Assert.assertEquals("Gif content type", "image/gif", response.getMetadata().getFirst("Content-Type"));
  // Make sure the image byte stream was not modified by the content type detection
  try {
    in = getClass().getResourceAsStream("/opencast_header.gif");
    byte[] bytesFromClasspath = IOUtils.toByteArray(in);
    responseIn = (InputStream) response.getEntity();
    byte[] bytesFromRepo = IOUtils.toByteArray(responseIn);
    Assert.assertTrue(Arrays.equals(bytesFromClasspath, bytesFromRepo));
  } finally {
    IOUtils.closeQuietly(in);
    IOUtils.closeQuietly(responseIn);
  }
}