Search in sources :

Example 36 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class TwoWayMEPTest method testPModeWrongMPCLeg2.

@Test
public void testPModeWrongMPCLeg2() throws Exception {
    final Ebms3UserMessage aEbms3UserMessage = new Ebms3UserMessage();
    final Document aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    aEbms3UserMessage.setPayloadInfo(MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null));
    // Default MessageInfo for testing
    aEbms3UserMessage.setMessageInfo(MessageHelperMethods.createEbms3MessageInfo());
    // Default CollaborationInfo for testing
    aEbms3UserMessage.setCollaborationInfo(MessageHelperMethods.createEbms3CollaborationInfo(null, DEFAULT_AGREEMENT, null, CAS4.DEFAULT_SERVICE_URL, CAS4.DEFAULT_ACTION_URL, AS4TestConstants.TEST_CONVERSATION_ID));
    // Default PartyInfo for testing
    aEbms3UserMessage.setPartyInfo(MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, DEFAULT_PARTY_ID, CAS4.DEFAULT_RESPONDER_URL, DEFAULT_PARTY_ID));
    // Default MessageProperties for testing
    aEbms3UserMessage.setMessageProperties(createDefaultProperties());
    m_aPMode.getLeg2().getBusinessInfo().setMPCID("wrongmpc-id");
    final IPMode aPMode = MetaAS4Manager.getPModeMgr().getPModeOfID(m_aPMode.getID());
    aEbms3UserMessage.getCollaborationInfo().getAgreementRef().setPmode(aPMode.getID());
    final Document aSignedDoc = AS4UserMessage.create(m_eSoapVersion, aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(aPayload);
    sendPlainMessageAndWait(new HttpXMLEntity(aSignedDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
}
Also used : IPMode(com.helger.phase4.model.pmode.IPMode) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 37 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class TwoWayMEPTest method testPModeWithOnlyLeg2.

@Test
public void testPModeWithOnlyLeg2() throws Exception {
    m_aPMode.setLeg1(null);
    MetaAS4Manager.getPModeMgr().createOrUpdatePMode(m_aPMode);
    final Document aDoc = modifyUserMessage(m_aPMode.getID(), null, null, createDefaultProperties(), null, null, null);
    sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
}
Also used : HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 38 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class TwoWayMEPTest method testReceiveUserMessageAsResponseSuccess.

@Test
public void testReceiveUserMessageAsResponseSuccess() throws Exception {
    final Document aDoc = modifyUserMessage(m_aPMode.getID(), null, null, createDefaultProperties(), null, null, null);
    final String sResponse = sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.USERMESSAGE_ASSERTCHECK));
    assertFalse(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    assertTrue(sResponse.contains(m_aPMode.getLeg2().getSecurity().getX509SignatureAlgorithm().getAlgorithmURI()));
}
Also used : HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 39 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class UserMessageDuplicateTest method testSendDuplicateMessageOnlyGetOneReceipt.

@Test
public void testSendDuplicateMessageOnlyGetOneReceipt() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final Document aDoc = MockMessages.createUserMessageNotSigned(m_eSoapVersion, aPayload, null).getAsSoapDocument(aPayload);
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType());
    // Send once
    sendPlainMessageAndWait(aEntity, true, null);
    // Send again
    sendPlainMessageAndWait(aEntity, false, EEbmsError.EBMS_OTHER.getErrorCode());
}
Also used : HttpEntity(org.apache.http.HttpEntity) Node(org.w3c.dom.Node) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 40 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class UserMessageDuplicateTest method testDuplicateSignedMessage.

@Test
public void testDuplicateSignedMessage() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final ESoapVersion eSOAPVersion = ESoapVersion.AS4_DEFAULT;
    final Document aDoc = MockMessages.createUserMessageSigned(eSOAPVersion, aPayload, null, s_aResMgr);
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, eSOAPVersion.getMimeType());
    // Send first
    final String sResponse = sendPlainMessage(aEntity, true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    // Send second
    sendPlainMessage(aEntity, false, EEbmsError.EBMS_OTHER.getErrorCode());
}
Also used : HttpEntity(org.apache.http.HttpEntity) ESoapVersion(com.helger.phase4.soap.ESoapVersion) Node(org.w3c.dom.Node) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Aggregations

HttpXMLEntity (com.helger.phase4.http.HttpXMLEntity)65 Document (org.w3c.dom.Document)61 Test (org.junit.Test)60 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)30 Node (org.w3c.dom.Node)18 HttpEntity (org.apache.http.HttpEntity)16 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)10 NodeList (org.w3c.dom.NodeList)10 Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)9 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)8 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)7 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)7 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)7 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)7 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)6 DocumentBuilder (javax.xml.parsers.DocumentBuilder)6 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)6 WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)5 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)5 IAS4CryptoFactory (com.helger.phase4.crypto.IAS4CryptoFactory)4