assertEquals("demo:5", fields.get(0).getPid().getValue());
}
@Test
public void testGetDatastreamDissemination() throws Exception {
MIMETypedStream ds = null;
// test for type X datastream
ds = apia.getDatastreamDissemination("demo:5", "DC", null);
byte[] bytes = TypeUtility.convertDataHandlerToBytes(ds.getStream());
String xml = new String(bytes, "UTF-8");
assertXpathExists("/oai_dc:dc", xml);
assertXpathEvaluatesTo("demo:5",
"/oai_dc:dc/dc:identifier/text( )",
xml);
assertEquals(ds.getMIMEType(), "text/xml");
// test for type E datastream
ds =
apia.getDatastreamDissemination("demo:SmileyBeerGlass",
"MEDIUM_SIZE",
null);
bytes = TypeUtility.convertDataHandlerToBytes(ds.getStream());
assertEquals(ds.getMIMEType(), "image/jpeg");
assertTrue(bytes.length > 0);
// test for type R datastream
ds = apia.getDatastreamDissemination("demo:31", "DS3", null);
assertEquals(ds.getMIMEType(), "application/fedora-redirect");
// test for type M datastream
ds = apia.getDatastreamDissemination("demo:5", "THUMBRES_IMG", null);
bytes = TypeUtility.convertDataHandlerToBytes(ds.getStream());
assertEquals(ds.getMIMEType(), "image/jpeg");
assertTrue(bytes.length > 0);
}