@Test
public void testEncodeURI() throws Exception {

  final URI uri1 = new URI("http://test.host/path/file.ext");
  MediaPackageSerializer serializer1 = createNiceMock(MediaPackageSerializer.class);
  expect(serializer1.getRanking()).andStubReturn(10);
  expect(serializer1.encodeURI(anyObject(URI.class))).andStubReturn(uri1);
  expect(serializer1.decodeURI(anyObject(URI.class))).andStubReturn(uri1);
  replay(serializer1);
  final URI uri2 = new URI("https://demo.com/something/else");
  MediaPackageSerializer serializer2 = createNiceMock(MediaPackageSerializer.class);
  expect(serializer2.getRanking()).andStubReturn(5);
  expect(serializer2.encodeURI(anyObject(URI.class))).andStubReturn(uri2);
  expect(serializer2.decodeURI(anyObject(URI.class))).andStubReturn(uri2);
  replay(serializer2);
  ChainingMediaPackageSerializer chain = new ChainingMediaPackageSerializer();
  chain.addMediaPackageSerializer(serializer1);
  chain.addMediaPackageSerializer(serializer2);
  final URI uri = new URI("file:///tmp/file");
  assertEquals(uri2, chain.encodeURI(uri));
  assertEquals(uri1, chain.decodeURI(uri));
}