Search in sources :

Example 1 with MIMEException

use of org.apache.axiom.mime.MIMEException in project webservices-axiom by apache.

the class AttachmentsTest method testIOExceptionInPartHeaders.

public void testIOExceptionInPartHeaders() throws Exception {
    InputStream in = MTOMSample.SAMPLE1.getInputStream();
    try {
        Attachments attachments = new Attachments(new ExceptionInputStream(in, 1050), MTOMSample.SAMPLE1.getContentType());
        // TODO: decide what exception should be thrown exactly here
        try {
            attachments.getDataHandler("1.urn:uuid:A3ADBAEE51A1A87B2A11443668160943@apache.org");
            fail("Expected exception");
        } catch (MIMEException ex) {
        // Expected
        }
    } finally {
        in.close();
    }
}
Also used : MIMEException(org.apache.axiom.mime.MIMEException) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) ExceptionInputStream(org.apache.axiom.testutils.io.ExceptionInputStream) InputStream(java.io.InputStream) ExceptionInputStream(org.apache.axiom.testutils.io.ExceptionInputStream)

Example 2 with MIMEException

use of org.apache.axiom.mime.MIMEException in project webservices-axiom by apache.

the class AttachmentsTest method testIOExceptionInPartContent.

public void testIOExceptionInPartContent() throws Exception {
    InputStream in = MTOMSample.SAMPLE1.getInputStream();
    try {
        Attachments attachments = new Attachments(new ExceptionInputStream(in, 1500), MTOMSample.SAMPLE1.getContentType());
        DataHandler dh = attachments.getDataHandler("1.urn:uuid:A3ADBAEE51A1A87B2A11443668160943@apache.org");
        // TODO: decide what exception should be thrown exactly here
        try {
            dh.getInputStream();
            fail("Expected exception");
        } catch (MIMEException ex) {
        // Expected
        }
    } finally {
        in.close();
    }
}
Also used : MIMEException(org.apache.axiom.mime.MIMEException) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) ExceptionInputStream(org.apache.axiom.testutils.io.ExceptionInputStream) InputStream(java.io.InputStream) ExceptionInputStream(org.apache.axiom.testutils.io.ExceptionInputStream) DataHandler(javax.activation.DataHandler)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 PipedInputStream (java.io.PipedInputStream)2 MIMEException (org.apache.axiom.mime.MIMEException)2 ExceptionInputStream (org.apache.axiom.testutils.io.ExceptionInputStream)2 DataHandler (javax.activation.DataHandler)1