当前位置: 首页>>代码示例>>Java>>正文


Java DOMReader类代码示例

本文整理汇总了Java中com.helger.xml.serialize.read.DOMReader的典型用法代码示例。如果您正苦于以下问题:Java DOMReader类的具体用法?Java DOMReader怎么用?Java DOMReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DOMReader类属于com.helger.xml.serialize.read包,在下文中一共展示了DOMReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUserMessageSOAPBodyPayloadSignedMimeSuccess

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void testUserMessageSOAPBodyPayloadSignedMimeSuccess () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  final MimeMessage aMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion,
                                                                   MockMessages.testSignedUserMessage (m_eSOAPVersion,
                                                                                                       aPayload,
                                                                                                       null,
                                                                                                       s_aResMgr),
                                                                   null);
  final String sResponse = sendMimeMessage (new HttpMimeMessageEntity (aMsg), true, null);

  assertTrue (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
  assertTrue (sResponse.contains (AS4TestConstants.NON_REPUDIATION_INFORMATION));
  assertTrue (sResponse.contains (ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI ()));
  assertTrue (sResponse.contains (ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI ()));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:18,代码来源:UserMessageSoapBodyPayloadTest.java

示例2: testUserMessageSOAPBodyPayloadEncryptSuccess

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@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.testUserMessageSoapNotSigned (m_eSOAPVersion, aPayload, aAttachments);
  aDoc = new EncryptionCreator (AS4CryptoFactory.DEFAULT_INSTANCE).encryptSoapBodyPayload (m_eSOAPVersion,
                                                                                           aDoc,
                                                                                           false,
                                                                                           ECryptoAlgorithmCrypt.ENCRPYTION_ALGORITHM_DEFAULT);

  final String sResponse = sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion), true, null);

  assertTrue (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:17,代码来源:UserMessageSoapBodyPayloadTest.java

示例3: testUserMessageSOAPBodyPayloadSignedEncryptedSuccess

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void testUserMessageSOAPBodyPayloadSignedEncryptedSuccess () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));

  final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
  Document aDoc = MockMessages.testSignedUserMessage (m_eSOAPVersion, aPayload, aAttachments, s_aResMgr);
  aDoc = new EncryptionCreator (AS4CryptoFactory.DEFAULT_INSTANCE).encryptSoapBodyPayload (m_eSOAPVersion,
                                                                                           aDoc,
                                                                                           false,
                                                                                           ECryptoAlgorithmCrypt.ENCRPYTION_ALGORITHM_DEFAULT);

  final String sResponse = sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion), true, null);

  assertTrue (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
  assertTrue (sResponse.contains (AS4TestConstants.NON_REPUDIATION_INFORMATION));
  assertTrue (sResponse.contains (ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI ()));
  assertTrue (sResponse.contains (ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI ()));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:20,代码来源:UserMessageSoapBodyPayloadTest.java

示例4: testPayloadChangedAfterSigningShouldFail

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void testPayloadChangedAfterSigningShouldFail () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));

  final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
  final Document aDoc = MockMessages.testSignedUserMessage (m_eSOAPVersion, aPayload, aAttachments, s_aResMgr);
  final NodeList nList = aDoc.getElementsByTagName (m_eSOAPVersion.getNamespacePrefix () + ":Body");
  for (int i = 0; i < nList.getLength (); i++)
  {
    final Node nNode = nList.item (i);
    final Element eElement = (Element) nNode;
    eElement.setAttribute ("INVALID", "INVALID");
  }
  sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion),
                    false,
                    EEbmsError.EBMS_FAILED_DECRYPTION.getErrorCode ());
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:19,代码来源:UserMessageFailureForgeryTest.java

示例5: testUserMessageWithPayloadInfoOnly

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void testUserMessageWithPayloadInfoOnly () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  final Document aDoc = MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion, aPayload, null);

  // Delete the added Payload in the soap body to confirm right behaviour when
  // the payload is missing
  final NodeList nList = aDoc.getElementsByTagName (m_eSOAPVersion.getNamespacePrefix () + ":Body");
  for (int i = 0; i < nList.getLength (); i++)
  {
    final Node nNode = nList.item (i);
    final Element aElement = (Element) nNode;
    XMLHelper.removeAllChildElements (aElement);
  }

  sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion),
                    false,
                    EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode ());
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:21,代码来源:UserMessageFailureForgeryTest.java

