Search in sources :

Example 51 with HttpXMLEntity

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

the class ErrorMessageTest method testSendErrorMessageNoRefToMessageID.

@Test
@Ignore("Allowed since 0.9.14")
public void testSendErrorMessageNoRefToMessageID() throws Exception {
    final Document aDoc = DOMReader.readXMLDOM(new ClassPathResource("testfiles/ErrorMessageNoRefToMessageID.xml"));
    sendPlainMessageAndWait(new HttpXMLEntity(aDoc, ESoapVersion.SOAP_12.getMimeType()), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 52 with HttpXMLEntity

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

the class PModeCheckTest method testPModeLegNullReject.

@Test
public void testPModeLegNullReject() throws Exception {
    final PMode aPMode = MockPModeGenerator.getTestPMode(SOAP_VERSION);
    aPMode.setLeg1(null);
    final IPModeManager aPModeMgr = MetaAS4Manager.getPModeMgr();
    // Needed since different ids set in message and pmode otherwise
    m_aEbms3UserMessage.setCollaborationInfo(MessageHelperMethods.createEbms3CollaborationInfo(aPMode.getInitiatorID() + "-" + aPMode.getResponderID(), DEFAULT_AGREEMENT, null, CAS4.DEFAULT_SERVICE_URL, CAS4.DEFAULT_ACTION_URL, AS4TestConstants.TEST_CONVERSATION_ID));
    try {
        for (final String sPModeID : aPModeMgr.getAllIDs()) {
            aPModeMgr.deletePMode(sPModeID);
        }
        assertTrue(aPModeMgr.getAllIDs().isEmpty());
        aPModeMgr.createOrUpdatePMode(aPMode);
        final AS4UserMessage aMsg = AS4UserMessage.create(SOAP_VERSION, m_aEbms3UserMessage).setMustUnderstand(true);
        final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(m_aPayload), SOAP_VERSION, aMsg.getMessagingID(), null, s_aResMgr, false, AS4SigningParams.createDefault());
        sendPlainMessageAndWait(new HttpXMLEntity(aSignedDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
    } finally {
        // The MockPModeGenerator generates automatically a PMode, we need
        // too delete it after we are done with the test
        aPModeMgr.deletePMode(aPMode.getID());
    }
}
Also used : IPModeManager(com.helger.phase4.model.pmode.IPModeManager) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) PMode(com.helger.phase4.model.pmode.PMode) Test(org.junit.Test)

Example 53 with HttpXMLEntity

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

the class PModeCheckTest method testUserMessageDifferentPropertiesValues.

@Test
public void testUserMessageDifferentPropertiesValues() throws Exception {
    final Ebms3MessageProperties aEbms3MessageProperties = new Ebms3MessageProperties();
    final ICommonsList<Ebms3Property> aEbms3Properties = new CommonsArrayList<>();
    aEbms3Properties.add(_createRandomProperty());
    aEbms3MessageProperties.setProperty(aEbms3Properties);
    m_aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
    final Document aDoc = AS4UserMessage.create(SOAP_VERSION, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
    sendPlainMessageAndWait(new HttpXMLEntity(aDoc, SOAP_VERSION.getMimeType()), false, "");
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Example 54 with HttpXMLEntity

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

the class PullRequestTest method testSendPullRequestFailure.

@Test
public void testSendPullRequestFailure() throws Exception {
    // Special MPC name handled in MockMessageProcessorSPI
    final String sFailure = MockMessageProcessorSPI.MPC_FAILURE;
    final MPC aMPC = new MPC(sFailure);
    if (MetaAS4Manager.getMPCMgr().getMPCOfID(sFailure) == null)
        MetaAS4Manager.getMPCMgr().createMPC(aMPC);
    final Document aDoc = AS4PullRequestMessage.create(m_eSoapVersion, MessageHelperMethods.createEbms3MessageInfo(), sFailure, null).getAsSoapDocument();
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType());
    sendPlainMessageAndWait(aEntity, false, EEbmsError.EBMS_OTHER.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 55 with HttpXMLEntity

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

the class PullRequestTest method testSendPullRequestEmpty.

@Test
public void testSendPullRequestEmpty() throws Exception {
    // Special MPC name handled in MockMessageProcessorSPI
    final String sFailure = MockMessageProcessorSPI.MPC_EMPTY;
    final MPC aMPC = new MPC(sFailure);
    if (MetaAS4Manager.getMPCMgr().getMPCOfID(sFailure) == null)
        MetaAS4Manager.getMPCMgr().createMPC(aMPC);
    final Document aDoc = AS4PullRequestMessage.create(m_eSoapVersion, MessageHelperMethods.createEbms3MessageInfo(), sFailure, null).getAsSoapDocument();
    final HttpEntity aEntity = new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType());
    sendPlainMessageAndWait(aEntity, false, EEbmsError.EBMS_EMPTY_MESSAGE_PARTITION_CHANNEL.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)

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