use of com.helger.phase4.model.EMEPBinding in project phase4 by phax.
the class ENTSOGCompatibilityValidator method validatePMode.
@Override
public void validatePMode(@Nonnull final IPMode aPMode, @Nonnull final ErrorList aErrorList) {
ValueEnforcer.isTrue(aErrorList.isEmpty(), () -> "Errors in global PMode validation: " + aErrorList.toString());
try {
MetaAS4Manager.getPModeMgr().validatePMode(aPMode);
} catch (final PModeValidationException ex) {
aErrorList.add(_createError(ex.getMessage()));
}
final EMEP eMEP = aPMode.getMEP();
final EMEPBinding eMEPBinding = aPMode.getMEPBinding();
if ((eMEP == EMEP.ONE_WAY && eMEPBinding == EMEPBinding.PUSH) || (eMEP == EMEP.TWO_WAY && eMEPBinding == EMEPBinding.PUSH_PUSH)) {
// Valid
} else {
aErrorList.add(_createError("An invalid combination of PMode MEP (" + eMEP + ") and MEP binding (" + eMEPBinding + ") was specified, valid are only one-way/push and two-way/push-push."));
}
// Leg1 must be present
final PModeLeg aPModeLeg1 = aPMode.getLeg1();
if (aPModeLeg1 == null) {
aErrorList.add(_createError("PMode.Leg[1] is missing"));
} else {
_checkIfLegIsValid(aErrorList, aPModeLeg1, "PMode.Leg[1].");
}
if (aPMode.getLeg2() != null) {
aErrorList.add(_createError("PMode.Leg[2] must not be present"));
}
final PModePayloadService aPayloadService = aPMode.getPayloadService();
if (aPayloadService != null) {
final EAS4CompressionMode eCompressionMode = aPayloadService.getCompressionMode();
if (eCompressionMode != null) {
if (!eCompressionMode.equals(EAS4CompressionMode.GZIP))
aErrorList.add(_createError("PMode.PayloadService.CompressionMode must be " + EAS4CompressionMode.GZIP + " instead of " + eCompressionMode));
} else {
aErrorList.add(_createError("PMode.PayloadService.CompressionMode is missing"));
}
} else {
aErrorList.add(_createError("PMode.PayloadService is missing"));
}
}
use of com.helger.phase4.model.EMEPBinding 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.model.EMEPBinding 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.model.EMEPBinding 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