示例6: testUserMessageWithBodyPayloadOnlyNoInfo

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void testUserMessageWithBodyPayloadOnlyNoInfo () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  final Document aDoc = MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion, aPayload, null);

  // Delete the added Payload in the soap body to confirm right behaviour when
  // the payload is missing
  Node aNext = XMLHelper.getFirstChildElementOfName (aDoc, "Envelope");
  aNext = XMLHelper.getFirstChildElementOfName (aNext, "Header");
  aNext = XMLHelper.getFirstChildElementOfName (aNext, CAS4.EBMS_NS, "Messaging");
  aNext = XMLHelper.getFirstChildElementOfName (aNext, CAS4.EBMS_NS, AS4TestConstants.USERMESSAGE_ASSERTCHECK);
  aNext = XMLHelper.getFirstChildElementOfName (aNext, CAS4.EBMS_NS, "PayloadInfo");

  aNext.getParentNode ().removeChild (aNext);

  sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion),
                    false,
                    EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode ());
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:21,代码来源:UserMessageFailureForgeryTest.java

示例7: sendPullRequestSuccessTwoWayPushPull

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void sendPullRequestSuccessTwoWayPushPull () 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 = PullRequestMessageCreator.createPullRequestMessage (m_eSOAPVersion,
                                                                            MessageHelperMethods.createEbms3MessageInfo (),
                                                                            AS4TestConstants.DEFAULT_MPC,
                                                                            aAny)
                                                 .getAsSOAPDocument ();
  final HttpEntity aEntity = new HttpXMLEntity (aDoc, m_eSOAPVersion);
  final String sResponse = sendPlainMessage (aEntity, true, null);

  assertTrue (sResponse.contains (AS4TestConstants.USERMESSAGE_ASSERTCHECK));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:21,代码来源:PullRequestTest.java

示例8: sendPullRequestSuccessTwoWayPullPush

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void sendPullRequestSuccessTwoWayPullPush () 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/PullPush.xml"));
  final ICommonsList <Object> aAny = new CommonsArrayList <> ();
  aAny.add (aPayload.getDocumentElement ());

  final Document aDoc = PullRequestMessageCreator.createPullRequestMessage (m_eSOAPVersion,
                                                                            MessageHelperMethods.createEbms3MessageInfo (),
                                                                            AS4TestConstants.DEFAULT_MPC,
                                                                            aAny)
                                                 .getAsSOAPDocument ();
  final HttpEntity aEntity = new HttpXMLEntity (aDoc, m_eSOAPVersion);
  final String sResponse = sendPlainMessage (aEntity, true, null);

  assertTrue (sResponse.contains (AS4TestConstants.USERMESSAGE_ASSERTCHECK));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:21,代码来源:PullRequestTest.java

示例9: sendDuplicateMessageTestDisposalFeature

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Ignore
@Test
public void sendDuplicateMessageTestDisposalFeature () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  final Document aDoc = MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion, aPayload, null);

  final HttpEntity aEntity = new HttpXMLEntity (aDoc, m_eSOAPVersion);

  sendPlainMessage (aEntity, true, null);

  // Making sure the message gets disposed off
  // 60 000 = 1 minute, *2 and + 10000 are a buffer
  // test file is configured for 1 minute can take LONGER if configured
  // differently
  Thread.sleep (AS4ServerConfiguration.getIncomingDuplicateDisposalMinutes () * 60000 * 2 + 10000);

  sendPlainMessage (aEntity, true, null);
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:20,代码来源:UserMessageDuplicateTest.java

