public static void parseAS2MessageEntity(HttpMessage message) throws HttpException {
        if (EntityUtils.hasEntity(message)) {
            HttpEntity entity = ObjectHelper.notNull(EntityUtils.getMessageEntity(message), "message entity");

            if (entity instanceof MimeEntity) {
                // already parsed
                return;
            }

            try {
                // Determine Content Type of Message
                String contentTypeStr = HttpMessageUtils.getHeaderValue(message, AS2Header.CONTENT_TYPE);
                if (contentTypeStr == null) {
                    // contentTypeStr can be null when dispositionNotificationTo isn't set
                    return;
                }
                doParseAS2MessageEntity(message, contentTypeStr, entity);
            } catch (HttpException e) {
                throw e;
            } catch (Exception e) {
                throw new HttpException("Failed to parse entity content", e);
            }
        }

    }
@Test
    public void parseMessageDispositionNotificationReportMessageTest() throws Exception {
        HttpResponse response = new BasicClassicHttpResponse(
                HttpStatus.SC_OK, EnglishReasonPhraseCatalog.INSTANCE.getReason(HttpStatus.SC_OK, null));
        response.setVersion(new ProtocolVersion("HTTP", 1, 1));
        HttpMessageUtils.setHeaderValue(response, AS2Header.CONTENT_TRANSFER_ENCODING,
                DISPOSITION_NOTIFICATION_CONTENT_TRANSFER_ENCODING);

        InputStream is = new ByteArrayInputStream(
                DISPOSITION_NOTIFICATION_REPORT_CONTENT.getBytes(DISPOSITION_NOTIFICATION_REPORT_CONTENT_CHARSET_NAME));
        BasicHttpEntity entity = new BasicHttpEntity(is, ContentType.parse(REPORT_CONTENT_TYPE_VALUE));
        EntityUtils.setMessageEntity(response, entity);

        EntityParser.parseAS2MessageEntity(response);
        HttpEntity parsedEntity = EntityUtils.getMessageEntity(response);
        assertNotNull(parsedEntity, "Unexpected Null message disposition notification report entity");
        assertTrue(parsedEntity instanceof DispositionNotificationMultipartReportEntity,
                "Unexpected type for message disposition notification report entity");
    }