Search in sources :

Example 21 with HttpXMLEntity

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

the class UserMessageFailureForgeryTest method testTwoUserMessagesShouldFail.

@Test
public void testTwoUserMessagesShouldFail() throws Exception {
    final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    // never forget this!
    domFactory.setNamespaceAware(true);
    final DocumentBuilder builder = domFactory.newDocumentBuilder();
    final Document aDoc = builder.parse(new ClassPathResource("testfiles/TwoUserMessages.xml").getInputStream());
    sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 22 with HttpXMLEntity

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

the class UserMessageSoapBodyPayloadTest method testSendUnsignedMessageSuccess.

@Test
public void testSendUnsignedMessageSuccess() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final Document aDoc = MockMessages.createUserMessageNotSigned(m_eSoapVersion, aPayload, null).getAsSoapDocument(aPayload);
    final String sResponse = sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
}
Also used : Node(org.w3c.dom.Node) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 23 with HttpXMLEntity

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

the class UserMessageSoapBodyPayloadTest method testUserMessageSOAPBodyPayloadEncryptSuccess.

@Test
public void testUserMessageSOAPBodyPayloadEncryptSuccess() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    Document aDoc = MockMessages.createUserMessageNotSigned(m_eSoapVersion, aPayload, aAttachments).getAsSoapDocument(aPayload);
    aDoc = AS4Encryptor.encryptSoapBodyPayload(m_aCryptoFactory, m_eSoapVersion, aDoc, false, m_aCryptParams);
    final String sResponse = sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
}
Also used : Node(org.w3c.dom.Node) 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) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Example 24 with HttpXMLEntity

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

the class ErrorMessageTest method testSendErrorMessage.

@Test
public void testSendErrorMessage() throws Exception {
    final Document aDoc = DOMReader.readXMLDOM(new ClassPathResource("testfiles/ErrorMessage.xml"));
    sendPlainMessageAndWait(new HttpXMLEntity(aDoc, ESoapVersion.SOAP_12.getMimeType()), true, null);
}
Also used : HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 25 with HttpXMLEntity

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

the class PModeCheckTest method testWrongPModeID.

// Can not do that anymore since everything gets accepted with default profile
// pmode
@Test
@Ignore("The PMode resolution is not done based on PMode ID - therefore this cannot fail")
public void testWrongPModeID() throws Exception {
    m_aEbms3UserMessage.getCollaborationInfo().getAgreementRef().setPmode("this-is-a-wrong-id");
    // Needed to set since also Action and Service combination gets checked if
    // they are already in the pmode pool
    final Ebms3Service aService = new Ebms3Service();
    aService.setValue("Random Value");
    m_aEbms3UserMessage.getCollaborationInfo().setService(aService);
    final Document aDoc = AS4UserMessage.create(SOAP_VERSION, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
    assertNotNull(aDoc);
    sendPlainMessageAndWait(new HttpXMLEntity(aDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
}
Also used : HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Ebms3Service(com.helger.phase4.ebms3header.Ebms3Service) Document(org.w3c.dom.Document) Ignore(org.junit.Ignore) 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