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));
}
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());
}
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());
}
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));
}
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());
}
Aggregations