use of org.apache.axiom.ext.activation.SizeAwareDataSource in project webservices-axiom by apache.
the class AttachmentsTest method testGetSizeOnDataSource.
private void testGetSizeOnDataSource(boolean useFiles) throws Exception {
InputStream in = MTOMSample.SAMPLE1.getInputStream();
try {
Attachments attachments;
if (useFiles) {
attachments = new Attachments(in, MTOMSample.SAMPLE1.getContentType(), true, getAttachmentsDir(), "4096");
} else {
attachments = new Attachments(in, MTOMSample.SAMPLE1.getContentType());
}
DataHandler dh = attachments.getDataHandler("2.urn:uuid:A3ADBAEE51A1A87B2A11443668160994@apache.org");
DataSource ds = dh.getDataSource();
assertTrue(ds instanceof SizeAwareDataSource);
assertEquals(13887, ((SizeAwareDataSource) ds).getSize());
} finally {
in.close();
}
}
Aggregations