use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA13.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile (One-Way/Push MEP). SMSH is simulated to send an AS4 User
* Message with compressed but damaged payloads. The SMSH sends the AS4 User
* Message to the RMSH.<br>
* <br>
* Predicate: <br>
* The RMSH sends back a synchronous error response with error code "Code =
* EBMS:0303, Short Description = DecompressionFailure, Severity = Failure,
* Category = Communication".
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA13() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
final WSS4JAttachment aAttachment = WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr);
aAttachment.setCharset(StandardCharsets.UTF_8);
aAttachments.add(aAttachment);
final AS4UserMessage aMsg = createTestUserMessageSoapNotSigned(m_aPayload, aAttachments);
// Damaged payload: txt file
aAttachments.get(0).setSourceStreamProvider(new ClassPathResource("attachment/CompressedPayload.txt"));
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aMsg.getAsSoapDocument(m_aPayload), aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), false, EEbmsError.EBMS_DECOMPRESSION_FAILURE.getErrorCode());
}
use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA16.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile (One-Way/Push MEP). SMSH sends an AS4 User Message with a
* several compressed payloads (XML and non XML) to the RMSH.<br>
* <br>
* Predicate: <br>
* The RMSH delivers the message with decompressed payloads to the consumer.
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA16() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_IMG_JPG)).mimeType(CMimeType.IMAGE_JPG).compressionGZIP().build(), s_aResMgr));
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML2_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
final Document aDoc = createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr);
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
}
use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class AS4_NETFuncTest method testSendToAS4_NET.
@Test
public void testSendToAS4_NET() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().build(), s_aResMgr));
// New message ID
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(false, aAttachments);
final Ebms3CollaborationInfo aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(m_aESENSOneWayPMode.getID(), DEFAULT_AGREEMENT, COLLABORATION_INFO_SERVICE_TYPE, COLLABORATION_INFO_SERVICE, COLLABORATION_INFO_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
final Ebms3PartyInfo aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "phase4-sender", CAS4.DEFAULT_RESPONDER_URL, TO_PARTY_ID);
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = new CommonsArrayList<>(MessageHelperMethods.createEbms3Property(CAS4.ORIGINAL_SENDER, null, "C1"), MessageHelperMethods.createEbms3Property(CAS4.FINAL_RECIPIENT, null, "C4"));
aEbms3Properties.add(MessageHelperMethods.createEbms3Property("trackingidentifier", "tracker"));
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final AS4UserMessage aUserMsg = AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, m_eSoapVersion).setMustUnderstand(true);
// Sign payload document
final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aUserMsg.getAsSoapDocument(), m_eSoapVersion, aUserMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault());
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aSignedDoc, aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
}
use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class HolodeckFuncTest method testSendToHolodeck.
@Test
public void testSendToHolodeck() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().build(), s_aResMgr));
// New message ID
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(false, aAttachments);
final Ebms3CollaborationInfo aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(true ? null : m_aESENSOneWayPMode.getID(), true ? null : DEFAULT_AGREEMENT, COLLABORATION_INFO_SERVICE_TYPE, COLLABORATION_INFO_SERVICE, COLLABORATION_INFO_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
final Ebms3PartyInfo aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "phase4-sender", CAS4.DEFAULT_RESPONDER_URL, TO_PARTY_ID);
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = new CommonsArrayList<>(MessageHelperMethods.createEbms3Property(CAS4.ORIGINAL_SENDER, null, "C1"), MessageHelperMethods.createEbms3Property(CAS4.FINAL_RECIPIENT, null, "C4"));
aEbms3Properties.add(MessageHelperMethods.createEbms3Property("trackingidentifier", "tracker"));
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final AS4UserMessage aUserMsg = AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, m_eSoapVersion).setMustUnderstand(true);
// Sign payload document
final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aUserMsg.getAsSoapDocument(), m_eSoapVersion, aUserMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault());
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aSignedDoc, aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
}
use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class UserMessageOneAttachmentTest method testUserMessageOneAttachmentMimeSuccess.
@Test
public void testUserMessageOneAttachmentMimeSuccess() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().build(), s_aResMgr));
final AS4UserMessage aMsg = MockMessages.createUserMessageNotSigned(m_eSOAPVersion, null, aAttachments);
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSOAPVersion, aMsg.getAsSoapDocument(), aAttachments);
final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
}
Aggregations