示例10: sendBodyPayloadSignedMessageSuccessful

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void sendBodyPayloadSignedMessageSuccessful () throws Exception
{
  final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
  aClient.setPayload (DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_PAYLOAD_XML)));

  // Keystore
  _setKeyStoreTestData (aClient);

  // Sign specific
  aClient.setCryptoAlgorithmSign (ECryptoAlgorithmSign.RSA_SHA_256);
  aClient.setCryptoAlgorithmSignDigest (ECryptoAlgorithmSignDigest.DIGEST_SHA_256);

  final IMicroDocument aDoc = aClient.sendMessageAndGetMicroDocument (SERVER_URL);
  assertTrue (MicroWriter.getNodeAsString (aDoc).contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:17,代码来源:AS4ClientUserMessageTest.java

示例11: sendBodyPayloadSignedEncryptedMessageSuccessful

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void sendBodyPayloadSignedEncryptedMessageSuccessful () throws Exception
{
  final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
  aClient.setPayload (DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_PAYLOAD_XML)));

  // Keystore
  _setKeyStoreTestData (aClient);

  // Sign specific
  aClient.setCryptoAlgorithmSign (ECryptoAlgorithmSign.RSA_SHA_256);
  aClient.setCryptoAlgorithmSignDigest (ECryptoAlgorithmSignDigest.DIGEST_SHA_256);

  // Encrypt specific
  aClient.setCryptoAlgorithmCrypt (ECryptoAlgorithmCrypt.AES_128_GCM);

  final IMicroDocument aDoc = aClient.sendMessageAndGetMicroDocument (SERVER_URL);
  assertTrue (MicroWriter.getNodeAsString (aDoc).contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:20,代码来源:AS4ClientUserMessageTest.java

示例12: buildMessageSignedChecks

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void buildMessageSignedChecks () throws Exception
{
  final AS4ClientReceiptMessage aClient = new AS4ClientReceiptMessage (s_aResMgr);
  aClient.setSOAPVersion (ESOAPVersion.AS4_DEFAULT);
  // Parse EBMS3 Messaging object
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  aClient.setSOAPDocument (MockMessages.testSignedUserMessage (aClient.getSOAPVersion (), aPayload, null, s_aResMgr));
  aClient.setNonRepudiation (true);
  aClient.setReceiptShouldBeSigned (true);

  aClient.setKeyStoreResource (new ClassPathResource ("keys/dummy-pw-test.jks"));
  aClient.setKeyStorePassword ("test");
  aClient.setKeyStoreType (EKeyStoreType.JKS);
  aClient.setKeyStoreAlias ("ph-as4");
  aClient.setKeyStoreKeyPassword ("test");

  aClient.setCryptoAlgorithmSign (ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT);
  aClient.setCryptoAlgorithmSignDigest (ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT);

  _ensureValidState (aClient);
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:23,代码来源:AS4ClientReceiptMessageTest.java

示例13: setUpCEF

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Before
public void setUpCEF ()
{
  m_aESENSTwoWayPMode = ESENSPMode.createESENSPModeTwoWay (AS4TestConstants.CEF_INITIATOR_ID,
                                                           AS4TestConstants.CEF_RESPONDER_ID,
                                                           AS4TestConstants.DEFAULT_SERVER_ADDRESS,
                                                           IPModeIDProvider.DEFAULT_DYNAMIC);

  m_eSOAPVersion = m_aESENSTwoWayPMode.getLeg1 ().getProtocol ().getSOAPVersion ();
  try
  {
    m_aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  }
  catch (final SAXException ex)
  {
    throw new IllegalStateException ("Failed to parse example XML", ex);
  }
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:19,代码来源:AbstractCEFTwoWayTestSetUp.java

示例14: setUpCEF

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Before
public void setUpCEF ()
{
  m_aESENSOneWayPMode = ESENSPMode.createESENSPMode (AS4TestConstants.CEF_INITIATOR_ID,
                                                     AS4TestConstants.CEF_RESPONDER_ID,
                                                     AS4TestConstants.DEFAULT_SERVER_ADDRESS,
                                                     IPModeIDProvider.DEFAULT_DYNAMIC);

  m_eSOAPVersion = m_aESENSOneWayPMode.getLeg1 ().getProtocol ().getSOAPVersion ();
  try
  {
    m_aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  }
  catch (final SAXException ex)
  {
    throw new IllegalStateException ("Failed to parse example XML", ex);
  }
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:19,代码来源:AbstractCEFTestSetUp.java

示例15: testDeliverInvoice1

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
/**
 * Basic test case. It is ignored by default, since no test username and
 * password are present. After setting {@link #USP_WS_USERNAME} and
 * {@link #USP_WS_PASSWORD} constants in this class, this test can be
 * "un-ignored".
 *
 * @throws SAXException
 *         in case XML reading fails
 */
@Test
@Ignore
public void testDeliverInvoice1 () throws SAXException
{
  final Node aXMLDocument = DOMReader.readXMLDOM (new ClassPathResource ("test-invoices/ebi40.xml"));
  assertNotNull ("Failed to read example invoice", aXMLDocument);

  final WS120Sender aSender = new WS120Sender (USP_WS_USERNAME, USP_WS_PASSWORD);
  aSender.setDebugMode (true);
  aSender.setTestVersion (true);

  // No attachments
  final List <AttachmentType> aAttachments = null;

  final SettingsType aSettings = new SettingsType ();
  // Perform only technical validation
  aSettings.setTest (Boolean.TRUE);

  // Deliver it
  final TypeUploadStatus aResult = aSender.deliverInvoice (aXMLDocument, aAttachments, aSettings);
  assertNotNull (aResult.toString (), aResult.getSuccess ());
}
 
开发者ID:phax,项目名称:erechnung.gv.at-webservice-client,代码行数:32,代码来源:WS120SenderTest.java


注:本文中的com.helger.xml.serialize.read.DOMReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。