Search in sources :

Example 56 with HttpXMLEntity

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

the class PullRequestTest method testSendPullRequestSuccessTwoWayPushPull.

@Test
public void testSendPullRequestSuccessTwoWayPushPull() throws Exception {
    // Depending on the payload a different EMEPBinding get chosen by
    // @MockPullRequestProcessorSPI
    // To Test the pull request part of the EMEPBinding
    final Document aPayload = DOMReader.readXMLDOM(new ClassPathResource("testfiles/PushPull.xml"));
    final ICommonsList<Object> aAny = new CommonsArrayList<>();
    aAny.add(aPayload.getDocumentElement());
    final Document aDoc = AS4PullRequestMessage.create(m_eSoapVersion, MessageHelperMethods.createEbms3MessageInfo(), AS4TestConstants.DEFAULT_MPC, aAny).getAsSoapDocument();
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType());
    final String sResponse = sendPlainMessageAndWait(aEntity, true, null);
    assertTrue(sResponse.contains(AS4TestConstants.USERMESSAGE_ASSERTCHECK));
}
Also used : HttpEntity(org.apache.http.HttpEntity) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Test(org.junit.Test)

Example 57 with HttpXMLEntity

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

the class PullRequestTest method testSendPullRequestTwoSPIsFailure.

@Test
public void testSendPullRequestTwoSPIsFailure() throws Exception {
    final String sMPC = "TWO-SPI";
    final MPC aMPC = new MPC(sMPC);
    if (MetaAS4Manager.getMPCMgr().getMPCOfID(sMPC) == null)
        MetaAS4Manager.getMPCMgr().createMPC(aMPC);
    final Document aDoc = AS4PullRequestMessage.create(m_eSoapVersion, MessageHelperMethods.createEbms3MessageInfo(), sMPC, null).getAsSoapDocument();
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType());
    sendPlainMessageAndWait(aEntity, false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : MPC(com.helger.phase4.model.mpc.MPC) HttpEntity(org.apache.http.HttpEntity) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 58 with HttpXMLEntity

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

the class TwoWayAsyncPullPushTest method testPullPushSuccess.

@Test
public void testPullPushSuccess() throws Exception {
    // Needs to be cleared so we can exactly see if two messages are contained
    // in the duplicate manager
    final IAS4DuplicateManager aIncomingDuplicateMgr = MetaAS4Manager.getIncomingDuplicateMgr();
    aIncomingDuplicateMgr.clearCache();
    assertTrue(aIncomingDuplicateMgr.isEmpty());
    // Depending on the payload a different EMEPBinding get chosen by
    // @MockPullRequestProcessorSPI
    // To Test the pull request part of the EMEPBinding
    final Document aPayload = DOMReader.readXMLDOM(new ClassPathResource("testfiles/PullPush.xml"));
    final ICommonsList<Object> aAny = new CommonsArrayList<>();
    aAny.add(aPayload.getDocumentElement());
    // add the ID from the usermessage since its still one async message
    // transfer
    Document aDoc = AS4PullRequestMessage.create(m_eSoapVersion, MessageHelperMethods.createEbms3MessageInfo(), AS4TestConstants.DEFAULT_MPC, aAny).getAsSoapDocument();
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType());
    String sResponse = sendPlainMessageAndWait(aEntity, true, null);
    // Avoid stopping server to receive async response
    LOGGER.info("Waiting for 1 second");
    ThreadHelper.sleepSeconds(1);
    final NodeList nPullList = aDoc.getElementsByTagName("eb:MessageId");
    // Should only be called once
    final String aPullID = nPullList.item(0).getTextContent();
    aDoc = modifyUserMessage(m_aPMode.getID(), null, null, createDefaultProperties(), null, aPullID, null);
    sResponse = sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
    final NodeList nList = aDoc.getElementsByTagName("eb:MessageId");
    // Should only be called once
    final String sID = nList.item(0).getTextContent();
    // Step one assertion for final the sync part
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    assertTrue(sResponse.contains("<eb:RefToMessageId>" + sID));
    assertNotNull(aIncomingDuplicateMgr.getItemOfMessageID(sID));
    // Pull => First UserMsg, Push part second UserMsg
    assertEquals(2, aIncomingDuplicateMgr.getAll().size());
}
Also used : IAS4DuplicateManager(com.helger.phase4.duplicate.IAS4DuplicateManager) HttpEntity(org.apache.http.HttpEntity) NodeList(org.w3c.dom.NodeList) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Test(org.junit.Test)

Example 59 with HttpXMLEntity

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

the class TwoWayAsyncPushPullTest method testPushPullSuccess.

@Test
public void testPushPullSuccess() throws Exception {
    // Needs to be cleared so we can exactly see if two messages are contained
    // in the duplicate manager
    final IAS4DuplicateManager aIncomingDuplicateMgr = MetaAS4Manager.getIncomingDuplicateMgr();
    aIncomingDuplicateMgr.clearCache();
    assertTrue(aIncomingDuplicateMgr.isEmpty());
    Document aDoc = modifyUserMessage(m_aPMode.getID(), null, null, createDefaultProperties(), null, null, null);
    String sResponse = sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
    // Avoid stopping server to receive async response
    LOGGER.info("Waiting for 1 second");
    ThreadHelper.sleepSeconds(1);
    // Step one assertion for the sync part
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    final NodeList nList = aDoc.getElementsByTagName("eb:MessageId");
    // Should only be called once
    final String sID = nList.item(0).getTextContent();
    assertNotNull(aIncomingDuplicateMgr.getItemOfMessageID(sID));
    assertEquals(1, aIncomingDuplicateMgr.size());
    assertTrue(sResponse.contains("<eb:RefToMessageId>" + sID));
    // Depending on the payload a different EMEPBinding get chosen by
    // @MockPullRequestProcessorSPI
    // To Test the pull request part of the EMEPBinding
    final Document aPayload = DOMReader.readXMLDOM(new ClassPathResource("testfiles/PushPull.xml"));
    final ICommonsList<Object> aAny = new CommonsArrayList<>();
    aAny.add(aPayload.getDocumentElement());
    // add the ID from the usermessage since its still one async message
    // transfer
    aDoc = AS4PullRequestMessage.create(m_eSoapVersion, MessageHelperMethods.createEbms3MessageInfo(sID), AS4TestConstants.DEFAULT_MPC, aAny).getAsSoapDocument();
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType());
    sResponse = sendPlainMessageAndWait(aEntity, true, null);
    final NodeList nUserList = aDoc.getElementsByTagName("eb:MessageId");
    // Should only be called once
    final String aUserMsgID = nUserList.item(0).getTextContent();
    assertTrue(sResponse.contains(aUserMsgID));
}
Also used : IAS4DuplicateManager(com.helger.phase4.duplicate.IAS4DuplicateManager) HttpEntity(org.apache.http.HttpEntity) NodeList(org.w3c.dom.NodeList) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Test(org.junit.Test)

Example 60 with HttpXMLEntity

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

the class TwoWayMEPTest method testPModeWithTwoWayButNoLeg2.

@Test
public void testPModeWithTwoWayButNoLeg2() throws Exception {
    m_aPMode.setLeg2(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)

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