use of com.helger.phase4.duplicate.IAS4DuplicateManager in project phase4 by phax.
the class AS4CEFTwoWayFuncTest method testAS4_TA01.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile: Two-Way/Push-and-Push MEP. SMSH sends an AS4 User Message
* (M1) associated to a specific conversation through variable (element)
* CONVERSATIONIDM1 (set by the producer). The consumer replies to the message
* M1.<br>
* <br>
* Predicate: <br>
* The RMSH sends back a User Message (M2) with element CONVERSATIONIDM2 equal
* to ConversationIdM1 (set by the consumer).
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA01() 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());
final Document aDoc = testSignedUserMessage(m_eSoapVersion, m_aPayload, null, s_aResMgr);
final 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 aNL = aDoc.getElementsByTagName("eb:MessageId");
// Should only be called once
final String aID = aNL.item(0).getTextContent();
assertNotNull(aIncomingDuplicateMgr.getItemOfMessageID(aID));
assertEquals(2, aIncomingDuplicateMgr.getAll().size());
}
use of com.helger.phase4.duplicate.IAS4DuplicateManager in project phase4 by phax.
the class AS4CEFTwoWayFuncTest method testAS4_TA02.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile: Two-Way/Push-and-Push MEP. SMSH sends an AS4 User Message
* (M1 with ID MessageId) that requires a consumer response to the RMSH.
* Additionally, the message is associated to a specific conversation through
* variable (element) CONVERSATIONIDM1 (set by the producer). The consumer
* replies to the message M1.<br>
* <br>
* Predicate: <br>
* The RMSH sends back a User Message (M2) with element REFTOMESSAGEID set to
* MESSAGEID (of M1) and with element CONVERSATIONIDM2 equal to
* ConversationIdM1.
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA02() 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());
final Document aDoc = testSignedUserMessage(m_eSoapVersion, m_aPayload, null, s_aResMgr);
final 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);
final NodeList aNL = aDoc.getElementsByTagName("eb:MessageId");
// Should only be called once
final String aID = aNL.item(0).getTextContent();
assertTrue(sResponse.contains("eb:RefToMessageId"));
assertTrue(sResponse.contains(aID));
assertNotNull(aIncomingDuplicateMgr.getItemOfMessageID(aID));
assertEquals(2, aIncomingDuplicateMgr.getAll().size());
}
use of com.helger.phase4.duplicate.IAS4DuplicateManager 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.duplicate.IAS4DuplicateManager 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));
}
Aggregations