@Test
public void testDistributeHLSElement() throws Exception {

  MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
  URI mpURI = AwsS3DistributionServiceImpl.class.getResource("/hls_mediapackage.xml").toURI();
  mp = builder.loadFromXml(mpURI.toURL().openStream());
  mpURI = AwsS3DistributionServiceImpl.class.getResource("/distributed_hls_mediapackage.xml").toURI();
  distributedMp = builder.loadFromXml(mpURI.toURL().openStream());
  Upload upload = EasyMock.createNiceMock(Upload.class);
  EasyMock.expect(tm.upload(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class),
          EasyMock.anyObject(File.class))).andReturn(upload).anyTimes();
  EasyMock.replay(upload, tm);
  Set<String> mpeIds = new LinkedHashSet<String>();
  mpeIds.add("presenter-mp4");
  mpeIds.add("presenter-m3u8");
  MediaPackageElement[] mpes = service.distributeElements("channelId", mp, mpeIds, false);
  MediaPackageElement mpe = mpes[0];
  Assert.assertEquals(new URI(
          "http://XYZ.cloudfront.net/channelId/efd6e4df-63b6-49af-be5f-15f598778877/presenter-mp4/video-presenter-delivery.mp4"),
          mpe.getURI());
  // Test that temp directory is removed
  Path tempfile = storageDir.toPath().resolve(mp.getIdentifier().toString());
  Assert.assertFalse(Files.exists(tempfile));
}